aboutsummaryrefslogtreecommitdiff
path: root/libvpx/vp9/common
diff options
context:
space:
mode:
authorJohann <johannkoenig@google.com>2019-12-19 15:13:14 -0800
committerJohann <johannkoenig@google.com>2020-01-13 15:18:33 -0800
commit6ec360e770aae975eb3702467d9df6f76bc29700 (patch)
tree2aefc46ce3861ac17b136a0d66f82212c5bfa5ab /libvpx/vp9/common
parentf95b460169fe5b77f1d493fd2e58b31a2dbf816b (diff)
downloadlibvpx-6ec360e770aae975eb3702467d9df6f76bc29700.tar.gz
libvpx: Pull from upstream
Current HEAD: 7ec7a33a081aeeb53fed1a8d87e4cbd189152527 git log from upstream: 7ec7a33a0 Release v1.8.2 Pekin Duck Test: upstream Change-Id: If7ab690a76b3cd93a3c922d5e9fc9a3996668005
Diffstat (limited to 'libvpx/vp9/common')
-rw-r--r--libvpx/vp9/common/vp9_alloccommon.c23
-rw-r--r--libvpx/vp9/common/vp9_alloccommon.h5
-rw-r--r--libvpx/vp9/common/vp9_blockd.h1
-rw-r--r--libvpx/vp9/common/vp9_mv.h2
-rw-r--r--libvpx/vp9/common/vp9_onyxc_int.h36
-rw-r--r--libvpx/vp9/common/vp9_postproc.c28
-rw-r--r--libvpx/vp9/common/vp9_postproc.h8
-rw-r--r--libvpx/vp9/common/vp9_reconinter.c4
-rw-r--r--libvpx/vp9/common/vp9_thread_common.c84
-rw-r--r--libvpx/vp9/common/vp9_thread_common.h2
10 files changed, 118 insertions, 75 deletions
diff --git a/libvpx/vp9/common/vp9_alloccommon.c b/libvpx/vp9/common/vp9_alloccommon.c
index 7345e259b..5702dca71 100644
--- a/libvpx/vp9/common/vp9_alloccommon.c
+++ b/libvpx/vp9/common/vp9_alloccommon.c
@@ -17,17 +17,26 @@
#include "vp9/common/vp9_entropymv.h"
#include "vp9/common/vp9_onyxc_int.h"
-void vp9_set_mb_mi(VP9_COMMON *cm, int width, int height) {
+void vp9_set_mi_size(int *mi_rows, int *mi_cols, int *mi_stride, int width,
+ int height) {
const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2);
const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2);
+ *mi_cols = aligned_width >> MI_SIZE_LOG2;
+ *mi_rows = aligned_height >> MI_SIZE_LOG2;
+ *mi_stride = calc_mi_size(*mi_cols);
+}
- cm->mi_cols = aligned_width >> MI_SIZE_LOG2;
- cm->mi_rows = aligned_height >> MI_SIZE_LOG2;
- cm->mi_stride = calc_mi_size(cm->mi_cols);
+void vp9_set_mb_size(int *mb_rows, int *mb_cols, int *mb_num, int mi_rows,
+ int mi_cols) {
+ *mb_cols = (mi_cols + 1) >> 1;
+ *mb_rows = (mi_rows + 1) >> 1;
+ *mb_num = (*mb_rows) * (*mb_cols);
+}
- cm->mb_cols = (cm->mi_cols + 1) >> 1;
- cm->mb_rows = (cm->mi_rows + 1) >> 1;
- cm->MBs = cm->mb_rows * cm->mb_cols;
+void vp9_set_mb_mi(VP9_COMMON *cm, int width, int height) {
+ vp9_set_mi_size(&cm->mi_rows, &cm->mi_cols, &cm->mi_stride, width, height);
+ vp9_set_mb_size(&cm->mb_rows, &cm->mb_cols, &cm->MBs, cm->mi_rows,
+ cm->mi_cols);
}
static int alloc_seg_map(VP9_COMMON *cm, int seg_map_size) {
diff --git a/libvpx/vp9/common/vp9_alloccommon.h b/libvpx/vp9/common/vp9_alloccommon.h
index 8900038ea..90cbb093d 100644
--- a/libvpx/vp9/common/vp9_alloccommon.h
+++ b/libvpx/vp9/common/vp9_alloccommon.h
@@ -33,6 +33,11 @@ void vp9_free_postproc_buffers(struct VP9Common *cm);
int vp9_alloc_state_buffers(struct VP9Common *cm, int width, int height);
void vp9_free_state_buffers(struct VP9Common *cm);
+void vp9_set_mi_size(int *mi_rows, int *mi_cols, int *mi_stride, int width,
+ int height);
+void vp9_set_mb_size(int *mb_rows, int *mb_cols, int *mb_num, int mi_rows,
+ int mi_cols);
+
void vp9_set_mb_mi(struct VP9Common *cm, int width, int height);
void vp9_swap_current_and_last_seg_map(struct VP9Common *cm);
diff --git a/libvpx/vp9/common/vp9_blockd.h b/libvpx/vp9/common/vp9_blockd.h
index 2ddc0f121..6ef8127a5 100644
--- a/libvpx/vp9/common/vp9_blockd.h
+++ b/libvpx/vp9/common/vp9_blockd.h
@@ -60,6 +60,7 @@ typedef struct {
#define GOLDEN_FRAME 2
#define ALTREF_FRAME 3
#define MAX_REF_FRAMES 4
+#define MAX_INTER_REF_FRAMES 3
typedef int8_t MV_REFERENCE_FRAME;
diff --git a/libvpx/vp9/common/vp9_mv.h b/libvpx/vp9/common/vp9_mv.h
index 14dde7dd0..76f93cf0b 100644
--- a/libvpx/vp9/common/vp9_mv.h
+++ b/libvpx/vp9/common/vp9_mv.h
@@ -19,6 +19,8 @@
extern "C" {
#endif
+#define INVALID_MV 0x80008000
+
typedef struct mv {
int16_t row;
int16_t col;
diff --git a/libvpx/vp9/common/vp9_onyxc_int.h b/libvpx/vp9/common/vp9_onyxc_int.h
index 662b8ef5e..f3942a8f0 100644
--- a/libvpx/vp9/common/vp9_onyxc_int.h
+++ b/libvpx/vp9/common/vp9_onyxc_int.h
@@ -244,14 +244,6 @@ typedef struct VP9Common {
int byte_alignment;
int skip_loop_filter;
- // Private data associated with the frame buffer callbacks.
- void *cb_priv;
- vpx_get_frame_buffer_cb_fn_t get_fb_cb;
- vpx_release_frame_buffer_cb_fn_t release_fb_cb;
-
- // Handles memory for the codec.
- InternalFrameBufferList int_frame_buffers;
-
// External BufferPool passed from outside.
BufferPool *buffer_pool;
@@ -262,6 +254,34 @@ typedef struct VP9Common {
int lf_row;
} VP9_COMMON;
+typedef struct {
+ int frame_width;
+ int frame_height;
+ int render_frame_width;
+ int render_frame_height;
+ int mi_rows;
+ int mi_cols;
+ int mb_rows;
+ int mb_cols;
+ int num_mbs;
+ vpx_bit_depth_t bit_depth;
+} FRAME_INFO;
+
+static INLINE void init_frame_info(FRAME_INFO *frame_info,
+ const VP9_COMMON *cm) {
+ frame_info->frame_width = cm->width;
+ frame_info->frame_height = cm->height;
+ frame_info->render_frame_width = cm->render_width;
+ frame_info->render_frame_height = cm->render_height;
+ frame_info->mi_cols = cm->mi_cols;
+ frame_info->mi_rows = cm->mi_rows;
+ frame_info->mb_cols = cm->mb_cols;
+ frame_info->mb_rows = cm->mb_rows;
+ frame_info->num_mbs = cm->MBs;
+ frame_info->bit_depth = cm->bit_depth;
+ // TODO(angiebird): Figure out how to get subsampling_x/y here
+}
+
static INLINE YV12_BUFFER_CONFIG *get_buf_frame(VP9_COMMON *cm, int index) {
if (index < 0 || index >= FRAME_BUFFERS) return NULL;
if (cm->error.error_code != VPX_CODEC_OK) return NULL;
diff --git a/libvpx/vp9/common/vp9_postproc.c b/libvpx/vp9/common/vp9_postproc.c
index 5373b0218..d2c8535b0 100644
--- a/libvpx/vp9/common/vp9_postproc.c
+++ b/libvpx/vp9/common/vp9_postproc.c
@@ -183,7 +183,8 @@ void vp9_highbd_mbpost_proc_down_c(uint16_t *dst, int pitch, int rows, int cols,
}
#endif // CONFIG_VP9_HIGHBITDEPTH
-static void deblock_and_de_macro_block(YV12_BUFFER_CONFIG *source,
+static void deblock_and_de_macro_block(VP9_COMMON *cm,
+ YV12_BUFFER_CONFIG *source,
YV12_BUFFER_CONFIG *post, int q,
int low_var_thresh, int flag,
uint8_t *limits) {
@@ -216,7 +217,7 @@ static void deblock_and_de_macro_block(YV12_BUFFER_CONFIG *source,
source->uv_height, source->uv_width, ppl);
} else {
#endif // CONFIG_VP9_HIGHBITDEPTH
- vp9_deblock(source, post, q, limits);
+ vp9_deblock(cm, source, post, q, limits);
vpx_mbpost_proc_across_ip(post->y_buffer, post->y_stride, post->y_height,
post->y_width, q2mbl(q));
vpx_mbpost_proc_down(post->y_buffer, post->y_stride, post->y_height,
@@ -226,8 +227,8 @@ static void deblock_and_de_macro_block(YV12_BUFFER_CONFIG *source,
#endif // CONFIG_VP9_HIGHBITDEPTH
}
-void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
- uint8_t *limits) {
+void vp9_deblock(struct VP9Common *cm, const YV12_BUFFER_CONFIG *src,
+ YV12_BUFFER_CONFIG *dst, int q, uint8_t *limits) {
const int ppl =
(int)(6.0e-05 * q * q * q - 0.0067 * q * q + 0.306 * q + 0.0065 + 0.5);
#if CONFIG_VP9_HIGHBITDEPTH
@@ -252,9 +253,8 @@ void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
} else {
#endif // CONFIG_VP9_HIGHBITDEPTH
int mbr;
- const int mb_rows = src->y_height / 16;
- const int mb_cols = src->y_width / 16;
-
+ const int mb_rows = cm->mb_rows;
+ const int mb_cols = cm->mb_cols;
memset(limits, (unsigned char)ppl, 16 * mb_cols);
for (mbr = 0; mbr < mb_rows; mbr++) {
@@ -276,9 +276,9 @@ void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
#endif // CONFIG_VP9_HIGHBITDEPTH
}
-void vp9_denoise(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
- uint8_t *limits) {
- vp9_deblock(src, dst, q, limits);
+void vp9_denoise(struct VP9Common *cm, const YV12_BUFFER_CONFIG *src,
+ YV12_BUFFER_CONFIG *dst, int q, uint8_t *limits) {
+ vp9_deblock(cm, src, dst, q, limits);
}
static void swap_mi_and_prev_mi(VP9_COMMON *cm) {
@@ -383,21 +383,21 @@ int vp9_post_proc_frame(struct VP9Common *cm, YV12_BUFFER_CONFIG *dest,
vpx_yv12_copy_frame(ppbuf, &cm->post_proc_buffer_int);
}
if ((flags & VP9D_DEMACROBLOCK) && cm->post_proc_buffer_int.buffer_alloc) {
- deblock_and_de_macro_block(&cm->post_proc_buffer_int, ppbuf,
+ deblock_and_de_macro_block(cm, &cm->post_proc_buffer_int, ppbuf,
q + (ppflags->deblocking_level - 5) * 10, 1, 0,
cm->postproc_state.limits);
} else if (flags & VP9D_DEBLOCK) {
- vp9_deblock(&cm->post_proc_buffer_int, ppbuf, q,
+ vp9_deblock(cm, &cm->post_proc_buffer_int, ppbuf, q,
cm->postproc_state.limits);
} else {
vpx_yv12_copy_frame(&cm->post_proc_buffer_int, ppbuf);
}
} else if (flags & VP9D_DEMACROBLOCK) {
- deblock_and_de_macro_block(cm->frame_to_show, ppbuf,
+ deblock_and_de_macro_block(cm, cm->frame_to_show, ppbuf,
q + (ppflags->deblocking_level - 5) * 10, 1, 0,
cm->postproc_state.limits);
} else if (flags & VP9D_DEBLOCK) {
- vp9_deblock(cm->frame_to_show, ppbuf, q, cm->postproc_state.limits);
+ vp9_deblock(cm, cm->frame_to_show, ppbuf, q, cm->postproc_state.limits);
} else {
vpx_yv12_copy_frame(cm->frame_to_show, ppbuf);
}
diff --git a/libvpx/vp9/common/vp9_postproc.h b/libvpx/vp9/common/vp9_postproc.h
index 67efc1b4e..bbe3aed83 100644
--- a/libvpx/vp9/common/vp9_postproc.h
+++ b/libvpx/vp9/common/vp9_postproc.h
@@ -40,11 +40,11 @@ struct VP9Common;
int vp9_post_proc_frame(struct VP9Common *cm, YV12_BUFFER_CONFIG *dest,
vp9_ppflags_t *ppflags, int unscaled_width);
-void vp9_denoise(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
- uint8_t *limits);
+void vp9_denoise(struct VP9Common *cm, const YV12_BUFFER_CONFIG *src,
+ YV12_BUFFER_CONFIG *dst, int q, uint8_t *limits);
-void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q,
- uint8_t *limits);
+void vp9_deblock(struct VP9Common *cm, const YV12_BUFFER_CONFIG *src,
+ YV12_BUFFER_CONFIG *dst, int q, uint8_t *limits);
#ifdef __cplusplus
} // extern "C"
diff --git a/libvpx/vp9/common/vp9_reconinter.c b/libvpx/vp9/common/vp9_reconinter.c
index 04f41e6a3..ff59ff504 100644
--- a/libvpx/vp9/common/vp9_reconinter.c
+++ b/libvpx/vp9/common/vp9_reconinter.c
@@ -96,8 +96,8 @@ MV clamp_mv_to_umv_border_sb(const MACROBLOCKD *xd, const MV *src_mv, int bw,
const int spel_right = spel_left - SUBPEL_SHIFTS;
const int spel_top = (VP9_INTERP_EXTEND + bh) << SUBPEL_BITS;
const int spel_bottom = spel_top - SUBPEL_SHIFTS;
- MV clamped_mv = { src_mv->row * (1 << (1 - ss_y)),
- src_mv->col * (1 << (1 - ss_x)) };
+ MV clamped_mv = { (short)(src_mv->row * (1 << (1 - ss_y))),
+ (short)(src_mv->col * (1 << (1 - ss_x))) };
assert(ss_x <= 1);
assert(ss_y <= 1);
diff --git a/libvpx/vp9/common/vp9_thread_common.c b/libvpx/vp9/common/vp9_thread_common.c
index c79d9b7f0..b3d50162b 100644
--- a/libvpx/vp9/common/vp9_thread_common.c
+++ b/libvpx/vp9/common/vp9_thread_common.c
@@ -298,7 +298,10 @@ void vp9_loop_filter_alloc(VP9LfSync *lf_sync, VP9_COMMON *cm, int rows,
pthread_cond_init(&lf_sync->cond[i], NULL);
}
}
- pthread_mutex_init(&lf_sync->lf_mutex, NULL);
+
+ CHECK_MEM_ERROR(cm, lf_sync->lf_mutex,
+ vpx_malloc(sizeof(*lf_sync->lf_mutex)));
+ pthread_mutex_init(lf_sync->lf_mutex, NULL);
CHECK_MEM_ERROR(cm, lf_sync->recon_done_mutex,
vpx_malloc(sizeof(*lf_sync->recon_done_mutex) * rows));
@@ -339,47 +342,50 @@ void vp9_loop_filter_alloc(VP9LfSync *lf_sync, VP9_COMMON *cm, int rows,
// Deallocate lf synchronization related mutex and data
void vp9_loop_filter_dealloc(VP9LfSync *lf_sync) {
- if (lf_sync != NULL) {
+ assert(lf_sync != NULL);
+
#if CONFIG_MULTITHREAD
+ if (lf_sync->mutex != NULL) {
int i;
-
- if (lf_sync->mutex != NULL) {
- for (i = 0; i < lf_sync->rows; ++i) {
- pthread_mutex_destroy(&lf_sync->mutex[i]);
- }
- vpx_free(lf_sync->mutex);
+ for (i = 0; i < lf_sync->rows; ++i) {
+ pthread_mutex_destroy(&lf_sync->mutex[i]);
}
- if (lf_sync->cond != NULL) {
- for (i = 0; i < lf_sync->rows; ++i) {
- pthread_cond_destroy(&lf_sync->cond[i]);
- }
- vpx_free(lf_sync->cond);
+ vpx_free(lf_sync->mutex);
+ }
+ if (lf_sync->cond != NULL) {
+ int i;
+ for (i = 0; i < lf_sync->rows; ++i) {
+ pthread_cond_destroy(&lf_sync->cond[i]);
}
- if (lf_sync->recon_done_mutex != NULL) {
- int i;
- for (i = 0; i < lf_sync->rows; ++i) {
- pthread_mutex_destroy(&lf_sync->recon_done_mutex[i]);
- }
- vpx_free(lf_sync->recon_done_mutex);
+ vpx_free(lf_sync->cond);
+ }
+ if (lf_sync->recon_done_mutex != NULL) {
+ int i;
+ for (i = 0; i < lf_sync->rows; ++i) {
+ pthread_mutex_destroy(&lf_sync->recon_done_mutex[i]);
}
+ vpx_free(lf_sync->recon_done_mutex);
+ }
- pthread_mutex_destroy(&lf_sync->lf_mutex);
- if (lf_sync->recon_done_cond != NULL) {
- int i;
- for (i = 0; i < lf_sync->rows; ++i) {
- pthread_cond_destroy(&lf_sync->recon_done_cond[i]);
- }
- vpx_free(lf_sync->recon_done_cond);
+ if (lf_sync->lf_mutex != NULL) {
+ pthread_mutex_destroy(lf_sync->lf_mutex);
+ vpx_free(lf_sync->lf_mutex);
+ }
+ if (lf_sync->recon_done_cond != NULL) {
+ int i;
+ for (i = 0; i < lf_sync->rows; ++i) {
+ pthread_cond_destroy(&lf_sync->recon_done_cond[i]);
}
+ vpx_free(lf_sync->recon_done_cond);
+ }
#endif // CONFIG_MULTITHREAD
- vpx_free(lf_sync->lfdata);
- vpx_free(lf_sync->cur_sb_col);
- vpx_free(lf_sync->num_tiles_done);
- // clear the structure as the source of this call may be a resize in which
- // case this call will be followed by an _alloc() which may fail.
- vp9_zero(*lf_sync);
- }
+ vpx_free(lf_sync->lfdata);
+ vpx_free(lf_sync->cur_sb_col);
+ vpx_free(lf_sync->num_tiles_done);
+ // clear the structure as the source of this call may be a resize in which
+ // case this call will be followed by an _alloc() which may fail.
+ vp9_zero(*lf_sync);
}
static int get_next_row(VP9_COMMON *cm, VP9LfSync *lf_sync) {
@@ -390,7 +396,7 @@ static int get_next_row(VP9_COMMON *cm, VP9LfSync *lf_sync) {
#if CONFIG_MULTITHREAD
const int tile_cols = 1 << cm->log2_tile_cols;
- pthread_mutex_lock(&lf_sync->lf_mutex);
+ pthread_mutex_lock(lf_sync->lf_mutex);
if (cm->lf_row < max_rows) {
cur_row = cm->lf_row >> MI_BLOCK_SIZE_LOG2;
return_val = cm->lf_row;
@@ -401,7 +407,7 @@ static int get_next_row(VP9_COMMON *cm, VP9LfSync *lf_sync) {
cur_row += 1;
}
}
- pthread_mutex_unlock(&lf_sync->lf_mutex);
+ pthread_mutex_unlock(lf_sync->lf_mutex);
if (return_val == -1) return return_val;
@@ -411,7 +417,7 @@ static int get_next_row(VP9_COMMON *cm, VP9LfSync *lf_sync) {
&lf_sync->recon_done_mutex[cur_row]);
}
pthread_mutex_unlock(&lf_sync->recon_done_mutex[cur_row]);
- pthread_mutex_lock(&lf_sync->lf_mutex);
+ pthread_mutex_lock(lf_sync->lf_mutex);
if (lf_sync->corrupted) {
int row = return_val >> MI_BLOCK_SIZE_LOG2;
pthread_mutex_lock(&lf_sync->mutex[row]);
@@ -420,7 +426,7 @@ static int get_next_row(VP9_COMMON *cm, VP9LfSync *lf_sync) {
pthread_mutex_unlock(&lf_sync->mutex[row]);
return_val = -1;
}
- pthread_mutex_unlock(&lf_sync->lf_mutex);
+ pthread_mutex_unlock(lf_sync->lf_mutex);
#else
(void)lf_sync;
if (cm->lf_row < max_rows) {
@@ -455,9 +461,9 @@ void vp9_loopfilter_rows(LFWorkerData *lf_data, VP9LfSync *lf_sync) {
void vp9_set_row(VP9LfSync *lf_sync, int num_tiles, int row, int is_last_row,
int corrupted) {
#if CONFIG_MULTITHREAD
- pthread_mutex_lock(&lf_sync->lf_mutex);
+ pthread_mutex_lock(lf_sync->lf_mutex);
lf_sync->corrupted |= corrupted;
- pthread_mutex_unlock(&lf_sync->lf_mutex);
+ pthread_mutex_unlock(lf_sync->lf_mutex);
pthread_mutex_lock(&lf_sync->recon_done_mutex[row]);
lf_sync->num_tiles_done[row] += 1;
if (num_tiles == lf_sync->num_tiles_done[row]) {
diff --git a/libvpx/vp9/common/vp9_thread_common.h b/libvpx/vp9/common/vp9_thread_common.h
index 94c9de659..5df0117f1 100644
--- a/libvpx/vp9/common/vp9_thread_common.h
+++ b/libvpx/vp9/common/vp9_thread_common.h
@@ -40,7 +40,7 @@ typedef struct VP9LfSyncData {
int num_active_workers; // number of scheduled workers.
#if CONFIG_MULTITHREAD
- pthread_mutex_t lf_mutex;
+ pthread_mutex_t *lf_mutex;
pthread_mutex_t *recon_done_mutex;
pthread_cond_t *recon_done_cond;
#endif