Merge "Tie the bit cost scale to a define."
diff --git a/examples/vp9_spatial_svc_encoder.c b/examples/vp9_spatial_svc_encoder.c
index d2b3688..271ab70 100644
--- a/examples/vp9_spatial_svc_encoder.c
+++ b/examples/vp9_spatial_svc_encoder.c
@@ -30,6 +30,7 @@
#include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h"
#include "../vpxstats.h"
+#include "vp9/encoder/vp9_encoder.h"
#define OUTPUT_RC_STATS 1
static const arg_def_t skip_frames_arg =
@@ -749,6 +750,7 @@
cx_time += vpx_usec_timer_elapsed(&timer);
printf("%s", vpx_svc_get_message(&svc_ctx));
+ fflush(stdout);
if (res != VPX_CODEC_OK) {
die_codec(&codec, "Failed to encode frame");
}
@@ -756,6 +758,7 @@
while ((cx_pkt = vpx_codec_get_cx_data(&codec, &iter)) != NULL) {
switch (cx_pkt->kind) {
case VPX_CODEC_CX_FRAME_PKT: {
+ SvcInternal_t *const si = (SvcInternal_t *)svc_ctx.internal;
if (cx_pkt->data.frame.sz > 0) {
#if OUTPUT_RC_STATS
uint32_t sizes[8];
@@ -851,6 +854,8 @@
printf("SVC frame: %d, kf: %d, size: %d, pts: %d\n", frames_received,
!!(cx_pkt->data.frame.flags & VPX_FRAME_IS_KEY),
(int)cx_pkt->data.frame.sz, (int)cx_pkt->data.frame.pts);
+ if (enc_cfg.ss_number_layers == 1 && enc_cfg.ts_number_layers == 1)
+ si->bytes_sum[0] += (int)cx_pkt->data.frame.sz;
++frames_received;
break;
}
diff --git a/examples/vpx_temporal_svc_encoder.c b/examples/vpx_temporal_svc_encoder.c
index 5adda9e..16abb9d 100644
--- a/examples/vpx_temporal_svc_encoder.c
+++ b/examples/vpx_temporal_svc_encoder.c
@@ -41,7 +41,7 @@
kDenoiserOnAdaptive
};
-static int mode_to_num_layers[12] = {1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3};
+static int mode_to_num_layers[13] = {1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3, 3};
// For rate control encoding stats.
struct RateControlMetrics {
@@ -432,7 +432,32 @@
layer_flags[7] = layer_flags[3];
break;
}
- case 11:
+ case 11: {
+ // 3-layers structure with one reference frame.
+ // This works same as temporal_layering_mode 3.
+ // This was added to compare with vp9_spatial_svc_encoder.
+
+ // 3-layers, 4-frame period.
+ int ids[4] = {0, 2, 1, 2};
+ cfg->ts_periodicity = 4;
+ *flag_periodicity = 4;
+ cfg->ts_number_layers = 3;
+ cfg->ts_rate_decimator[0] = 4;
+ cfg->ts_rate_decimator[1] = 2;
+ cfg->ts_rate_decimator[2] = 1;
+ memcpy(cfg->ts_layer_id, ids, sizeof(ids));
+ // 0=L, 1=GF, 2=ARF, Intra-layer prediction disabled.
+ layer_flags[0] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
+ VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
+ layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
+ VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
+ layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
+ VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
+ layer_flags[3] = VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_ARF |
+ VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
+ break;
+ }
+ case 12:
default: {
// 3-layers structure as in case 10, but no sync/refresh points for
// layer 1 and 2.
@@ -530,7 +555,7 @@
}
layering_mode = strtol(argv[10], NULL, 0);
- if (layering_mode < 0 || layering_mode > 12) {
+ if (layering_mode < 0 || layering_mode > 13) {
die("Invalid layering mode (0..12) %s", argv[10]);
}
diff --git a/test/datarate_test.cc b/test/datarate_test.cc
index cec6d09..b98f8c8 100644
--- a/test/datarate_test.cc
+++ b/test/datarate_test.cc
@@ -905,9 +905,7 @@
svc_params_.scaling_factor_den[0] = 288;
svc_params_.scaling_factor_num[1] = 288;
svc_params_.scaling_factor_den[1] = 288;
- // TODO(wonkap/marpan): No frame drop for now, we need to implement correct
- // frame dropping for SVC.
- cfg_.rc_dropframe_thresh = 0;
+ cfg_.rc_dropframe_thresh = 10;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 200);
// TODO(wonkap/marpan): Check that effective_datarate for each layer hits the
@@ -949,9 +947,7 @@
svc_params_.scaling_factor_den[0] = 288;
svc_params_.scaling_factor_num[1] = 288;
svc_params_.scaling_factor_den[1] = 288;
- // TODO(wonkap/marpan): No frame drop for now, we need to implement correct
- // frame dropping for SVC.
- cfg_.rc_dropframe_thresh = 0;
+ cfg_.rc_dropframe_thresh = 10;
::libvpx_test::I420VideoSource video("niklas_1280_720_30.y4m", 1280, 720,
30, 1, 0, 300);
cfg_.rc_target_bitrate = 800;
diff --git a/vp8/common/threading.h b/vp8/common/threading.h
index 01c82db..bc99dbb 100644
--- a/vp8/common/threading.h
+++ b/vp8/common/threading.h
@@ -12,6 +12,7 @@
#ifndef VP8_COMMON_THREADING_H_
#define VP8_COMMON_THREADING_H_
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -28,8 +29,6 @@
#define THREAD_SPECIFIC_INDEX DWORD
#define pthread_t HANDLE
#define pthread_attr_t DWORD
-#define pthread_create(thhandle,attr,thfunc,tharg) (int)((*thhandle=(HANDLE)_beginthreadex(NULL,0,(unsigned int (__stdcall *)(void *))thfunc,tharg,0,NULL))==NULL)
-#define pthread_join(thread, result) ((WaitForSingleObject((thread),INFINITE)!=WAIT_OBJECT_0) || !CloseHandle(thread))
#define pthread_detach(thread) if(thread!=NULL)CloseHandle(thread)
#define thread_sleep(nms) Sleep(nms)
#define pthread_cancel(thread) terminate_thread(thread,0)
@@ -49,9 +48,6 @@
#define THREAD_SPECIFIC_INDEX PULONG
#define pthread_t TID
#define pthread_attr_t ULONG
-#define pthread_create(thhandle,attr,thfunc,tharg) \
- ((int)((*(thhandle)=_beginthread(thfunc,NULL,1024*1024,tharg))==-1))
-#define pthread_join(thread, result) ((int)DosWaitThread(&(thread),0))
#define pthread_detach(thread) 0
#define thread_sleep(nms) DosSleep(nms)
#define pthread_cancel(thread) DosKillThread(thread)
@@ -185,6 +181,47 @@
#define x86_pause_hint()
#endif
+#include "vpx_util/vpx_thread.h"
+
+static INLINE void mutex_lock(pthread_mutex_t *const mutex) {
+ const int kMaxTryLocks = 4000;
+ int locked = 0;
+ int i;
+
+ for (i = 0; i < kMaxTryLocks; ++i) {
+ if (!pthread_mutex_trylock(mutex)) {
+ locked = 1;
+ break;
+ }
+ }
+
+ if (!locked)
+ pthread_mutex_lock(mutex);
+}
+
+static INLINE int protected_read(pthread_mutex_t *const mutex, const int *p) {
+ int ret;
+ mutex_lock(mutex);
+ ret = *p;
+ pthread_mutex_unlock(mutex);
+ return ret;
+}
+
+static INLINE void sync_read(pthread_mutex_t *const mutex, int mb_col,
+ const int *last_row_current_mb_col,
+ const int nsync) {
+ while (mb_col > (protected_read(mutex, last_row_current_mb_col) - nsync)) {
+ x86_pause_hint();
+ thread_sleep(0);
+ }
+}
+
+static INLINE void protected_write(pthread_mutex_t *mutex, int *p, int v) {
+ mutex_lock(mutex);
+ *p = v;
+ pthread_mutex_unlock(mutex);
+}
+
#endif /* CONFIG_OS_SUPPORT && CONFIG_MULTITHREAD */
#ifdef __cplusplus
diff --git a/vp8/decoder/onyxd_int.h b/vp8/decoder/onyxd_int.h
index aa2cc57..313fe01 100644
--- a/vp8/decoder/onyxd_int.h
+++ b/vp8/decoder/onyxd_int.h
@@ -81,7 +81,7 @@
#if CONFIG_MULTITHREAD
/* variable for threading */
- volatile int b_multithreaded_rd;
+ int b_multithreaded_rd;
int max_threads;
int current_mb_col_main;
unsigned int decoding_thread_count;
@@ -90,6 +90,8 @@
int mt_baseline_filter_level[MAX_MB_SEGMENTS];
int sync_range;
int *mt_current_mb_col; /* Each row remembers its already decoded column. */
+ pthread_mutex_t *pmutex;
+ pthread_mutex_t mt_mutex; /* mutex for b_multithreaded_rd */
unsigned char **mt_yabove_row; /* mb_rows x width */
unsigned char **mt_uabove_row;
diff --git a/vp8/decoder/threading.c b/vp8/decoder/threading.c
index 7c7184c..97979e3 100644
--- a/vp8/decoder/threading.c
+++ b/vp8/decoder/threading.c
@@ -52,9 +52,6 @@
mbd->subpixel_predict8x8 = xd->subpixel_predict8x8;
mbd->subpixel_predict16x16 = xd->subpixel_predict16x16;
- mbd->mode_info_context = pc->mi + pc->mode_info_stride * (i + 1);
- mbd->mode_info_stride = pc->mode_info_stride;
-
mbd->frame_type = pc->frame_type;
mbd->pre = xd->pre;
mbd->dst = xd->dst;
@@ -298,8 +295,8 @@
static void mt_decode_mb_rows(VP8D_COMP *pbi, MACROBLOCKD *xd, int start_mb_row)
{
- volatile const int *last_row_current_mb_col;
- volatile int *current_mb_col;
+ const int *last_row_current_mb_col;
+ int *current_mb_col;
int mb_row;
VP8_COMMON *pc = &pbi->common;
const int nsync = pbi->sync_range;
@@ -337,6 +334,9 @@
xd->up_available = (start_mb_row != 0);
+ xd->mode_info_context = pc->mi + pc->mode_info_stride * start_mb_row;
+ xd->mode_info_stride = pc->mode_info_stride;
+
for (mb_row = start_mb_row; mb_row < pc->mb_rows; mb_row += (pbi->decoding_thread_count + 1))
{
int recon_yoffset, recon_uvoffset;
@@ -405,17 +405,15 @@
xd->dst.uv_stride);
}
- for (mb_col = 0; mb_col < pc->mb_cols; mb_col++)
- {
- *current_mb_col = mb_col - 1;
+ for (mb_col = 0; mb_col < pc->mb_cols; mb_col++) {
+ if (((mb_col - 1) % nsync) == 0) {
+ pthread_mutex_t *mutex = &pbi->pmutex[mb_row];
+ protected_write(mutex, current_mb_col, mb_col - 1);
+ }
- if ((mb_col & (nsync - 1)) == 0)
- {
- while (mb_col > (*last_row_current_mb_col - nsync))
- {
- x86_pause_hint();
- thread_sleep(0);
- }
+ if (mb_row && !(mb_col & (nsync - 1))) {
+ pthread_mutex_t *mutex = &pbi->pmutex[mb_row-1];
+ sync_read(mutex, mb_col, last_row_current_mb_col, nsync);
}
/* Distance of MB to the various image edges.
@@ -604,7 +602,7 @@
xd->dst.u_buffer + 8, xd->dst.v_buffer + 8);
/* last MB of row is ready just after extension is done */
- *current_mb_col = mb_col + nsync;
+ protected_write(&pbi->pmutex[mb_row], current_mb_col, mb_col + nsync);
++xd->mode_info_context; /* skip prediction column */
xd->up_available = 1;
@@ -629,12 +627,12 @@
while (1)
{
- if (pbi->b_multithreaded_rd == 0)
+ if (protected_read(&pbi->mt_mutex, &pbi->b_multithreaded_rd) == 0)
break;
if (sem_wait(&pbi->h_event_start_decoding[ithread]) == 0)
{
- if (pbi->b_multithreaded_rd == 0)
+ if (protected_read(&pbi->mt_mutex, &pbi->b_multithreaded_rd) == 0)
break;
else
{
@@ -657,6 +655,7 @@
pbi->b_multithreaded_rd = 0;
pbi->allocated_decoding_thread_count = 0;
+ pthread_mutex_init(&pbi->mt_mutex, NULL);
/* limit decoding threads to the max number of token partitions */
core_count = (pbi->max_threads > 8) ? 8 : pbi->max_threads;
@@ -699,8 +698,17 @@
{
int i;
- if (pbi->b_multithreaded_rd)
+ if (protected_read(&pbi->mt_mutex, &pbi->b_multithreaded_rd))
{
+ /* De-allocate mutex */
+ if (pbi->pmutex != NULL) {
+ for (i = 0; i < mb_rows; i++) {
+ pthread_mutex_destroy(&pbi->pmutex[i]);
+ }
+ vpx_free(pbi->pmutex);
+ pbi->pmutex = NULL;
+ }
+
vpx_free(pbi->mt_current_mb_col);
pbi->mt_current_mb_col = NULL ;
@@ -781,7 +789,7 @@
int i;
int uv_width;
- if (pbi->b_multithreaded_rd)
+ if (protected_read(&pbi->mt_mutex, &pbi->b_multithreaded_rd))
{
vp8mt_de_alloc_temp_buffers(pbi, prev_mb_rows);
@@ -796,6 +804,15 @@
uv_width = width >>1;
+ /* Allocate mutex */
+ CHECK_MEM_ERROR(pbi->pmutex, vpx_malloc(sizeof(*pbi->pmutex) *
+ pc->mb_rows));
+ if (pbi->pmutex) {
+ for (i = 0; i < pc->mb_rows; i++) {
+ pthread_mutex_init(&pbi->pmutex[i], NULL);
+ }
+ }
+
/* Allocate an int for each mb row. */
CALLOC_ARRAY(pbi->mt_current_mb_col, pc->mb_rows);
@@ -831,11 +848,11 @@
void vp8_decoder_remove_threads(VP8D_COMP *pbi)
{
/* shutdown MB Decoding thread; */
- if (pbi->b_multithreaded_rd)
+ if (protected_read(&pbi->mt_mutex, &pbi->b_multithreaded_rd))
{
int i;
- pbi->b_multithreaded_rd = 0;
+ protected_write(&pbi->mt_mutex, &pbi->b_multithreaded_rd, 0);
/* allow all threads to exit */
for (i = 0; i < pbi->allocated_decoding_thread_count; i++)
@@ -863,6 +880,7 @@
vpx_free(pbi->de_thread_data);
pbi->de_thread_data = NULL;
}
+ pthread_mutex_destroy(&pbi->mt_mutex);
}
void vp8mt_decode_mb_rows( VP8D_COMP *pbi, MACROBLOCKD *xd)
diff --git a/vp8/encoder/denoising.c b/vp8/encoder/denoising.c
index d197f8f..2a21943 100644
--- a/vp8/encoder/denoising.c
+++ b/vp8/encoder/denoising.c
@@ -604,10 +604,9 @@
NOISE_MOTION_THRESHOLD;
// If block is considered to be skin area, lower the motion threshold.
- // In current version set threshold = 1, so only denoise very low
- // (i.e., zero) mv on skin.
+ // In current version set threshold = 0, so only denoise zero mv on skin.
if (x->is_skin)
- motion_threshold = 1;
+ motion_threshold = 0;
if (motion_magnitude2 <
denoiser->denoise_pars.scale_increase_filter * NOISE_MOTION_THRESHOLD)
diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c
index b0aaa2f..9b05cd1 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -386,8 +386,8 @@
#if CONFIG_MULTITHREAD
const int nsync = cpi->mt_sync_range;
const int rightmost_col = cm->mb_cols + nsync;
- volatile const int *last_row_current_mb_col;
- volatile int *current_mb_col = &cpi->mt_current_mb_col[mb_row];
+ const int *last_row_current_mb_col;
+ int *current_mb_col = &cpi->mt_current_mb_col[mb_row];
if ((cpi->b_multi_threaded != 0) && (mb_row != 0))
last_row_current_mb_col = &cpi->mt_current_mb_col[mb_row - 1];
@@ -461,17 +461,15 @@
vp8_copy_mem16x16(x->src.y_buffer, x->src.y_stride, x->thismb, 16);
#if CONFIG_MULTITHREAD
- if (cpi->b_multi_threaded != 0)
- {
- *current_mb_col = mb_col - 1; /* set previous MB done */
+ if (cpi->b_multi_threaded != 0) {
+ if (((mb_col - 1) % nsync) == 0) {
+ pthread_mutex_t *mutex = &cpi->pmutex[mb_row];
+ protected_write(mutex, current_mb_col, mb_col - 1);
+ }
- if ((mb_col & (nsync - 1)) == 0)
- {
- while (mb_col > (*last_row_current_mb_col - nsync))
- {
- x86_pause_hint();
- thread_sleep(0);
- }
+ if (mb_row && !(mb_col & (nsync - 1))) {
+ pthread_mutex_t *mutex = &cpi->pmutex[mb_row-1];
+ sync_read(mutex, mb_col, last_row_current_mb_col, nsync);
}
}
#endif
@@ -616,7 +614,7 @@
#if CONFIG_MULTITHREAD
if (cpi->b_multi_threaded != 0)
- *current_mb_col = rightmost_col;
+ protected_write(&cpi->pmutex[mb_row], current_mb_col, rightmost_col);
#endif
/* this is to account for the border */
diff --git a/vp8/encoder/ethreading.c b/vp8/encoder/ethreading.c
index 4e234cc..4f689c4 100644
--- a/vp8/encoder/ethreading.c
+++ b/vp8/encoder/ethreading.c
@@ -26,12 +26,13 @@
while (1)
{
- if (cpi->b_multi_threaded == 0)
+ if (protected_read(&cpi->mt_mutex, &cpi->b_multi_threaded) == 0)
break;
if (sem_wait(&cpi->h_event_start_lpf) == 0)
{
- if (cpi->b_multi_threaded == 0) /* we're shutting down */
+ /* we're shutting down */
+ if (protected_read(&cpi->mt_mutex, &cpi->b_multi_threaded) == 0)
break;
vp8_loopfilter_frame(cpi, cm);
@@ -53,7 +54,7 @@
while (1)
{
- if (cpi->b_multi_threaded == 0)
+ if (protected_read(&cpi->mt_mutex, &cpi->b_multi_threaded) == 0)
break;
if (sem_wait(&cpi->h_event_start_encoding[ithread]) == 0)
@@ -72,9 +73,14 @@
int *segment_counts = mbri->segment_counts;
int *totalrate = &mbri->totalrate;
- if (cpi->b_multi_threaded == 0) /* we're shutting down */
+ /* we're shutting down */
+ if (protected_read(&cpi->mt_mutex, &cpi->b_multi_threaded) == 0)
break;
+ xd->mode_info_context = cm->mi + cm->mode_info_stride *
+ (ithread + 1);
+ xd->mode_info_stride = cm->mode_info_stride;
+
for (mb_row = ithread + 1; mb_row < cm->mb_rows; mb_row += (cpi->encoding_thread_count + 1))
{
@@ -85,8 +91,8 @@
int recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
int recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
int map_index = (mb_row * cm->mb_cols);
- volatile const int *last_row_current_mb_col;
- volatile int *current_mb_col = &cpi->mt_current_mb_col[mb_row];
+ const int *last_row_current_mb_col;
+ int *current_mb_col = &cpi->mt_current_mb_col[mb_row];
#if (CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING)
vp8_writer *w = &cpi->bc[1 + (mb_row % num_part)];
@@ -113,15 +119,14 @@
/* for each macroblock col in image */
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
{
- *current_mb_col = mb_col - 1;
+ if (((mb_col - 1) % nsync) == 0) {
+ pthread_mutex_t *mutex = &cpi->pmutex[mb_row];
+ protected_write(mutex, current_mb_col, mb_col - 1);
+ }
- if ((mb_col & (nsync - 1)) == 0)
- {
- while (mb_col > (*last_row_current_mb_col - nsync))
- {
- x86_pause_hint();
- thread_sleep(0);
- }
+ if (mb_row && !(mb_col & (nsync - 1))) {
+ pthread_mutex_t *mutex = &cpi->pmutex[mb_row-1];
+ sync_read(mutex, mb_col, last_row_current_mb_col, nsync);
}
#if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING
@@ -296,7 +301,8 @@
xd->dst.u_buffer + 8,
xd->dst.v_buffer + 8);
- *current_mb_col = mb_col + nsync;
+ protected_write(&cpi->pmutex[mb_row], current_mb_col,
+ mb_col + nsync);
/* this is to account for the border */
xd->mode_info_context++;
@@ -473,9 +479,6 @@
mb->partition_info = x->pi + x->e_mbd.mode_info_stride * (i + 1);
- mbd->mode_info_context = cm->mi + x->e_mbd.mode_info_stride * (i + 1);
- mbd->mode_info_stride = cm->mode_info_stride;
-
mbd->frame_type = cm->frame_type;
mb->src = * cpi->Source;
@@ -517,6 +520,8 @@
cpi->encoding_thread_count = 0;
cpi->b_lpf_running = 0;
+ pthread_mutex_init(&cpi->mt_mutex, NULL);
+
if (cm->processor_core_count > 1 && cpi->oxcf.multi_threaded > 1)
{
int ithread;
@@ -580,7 +585,7 @@
if(rc)
{
/* shutdown other threads */
- cpi->b_multi_threaded = 0;
+ protected_write(&cpi->mt_mutex, &cpi->b_multi_threaded, 0);
for(--ithread; ithread >= 0; ithread--)
{
pthread_join(cpi->h_encoding_thread[ithread], 0);
@@ -594,6 +599,8 @@
vpx_free(cpi->mb_row_ei);
vpx_free(cpi->en_thread_data);
+ pthread_mutex_destroy(&cpi->mt_mutex);
+
return -1;
}
@@ -611,7 +618,7 @@
if(rc)
{
/* shutdown other threads */
- cpi->b_multi_threaded = 0;
+ protected_write(&cpi->mt_mutex, &cpi->b_multi_threaded, 0);
for(--ithread; ithread >= 0; ithread--)
{
sem_post(&cpi->h_event_start_encoding[ithread]);
@@ -628,6 +635,8 @@
vpx_free(cpi->mb_row_ei);
vpx_free(cpi->en_thread_data);
+ pthread_mutex_destroy(&cpi->mt_mutex);
+
return -2;
}
}
@@ -637,10 +646,10 @@
void vp8cx_remove_encoder_threads(VP8_COMP *cpi)
{
- if (cpi->b_multi_threaded)
+ if (protected_read(&cpi->mt_mutex, &cpi->b_multi_threaded))
{
/* shutdown other threads */
- cpi->b_multi_threaded = 0;
+ protected_write(&cpi->mt_mutex, &cpi->b_multi_threaded, 0);
{
int i;
@@ -666,5 +675,6 @@
vpx_free(cpi->mb_row_ei);
vpx_free(cpi->en_thread_data);
}
+ pthread_mutex_destroy(&cpi->mt_mutex);
}
#endif
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index df5bcf6..5a4b37d 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -477,6 +477,18 @@
cpi->mb.pip = 0;
#if CONFIG_MULTITHREAD
+ /* De-allocate mutex */
+ if (cpi->pmutex != NULL) {
+ VP8_COMMON *const pc = &cpi->common;
+ int i;
+
+ for (i = 0; i < pc->mb_rows; i++) {
+ pthread_mutex_destroy(&cpi->pmutex[i]);
+ }
+ vpx_free(cpi->pmutex);
+ cpi->pmutex = NULL;
+ }
+
vpx_free(cpi->mt_current_mb_col);
cpi->mt_current_mb_col = NULL;
#endif
@@ -1180,6 +1192,9 @@
int width = cm->Width;
int height = cm->Height;
+#if CONFIG_MULTITHREAD
+ int prev_mb_rows = cm->mb_rows;
+#endif
if (vp8_alloc_frame_buffers(cm, width, height))
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
@@ -1271,6 +1286,25 @@
if (cpi->oxcf.multi_threaded > 1)
{
+ int i;
+
+ /* De-allocate and re-allocate mutex */
+ if (cpi->pmutex != NULL) {
+ for (i = 0; i < prev_mb_rows; i++) {
+ pthread_mutex_destroy(&cpi->pmutex[i]);
+ }
+ vpx_free(cpi->pmutex);
+ cpi->pmutex = NULL;
+ }
+
+ CHECK_MEM_ERROR(cpi->pmutex, vpx_malloc(sizeof(*cpi->pmutex) *
+ cm->mb_rows));
+ if (cpi->pmutex) {
+ for (i = 0; i < cm->mb_rows; i++) {
+ pthread_mutex_init(&cpi->pmutex[i], NULL);
+ }
+ }
+
vpx_free(cpi->mt_current_mb_col);
CHECK_MEM_ERROR(cpi->mt_current_mb_col,
vpx_malloc(sizeof(*cpi->mt_current_mb_col) * cm->mb_rows));
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index 317e4b9..2b2f7a0 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -530,6 +530,8 @@
#if CONFIG_MULTITHREAD
/* multithread data */
+ pthread_mutex_t *pmutex;
+ pthread_mutex_t mt_mutex; /* mutex for b_multi_threaded */
int * mt_current_mb_col;
int mt_sync_range;
int b_multi_threaded;
diff --git a/vp9/common/vp9_blockd.c b/vp9/common/vp9_blockd.c
index 0e104ee..7bab27d 100644
--- a/vp9/common/vp9_blockd.c
+++ b/vp9/common/vp9_blockd.c
@@ -13,7 +13,7 @@
PREDICTION_MODE vp9_left_block_mode(const MODE_INFO *cur_mi,
const MODE_INFO *left_mi, int b) {
if (b == 0 || b == 2) {
- if (!left_mi || is_inter_block(&left_mi->mbmi))
+ if (!left_mi || is_inter_block(left_mi))
return DC_PRED;
return get_y_mode(left_mi, b + 1);
@@ -26,7 +26,7 @@
PREDICTION_MODE vp9_above_block_mode(const MODE_INFO *cur_mi,
const MODE_INFO *above_mi, int b) {
if (b == 0 || b == 1) {
- if (!above_mi || is_inter_block(&above_mi->mbmi))
+ if (!above_mi || is_inter_block(above_mi))
return DC_PRED;
return get_y_mode(above_mi, b + 2);
@@ -40,12 +40,12 @@
const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane,
foreach_transformed_block_visitor visit, void *arg) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
- const MB_MODE_INFO* mbmi = &xd->mi[0]->mbmi;
+ const MODE_INFO* mi = xd->mi[0];
// block and transform sizes, in number of 4x4 blocks log 2 ("*_b")
// 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
// transform size varies per plane, look it up in a common way.
- const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi, pd)
- : mbmi->tx_size;
+ const TX_SIZE tx_size = plane ? get_uv_tx_size(mi, pd)
+ : mi->tx_size;
const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize];
const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize];
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index 61eb591..ae2f66a 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -64,7 +64,7 @@
typedef int8_t MV_REFERENCE_FRAME;
// This structure now relates to 8x8 block regions.
-typedef struct {
+typedef struct MODE_INFO {
// Common for both INTER and INTRA blocks
BLOCK_SIZE sb_type;
PREDICTION_MODE mode;
@@ -82,24 +82,21 @@
// TODO(slavarnway): Delete and use bmi[3].as_mv[] instead.
int_mv mv[2];
-} MB_MODE_INFO;
-typedef struct MODE_INFO {
- MB_MODE_INFO mbmi;
b_mode_info bmi[4];
} MODE_INFO;
static INLINE PREDICTION_MODE get_y_mode(const MODE_INFO *mi, int block) {
- return mi->mbmi.sb_type < BLOCK_8X8 ? mi->bmi[block].as_mode
- : mi->mbmi.mode;
+ return mi->sb_type < BLOCK_8X8 ? mi->bmi[block].as_mode
+ : mi->mode;
}
-static INLINE int is_inter_block(const MB_MODE_INFO *mbmi) {
- return mbmi->ref_frame[0] > INTRA_FRAME;
+static INLINE int is_inter_block(const MODE_INFO *mi) {
+ return mi->ref_frame[0] > INTRA_FRAME;
}
-static INLINE int has_second_ref(const MB_MODE_INFO *mbmi) {
- return mbmi->ref_frame[1] > INTRA_FRAME;
+static INLINE int has_second_ref(const MODE_INFO *mi) {
+ return mi->ref_frame[1] > INTRA_FRAME;
}
PREDICTION_MODE vp9_left_block_mode(const MODE_INFO *cur_mi,
@@ -160,8 +157,6 @@
MODE_INFO **mi;
MODE_INFO *left_mi;
MODE_INFO *above_mi;
- MB_MODE_INFO *left_mbmi;
- MB_MODE_INFO *above_mbmi;
int up_available;
int left_available;
@@ -212,19 +207,19 @@
static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type,
const MACROBLOCKD *xd) {
- const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ const MODE_INFO *const mi = xd->mi[0];
- if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(mbmi))
+ if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(mi))
return DCT_DCT;
- return intra_mode_to_tx_type_lookup[mbmi->mode];
+ return intra_mode_to_tx_type_lookup[mi->mode];
}
static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type,
const MACROBLOCKD *xd, int ib) {
const MODE_INFO *const mi = xd->mi[0];
- if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(&mi->mbmi))
+ if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(mi))
return DCT_DCT;
return intra_mode_to_tx_type_lookup[get_y_mode(mi, ib)];
@@ -242,9 +237,9 @@
}
}
-static INLINE TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi,
+static INLINE TX_SIZE get_uv_tx_size(const MODE_INFO *mi,
const struct macroblockd_plane *pd) {
- return get_uv_tx_size_impl(mbmi->tx_size, mbmi->sb_type, pd->subsampling_x,
+ return get_uv_tx_size_impl(mi->tx_size, mi->sb_type, pd->subsampling_x,
pd->subsampling_y);
}
diff --git a/vp9/common/vp9_debugmodes.c b/vp9/common/vp9_debugmodes.c
index 3d80103..d9c1fd9 100644
--- a/vp9/common/vp9_debugmodes.c
+++ b/vp9/common/vp9_debugmodes.c
@@ -35,7 +35,7 @@
fprintf(file, "%c ", prefix);
for (mi_col = 0; mi_col < cols; mi_col++) {
fprintf(file, "%2d ",
- *((int*) ((char *) (&mi[0]->mbmi) +
+ *((int*) ((char *) (mi[0]) +
member_offset)));
mi++;
}
@@ -53,18 +53,18 @@
int rows = cm->mi_rows;
int cols = cm->mi_cols;
- print_mi_data(cm, mvs, "Partitions:", offsetof(MB_MODE_INFO, sb_type));
- print_mi_data(cm, mvs, "Modes:", offsetof(MB_MODE_INFO, mode));
- print_mi_data(cm, mvs, "Ref frame:", offsetof(MB_MODE_INFO, ref_frame[0]));
- print_mi_data(cm, mvs, "Transform:", offsetof(MB_MODE_INFO, tx_size));
- print_mi_data(cm, mvs, "UV Modes:", offsetof(MB_MODE_INFO, uv_mode));
+ print_mi_data(cm, mvs, "Partitions:", offsetof(MODE_INFO, sb_type));
+ print_mi_data(cm, mvs, "Modes:", offsetof(MODE_INFO, mode));
+ print_mi_data(cm, mvs, "Ref frame:", offsetof(MODE_INFO, ref_frame[0]));
+ print_mi_data(cm, mvs, "Transform:", offsetof(MODE_INFO, tx_size));
+ print_mi_data(cm, mvs, "UV Modes:", offsetof(MODE_INFO, uv_mode));
// output skip infomation.
log_frame_info(cm, "Skips:", mvs);
for (mi_row = 0; mi_row < rows; mi_row++) {
fprintf(mvs, "S ");
for (mi_col = 0; mi_col < cols; mi_col++) {
- fprintf(mvs, "%2d ", mi[0]->mbmi.skip);
+ fprintf(mvs, "%2d ", mi[0]->skip);
mi++;
}
fprintf(mvs, "\n");
@@ -78,8 +78,8 @@
for (mi_row = 0; mi_row < rows; mi_row++) {
fprintf(mvs, "V ");
for (mi_col = 0; mi_col < cols; mi_col++) {
- fprintf(mvs, "%4d:%4d ", mi[0]->mbmi.mv[0].as_mv.row,
- mi[0]->mbmi.mv[0].as_mv.col);
+ fprintf(mvs, "%4d:%4d ", mi[0]->mv[0].as_mv.row,
+ mi[0]->mv[0].as_mv.col);
mi++;
}
fprintf(mvs, "\n");
diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c
index b8a1132..79c3c48 100644
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -232,9 +232,9 @@
}
static uint8_t get_filter_level(const loop_filter_info_n *lfi_n,
- const MB_MODE_INFO *mbmi) {
- return lfi_n->lvl[mbmi->segment_id][mbmi->ref_frame[0]]
- [mode_lf_lut[mbmi->mode]];
+ const MODE_INFO *mi) {
+ return lfi_n->lvl[mi->segment_id][mi->ref_frame[0]]
+ [mode_lf_lut[mi->mode]];
}
void vp9_loop_filter_init(VP9_COMMON *cm) {
@@ -709,11 +709,10 @@
const MODE_INFO *mi, const int shift_y,
const int shift_uv,
LOOP_FILTER_MASK *lfm) {
- const MB_MODE_INFO *mbmi = &mi->mbmi;
- const BLOCK_SIZE block_size = mbmi->sb_type;
- const TX_SIZE tx_size_y = mbmi->tx_size;
+ const BLOCK_SIZE block_size = mi->sb_type;
+ const TX_SIZE tx_size_y = mi->tx_size;
const TX_SIZE tx_size_uv = get_uv_tx_size_impl(tx_size_y, block_size, 1, 1);
- const int filter_level = get_filter_level(lfi_n, mbmi);
+ const int filter_level = get_filter_level(lfi_n, mi);
uint64_t *const left_y = &lfm->left_y[tx_size_y];
uint64_t *const above_y = &lfm->above_y[tx_size_y];
uint64_t *const int_4x4_y = &lfm->int_4x4_y;
@@ -754,7 +753,7 @@
// If the block has no coefficients and is not intra we skip applying
// the loop filter on block edges.
- if (mbmi->skip && is_inter_block(mbmi))
+ if (mi->skip && is_inter_block(mi))
return;
// Here we are adding a mask for the transform size. The transform
@@ -788,10 +787,9 @@
static void build_y_mask(const loop_filter_info_n *const lfi_n,
const MODE_INFO *mi, const int shift_y,
LOOP_FILTER_MASK *lfm) {
- const MB_MODE_INFO *mbmi = &mi->mbmi;
- const BLOCK_SIZE block_size = mbmi->sb_type;
- const TX_SIZE tx_size_y = mbmi->tx_size;
- const int filter_level = get_filter_level(lfi_n, mbmi);
+ const BLOCK_SIZE block_size = mi->sb_type;
+ const TX_SIZE tx_size_y = mi->tx_size;
+ const int filter_level = get_filter_level(lfi_n, mi);
uint64_t *const left_y = &lfm->left_y[tx_size_y];
uint64_t *const above_y = &lfm->above_y[tx_size_y];
uint64_t *const int_4x4_y = &lfm->int_4x4_y;
@@ -812,7 +810,7 @@
*above_y |= above_prediction_mask[block_size] << shift_y;
*left_y |= left_prediction_mask[block_size] << shift_y;
- if (mbmi->skip && is_inter_block(mbmi))
+ if (mi->skip && is_inter_block(mi))
return;
*above_y |= (size_mask[block_size] &
@@ -980,7 +978,7 @@
// TODO(jimbankoski): Try moving most of the following code into decode
// loop and storing lfm in the mbmi structure so that we don't have to go
// through the recursive loop structure multiple times.
- switch (mip[0]->mbmi.sb_type) {
+ switch (mip[0]->sb_type) {
case BLOCK_64X64:
build_masks(lfi_n, mip[0] , 0, 0, lfm);
break;
@@ -1006,7 +1004,7 @@
const int mi_32_row_offset = ((idx_32 >> 1) << 2);
if (mi_32_col_offset >= max_cols || mi_32_row_offset >= max_rows)
continue;
- switch (mip[0]->mbmi.sb_type) {
+ switch (mip[0]->sb_type) {
case BLOCK_32X32:
build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm);
break;
@@ -1036,7 +1034,7 @@
if (mi_16_col_offset >= max_cols || mi_16_row_offset >= max_rows)
continue;
- switch (mip[0]->mbmi.sb_type) {
+ switch (mip[0]->sb_type) {
case BLOCK_16X16:
build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm);
break;
@@ -1186,8 +1184,8 @@
// Determine the vertical edges that need filtering
for (c = 0; c < MI_BLOCK_SIZE && mi_col + c < cm->mi_cols; c += col_step) {
const MODE_INFO *mi = mi_8x8[c];
- const BLOCK_SIZE sb_type = mi[0].mbmi.sb_type;
- const int skip_this = mi[0].mbmi.skip && is_inter_block(&mi[0].mbmi);
+ const BLOCK_SIZE sb_type = mi[0].sb_type;
+ const int skip_this = mi[0].skip && is_inter_block(mi);
// left edge of current unit is block/partition edge -> no skip
const int block_edge_left = (num_4x4_blocks_wide_lookup[sb_type] > 1) ?
!(c & (num_8x8_blocks_wide_lookup[sb_type] - 1)) : 1;
@@ -1196,13 +1194,13 @@
const int block_edge_above = (num_4x4_blocks_high_lookup[sb_type] > 1) ?
!(r & (num_8x8_blocks_high_lookup[sb_type] - 1)) : 1;
const int skip_this_r = skip_this && !block_edge_above;
- const TX_SIZE tx_size = get_uv_tx_size(&mi[0].mbmi, plane);
+ const TX_SIZE tx_size = get_uv_tx_size(mi, plane);
const int skip_border_4x4_c = ss_x && mi_col + c == cm->mi_cols - 1;
const int skip_border_4x4_r = ss_y && mi_row + r == cm->mi_rows - 1;
// Filter level can vary per MI
if (!(lfl[(r << 3) + (c >> ss_x)] =
- get_filter_level(&cm->lf_info, &mi[0].mbmi)))
+ get_filter_level(&cm->lf_info, mi)))
continue;
// Build masks based on the transform size of each block
@@ -1640,12 +1638,12 @@
// This function sets up the bit masks for a block represented
// by mi_row, mi_col in a 64x64 region.
// TODO(SJL): This function only works for yv12.
-void vp9_build_mask(VP9_COMMON *cm, const MB_MODE_INFO *mbmi, int mi_row,
+void vp9_build_mask(VP9_COMMON *cm, const MODE_INFO *mi, int mi_row,
int mi_col, int bw, int bh) {
- const BLOCK_SIZE block_size = mbmi->sb_type;
- const TX_SIZE tx_size_y = mbmi->tx_size;
+ const BLOCK_SIZE block_size = mi->sb_type;
+ const TX_SIZE tx_size_y = mi->tx_size;
const loop_filter_info_n *const lfi_n = &cm->lf_info;
- const int filter_level = get_filter_level(lfi_n, mbmi);
+ const int filter_level = get_filter_level(lfi_n, mi);
const TX_SIZE tx_size_uv = get_uv_tx_size_impl(tx_size_y, block_size, 1, 1);
LOOP_FILTER_MASK *const lfm = get_lfm(&cm->lf, mi_row, mi_col);
uint64_t *const left_y = &lfm->left_y[tx_size_y];
@@ -1693,7 +1691,7 @@
// If the block has no coefficients and is not intra we skip applying
// the loop filter on block edges.
- if (mbmi->skip && is_inter_block(mbmi))
+ if (mi->skip && is_inter_block(mi))
return;
// Add a mask for the transform size. The transform size mask is set to
diff --git a/vp9/common/vp9_loopfilter.h b/vp9/common/vp9_loopfilter.h
index 7f943ea..b2893a4 100644
--- a/vp9/common/vp9_loopfilter.h
+++ b/vp9/common/vp9_loopfilter.h
@@ -134,7 +134,7 @@
return &lf->lfm[(mi_col >> 3) + ((mi_row >> 3) * lf->lfm_stride)];
}
-void vp9_build_mask(struct VP9Common *cm, const MB_MODE_INFO *mbmi, int mi_row,
+void vp9_build_mask(struct VP9Common *cm, const MODE_INFO *mi, int mi_row,
int mi_col, int bw, int bh);
void vp9_adjust_mask(struct VP9Common *const cm, const int mi_row,
const int mi_col, LOOP_FILTER_MASK *lfm);
diff --git a/vp9/common/vp9_mfqe.c b/vp9/common/vp9_mfqe.c
index 6d560f4..f526466 100644
--- a/vp9/common/vp9_mfqe.c
+++ b/vp9/common/vp9_mfqe.c
@@ -203,12 +203,12 @@
static int mfqe_decision(MODE_INFO *mi, BLOCK_SIZE cur_bs) {
// Check the motion in current block(for inter frame),
// or check the motion in the correlated block in last frame (for keyframe).
- const int mv_len_square = mi->mbmi.mv[0].as_mv.row *
- mi->mbmi.mv[0].as_mv.row +
- mi->mbmi.mv[0].as_mv.col *
- mi->mbmi.mv[0].as_mv.col;
+ const int mv_len_square = mi->mv[0].as_mv.row *
+ mi->mv[0].as_mv.row +
+ mi->mv[0].as_mv.col *
+ mi->mv[0].as_mv.col;
const int mv_threshold = 100;
- return mi->mbmi.mode >= NEARESTMV && // Not an intra block
+ return mi->mode >= NEARESTMV && // Not an intra block
cur_bs >= BLOCK_16X16 &&
mv_len_square <= mv_threshold;
}
@@ -220,7 +220,7 @@
uint8_t *yd, uint8_t *ud, uint8_t *vd,
int yd_stride, int uvd_stride) {
int mi_offset, y_offset, uv_offset;
- const BLOCK_SIZE cur_bs = mi->mbmi.sb_type;
+ const BLOCK_SIZE cur_bs = mi->sb_type;
const int qdiff = cm->base_qindex - cm->postproc_state.last_base_qindex;
const int bsl = b_width_log2_lookup[bs];
PARTITION_TYPE partition = partition_lookup[bsl][cur_bs];
diff --git a/vp9/common/vp9_mvref_common.c b/vp9/common/vp9_mvref_common.c
index 9803ff6..0eb01a5 100644
--- a/vp9/common/vp9_mvref_common.c
+++ b/vp9/common/vp9_mvref_common.c
@@ -20,7 +20,7 @@
uint8_t *mode_context) {
const int *ref_sign_bias = cm->ref_frame_sign_bias;
int i, refmv_count = 0;
- const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type];
+ const POSITION *const mv_ref_search = mv_ref_blocks[mi->sb_type];
int different_ref_found = 0;
int context_counter = 0;
const MV_REF *const prev_frame_mvs = cm->use_prev_frame_mvs ?
@@ -38,15 +38,14 @@
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
const MODE_INFO *const candidate_mi = xd->mi[mv_ref->col + mv_ref->row *
xd->mi_stride];
- const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
// Keep counts for entropy encoding.
- context_counter += mode_2_counter[candidate->mode];
+ context_counter += mode_2_counter[candidate_mi->mode];
different_ref_found = 1;
- if (candidate->ref_frame[0] == ref_frame)
+ if (candidate_mi->ref_frame[0] == ref_frame)
ADD_MV_REF_LIST(get_sub_block_mv(candidate_mi, 0, mv_ref->col, block),
refmv_count, mv_ref_list, Done);
- else if (candidate->ref_frame[1] == ref_frame)
+ else if (candidate_mi->ref_frame[1] == ref_frame)
ADD_MV_REF_LIST(get_sub_block_mv(candidate_mi, 1, mv_ref->col, block),
refmv_count, mv_ref_list, Done);
}
@@ -58,14 +57,14 @@
for (; i < MVREF_NEIGHBOURS; ++i) {
const POSITION *const mv_ref = &mv_ref_search[i];
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
- const MB_MODE_INFO *const candidate =
- &xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]->mbmi;
+ const MODE_INFO *const candidate_mi =
+ xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride];
different_ref_found = 1;
- if (candidate->ref_frame[0] == ref_frame)
- ADD_MV_REF_LIST(candidate->mv[0], refmv_count, mv_ref_list, Done);
- else if (candidate->ref_frame[1] == ref_frame)
- ADD_MV_REF_LIST(candidate->mv[1], refmv_count, mv_ref_list, Done);
+ if (candidate_mi->ref_frame[0] == ref_frame)
+ ADD_MV_REF_LIST(candidate_mi->mv[0], refmv_count, mv_ref_list, Done);
+ else if (candidate_mi->ref_frame[1] == ref_frame)
+ ADD_MV_REF_LIST(candidate_mi->mv[1], refmv_count, mv_ref_list, Done);
}
}
@@ -85,11 +84,11 @@
for (i = 0; i < MVREF_NEIGHBOURS; ++i) {
const POSITION *mv_ref = &mv_ref_search[i];
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
- const MB_MODE_INFO *const candidate =
- &xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]->mbmi;
+ const MODE_INFO *const candidate_mi =
+ xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride];
// If the candidate is INTRA we don't want to consider its mv.
- IF_DIFF_REF_FRAME_ADD_MV(candidate, ref_frame, ref_sign_bias,
+ IF_DIFF_REF_FRAME_ADD_MV(candidate_mi, ref_frame, ref_sign_bias,
refmv_count, mv_ref_list, Done);
}
}
@@ -163,7 +162,7 @@
assert(MAX_MV_REF_CANDIDATES == 2);
- find_mv_refs_idx(cm, xd, mi, mi->mbmi.ref_frame[ref], mv_list, block,
+ find_mv_refs_idx(cm, xd, mi, mi->ref_frame[ref], mv_list, block,
mi_row, mi_col, mode_context);
near_mv->as_int = 0;
diff --git a/vp9/common/vp9_mvref_common.h b/vp9/common/vp9_mvref_common.h
index a6dddd0..4380843 100644
--- a/vp9/common/vp9_mvref_common.h
+++ b/vp9/common/vp9_mvref_common.h
@@ -136,19 +136,19 @@
// on whether the block_size < 8x8 and we have check_sub_blocks set.
static INLINE int_mv get_sub_block_mv(const MODE_INFO *candidate, int which_mv,
int search_col, int block_idx) {
- return block_idx >= 0 && candidate->mbmi.sb_type < BLOCK_8X8
+ return block_idx >= 0 && candidate->sb_type < BLOCK_8X8
? candidate->bmi[idx_n_column_to_subblock[block_idx][search_col == 0]]
.as_mv[which_mv]
- : candidate->mbmi.mv[which_mv];
+ : candidate->mv[which_mv];
}
// Performs mv sign inversion if indicated by the reference frame combination.
-static INLINE int_mv scale_mv(const MB_MODE_INFO *mbmi, int ref,
+static INLINE int_mv scale_mv(const MODE_INFO *mi, int ref,
const MV_REFERENCE_FRAME this_ref_frame,
const int *ref_sign_bias) {
- int_mv mv = mbmi->mv[ref];
- if (ref_sign_bias[mbmi->ref_frame[ref]] != ref_sign_bias[this_ref_frame]) {
+ int_mv mv = mi->mv[ref];
+ if (ref_sign_bias[mi->ref_frame[ref]] != ref_sign_bias[this_ref_frame]) {
mv.as_mv.row *= -1;
mv.as_mv.col *= -1;
}
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index ceffded..fd674cb 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -406,22 +406,17 @@
// Are edges available for intra prediction?
xd->up_available = (mi_row != 0);
xd->left_available = (mi_col > tile->mi_col_start);
+ // TODO(slavarnway): eliminate up/left available ???
if (xd->up_available) {
xd->above_mi = xd->mi[-xd->mi_stride];
- // above_mi may be NULL in VP9 encoder's first pass.
- xd->above_mbmi = xd->above_mi ? &xd->above_mi->mbmi : NULL;
} else {
xd->above_mi = NULL;
- xd->above_mbmi = NULL;
}
if (xd->left_available) {
xd->left_mi = xd->mi[-1];
- // left_mi may be NULL in VP9 encoder's first pass.
- xd->left_mbmi = xd->left_mi ? &xd->left_mi->mbmi : NULL;
} else {
xd->left_mi = NULL;
- xd->left_mbmi = NULL;
}
}
diff --git a/vp9/common/vp9_pred_common.c b/vp9/common/vp9_pred_common.c
index 1f16325..1bb11ef 100644
--- a/vp9/common/vp9_pred_common.c
+++ b/vp9/common/vp9_pred_common.c
@@ -19,12 +19,12 @@
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
- const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
- const int left_type = xd->left_available && is_inter_block(left_mbmi) ?
- left_mbmi->interp_filter : SWITCHABLE_FILTERS;
- const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
- const int above_type = xd->up_available && is_inter_block(above_mbmi) ?
- above_mbmi->interp_filter : SWITCHABLE_FILTERS;
+ const MODE_INFO *const left_mi = xd->left_mi;
+ const int left_type = xd->left_available && is_inter_block(left_mi) ?
+ left_mi->interp_filter : SWITCHABLE_FILTERS;
+ const MODE_INFO *const above_mi = xd->above_mi;
+ const int above_type = xd->up_available && is_inter_block(above_mi) ?
+ above_mi->interp_filter : SWITCHABLE_FILTERS;
if (left_type == above_type)
return left_type;
@@ -44,18 +44,18 @@
// 2 - intra/--, --/intra
// 3 - intra/intra
int vp9_get_intra_inter_context(const MACROBLOCKD *xd) {
- const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
- const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
+ const MODE_INFO *const above_mi = xd->above_mi;
+ const MODE_INFO *const left_mi = xd->left_mi;
const int has_above = xd->up_available;
const int has_left = xd->left_available;
if (has_above && has_left) { // both edges available
- const int above_intra = !is_inter_block(above_mbmi);
- const int left_intra = !is_inter_block(left_mbmi);
+ const int above_intra = !is_inter_block(above_mi);
+ const int left_intra = !is_inter_block(left_mi);
return left_intra && above_intra ? 3
: left_intra || above_intra;
} else if (has_above || has_left) { // one edge available
- return 2 * !is_inter_block(has_above ? above_mbmi : left_mbmi);
+ return 2 * !is_inter_block(has_above ? above_mi : left_mi);
} else {
return 0;
}
@@ -64,8 +64,8 @@
int vp9_get_reference_mode_context(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
int ctx;
- const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
- const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
+ const MODE_INFO *const above_mi = xd->above_mi;
+ const MODE_INFO *const left_mi = xd->left_mi;
const int has_above = xd->up_available;
const int has_left = xd->left_available;
// Note:
@@ -73,26 +73,26 @@
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
if (has_above && has_left) { // both edges available
- if (!has_second_ref(above_mbmi) && !has_second_ref(left_mbmi))
+ if (!has_second_ref(above_mi) && !has_second_ref(left_mi))
// neither edge uses comp pred (0/1)
- ctx = (above_mbmi->ref_frame[0] == cm->comp_fixed_ref) ^
- (left_mbmi->ref_frame[0] == cm->comp_fixed_ref);
- else if (!has_second_ref(above_mbmi))
+ ctx = (above_mi->ref_frame[0] == cm->comp_fixed_ref) ^
+ (left_mi->ref_frame[0] == cm->comp_fixed_ref);
+ else if (!has_second_ref(above_mi))
// one of two edges uses comp pred (2/3)
- ctx = 2 + (above_mbmi->ref_frame[0] == cm->comp_fixed_ref ||
- !is_inter_block(above_mbmi));
- else if (!has_second_ref(left_mbmi))
+ ctx = 2 + (above_mi->ref_frame[0] == cm->comp_fixed_ref ||
+ !is_inter_block(above_mi));
+ else if (!has_second_ref(left_mi))
// one of two edges uses comp pred (2/3)
- ctx = 2 + (left_mbmi->ref_frame[0] == cm->comp_fixed_ref ||
- !is_inter_block(left_mbmi));
+ ctx = 2 + (left_mi->ref_frame[0] == cm->comp_fixed_ref ||
+ !is_inter_block(left_mi));
else // both edges use comp pred (4)
ctx = 4;
} else if (has_above || has_left) { // one edge available
- const MB_MODE_INFO *edge_mbmi = has_above ? above_mbmi : left_mbmi;
+ const MODE_INFO *edge_mi = has_above ? above_mi : left_mi;
- if (!has_second_ref(edge_mbmi))
+ if (!has_second_ref(edge_mi))
// edge does not use comp pred (0/1)
- ctx = edge_mbmi->ref_frame[0] == cm->comp_fixed_ref;
+ ctx = edge_mi->ref_frame[0] == cm->comp_fixed_ref;
else
// edge uses comp pred (3)
ctx = 3;
@@ -107,8 +107,8 @@
int vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
int pred_context;
- const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
- const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
+ const MODE_INFO *const above_mi = xd->above_mi;
+ const MODE_INFO *const left_mi = xd->left_mi;
const int above_in_image = xd->up_available;
const int left_in_image = xd->left_available;
@@ -120,26 +120,26 @@
const int var_ref_idx = !fix_ref_idx;
if (above_in_image && left_in_image) { // both edges available
- const int above_intra = !is_inter_block(above_mbmi);
- const int left_intra = !is_inter_block(left_mbmi);
+ const int above_intra = !is_inter_block(above_mi);
+ const int left_intra = !is_inter_block(left_mi);
if (above_intra && left_intra) { // intra/intra (2)
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter
- const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
+ const MODE_INFO *edge_mi = above_intra ? left_mi : above_mi;
- if (!has_second_ref(edge_mbmi)) // single pred (1/3)
- pred_context = 1 + 2 * (edge_mbmi->ref_frame[0] != cm->comp_var_ref[1]);
+ if (!has_second_ref(edge_mi)) // single pred (1/3)
+ pred_context = 1 + 2 * (edge_mi->ref_frame[0] != cm->comp_var_ref[1]);
else // comp pred (1/3)
- pred_context = 1 + 2 * (edge_mbmi->ref_frame[var_ref_idx]
+ pred_context = 1 + 2 * (edge_mi->ref_frame[var_ref_idx]
!= cm->comp_var_ref[1]);
} else { // inter/inter
- const int l_sg = !has_second_ref(left_mbmi);
- const int a_sg = !has_second_ref(above_mbmi);
- const MV_REFERENCE_FRAME vrfa = a_sg ? above_mbmi->ref_frame[0]
- : above_mbmi->ref_frame[var_ref_idx];
- const MV_REFERENCE_FRAME vrfl = l_sg ? left_mbmi->ref_frame[0]
- : left_mbmi->ref_frame[var_ref_idx];
+ const int l_sg = !has_second_ref(left_mi);
+ const int a_sg = !has_second_ref(above_mi);
+ const MV_REFERENCE_FRAME vrfa = a_sg ? above_mi->ref_frame[0]
+ : above_mi->ref_frame[var_ref_idx];
+ const MV_REFERENCE_FRAME vrfl = l_sg ? left_mi->ref_frame[0]
+ : left_mi->ref_frame[var_ref_idx];
if (vrfa == vrfl && cm->comp_var_ref[1] == vrfa) {
pred_context = 0;
@@ -167,16 +167,16 @@
}
}
} else if (above_in_image || left_in_image) { // one edge available
- const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
+ const MODE_INFO *edge_mi = above_in_image ? above_mi : left_mi;
- if (!is_inter_block(edge_mbmi)) {
+ if (!is_inter_block(edge_mi)) {
pred_context = 2;
} else {
- if (has_second_ref(edge_mbmi))
- pred_context = 4 * (edge_mbmi->ref_frame[var_ref_idx]
+ if (has_second_ref(edge_mi))
+ pred_context = 4 * (edge_mi->ref_frame[var_ref_idx]
!= cm->comp_var_ref[1]);
else
- pred_context = 3 * (edge_mbmi->ref_frame[0] != cm->comp_var_ref[1]);
+ pred_context = 3 * (edge_mi->ref_frame[0] != cm->comp_var_ref[1]);
}
} else { // no edges available (2)
pred_context = 2;
@@ -188,8 +188,8 @@
int vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd) {
int pred_context;
- const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
- const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
+ const MODE_INFO *const above_mi = xd->above_mi;
+ const MODE_INFO *const left_mi = xd->left_mi;
const int has_above = xd->up_available;
const int has_left = xd->left_available;
// Note:
@@ -197,25 +197,25 @@
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
if (has_above && has_left) { // both edges available
- const int above_intra = !is_inter_block(above_mbmi);
- const int left_intra = !is_inter_block(left_mbmi);
+ const int above_intra = !is_inter_block(above_mi);
+ const int left_intra = !is_inter_block(left_mi);
if (above_intra && left_intra) { // intra/intra
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter or inter/intra
- const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
- if (!has_second_ref(edge_mbmi))
- pred_context = 4 * (edge_mbmi->ref_frame[0] == LAST_FRAME);
+ const MODE_INFO *edge_mi = above_intra ? left_mi : above_mi;
+ if (!has_second_ref(edge_mi))
+ pred_context = 4 * (edge_mi->ref_frame[0] == LAST_FRAME);
else
- pred_context = 1 + (edge_mbmi->ref_frame[0] == LAST_FRAME ||
- edge_mbmi->ref_frame[1] == LAST_FRAME);
+ pred_context = 1 + (edge_mi->ref_frame[0] == LAST_FRAME ||
+ edge_mi->ref_frame[1] == LAST_FRAME);
} else { // inter/inter
- const int above_has_second = has_second_ref(above_mbmi);
- const int left_has_second = has_second_ref(left_mbmi);
- const MV_REFERENCE_FRAME above0 = above_mbmi->ref_frame[0];
- const MV_REFERENCE_FRAME above1 = above_mbmi->ref_frame[1];
- const MV_REFERENCE_FRAME left0 = left_mbmi->ref_frame[0];
- const MV_REFERENCE_FRAME left1 = left_mbmi->ref_frame[1];
+ const int above_has_second = has_second_ref(above_mi);
+ const int left_has_second = has_second_ref(left_mi);
+ const MV_REFERENCE_FRAME above0 = above_mi->ref_frame[0];
+ const MV_REFERENCE_FRAME above1 = above_mi->ref_frame[1];
+ const MV_REFERENCE_FRAME left0 = left_mi->ref_frame[0];
+ const MV_REFERENCE_FRAME left1 = left_mi->ref_frame[1];
if (above_has_second && left_has_second) {
pred_context = 1 + (above0 == LAST_FRAME || above1 == LAST_FRAME ||
@@ -234,15 +234,15 @@
}
}
} else if (has_above || has_left) { // one edge available
- const MB_MODE_INFO *edge_mbmi = has_above ? above_mbmi : left_mbmi;
- if (!is_inter_block(edge_mbmi)) { // intra
+ const MODE_INFO *edge_mi = has_above ? above_mi : left_mi;
+ if (!is_inter_block(edge_mi)) { // intra
pred_context = 2;
} else { // inter
- if (!has_second_ref(edge_mbmi))
- pred_context = 4 * (edge_mbmi->ref_frame[0] == LAST_FRAME);
+ if (!has_second_ref(edge_mi))
+ pred_context = 4 * (edge_mi->ref_frame[0] == LAST_FRAME);
else
- pred_context = 1 + (edge_mbmi->ref_frame[0] == LAST_FRAME ||
- edge_mbmi->ref_frame[1] == LAST_FRAME);
+ pred_context = 1 + (edge_mi->ref_frame[0] == LAST_FRAME ||
+ edge_mi->ref_frame[1] == LAST_FRAME);
}
} else { // no edges available
pred_context = 2;
@@ -254,8 +254,8 @@
int vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) {
int pred_context;
- const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
- const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
+ const MODE_INFO *const above_mi = xd->above_mi;
+ const MODE_INFO *const left_mi = xd->left_mi;
const int has_above = xd->up_available;
const int has_left = xd->left_available;
@@ -264,29 +264,29 @@
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
if (has_above && has_left) { // both edges available
- const int above_intra = !is_inter_block(above_mbmi);
- const int left_intra = !is_inter_block(left_mbmi);
+ const int above_intra = !is_inter_block(above_mi);
+ const int left_intra = !is_inter_block(left_mi);
if (above_intra && left_intra) { // intra/intra
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter or inter/intra
- const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
- if (!has_second_ref(edge_mbmi)) {
- if (edge_mbmi->ref_frame[0] == LAST_FRAME)
+ const MODE_INFO *edge_mi = above_intra ? left_mi : above_mi;
+ if (!has_second_ref(edge_mi)) {
+ if (edge_mi->ref_frame[0] == LAST_FRAME)
pred_context = 3;
else
- pred_context = 4 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME);
+ pred_context = 4 * (edge_mi->ref_frame[0] == GOLDEN_FRAME);
} else {
- pred_context = 1 + 2 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME ||
- edge_mbmi->ref_frame[1] == GOLDEN_FRAME);
+ pred_context = 1 + 2 * (edge_mi->ref_frame[0] == GOLDEN_FRAME ||
+ edge_mi->ref_frame[1] == GOLDEN_FRAME);
}
} else { // inter/inter
- const int above_has_second = has_second_ref(above_mbmi);
- const int left_has_second = has_second_ref(left_mbmi);
- const MV_REFERENCE_FRAME above0 = above_mbmi->ref_frame[0];
- const MV_REFERENCE_FRAME above1 = above_mbmi->ref_frame[1];
- const MV_REFERENCE_FRAME left0 = left_mbmi->ref_frame[0];
- const MV_REFERENCE_FRAME left1 = left_mbmi->ref_frame[1];
+ const int above_has_second = has_second_ref(above_mi);
+ const int left_has_second = has_second_ref(left_mi);
+ const MV_REFERENCE_FRAME above0 = above_mi->ref_frame[0];
+ const MV_REFERENCE_FRAME above1 = above_mi->ref_frame[1];
+ const MV_REFERENCE_FRAME left0 = left_mi->ref_frame[0];
+ const MV_REFERENCE_FRAME left1 = left_mi->ref_frame[1];
if (above_has_second && left_has_second) {
if (above0 == left0 && above1 == left1)
@@ -321,16 +321,16 @@
}
}
} else if (has_above || has_left) { // one edge available
- const MB_MODE_INFO *edge_mbmi = has_above ? above_mbmi : left_mbmi;
+ const MODE_INFO *edge_mi = has_above ? above_mi : left_mi;
- if (!is_inter_block(edge_mbmi) ||
- (edge_mbmi->ref_frame[0] == LAST_FRAME && !has_second_ref(edge_mbmi)))
+ if (!is_inter_block(edge_mi) ||
+ (edge_mi->ref_frame[0] == LAST_FRAME && !has_second_ref(edge_mi)))
pred_context = 2;
- else if (!has_second_ref(edge_mbmi))
- pred_context = 4 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME);
+ else if (!has_second_ref(edge_mi))
+ pred_context = 4 * (edge_mi->ref_frame[0] == GOLDEN_FRAME);
else
- pred_context = 3 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME ||
- edge_mbmi->ref_frame[1] == GOLDEN_FRAME);
+ pred_context = 3 * (edge_mi->ref_frame[0] == GOLDEN_FRAME ||
+ edge_mi->ref_frame[1] == GOLDEN_FRAME);
} else { // no edges available (2)
pred_context = 2;
}
diff --git a/vp9/common/vp9_pred_common.h b/vp9/common/vp9_pred_common.h
index 6f7af4a..254cb8b 100644
--- a/vp9/common/vp9_pred_common.h
+++ b/vp9/common/vp9_pred_common.h
@@ -42,8 +42,8 @@
const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *const left_mi = xd->left_mi;
const int above_sip = (above_mi != NULL) ?
- above_mi->mbmi.seg_id_predicted : 0;
- const int left_sip = (left_mi != NULL) ? left_mi->mbmi.seg_id_predicted : 0;
+ above_mi->seg_id_predicted : 0;
+ const int left_sip = (left_mi != NULL) ? left_mi->seg_id_predicted : 0;
return above_sip + left_sip;
}
@@ -56,8 +56,8 @@
static INLINE int vp9_get_skip_context(const MACROBLOCKD *xd) {
const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *const left_mi = xd->left_mi;
- const int above_skip = (above_mi != NULL) ? above_mi->mbmi.skip : 0;
- const int left_skip = (left_mi != NULL) ? left_mi->mbmi.skip : 0;
+ const int above_skip = (above_mi != NULL) ? above_mi->skip : 0;
+ const int left_skip = (left_mi != NULL) ? left_mi->skip : 0;
return above_skip + left_skip;
}
@@ -110,15 +110,15 @@
// left of the entries corresponding to real blocks.
// The prediction flags in these dummy entries are initialized to 0.
static INLINE int get_tx_size_context(const MACROBLOCKD *xd) {
- const int max_tx_size = max_txsize_lookup[xd->mi[0]->mbmi.sb_type];
- const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
- const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
+ const int max_tx_size = max_txsize_lookup[xd->mi[0]->sb_type];
+ const MODE_INFO *const above_mi = xd->above_mi;
+ const MODE_INFO *const left_mi = xd->left_mi;
const int has_above = xd->up_available;
const int has_left = xd->left_available;
- int above_ctx = (has_above && !above_mbmi->skip) ? (int)above_mbmi->tx_size
- : max_tx_size;
- int left_ctx = (has_left && !left_mbmi->skip) ? (int)left_mbmi->tx_size
- : max_tx_size;
+ int above_ctx = (has_above && !above_mi->skip) ? (int)above_mi->tx_size
+ : max_tx_size;
+ int left_ctx = (has_left && !left_mi->skip) ? (int)left_mi->tx_size
+ : max_tx_size;
if (!has_left)
left_ctx = above_ctx;
diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c
index 37658dc..74bc1d2 100644
--- a/vp9/common/vp9_reconinter.c
+++ b/vp9/common/vp9_reconinter.c
@@ -159,8 +159,8 @@
int mi_x, int mi_y) {
struct macroblockd_plane *const pd = &xd->plane[plane];
const MODE_INFO *mi = xd->mi[0];
- const int is_compound = has_second_ref(&mi->mbmi);
- const InterpKernel *kernel = vp9_filter_kernels[mi->mbmi.interp_filter];
+ const int is_compound = has_second_ref(mi);
+ const InterpKernel *kernel = vp9_filter_kernels[mi->interp_filter];
int ref;
for (ref = 0; ref < 1 + is_compound; ++ref) {
@@ -168,9 +168,9 @@
struct buf_2d *const pre_buf = &pd->pre[ref];
struct buf_2d *const dst_buf = &pd->dst;
uint8_t *const dst = dst_buf->buf + dst_buf->stride * y + x;
- const MV mv = mi->mbmi.sb_type < BLOCK_8X8
+ const MV mv = mi->sb_type < BLOCK_8X8
? average_split_mvs(pd, mi, ref, block)
- : mi->mbmi.mv[ref].as_mv;
+ : mi->mv[ref].as_mv;
// TODO(jkoleszar): This clamping is done in the incorrect place for the
// scaling case. It needs to be done on the scaled MV, not the pre-scaling
@@ -191,8 +191,8 @@
const int x_start = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x));
const int y_start = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y));
#if CONFIG_BETTER_HW_COMPATIBILITY
- assert(xd->mi[0]->mbmi.sb_type != BLOCK_4X8 &&
- xd->mi[0]->mbmi.sb_type != BLOCK_8X4);
+ assert(xd->mi[0]->sb_type != BLOCK_4X8 &&
+ xd->mi[0]->sb_type != BLOCK_8X4);
assert(mv_q4.row == mv.row * (1 << (1 - pd->subsampling_y)) &&
mv_q4.col == mv.col * (1 << (1 - pd->subsampling_x)));
#endif
@@ -250,7 +250,7 @@
const int bw = 4 * num_4x4_w;
const int bh = 4 * num_4x4_h;
- if (xd->mi[0]->mbmi.sb_type < BLOCK_8X8) {
+ if (xd->mi[0]->sb_type < BLOCK_8X8) {
int i = 0, x, y;
assert(bsize == BLOCK_8X8);
for (y = 0; y < num_4x4_h; ++y)
diff --git a/vp9/common/vp9_scan.h b/vp9/common/vp9_scan.h
index 1d86b5c..4c1ee81 100644
--- a/vp9/common/vp9_scan.h
+++ b/vp9/common/vp9_scan.h
@@ -42,7 +42,7 @@
PLANE_TYPE type, int block_idx) {
const MODE_INFO *const mi = xd->mi[0];
- if (is_inter_block(&mi->mbmi) || type != PLANE_TYPE_Y || xd->lossless) {
+ if (is_inter_block(mi) || type != PLANE_TYPE_Y || xd->lossless) {
return &vp9_default_scan_orders[tx_size];
} else {
const PREDICTION_MODE mode = get_y_mode(mi, block_idx);
diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c
index e27634c..7d58cc6 100644
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -365,16 +365,16 @@
static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
vpx_reader *r,
- MB_MODE_INFO *const mbmi,
+ MODE_INFO *const mi,
int plane,
int row, int col,
TX_SIZE tx_size) {
struct macroblockd_plane *const pd = &xd->plane[plane];
- PREDICTION_MODE mode = (plane == 0) ? mbmi->mode : mbmi->uv_mode;
+ PREDICTION_MODE mode = (plane == 0) ? mi->mode : mi->uv_mode;
uint8_t *dst;
dst = &pd->dst.buf[4 * row * pd->dst.stride + 4 * col];
- if (mbmi->sb_type < BLOCK_8X8)
+ if (mi->sb_type < BLOCK_8X8)
if (plane == 0)
mode = xd->mi[0]->bmi[(row << 1) + col].as_mode;
@@ -382,25 +382,25 @@
dst, pd->dst.stride, dst, pd->dst.stride,
col, row, plane);
- if (!mbmi->skip) {
+ if (!mi->skip) {
const TX_TYPE tx_type = (plane || xd->lossless) ?
DCT_DCT : intra_mode_to_tx_type_lookup[mode];
const scan_order *sc = (plane || xd->lossless) ?
&vp9_default_scan_orders[tx_size] : &vp9_scan_orders[tx_size][tx_type];
const int eob = vp9_decode_block_tokens(xd, plane, sc, col, row, tx_size,
- r, mbmi->segment_id);
+ r, mi->segment_id);
inverse_transform_block_intra(xd, plane, tx_type, tx_size,
dst, pd->dst.stride, eob);
}
}
static int reconstruct_inter_block(MACROBLOCKD *const xd, vpx_reader *r,
- MB_MODE_INFO *const mbmi, int plane,
+ MODE_INFO *const mi, int plane,
int row, int col, TX_SIZE tx_size) {
struct macroblockd_plane *const pd = &xd->plane[plane];
const scan_order *sc = &vp9_default_scan_orders[tx_size];
const int eob = vp9_decode_block_tokens(xd, plane, sc, col, row, tx_size, r,
- mbmi->segment_id);
+ mi->segment_id);
inverse_transform_block_inter(xd, plane, tx_size,
&pd->dst.buf[4 * row * pd->dst.stride + 4 * col],
@@ -588,8 +588,8 @@
int x_start = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x));
int y_start = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y));
#if CONFIG_BETTER_HW_COMPATIBILITY
- assert(xd->mi[0]->mbmi.sb_type != BLOCK_4X8 &&
- xd->mi[0]->mbmi.sb_type != BLOCK_8X4);
+ assert(xd->mi[0]->sb_type != BLOCK_4X8 &&
+ xd->mi[0]->sb_type != BLOCK_8X4);
assert(mv_q4.row == mv->row * (1 << (1 - pd->subsampling_y)) &&
mv_q4.col == mv->col * (1 << (1 - pd->subsampling_x)));
#endif
@@ -716,13 +716,13 @@
const int mi_x = mi_col * MI_SIZE;
const int mi_y = mi_row * MI_SIZE;
const MODE_INFO *mi = xd->mi[0];
- const InterpKernel *kernel = vp9_filter_kernels[mi->mbmi.interp_filter];
- const BLOCK_SIZE sb_type = mi->mbmi.sb_type;
- const int is_compound = has_second_ref(&mi->mbmi);
+ const InterpKernel *kernel = vp9_filter_kernels[mi->interp_filter];
+ const BLOCK_SIZE sb_type = mi->sb_type;
+ const int is_compound = has_second_ref(mi);
int ref;
for (ref = 0; ref < 1 + is_compound; ++ref) {
- const MV_REFERENCE_FRAME frame = mi->mbmi.ref_frame[ref];
+ const MV_REFERENCE_FRAME frame = mi->ref_frame[ref];
RefBuffer *ref_buf = &pbi->common.frame_refs[frame - LAST_FRAME];
xd->block_refs[ref] = ref_buf;
@@ -762,7 +762,7 @@
}
}
} else {
- const MV mv = mi->mbmi.mv[ref].as_mv;
+ const MV mv = mi->mv[ref].as_mv;
dec_build_inter_predictors(pbi, xd, plane, n4w_x4, n4h_x4,
0, 0, n4w_x4, n4h_x4, mi_x, mi_y, kernel,
sf, pre_buf, dst_buf, &mv, ref_frame_buf,
@@ -772,11 +772,11 @@
}
}
-static INLINE TX_SIZE dec_get_uv_tx_size(const MB_MODE_INFO *mbmi,
+static INLINE TX_SIZE dec_get_uv_tx_size(const MODE_INFO *mi,
int n4_wl, int n4_hl) {
// get minimum log2 num4x4s dimension
const int x = VPXMIN(n4_wl, n4_hl);
- return VPXMIN(mbmi->tx_size, x);
+ return VPXMIN(mi->tx_size, x);
}
static INLINE void dec_reset_skip_context(MACROBLOCKD *xd) {
@@ -799,10 +799,10 @@
}
}
-static MB_MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd,
- BLOCK_SIZE bsize, int mi_row, int mi_col,
- int bw, int bh, int x_mis, int y_mis,
- int bwl, int bhl) {
+static MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd,
+ BLOCK_SIZE bsize, int mi_row, int mi_col,
+ int bw, int bh, int x_mis, int y_mis,
+ int bwl, int bhl) {
const int offset = mi_row * cm->mi_stride + mi_col;
int x, y;
const TileInfo *const tile = &xd->tile;
@@ -811,7 +811,7 @@
xd->mi[0] = &cm->mi[offset];
// TODO(slavarnway): Generate sb_type based on bwl and bhl, instead of
// passing bsize from decode_partition().
- xd->mi[0]->mbmi.sb_type = bsize;
+ xd->mi[0]->sb_type = bsize;
for (y = 0; y < y_mis; ++y)
for (x = !y; x < x_mis; ++x) {
xd->mi[y * cm->mi_stride + x] = xd->mi[0];
@@ -826,7 +826,7 @@
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col);
- return &xd->mi[0]->mbmi;
+ return xd->mi[0];
}
static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
@@ -840,8 +840,8 @@
const int x_mis = VPXMIN(bw, cm->mi_cols - mi_col);
const int y_mis = VPXMIN(bh, cm->mi_rows - mi_row);
- MB_MODE_INFO *mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col,
- bw, bh, x_mis, y_mis, bwl, bhl);
+ MODE_INFO *mi = set_offsets(cm, xd, bsize, mi_row, mi_col,
+ bw, bh, x_mis, y_mis, bwl, bhl);
if (bsize >= BLOCK_8X8 && (cm->subsampling_x || cm->subsampling_y)) {
const BLOCK_SIZE uv_subsize =
@@ -853,17 +853,17 @@
vpx_read_mode_info(pbi, xd, mi_row, mi_col, r, x_mis, y_mis);
- if (mbmi->skip) {
+ if (mi->skip) {
dec_reset_skip_context(xd);
}
- if (!is_inter_block(mbmi)) {
+ if (!is_inter_block(mi)) {
int plane;
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const TX_SIZE tx_size =
- plane ? dec_get_uv_tx_size(mbmi, pd->n4_wl, pd->n4_hl)
- : mbmi->tx_size;
+ plane ? dec_get_uv_tx_size(mi, pd->n4_wl, pd->n4_hl)
+ : mi->tx_size;
const int num_4x4_w = pd->n4_w;
const int num_4x4_h = pd->n4_h;
const int step = (1 << tx_size);
@@ -875,7 +875,7 @@
for (row = 0; row < max_blocks_high; row += step)
for (col = 0; col < max_blocks_wide; col += step)
- predict_and_reconstruct_intra_block(xd, r, mbmi, plane,
+ predict_and_reconstruct_intra_block(xd, r, mi, plane,
row, col, tx_size);
}
} else {
@@ -883,15 +883,15 @@
dec_build_inter_predictors_sb(pbi, xd, mi_row, mi_col);
// Reconstruction
- if (!mbmi->skip) {
+ if (!mi->skip) {
int eobtotal = 0;
int plane;
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const TX_SIZE tx_size =
- plane ? dec_get_uv_tx_size(mbmi, pd->n4_wl, pd->n4_hl)
- : mbmi->tx_size;
+ plane ? dec_get_uv_tx_size(mi, pd->n4_wl, pd->n4_hl)
+ : mi->tx_size;
const int num_4x4_w = pd->n4_w;
const int num_4x4_h = pd->n4_h;
const int step = (1 << tx_size);
@@ -903,19 +903,19 @@
for (row = 0; row < max_blocks_high; row += step)
for (col = 0; col < max_blocks_wide; col += step)
- eobtotal += reconstruct_inter_block(xd, r, mbmi, plane, row, col,
+ eobtotal += reconstruct_inter_block(xd, r, mi, plane, row, col,
tx_size);
}
if (!less8x8 && eobtotal == 0)
- mbmi->skip = 1; // skip loopfilter
+ mi->skip = 1; // skip loopfilter
}
}
xd->corrupted |= vpx_reader_has_error(r);
if (cm->lf.filter_level) {
- vp9_build_mask(cm, mbmi, mi_row, mi_col, bw, bh);
+ vp9_build_mask(cm, mi, mi_row, mi_col, bw, bh);
}
}
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index bf5d81d..c2fd178 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -84,7 +84,7 @@
static TX_SIZE read_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd,
int allow_select, vpx_reader *r) {
TX_MODE tx_mode = cm->tx_mode;
- BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
+ BLOCK_SIZE bsize = xd->mi[0]->sb_type;
const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8)
return read_selected_tx_size(cm, xd, max_tx_size, r);
@@ -151,7 +151,7 @@
static int read_inter_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd,
int mi_row, int mi_col, vpx_reader *r) {
struct segmentation *const seg = &cm->seg;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
int predicted_segment_id, segment_id;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = xd->plane[0].n4_w >> 1;
@@ -176,9 +176,9 @@
if (seg->temporal_update) {
const vpx_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd);
- mbmi->seg_id_predicted = vpx_read(r, pred_prob);
- segment_id = mbmi->seg_id_predicted ? predicted_segment_id
- : read_segment_id(r, seg);
+ mi->seg_id_predicted = vpx_read(r, pred_prob);
+ segment_id = mi->seg_id_predicted ? predicted_segment_id
+ : read_segment_id(r, seg);
} else {
segment_id = read_segment_id(r, seg);
}
@@ -204,10 +204,9 @@
MACROBLOCKD *const xd,
int mi_row, int mi_col, vpx_reader *r) {
MODE_INFO *const mi = xd->mi[0];
- MB_MODE_INFO *const mbmi = &mi->mbmi;
const MODE_INFO *above_mi = xd->above_mi;
const MODE_INFO *left_mi = xd->left_mi;
- const BLOCK_SIZE bsize = mbmi->sb_type;
+ const BLOCK_SIZE bsize = mi->sb_type;
int i;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = xd->plane[0].n4_w >> 1;
@@ -217,37 +216,37 @@
const int x_mis = VPXMIN(cm->mi_cols - mi_col, bw);
const int y_mis = VPXMIN(cm->mi_rows - mi_row, bh);
- mbmi->segment_id = read_intra_segment_id(cm, mi_offset, x_mis, y_mis, r);
- mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
- mbmi->tx_size = read_tx_size(cm, xd, 1, r);
- mbmi->ref_frame[0] = INTRA_FRAME;
- mbmi->ref_frame[1] = NONE;
+ mi->segment_id = read_intra_segment_id(cm, mi_offset, x_mis, y_mis, r);
+ mi->skip = read_skip(cm, xd, mi->segment_id, r);
+ mi->tx_size = read_tx_size(cm, xd, 1, r);
+ mi->ref_frame[0] = INTRA_FRAME;
+ mi->ref_frame[1] = NONE;
switch (bsize) {
case BLOCK_4X4:
for (i = 0; i < 4; ++i)
mi->bmi[i].as_mode =
read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, i));
- mbmi->mode = mi->bmi[3].as_mode;
+ mi->mode = mi->bmi[3].as_mode;
break;
case BLOCK_4X8:
mi->bmi[0].as_mode = mi->bmi[2].as_mode =
read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, 0));
- mi->bmi[1].as_mode = mi->bmi[3].as_mode = mbmi->mode =
+ mi->bmi[1].as_mode = mi->bmi[3].as_mode = mi->mode =
read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, 1));
break;
case BLOCK_8X4:
mi->bmi[0].as_mode = mi->bmi[1].as_mode =
read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, 0));
- mi->bmi[2].as_mode = mi->bmi[3].as_mode = mbmi->mode =
+ mi->bmi[2].as_mode = mi->bmi[3].as_mode = mi->mode =
read_intra_mode(r, get_y_mode_probs(mi, above_mi, left_mi, 2));
break;
default:
- mbmi->mode = read_intra_mode(r,
- get_y_mode_probs(mi, above_mi, left_mi, 0));
+ mi->mode = read_intra_mode(r,
+ get_y_mode_probs(mi, above_mi, left_mi, 0));
}
- mbmi->uv_mode = read_intra_mode(r, vp9_kf_uv_mode_prob[mbmi->mode]);
+ mi->uv_mode = read_intra_mode(r, vp9_kf_uv_mode_prob[mi->mode]);
}
static int read_mv_component(vpx_reader *r,
@@ -381,36 +380,35 @@
static void read_intra_block_mode_info(VP9_COMMON *const cm,
MACROBLOCKD *const xd, MODE_INFO *mi,
vpx_reader *r) {
- MB_MODE_INFO *const mbmi = &mi->mbmi;
- const BLOCK_SIZE bsize = mi->mbmi.sb_type;
+ const BLOCK_SIZE bsize = mi->sb_type;
int i;
- mbmi->ref_frame[0] = INTRA_FRAME;
- mbmi->ref_frame[1] = NONE;
+ mi->ref_frame[0] = INTRA_FRAME;
+ mi->ref_frame[1] = NONE;
switch (bsize) {
case BLOCK_4X4:
for (i = 0; i < 4; ++i)
mi->bmi[i].as_mode = read_intra_mode_y(cm, xd, r, 0);
- mbmi->mode = mi->bmi[3].as_mode;
+ mi->mode = mi->bmi[3].as_mode;
break;
case BLOCK_4X8:
mi->bmi[0].as_mode = mi->bmi[2].as_mode = read_intra_mode_y(cm, xd,
r, 0);
- mi->bmi[1].as_mode = mi->bmi[3].as_mode = mbmi->mode =
+ mi->bmi[1].as_mode = mi->bmi[3].as_mode = mi->mode =
read_intra_mode_y(cm, xd, r, 0);
break;
case BLOCK_8X4:
mi->bmi[0].as_mode = mi->bmi[1].as_mode = read_intra_mode_y(cm, xd,
r, 0);
- mi->bmi[2].as_mode = mi->bmi[3].as_mode = mbmi->mode =
+ mi->bmi[2].as_mode = mi->bmi[3].as_mode = mi->mode =
read_intra_mode_y(cm, xd, r, 0);
break;
default:
- mbmi->mode = read_intra_mode_y(cm, xd, r, size_group_lookup[bsize]);
+ mi->mode = read_intra_mode_y(cm, xd, r, size_group_lookup[bsize]);
}
- mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
+ mi->uv_mode = read_intra_mode_uv(cm, xd, r, mi->mode);
}
static INLINE int is_mv_valid(const MV *mv) {
@@ -547,8 +545,8 @@
const TileInfo *const tile = &xd->tile;
// If mode is nearestmv or newmv (uses nearestmv as a reference) then stop
// searching after the first mv is found.
- const int early_break = (mi->mbmi.mode == NEARESTMV) ||
- (mi->mbmi.mode == NEWMV);
+ const int early_break = (mi->mode == NEARESTMV) ||
+ (mi->mode == NEWMV);
// Blank the reference vector list
memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES);
@@ -559,8 +557,8 @@
for (i = 0; i < MVREF_NEIGHBOURS; ++i) {
const POSITION *const mv_ref = &mv_ref_search[i];
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
- const MB_MODE_INFO *const candidate =
- &xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]->mbmi;
+ const MODE_INFO *const candidate =
+ xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride];
different_ref_found = 1;
if (candidate->ref_frame[0] == ref_frame)
@@ -601,8 +599,8 @@
for (i = 0; i < MVREF_NEIGHBOURS; ++i) {
const POSITION *mv_ref = &mv_ref_search[i];
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
- const MB_MODE_INFO *const candidate =
- &xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]->mbmi;
+ const MODE_INFO *const candidate =
+ xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride];
// If the candidate is INTRA we don't want to consider its mv.
IF_DIFF_REF_FRAME_ADD_MV_EB(candidate, ref_frame, ref_sign_bias,
@@ -637,7 +635,7 @@
}
}
- if (mi->mbmi.mode == NEARMV)
+ if (mi->mode == NEARMV)
refmv_count = MAX_MV_REF_CANDIDATES;
else
// we only care about the nearestmv for the remaining modes
@@ -662,9 +660,8 @@
for (i = 0; i < 2; ++i) {
const POSITION *const mv_ref = &mv_ref_search[i];
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
- const MODE_INFO *const candidate_mi = xd->mi[mv_ref->col + mv_ref->row *
- xd->mi_stride];
- const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
+ const MODE_INFO *const candidate =
+ xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride];
// Keep counts for entropy encoding.
context_counter += mode_2_counter[candidate->mode];
}
@@ -678,20 +675,19 @@
MODE_INFO *const mi,
int mi_row, int mi_col, vpx_reader *r) {
VP9_COMMON *const cm = &pbi->common;
- MB_MODE_INFO *const mbmi = &mi->mbmi;
- const BLOCK_SIZE bsize = mbmi->sb_type;
+ const BLOCK_SIZE bsize = mi->sb_type;
const int allow_hp = cm->allow_high_precision_mv;
int_mv nearestmv[2], nearmv[2];
int ref, is_compound;
uint8_t inter_mode_ctx;
const POSITION *const mv_ref_search = mv_ref_blocks[bsize];
- read_ref_frames(cm, xd, r, mbmi->segment_id, mbmi->ref_frame);
- is_compound = has_second_ref(mbmi);
+ read_ref_frames(cm, xd, r, mi->segment_id, mi->ref_frame);
+ is_compound = has_second_ref(mi);
inter_mode_ctx = get_mode_context(cm, xd, mv_ref_search, mi_row, mi_col);
- if (segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
- mbmi->mode = ZEROMV;
+ if (segfeature_active(&cm->seg, mi->segment_id, SEG_LVL_SKIP)) {
+ mi->mode = ZEROMV;
if (bsize < BLOCK_8X8) {
vpx_internal_error(xd->error_info, VPX_CODEC_UNSUP_BITSTREAM,
"Invalid usage of segement feature on small blocks");
@@ -699,18 +695,18 @@
}
} else {
if (bsize >= BLOCK_8X8)
- mbmi->mode = read_inter_mode(cm, xd, r, inter_mode_ctx);
+ mi->mode = read_inter_mode(cm, xd, r, inter_mode_ctx);
else
// Sub 8x8 blocks use the nearestmv as a ref_mv if the b_mode is NEWMV.
// Setting mode to NEARESTMV forces the search to stop after the nearestmv
// has been found. After b_modes have been read, mode will be overwritten
// by the last b_mode.
- mbmi->mode = NEARESTMV;
+ mi->mode = NEARESTMV;
- if (mbmi->mode != ZEROMV) {
+ if (mi->mode != ZEROMV) {
for (ref = 0; ref < 1 + is_compound; ++ref) {
int_mv ref_mvs[MAX_MV_REF_CANDIDATES];
- const MV_REFERENCE_FRAME frame = mbmi->ref_frame[ref];
+ const MV_REFERENCE_FRAME frame = mi->ref_frame[ref];
int refmv_count;
refmv_count = dec_find_mv_refs(cm, xd, mi, frame, mv_ref_search,
@@ -723,7 +719,7 @@
}
}
- mbmi->interp_filter = (cm->interp_filter == SWITCHABLE)
+ mi->interp_filter = (cm->interp_filter == SWITCHABLE)
? read_switchable_interp_filter(cm, xd, r)
: cm->interp_filter;
@@ -766,12 +762,12 @@
}
}
- mi->mbmi.mode = b_mode;
+ mi->mode = b_mode;
- mbmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int;
- mbmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
+ mi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int;
+ mi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
} else {
- xd->corrupted |= !assign_mv(cm, xd, mbmi->mode, mbmi->mv, nearestmv,
+ xd->corrupted |= !assign_mv(cm, xd, mi->mode, mi->mv, nearestmv,
nearestmv, nearmv, is_compound, allow_hp, r);
}
}
@@ -781,15 +777,14 @@
int mi_row, int mi_col, vpx_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MODE_INFO *const mi = xd->mi[0];
- MB_MODE_INFO *const mbmi = &mi->mbmi;
int inter_block;
- mbmi->mv[0].as_int = 0;
- mbmi->mv[1].as_int = 0;
- mbmi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, r);
- mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
- inter_block = read_is_inter_block(cm, xd, mbmi->segment_id, r);
- mbmi->tx_size = read_tx_size(cm, xd, !mbmi->skip || !inter_block, r);
+ mi->mv[0].as_int = 0;
+ mi->mv[1].as_int = 0;
+ mi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, r);
+ mi->skip = read_skip(cm, xd, mi->segment_id, r);
+ inter_block = read_is_inter_block(cm, xd, mi->segment_id, r);
+ mi->tx_size = read_tx_size(cm, xd, !mi->skip || !inter_block, r);
if (inter_block)
read_inter_block_mode_info(pbi, xd, mi, mi_row, mi_col, r);
@@ -814,10 +809,10 @@
MV_REF *const frame_mv = frame_mvs + h * cm->mi_cols;
for (w = 0; w < x_mis; ++w) {
MV_REF *const mv = frame_mv + w;
- mv->ref_frame[0] = mi->mbmi.ref_frame[0];
- mv->ref_frame[1] = mi->mbmi.ref_frame[1];
- mv->mv[0].as_int = mi->mbmi.mv[0].as_int;
- mv->mv[1].as_int = mi->mbmi.mv[1].as_int;
+ mv->ref_frame[0] = mi->ref_frame[0];
+ mv->ref_frame[1] = mi->ref_frame[1];
+ mv->mv[0].as_int = mi->mv[0].as_int;
+ mv->mv[1].as_int = mi->mv[1].as_int;
}
}
}
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index 073cbae..dbcf2be 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -53,7 +53,7 @@
FRAME_COUNTS *counts = xd->counts;
const int max_eob = 16 << (tx_size << 1);
const FRAME_CONTEXT *const fc = xd->fc;
- const int ref = is_inter_block(&xd->mi[0]->mbmi);
+ const int ref = is_inter_block(xd->mi[0]);
int band, c = 0;
const vpx_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
fc->coef_probs[tx_size][type][ref];
diff --git a/vp9/encoder/vp9_aq_cyclicrefresh.c b/vp9/encoder/vp9_aq_cyclicrefresh.c
index 63db214..57a81c0 100644
--- a/vp9/encoder/vp9_aq_cyclicrefresh.c
+++ b/vp9/encoder/vp9_aq_cyclicrefresh.c
@@ -60,6 +60,8 @@
}
// Check if we should turn off cyclic refresh based on bitrate condition.
+// TODO(marpan): May be better in some cases to just reduce the amount/delta-qp
+// instead of completely shutting off.
static int apply_cyclic_refresh_bitrate(const VP9_COMMON *cm,
const RATE_CONTROL *rc) {
// Turn off cyclic refresh if bits available per frame is not sufficiently
@@ -67,10 +69,10 @@
// with number of seg blocks, so compare available bits to number of blocks.
// Average bits available per frame = avg_frame_bandwidth
// Number of (8x8) blocks in frame = mi_rows * mi_cols;
- const float factor = 0.25;
+ const float factor = 0.15;
const int number_blocks = cm->mi_rows * cm->mi_cols;
// The condition below corresponds to turning off at target bitrates:
- // (at 30fps), ~12kbps for CIF, 36kbps for VGA, 100kps for HD/720p.
+ // (at 30fps), ~8kbps for CIF, 20kbps for VGA, 60kps for HD/720p.
// Also turn off at very small frame sizes, to avoid too large fraction of
// superblocks to be refreshed per frame. Threshold below is less than QCIF.
if (rc->avg_frame_bandwidth < factor * number_blocks ||
@@ -85,11 +87,11 @@
// size of the coding block (i.e., below min_block size rejected), coding
// mode, and rate/distortion.
static int candidate_refresh_aq(const CYCLIC_REFRESH *cr,
- const MB_MODE_INFO *mbmi,
+ const MODE_INFO *mi,
int64_t rate,
int64_t dist,
int bsize) {
- MV mv = mbmi->mv[0].as_mv;
+ MV mv = mi->mv[0].as_mv;
// Reject the block for lower-qp coding if projected distortion
// is above the threshold, and any of the following is true:
// 1) mode uses large mv
@@ -98,12 +100,12 @@
if (dist > cr->thresh_dist_sb &&
(mv.row > cr->motion_thresh || mv.row < -cr->motion_thresh ||
mv.col > cr->motion_thresh || mv.col < -cr->motion_thresh ||
- !is_inter_block(mbmi)))
+ !is_inter_block(mi)))
return CR_SEGMENT_ID_BASE;
else if (bsize >= BLOCK_16X16 &&
rate < cr->thresh_rate_sb &&
- is_inter_block(mbmi) &&
- mbmi->mv[0].as_int == 0 &&
+ is_inter_block(mi) &&
+ mi->mv[0].as_int == 0 &&
cr->rate_boost_fac > 10)
// More aggressive delta-q for bigger blocks with zero motion.
return CR_SEGMENT_ID_BOOST2;
@@ -186,7 +188,7 @@
// check if we should reset the segment_id, and update the cyclic_refresh map
// and segmentation map.
void vp9_cyclic_refresh_update_segment(VP9_COMP *const cpi,
- MB_MODE_INFO *const mbmi,
+ MODE_INFO *const mi,
int mi_row, int mi_col,
BLOCK_SIZE bsize,
int64_t rate,
@@ -200,7 +202,7 @@
const int xmis = VPXMIN(cm->mi_cols - mi_col, bw);
const int ymis = VPXMIN(cm->mi_rows - mi_row, bh);
const int block_index = mi_row * cm->mi_cols + mi_col;
- int refresh_this_block = candidate_refresh_aq(cr, mbmi, rate, dist, bsize);
+ int refresh_this_block = candidate_refresh_aq(cr, mi, rate, dist, bsize);
// Default is to not update the refresh map.
int new_map_value = cr->map[block_index];
int x = 0; int y = 0;
@@ -221,18 +223,18 @@
// If this block is labeled for refresh, check if we should reset the
// segment_id.
- if (cyclic_refresh_segment_id_boosted(mbmi->segment_id)) {
- mbmi->segment_id = refresh_this_block;
+ if (cyclic_refresh_segment_id_boosted(mi->segment_id)) {
+ mi->segment_id = refresh_this_block;
// Reset segment_id if it will be skipped.
if (skip)
- mbmi->segment_id = CR_SEGMENT_ID_BASE;
+ mi->segment_id = CR_SEGMENT_ID_BASE;
}
// Update the cyclic refresh map, to be used for setting segmentation map
// for the next frame. If the block will be refreshed this frame, mark it
// as clean. The magnitude of the -ve influences how long before we consider
// it for refresh again.
- if (cyclic_refresh_segment_id_boosted(mbmi->segment_id)) {
+ if (cyclic_refresh_segment_id_boosted(mi->segment_id)) {
new_map_value = -cr->time_for_refresh;
} else if (refresh_this_block) {
// Else if it is accepted as candidate for refresh, and has not already
@@ -251,17 +253,17 @@
for (x = 0; x < xmis; x++) {
int map_offset = block_index + y * cm->mi_cols + x;
cr->map[map_offset] = new_map_value;
- cpi->segmentation_map[map_offset] = mbmi->segment_id;
+ cpi->segmentation_map[map_offset] = mi->segment_id;
}
}
void vp9_cyclic_refresh_update_sb_postencode(VP9_COMP *const cpi,
- const MB_MODE_INFO *const mbmi,
+ const MODE_INFO *const mi,
int mi_row, int mi_col,
BLOCK_SIZE bsize) {
const VP9_COMMON *const cm = &cpi->common;
CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
- MV mv = mbmi->mv[0].as_mv;
+ MV mv = mi->mv[0].as_mv;
const int bw = num_8x8_blocks_wide_lookup[bsize];
const int bh = num_8x8_blocks_high_lookup[bsize];
const int xmis = VPXMIN(cm->mi_cols - mi_col, bw);
@@ -275,18 +277,18 @@
// don't update the map for them. For cases where motion is non-zero or
// the reference frame isn't the previous frame, the previous value in
// the map for this spatial location is not entirely correct.
- if ((!is_inter_block(mbmi) || !mbmi->skip) &&
- mbmi->segment_id <= CR_SEGMENT_ID_BOOST2) {
+ if ((!is_inter_block(mi) || !mi->skip) &&
+ mi->segment_id <= CR_SEGMENT_ID_BOOST2) {
cr->last_coded_q_map[map_offset] = clamp(
- cm->base_qindex + cr->qindex_delta[mbmi->segment_id], 0, MAXQ);
- } else if (is_inter_block(mbmi) && mbmi->skip &&
- mbmi->segment_id <= CR_SEGMENT_ID_BOOST2) {
+ cm->base_qindex + cr->qindex_delta[mi->segment_id], 0, MAXQ);
+ } else if (is_inter_block(mi) && mi->skip &&
+ mi->segment_id <= CR_SEGMENT_ID_BOOST2) {
cr->last_coded_q_map[map_offset] = VPXMIN(
- clamp(cm->base_qindex + cr->qindex_delta[mbmi->segment_id],
+ clamp(cm->base_qindex + cr->qindex_delta[mi->segment_id],
0, MAXQ),
cr->last_coded_q_map[map_offset]);
// Update the consecutive zero/low_mv count.
- if (is_inter_block(mbmi) && (abs(mv.row) < 8 && abs(mv.col) < 8)) {
+ if (is_inter_block(mi) && (abs(mv.row) < 8 && abs(mv.col) < 8)) {
if (cr->consec_zero_mv[map_offset] < 255)
cr->consec_zero_mv[map_offset]++;
} else {
@@ -347,10 +349,10 @@
for (mi_row = 0; mi_row < rows; mi_row++) {
for (mi_col = 0; mi_col < cols; mi_col++) {
- int16_t abs_mvr = mi[0]->mbmi.mv[0].as_mv.row >= 0 ?
- mi[0]->mbmi.mv[0].as_mv.row : -1 * mi[0]->mbmi.mv[0].as_mv.row;
- int16_t abs_mvc = mi[0]->mbmi.mv[0].as_mv.col >= 0 ?
- mi[0]->mbmi.mv[0].as_mv.col : -1 * mi[0]->mbmi.mv[0].as_mv.col;
+ int16_t abs_mvr = mi[0]->mv[0].as_mv.row >= 0 ?
+ mi[0]->mv[0].as_mv.row : -1 * mi[0]->mv[0].as_mv.row;
+ int16_t abs_mvc = mi[0]->mv[0].as_mv.col >= 0 ?
+ mi[0]->mv[0].as_mv.col : -1 * mi[0]->mv[0].as_mv.col;
// Calculate the motion of the background.
if (abs_mvr <= 16 && abs_mvc <= 16) {
diff --git a/vp9/encoder/vp9_aq_cyclicrefresh.h b/vp9/encoder/vp9_aq_cyclicrefresh.h
index edf0a97..095b928 100644
--- a/vp9/encoder/vp9_aq_cyclicrefresh.h
+++ b/vp9/encoder/vp9_aq_cyclicrefresh.h
@@ -93,13 +93,13 @@
// check if we should reset the segment_id, and update the cyclic_refresh map
// and segmentation map.
void vp9_cyclic_refresh_update_segment(struct VP9_COMP *const cpi,
- MB_MODE_INFO *const mbmi,
+ MODE_INFO *const mi,
int mi_row, int mi_col, BLOCK_SIZE bsize,
int64_t rate, int64_t dist, int skip,
struct macroblock_plane *const p);
void vp9_cyclic_refresh_update_sb_postencode(struct VP9_COMP *const cpi,
- const MB_MODE_INFO *const mbmi,
+ const MODE_INFO *const mi,
int mi_row, int mi_col,
BLOCK_SIZE bsize);
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index 1a14ea9..5600ed4 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -79,8 +79,8 @@
static void write_selected_tx_size(const VP9_COMMON *cm,
const MACROBLOCKD *xd, vpx_writer *w) {
- TX_SIZE tx_size = xd->mi[0]->mbmi.tx_size;
- BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
+ TX_SIZE tx_size = xd->mi[0]->tx_size;
+ BLOCK_SIZE bsize = xd->mi[0]->sb_type;
const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
const vpx_prob *const tx_probs = get_tx_probs2(max_tx_size, xd,
&cm->fc->tx_probs);
@@ -97,7 +97,7 @@
if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) {
return 1;
} else {
- const int skip = mi->mbmi.skip;
+ const int skip = mi->skip;
vpx_write(w, skip, vp9_get_skip_prob(cm, xd));
return skip;
}
@@ -194,15 +194,15 @@
// This function encodes the reference frame
static void write_ref_frames(const VP9_COMMON *cm, const MACROBLOCKD *xd,
vpx_writer *w) {
- const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
- const int is_compound = has_second_ref(mbmi);
- const int segment_id = mbmi->segment_id;
+ const MODE_INFO *const mi = xd->mi[0];
+ const int is_compound = has_second_ref(mi);
+ const int segment_id = mi->segment_id;
// If segment level coding of this signal is disabled...
// or the segment allows multiple reference frame options
if (segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
assert(!is_compound);
- assert(mbmi->ref_frame[0] ==
+ assert(mi->ref_frame[0] ==
get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME));
} else {
// does the feature use compound prediction or not
@@ -214,13 +214,13 @@
}
if (is_compound) {
- vpx_write(w, mbmi->ref_frame[0] == GOLDEN_FRAME,
+ vpx_write(w, mi->ref_frame[0] == GOLDEN_FRAME,
vp9_get_pred_prob_comp_ref_p(cm, xd));
} else {
- const int bit0 = mbmi->ref_frame[0] != LAST_FRAME;
+ const int bit0 = mi->ref_frame[0] != LAST_FRAME;
vpx_write(w, bit0, vp9_get_pred_prob_single_ref_p1(cm, xd));
if (bit0) {
- const int bit1 = mbmi->ref_frame[0] != GOLDEN_FRAME;
+ const int bit1 = mi->ref_frame[0] != GOLDEN_FRAME;
vpx_write(w, bit1, vp9_get_pred_prob_single_ref_p2(cm, xd));
}
}
@@ -234,19 +234,18 @@
const MACROBLOCK *const x = &cpi->td.mb;
const MACROBLOCKD *const xd = &x->e_mbd;
const struct segmentation *const seg = &cm->seg;
- const MB_MODE_INFO *const mbmi = &mi->mbmi;
const MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
- const PREDICTION_MODE mode = mbmi->mode;
- const int segment_id = mbmi->segment_id;
- const BLOCK_SIZE bsize = mbmi->sb_type;
+ const PREDICTION_MODE mode = mi->mode;
+ const int segment_id = mi->segment_id;
+ const BLOCK_SIZE bsize = mi->sb_type;
const int allow_hp = cm->allow_high_precision_mv;
- const int is_inter = is_inter_block(mbmi);
- const int is_compound = has_second_ref(mbmi);
+ const int is_inter = is_inter_block(mi);
+ const int is_compound = has_second_ref(mi);
int skip, ref;
if (seg->update_map) {
if (seg->temporal_update) {
- const int pred_flag = mbmi->seg_id_predicted;
+ const int pred_flag = mi->seg_id_predicted;
vpx_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd);
vpx_write(w, pred_flag, pred_prob);
if (!pred_flag)
@@ -280,9 +279,9 @@
}
}
}
- write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mode]);
+ write_intra_mode(w, mi->uv_mode, cm->fc->uv_mode_prob[mode]);
} else {
- const int mode_ctx = mbmi_ext->mode_context[mbmi->ref_frame[0]];
+ const int mode_ctx = mbmi_ext->mode_context[mi->ref_frame[0]];
const vpx_prob *const inter_probs = cm->fc->inter_mode_probs[mode_ctx];
write_ref_frames(cm, xd, w);
@@ -297,10 +296,10 @@
const int ctx = vp9_get_pred_context_switchable_interp(xd);
vp9_write_token(w, vp9_switchable_interp_tree,
cm->fc->switchable_interp_prob[ctx],
- &switchable_interp_encodings[mbmi->interp_filter]);
- ++cpi->interp_filter_selected[0][mbmi->interp_filter];
+ &switchable_interp_encodings[mi->interp_filter]);
+ ++cpi->interp_filter_selected[0][mi->interp_filter];
} else {
- assert(mbmi->interp_filter == cm->interp_filter);
+ assert(mi->interp_filter == cm->interp_filter);
}
if (bsize < BLOCK_8X8) {
@@ -315,7 +314,7 @@
if (b_mode == NEWMV) {
for (ref = 0; ref < 1 + is_compound; ++ref)
vp9_encode_mv(cpi, w, &mi->bmi[j].as_mv[ref].as_mv,
- &mbmi_ext->ref_mvs[mbmi->ref_frame[ref]][0].as_mv,
+ &mbmi_ext->ref_mvs[mi->ref_frame[ref]][0].as_mv,
nmvc, allow_hp);
}
}
@@ -323,8 +322,8 @@
} else {
if (mode == NEWMV) {
for (ref = 0; ref < 1 + is_compound; ++ref)
- vp9_encode_mv(cpi, w, &mbmi->mv[ref].as_mv,
- &mbmi_ext->ref_mvs[mbmi->ref_frame[ref]][0].as_mv, nmvc,
+ vp9_encode_mv(cpi, w, &mi->mv[ref].as_mv,
+ &mbmi_ext->ref_mvs[mi->ref_frame[ref]][0].as_mv, nmvc,
allow_hp);
}
}
@@ -337,19 +336,18 @@
const MODE_INFO *const mi = mi_8x8[0];
const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *const left_mi = xd->left_mi;
- const MB_MODE_INFO *const mbmi = &mi->mbmi;
- const BLOCK_SIZE bsize = mbmi->sb_type;
+ const BLOCK_SIZE bsize = mi->sb_type;
if (seg->update_map)
- write_segment_id(w, seg, mbmi->segment_id);
+ write_segment_id(w, seg, mi->segment_id);
- write_skip(cm, xd, mbmi->segment_id, mi, w);
+ write_skip(cm, xd, mi->segment_id, mi, w);
if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT)
write_selected_tx_size(cm, xd, w);
if (bsize >= BLOCK_8X8) {
- write_intra_mode(w, mbmi->mode, get_y_mode_probs(mi, above_mi, left_mi, 0));
+ write_intra_mode(w, mi->mode, get_y_mode_probs(mi, above_mi, left_mi, 0));
} else {
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
@@ -364,7 +362,7 @@
}
}
- write_intra_mode(w, mbmi->uv_mode, vp9_kf_uv_mode_prob[mbmi->mode]);
+ write_intra_mode(w, mi->uv_mode, vp9_kf_uv_mode_prob[mi->mode]);
}
static void write_modes_b(VP9_COMP *cpi, const TileInfo *const tile,
@@ -382,8 +380,8 @@
(mi_row * cm->mi_cols + mi_col);
set_mi_row_col(xd, tile,
- mi_row, num_8x8_blocks_high_lookup[m->mbmi.sb_type],
- mi_col, num_8x8_blocks_wide_lookup[m->mbmi.sb_type],
+ mi_row, num_8x8_blocks_high_lookup[m->sb_type],
+ mi_col, num_8x8_blocks_wide_lookup[m->sb_type],
cm->mi_rows, cm->mi_cols);
if (frame_is_intra_only(cm)) {
write_mb_modes_kf(cm, xd, xd->mi, w);
@@ -435,7 +433,7 @@
m = cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col];
- partition = partition_lookup[bsl][m->mbmi.sb_type];
+ partition = partition_lookup[bsl][m->sb_type];
write_partition(cm, xd, bs, mi_row, mi_col, partition, bsize, w);
subsize = get_subsize(bsize, partition);
if (subsize < BLOCK_8X8) {
diff --git a/vp9/encoder/vp9_denoiser.c b/vp9/encoder/vp9_denoiser.c
index 6533902..3280e73 100644
--- a/vp9/encoder/vp9_denoiser.c
+++ b/vp9/encoder/vp9_denoiser.c
@@ -200,8 +200,8 @@
int sse_diff = ctx->zeromv_sse - ctx->newmv_sse;
MV_REFERENCE_FRAME frame;
MACROBLOCKD *filter_mbd = &mb->e_mbd;
- MB_MODE_INFO *mbmi = &filter_mbd->mi[0]->mbmi;
- MB_MODE_INFO saved_mbmi;
+ MODE_INFO *mi = filter_mbd->mi[0];
+ MODE_INFO saved_mi;
int i, j;
struct buf_2d saved_dst[MAX_MB_PLANE];
struct buf_2d saved_pre[MAX_MB_PLANE][2]; // 2 pre buffers
@@ -210,18 +210,18 @@
mv_row = ctx->best_sse_mv.as_mv.row;
frame = ctx->best_reference_frame;
- saved_mbmi = *mbmi;
+ saved_mi = *mi;
- if (is_skin && motion_magnitude > 16)
+ if (is_skin && motion_magnitude > 0)
return COPY_BLOCK;
// If the best reference frame uses inter-prediction and there is enough of a
// difference in sum-squared-error, use it.
if (frame != INTRA_FRAME &&
sse_diff > sse_diff_thresh(bs, increase_denoising, motion_magnitude)) {
- mbmi->ref_frame[0] = ctx->best_reference_frame;
- mbmi->mode = ctx->best_sse_inter_mode;
- mbmi->mv[0] = ctx->best_sse_mv;
+ mi->ref_frame[0] = ctx->best_reference_frame;
+ mi->mode = ctx->best_sse_inter_mode;
+ mi->mv[0] = ctx->best_sse_mv;
} else {
// Otherwise, use the zero reference frame.
frame = ctx->best_zeromv_reference_frame;
@@ -233,9 +233,9 @@
frame = LAST_FRAME;
ctx->newmv_sse = ctx->zeromv_lastref_sse;
}
- mbmi->ref_frame[0] = frame;
- mbmi->mode = ZEROMV;
- mbmi->mv[0].as_int = 0;
+ mi->ref_frame[0] = frame;
+ mi->mode = ZEROMV;
+ mi->mv[0].as_int = 0;
ctx->best_sse_inter_mode = ZEROMV;
ctx->best_sse_mv.as_int = 0;
*zeromv_filter = 1;
@@ -243,13 +243,13 @@
if (ctx->newmv_sse > sse_thresh(bs, increase_denoising)) {
// Restore everything to its original state
- *mbmi = saved_mbmi;
+ *mi = saved_mi;
return COPY_BLOCK;
}
if (motion_magnitude >
(noise_motion_thresh(bs, increase_denoising) << 3)) {
// Restore everything to its original state
- *mbmi = saved_mbmi;
+ *mi = saved_mi;
return COPY_BLOCK;
}
@@ -302,7 +302,7 @@
vp9_build_inter_predictors_sby(filter_mbd, mv_row, mv_col, bs);
// Restore everything to its original state
- *mbmi = saved_mbmi;
+ *mi = saved_mi;
for (i = 0; i < MAX_MB_PLANE; ++i) {
for (j = 0; j < 2; ++j) {
filter_mbd->plane[i].pre[j] = saved_pre[i][j];
@@ -461,22 +461,22 @@
ctx->zeromv_lastref_sse = UINT_MAX;
}
-void vp9_denoiser_update_frame_stats(MB_MODE_INFO *mbmi, unsigned int sse,
+void vp9_denoiser_update_frame_stats(MODE_INFO *mi, unsigned int sse,
PREDICTION_MODE mode,
PICK_MODE_CONTEXT *ctx) {
// TODO(tkopp): Use both MVs if possible
- if (mbmi->mv[0].as_int == 0 && sse < ctx->zeromv_sse) {
+ if (mi->mv[0].as_int == 0 && sse < ctx->zeromv_sse) {
ctx->zeromv_sse = sse;
- ctx->best_zeromv_reference_frame = mbmi->ref_frame[0];
- if (mbmi->ref_frame[0] == LAST_FRAME)
+ ctx->best_zeromv_reference_frame = mi->ref_frame[0];
+ if (mi->ref_frame[0] == LAST_FRAME)
ctx->zeromv_lastref_sse = sse;
}
- if (mbmi->mv[0].as_int != 0 && sse < ctx->newmv_sse) {
+ if (mi->mv[0].as_int != 0 && sse < ctx->newmv_sse) {
ctx->newmv_sse = sse;
ctx->best_sse_inter_mode = mode;
- ctx->best_sse_mv = mbmi->mv[0];
- ctx->best_reference_frame = mbmi->ref_frame[0];
+ ctx->best_sse_mv = mi->mv[0];
+ ctx->best_reference_frame = mi->ref_frame[0];
}
}
diff --git a/vp9/encoder/vp9_denoiser.h b/vp9/encoder/vp9_denoiser.h
index d07056b..12dd5b5 100644
--- a/vp9/encoder/vp9_denoiser.h
+++ b/vp9/encoder/vp9_denoiser.h
@@ -60,7 +60,7 @@
void vp9_denoiser_reset_frame_stats(PICK_MODE_CONTEXT *ctx);
-void vp9_denoiser_update_frame_stats(MB_MODE_INFO *mbmi,
+void vp9_denoiser_update_frame_stats(MODE_INFO *mi,
unsigned int sse, PREDICTION_MODE mode,
PICK_MODE_CONTEXT *ctx);
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 6e999ca..13e4894 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -187,7 +187,7 @@
BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *mbmi;
+ MODE_INFO *mi;
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
const int mi_height = num_8x8_blocks_high_lookup[bsize];
const struct segmentation *const seg = &cm->seg;
@@ -196,7 +196,7 @@
set_mode_info_offsets(cm, x, xd, mi_row, mi_col);
- mbmi = &xd->mi[0]->mbmi;
+ mi = xd->mi[0];
// Set up destination pointers.
vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col);
@@ -226,13 +226,13 @@
cpi->oxcf.aq_mode != EQUATOR360_AQ) {
const uint8_t *const map = seg->update_map ? cpi->segmentation_map
: cm->last_frame_seg_map;
- mbmi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
+ mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
}
vp9_init_plane_quantizers(cpi, x);
- x->encode_breakout = cpi->segment_encode_breakout[mbmi->segment_id];
+ x->encode_breakout = cpi->segment_encode_breakout[mi->segment_id];
} else {
- mbmi->segment_id = 0;
+ mi->segment_id = 0;
x->encode_breakout = cpi->encode_breakout;
}
@@ -260,7 +260,7 @@
BLOCK_SIZE bsize) {
if (cpi->common.mi_cols > mi_col && cpi->common.mi_rows > mi_row) {
set_mode_info_offsets(&cpi->common, x, xd, mi_row, mi_col);
- xd->mi[0]->mbmi.sb_type = bsize;
+ xd->mi[0]->sb_type = bsize;
}
}
@@ -718,7 +718,7 @@
// In the case of spatial/temporal scalable coding, the assumption here is
// that the temporal reference frame will always be of type LAST_FRAME.
// TODO(marpan): If that assumption is broken, we need to revisit this code.
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *mi = xd->mi[0];
unsigned int uv_sad;
const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, LAST_FRAME);
@@ -749,21 +749,21 @@
vp9_setup_pre_planes(xd, 0, yv12, mi_row, mi_col,
&cm->frame_refs[LAST_FRAME - 1].sf);
- mbmi->ref_frame[0] = LAST_FRAME;
- mbmi->ref_frame[1] = NONE;
- mbmi->sb_type = BLOCK_64X64;
- mbmi->mv[0].as_int = 0;
- mbmi->interp_filter = BILINEAR;
+ mi->ref_frame[0] = LAST_FRAME;
+ mi->ref_frame[1] = NONE;
+ mi->sb_type = BLOCK_64X64;
+ mi->mv[0].as_int = 0;
+ mi->interp_filter = BILINEAR;
y_sad = vp9_int_pro_motion_estimation(cpi, x, bsize, mi_row, mi_col);
if (y_sad_g < y_sad) {
vp9_setup_pre_planes(xd, 0, yv12_g, mi_row, mi_col,
&cm->frame_refs[GOLDEN_FRAME - 1].sf);
- mbmi->ref_frame[0] = GOLDEN_FRAME;
- mbmi->mv[0].as_int = 0;
+ mi->ref_frame[0] = GOLDEN_FRAME;
+ mi->mv[0].as_int = 0;
y_sad = y_sad_g;
} else {
- x->pred_mv[LAST_FRAME] = mbmi->mv[0].as_mv;
+ x->pred_mv[LAST_FRAME] = mi->mv[0].as_mv;
}
vp9_build_inter_predictors_sb(xd, mi_row, mi_col, BLOCK_64X64);
@@ -1012,11 +1012,11 @@
struct macroblock_plane *const p = x->plane;
struct macroblockd_plane *const pd = xd->plane;
MODE_INFO *mi = &ctx->mic;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const xdmi = xd->mi[0];
MODE_INFO *mi_addr = xd->mi[0];
const struct segmentation *const seg = &cm->seg;
- const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type];
- const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type];
+ const int bw = num_8x8_blocks_wide_lookup[mi->sb_type];
+ const int bh = num_8x8_blocks_high_lookup[mi->sb_type];
const int x_mis = VPXMIN(bw, cm->mi_cols - mi_col);
const int y_mis = VPXMIN(bh, cm->mi_rows - mi_row);
MV_REF *const frame_mvs =
@@ -1028,7 +1028,7 @@
const int mi_height = num_8x8_blocks_high_lookup[bsize];
int max_plane;
- assert(mi->mbmi.sb_type == bsize);
+ assert(mi->sb_type == bsize);
*mi_addr = *mi;
*x->mbmi_ext = ctx->mbmi_ext;
@@ -1039,19 +1039,19 @@
if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) {
const uint8_t *const map = seg->update_map ? cpi->segmentation_map
: cm->last_frame_seg_map;
- mi_addr->mbmi.segment_id =
+ mi_addr->segment_id =
get_segment_id(cm, map, bsize, mi_row, mi_col);
}
// Else for cyclic refresh mode update the segment map, set the segment id
// and then update the quantizer.
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) {
- vp9_cyclic_refresh_update_segment(cpi, &xd->mi[0]->mbmi, mi_row,
+ vp9_cyclic_refresh_update_segment(cpi, xd->mi[0], mi_row,
mi_col, bsize, ctx->rate, ctx->dist,
x->skip, p);
}
}
- max_plane = is_inter_block(mbmi) ? MAX_MB_PLANE : 1;
+ max_plane = is_inter_block(xdmi) ? MAX_MB_PLANE : 1;
for (i = 0; i < max_plane; ++i) {
p[i].coeff = ctx->coeff_pbuf[i][1];
p[i].qcoeff = ctx->qcoeff_pbuf[i][1];
@@ -1078,13 +1078,13 @@
if (cpi->oxcf.aq_mode)
vp9_init_plane_quantizers(cpi, x);
- if (is_inter_block(mbmi) && mbmi->sb_type < BLOCK_8X8) {
- mbmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int;
- mbmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
+ if (is_inter_block(xdmi) && xdmi->sb_type < BLOCK_8X8) {
+ xdmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int;
+ xdmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
}
x->skip = ctx->skip;
- memcpy(x->zcoeff_blk[mbmi->tx_size], ctx->zcoeff_blk,
+ memcpy(x->zcoeff_blk[xdmi->tx_size], ctx->zcoeff_blk,
sizeof(ctx->zcoeff_blk[0]) * ctx->num_4x4_blk);
if (!output_enabled)
@@ -1104,19 +1104,19 @@
THR_D63_PRED /*D63_PRED*/,
THR_TM /*TM_PRED*/,
};
- ++cpi->mode_chosen_counts[kf_mode_index[mbmi->mode]];
+ ++cpi->mode_chosen_counts[kf_mode_index[mi->mode]];
} else {
// Note how often each mode chosen as best
++cpi->mode_chosen_counts[ctx->best_mode_index];
}
#endif
if (!frame_is_intra_only(cm)) {
- if (is_inter_block(mbmi)) {
+ if (is_inter_block(xdmi)) {
vp9_update_mv_count(td);
if (cm->interp_filter == SWITCHABLE) {
const int ctx = vp9_get_pred_context_switchable_interp(xd);
- ++td->counts->switchable_interp[ctx][mbmi->interp_filter];
+ ++td->counts->switchable_interp[ctx][xdmi->interp_filter];
}
}
@@ -1132,10 +1132,10 @@
MV_REF *const frame_mv = frame_mvs + h * cm->mi_cols;
for (w = 0; w < x_mis; ++w) {
MV_REF *const mv = frame_mv + w;
- mv->ref_frame[0] = mi->mbmi.ref_frame[0];
- mv->ref_frame[1] = mi->mbmi.ref_frame[1];
- mv->mv[0].as_int = mi->mbmi.mv[0].as_int;
- mv->mv[1].as_int = mi->mbmi.mv[1].as_int;
+ mv->ref_frame[0] = mi->ref_frame[0];
+ mv->ref_frame[1] = mi->ref_frame[1];
+ mv->mv[0].as_int = mi->mv[0].as_int;
+ mv->mv[1].as_int = mi->mv[1].as_int;
}
}
}
@@ -1158,26 +1158,26 @@
static void set_mode_info_seg_skip(MACROBLOCK *x, TX_MODE tx_mode,
RD_COST *rd_cost, BLOCK_SIZE bsize) {
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
INTERP_FILTER filter_ref;
if (xd->up_available)
- filter_ref = xd->mi[-xd->mi_stride]->mbmi.interp_filter;
+ filter_ref = xd->mi[-xd->mi_stride]->interp_filter;
else if (xd->left_available)
- filter_ref = xd->mi[-1]->mbmi.interp_filter;
+ filter_ref = xd->mi[-1]->interp_filter;
else
filter_ref = EIGHTTAP;
- mbmi->sb_type = bsize;
- mbmi->mode = ZEROMV;
- mbmi->tx_size =
+ mi->sb_type = bsize;
+ mi->mode = ZEROMV;
+ mi->tx_size =
VPXMIN(max_txsize_lookup[bsize], tx_mode_to_biggest_tx_size[tx_mode]);
- mbmi->skip = 1;
- mbmi->uv_mode = DC_PRED;
- mbmi->ref_frame[0] = LAST_FRAME;
- mbmi->ref_frame[1] = NONE;
- mbmi->mv[0].as_int = 0;
- mbmi->interp_filter = filter_ref;
+ mi->skip = 1;
+ mi->uv_mode = DC_PRED;
+ mi->ref_frame[0] = LAST_FRAME;
+ mi->ref_frame[1] = NONE;
+ mi->mv[0].as_int = 0;
+ mi->interp_filter = filter_ref;
xd->mi[0]->bmi[0].as_mv[0].as_int = 0;
x->skip = 1;
@@ -1206,7 +1206,7 @@
VP9_COMMON *const cm = &cpi->common;
TileInfo *const tile_info = &tile_data->tile_info;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *mbmi;
+ MODE_INFO *mi;
struct macroblock_plane *const p = x->plane;
struct macroblockd_plane *const pd = xd->plane;
const AQ_MODE aq_mode = cpi->oxcf.aq_mode;
@@ -1218,8 +1218,8 @@
x->use_lp32x32fdct = 1;
set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize);
- mbmi = &xd->mi[0]->mbmi;
- mbmi->sb_type = bsize;
+ mi = xd->mi[0];
+ mi->sb_type = bsize;
for (i = 0; i < MAX_MB_PLANE; ++i) {
p[i].coeff = ctx->coeff_pbuf[i][0];
@@ -1233,7 +1233,7 @@
x->skip_recode = 0;
// Set to zero to make sure we do not use the previous encoded frame stats
- mbmi->skip = 0;
+ mi->skip = 0;
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
@@ -1258,24 +1258,24 @@
if (cm->frame_type == KEY_FRAME ||
cpi->refresh_alt_ref_frame ||
(cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) {
- mbmi->segment_id = vp9_vaq_segment_id(energy);
+ mi->segment_id = vp9_vaq_segment_id(energy);
} else {
const uint8_t *const map = cm->seg.update_map ? cpi->segmentation_map
: cm->last_frame_seg_map;
- mbmi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
+ mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
}
- x->rdmult = set_segment_rdmult(cpi, x, mbmi->segment_id);
+ x->rdmult = set_segment_rdmult(cpi, x, mi->segment_id);
} else if (aq_mode == EQUATOR360_AQ) {
if (cm->frame_type == KEY_FRAME) {
- mbmi->segment_id = vp9_360aq_segment_id(mi_row, cm->mi_rows);
+ mi->segment_id = vp9_360aq_segment_id(mi_row, cm->mi_rows);
} else {
const uint8_t *const map = cm->seg.update_map ? cpi->segmentation_map
: cm->last_frame_seg_map;
- mbmi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
+ mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
}
- x->rdmult = set_segment_rdmult(cpi, x, mbmi->segment_id);
+ x->rdmult = set_segment_rdmult(cpi, x, mi->segment_id);
} else if (aq_mode == COMPLEXITY_AQ) {
- x->rdmult = set_segment_rdmult(cpi, x, mbmi->segment_id);
+ x->rdmult = set_segment_rdmult(cpi, x, mi->segment_id);
} else if (aq_mode == CYCLIC_REFRESH_AQ) {
const uint8_t *const map = cm->seg.update_map ? cpi->segmentation_map
: cm->last_frame_seg_map;
@@ -1291,7 +1291,7 @@
vp9_rd_pick_intra_mode_sb(cpi, x, rd_cost, bsize, ctx, best_rd);
} else {
if (bsize >= BLOCK_8X8) {
- if (segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP))
+ if (segfeature_active(&cm->seg, mi->segment_id, SEG_LVL_SKIP))
vp9_rd_pick_inter_mode_sb_seg_skip(cpi, tile_data, x, rd_cost, bsize,
ctx, best_rd);
else
@@ -1328,14 +1328,13 @@
const MACROBLOCK *x = &td->mb;
const MACROBLOCKD *const xd = &x->e_mbd;
const MODE_INFO *const mi = xd->mi[0];
- const MB_MODE_INFO *const mbmi = &mi->mbmi;
const MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
- const BLOCK_SIZE bsize = mbmi->sb_type;
+ const BLOCK_SIZE bsize = mi->sb_type;
if (!frame_is_intra_only(cm)) {
FRAME_COUNTS *const counts = td->counts;
- const int inter_block = is_inter_block(mbmi);
- const int seg_ref_active = segfeature_active(&cm->seg, mbmi->segment_id,
+ const int inter_block = is_inter_block(mi);
+ const int seg_ref_active = segfeature_active(&cm->seg, mi->segment_id,
SEG_LVL_REF_FRAME);
if (!seg_ref_active) {
counts->intra_inter[vp9_get_intra_inter_context(xd)][inter_block]++;
@@ -1343,12 +1342,12 @@
// reference frame allowed for the segment so exclude it from
// the reference frame counts used to work out probabilities.
if (inter_block) {
- const MV_REFERENCE_FRAME ref0 = mbmi->ref_frame[0];
+ const MV_REFERENCE_FRAME ref0 = mi->ref_frame[0];
if (cm->reference_mode == REFERENCE_MODE_SELECT)
counts->comp_inter[vp9_get_reference_mode_context(cm, xd)]
- [has_second_ref(mbmi)]++;
+ [has_second_ref(mi)]++;
- if (has_second_ref(mbmi)) {
+ if (has_second_ref(mi)) {
counts->comp_ref[vp9_get_pred_context_comp_ref_p(cm, xd)]
[ref0 == GOLDEN_FRAME]++;
} else {
@@ -1361,10 +1360,10 @@
}
}
if (inter_block &&
- !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
- const int mode_ctx = mbmi_ext->mode_context[mbmi->ref_frame[0]];
+ !segfeature_active(&cm->seg, mi->segment_id, SEG_LVL_SKIP)) {
+ const int mode_ctx = mbmi_ext->mode_context[mi->ref_frame[0]];
if (bsize >= BLOCK_8X8) {
- const PREDICTION_MODE mode = mbmi->mode;
+ const PREDICTION_MODE mode = mi->mode;
++counts->inter_mode[mode_ctx][INTER_OFFSET(mode)];
} else {
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
@@ -1566,7 +1565,7 @@
for (c = 0; c < MI_BLOCK_SIZE; c += bw) {
const int index = r * mis + c;
mi_8x8[index] = mi + index;
- mi_8x8[index]->mbmi.sb_type = find_partition_size(bsize,
+ mi_8x8[index]->sb_type = find_partition_size(bsize,
row8x8_remaining - r, col8x8_remaining - c, &bh, &bw);
}
}
@@ -1598,7 +1597,7 @@
for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) {
int index = block_row * mis + block_col;
mi_8x8[index] = mi_upper_left + index;
- mi_8x8[index]->mbmi.sb_type = bsize;
+ mi_8x8[index]->sb_type = bsize;
}
}
} else {
@@ -1663,7 +1662,7 @@
index = b_mi_row * mis + b_mi_col;
mi_8x8[index] = mi_upper_left + index;
- mi_8x8[index]->mbmi.sb_type = BLOCK_16X16;
+ mi_8x8[index]->sb_type = BLOCK_16X16;
// TODO(yunqingwang): If d16[j].var is very large, use 8x8 partition
// size to further improve quality.
@@ -1685,7 +1684,7 @@
index = coord_lookup[i*4].row * mis + coord_lookup[i*4].col;
mi_8x8[index] = mi_upper_left + index;
- mi_8x8[index]->mbmi.sb_type = BLOCK_32X32;
+ mi_8x8[index]->sb_type = BLOCK_32X32;
}
}
@@ -1697,7 +1696,7 @@
// Use 64x64 partition
if (is_larger_better) {
mi_8x8[0] = mi_upper_left;
- mi_8x8[0]->mbmi.sb_type = BLOCK_64X64;
+ mi_8x8[0]->sb_type = BLOCK_64X64;
}
}
} else { // partial in-image SB64
@@ -1715,11 +1714,10 @@
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
MODE_INFO *const mi = xd->mi[0];
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
struct macroblock_plane *const p = x->plane;
const struct segmentation *const seg = &cm->seg;
- const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type];
- const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type];
+ const int bw = num_8x8_blocks_wide_lookup[mi->sb_type];
+ const int bh = num_8x8_blocks_high_lookup[mi->sb_type];
const int x_mis = VPXMIN(bw, cm->mi_cols - mi_col);
const int y_mis = VPXMIN(bh, cm->mi_rows - mi_row);
@@ -1734,29 +1732,31 @@
cpi->oxcf.aq_mode == EQUATOR360_AQ) {
const uint8_t *const map = seg->update_map ? cpi->segmentation_map
: cm->last_frame_seg_map;
- mbmi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
+ mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
} else {
// Setting segmentation map for cyclic_refresh.
- vp9_cyclic_refresh_update_segment(cpi, mbmi, mi_row, mi_col, bsize,
+ vp9_cyclic_refresh_update_segment(cpi, mi, mi_row, mi_col, bsize,
ctx->rate, ctx->dist, x->skip, p);
}
vp9_init_plane_quantizers(cpi, x);
}
- if (is_inter_block(mbmi)) {
+ if (is_inter_block(mi)) {
vp9_update_mv_count(td);
if (cm->interp_filter == SWITCHABLE) {
const int pred_ctx = vp9_get_pred_context_switchable_interp(xd);
- ++td->counts->switchable_interp[pred_ctx][mbmi->interp_filter];
+ ++td->counts->switchable_interp[pred_ctx][mi->interp_filter];
}
- if (mbmi->sb_type < BLOCK_8X8) {
- mbmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int;
- mbmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
+ if (mi->sb_type < BLOCK_8X8) {
+ mi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int;
+ mi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
}
}
- if (cm->use_prev_frame_mvs) {
+ if (cm->use_prev_frame_mvs ||
+ (cpi->svc.use_base_mv && cpi->svc.number_spatial_layers > 1
+ && cpi->svc.spatial_layer_id != cpi->svc.number_spatial_layers - 1)) {
MV_REF *const frame_mvs =
cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col;
int w, h;
@@ -1765,16 +1765,16 @@
MV_REF *const frame_mv = frame_mvs + h * cm->mi_cols;
for (w = 0; w < x_mis; ++w) {
MV_REF *const mv = frame_mv + w;
- mv->ref_frame[0] = mi->mbmi.ref_frame[0];
- mv->ref_frame[1] = mi->mbmi.ref_frame[1];
- mv->mv[0].as_int = mi->mbmi.mv[0].as_int;
- mv->mv[1].as_int = mi->mbmi.mv[1].as_int;
+ mv->ref_frame[0] = mi->ref_frame[0];
+ mv->ref_frame[1] = mi->ref_frame[1];
+ mv->mv[0].as_int = mi->mv[0].as_int;
+ mv->mv[1].as_int = mi->mv[1].as_int;
}
}
}
x->skip = ctx->skip;
- x->skip_txfm[0] = mbmi->segment_id ? 0 : ctx->skip_txfm[0];
+ x->skip_txfm[0] = mi->segment_id ? 0 : ctx->skip_txfm[0];
}
static void encode_b_rt(VP9_COMP *cpi, ThreadData *td,
@@ -1814,7 +1814,7 @@
const int idx_str = xd->mi_stride * mi_row + mi_col;
MODE_INFO ** mi_8x8 = cm->mi_grid_visible + idx_str;
ctx = partition_plane_context(xd, mi_row, mi_col, bsize);
- subsize = mi_8x8[0]->mbmi.sb_type;
+ subsize = mi_8x8[0]->sb_type;
} else {
ctx = 0;
subsize = BLOCK_4X4;
@@ -1889,7 +1889,7 @@
RD_COST last_part_rdc, none_rdc, chosen_rdc;
BLOCK_SIZE sub_subsize = BLOCK_4X4;
int splits_below = 0;
- BLOCK_SIZE bs_type = mi_8x8[0]->mbmi.sb_type;
+ BLOCK_SIZE bs_type = mi_8x8[0]->sb_type;
int do_partition_search = 1;
PICK_MODE_CONTEXT *ctx = &pc_tree->none;
@@ -1924,7 +1924,7 @@
for (i = 0; i < 4; i++) {
int jj = i >> 1, ii = i & 0x01;
MODE_INFO *this_mi = mi_8x8[jj * bss * mis + ii * bss];
- if (this_mi && this_mi->mbmi.sb_type >= sub_subsize) {
+ if (this_mi && this_mi->sb_type >= sub_subsize) {
splits_below = 0;
}
}
@@ -1948,7 +1948,7 @@
}
restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize);
- mi_8x8[0]->mbmi.sb_type = bs_type;
+ mi_8x8[0]->sb_type = bs_type;
pc_tree->partitioning = partition;
}
}
@@ -2106,7 +2106,7 @@
// If last_part is better set the partitioning to that.
if (last_part_rdc.rdcost < chosen_rdc.rdcost) {
- mi_8x8[0]->mbmi.sb_type = bsize;
+ mi_8x8[0]->sb_type = bsize;
if (bsize >= BLOCK_8X8)
pc_tree->partitioning = partition;
chosen_rdc = last_part_rdc;
@@ -2172,7 +2172,7 @@
for (i = 0; i < sb_height_in_blocks; ++i) {
for (j = 0; j < sb_width_in_blocks; ++j) {
MODE_INFO *mi = mi_8x8[index+j];
- BLOCK_SIZE sb_type = mi ? mi->mbmi.sb_type : 0;
+ BLOCK_SIZE sb_type = mi ? mi->sb_type : 0;
bs_hist[sb_type]++;
*min_block_size = VPXMIN(*min_block_size, sb_type);
*max_block_size = VPXMAX(*max_block_size, sb_type);
@@ -2288,7 +2288,7 @@
for (idy = 0; idy < mi_height; ++idy) {
for (idx = 0; idx < mi_width; ++idx) {
mi = prev_mi[idy * cm->mi_stride + idx];
- bs = mi ? mi->mbmi.sb_type : bsize;
+ bs = mi ? mi->sb_type : bsize;
min_size = VPXMIN(min_size, bs);
max_size = VPXMAX(max_size, bs);
}
@@ -2298,7 +2298,7 @@
if (xd->left_available) {
for (idy = 0; idy < mi_height; ++idy) {
mi = xd->mi[idy * cm->mi_stride - 1];
- bs = mi ? mi->mbmi.sb_type : bsize;
+ bs = mi ? mi->sb_type : bsize;
min_size = VPXMIN(min_size, bs);
max_size = VPXMAX(max_size, bs);
}
@@ -2307,7 +2307,7 @@
if (xd->up_available) {
for (idx = 0; idx < mi_width; ++idx) {
mi = xd->mi[idx - cm->mi_stride];
- bs = mi ? mi->mbmi.sb_type : bsize;
+ bs = mi ? mi->sb_type : bsize;
min_size = VPXMIN(min_size, bs);
max_size = VPXMAX(max_size, bs);
}
@@ -2625,7 +2625,7 @@
i = 4;
if (cpi->sf.adaptive_pred_interp_filter && partition_none_allowed)
pc_tree->leaf_split[0]->pred_interp_filter =
- ctx->mic.mbmi.interp_filter;
+ ctx->mic.interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
pc_tree->leaf_split[0], best_rdc.rdcost);
if (sum_rdc.rate == INT_MAX)
@@ -2696,7 +2696,7 @@
if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 &&
partition_none_allowed)
pc_tree->horizontal[0].pred_interp_filter =
- ctx->mic.mbmi.interp_filter;
+ ctx->mic.interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
&pc_tree->horizontal[0], best_rdc.rdcost);
@@ -2711,7 +2711,7 @@
if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 &&
partition_none_allowed)
pc_tree->horizontal[1].pred_interp_filter =
- ctx->mic.mbmi.interp_filter;
+ ctx->mic.interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row + mi_step, mi_col,
&this_rdc, subsize, &pc_tree->horizontal[1],
best_rdc.rdcost - sum_rdc.rdcost);
@@ -2749,7 +2749,7 @@
if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 &&
partition_none_allowed)
pc_tree->vertical[0].pred_interp_filter =
- ctx->mic.mbmi.interp_filter;
+ ctx->mic.interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
&pc_tree->vertical[0], best_rdc.rdcost);
if (sum_rdc.rdcost < best_rdc.rdcost && mi_col + mi_step < cm->mi_cols &&
@@ -2763,7 +2763,7 @@
if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 &&
partition_none_allowed)
pc_tree->vertical[1].pred_interp_filter =
- ctx->mic.mbmi.interp_filter;
+ ctx->mic.interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + mi_step,
&this_rdc, subsize,
&pc_tree->vertical[1], best_rdc.rdcost - sum_rdc.rdcost);
@@ -2935,8 +2935,8 @@
for (mi_row = 0; mi_row < cm->mi_rows; ++mi_row, mi_ptr += mis) {
for (mi_col = 0; mi_col < cm->mi_cols; ++mi_col) {
- if (mi_ptr[mi_col]->mbmi.tx_size > max_tx_size)
- mi_ptr[mi_col]->mbmi.tx_size = max_tx_size;
+ if (mi_ptr[mi_col]->tx_size > max_tx_size)
+ mi_ptr[mi_col]->tx_size = max_tx_size;
}
}
}
@@ -2983,18 +2983,18 @@
VP9_COMMON *const cm = &cpi->common;
TileInfo *const tile_info = &tile_data->tile_info;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *mbmi;
+ MODE_INFO *mi;
set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize);
- mbmi = &xd->mi[0]->mbmi;
- mbmi->sb_type = bsize;
+ mi = xd->mi[0];
+ mi->sb_type = bsize;
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled)
- if (cyclic_refresh_segment_id_boosted(mbmi->segment_id))
+ if (cyclic_refresh_segment_id_boosted(mi->segment_id))
x->rdmult = vp9_cyclic_refresh_get_rdmult(cpi->cyclic_refresh);
if (cm->frame_type == KEY_FRAME)
hybrid_intra_mode_search(cpi, x, rd_cost, bsize, ctx);
- else if (segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP))
+ else if (segfeature_active(&cm->seg, mi->segment_id, SEG_LVL_SKIP))
set_mode_info_seg_skip(x, cm->tx_mode, rd_cost, bsize);
else if (bsize >= BLOCK_8X8)
vp9_pick_inter_mode(cpi, x, tile_data, mi_row, mi_col,
@@ -3154,7 +3154,7 @@
if (partition_none_allowed) {
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col,
&this_rdc, bsize, ctx);
- ctx->mic.mbmi = xd->mi[0]->mbmi;
+ ctx->mic = *xd->mi[0];
ctx->mbmi_ext = *x->mbmi_ext;
ctx->skip_txfm[0] = x->skip_txfm[0];
ctx->skip = x->skip;
@@ -3237,7 +3237,7 @@
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
&pc_tree->horizontal[0]);
- pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->horizontal[0].mic = *xd->mi[0];
pc_tree->horizontal[0].mbmi_ext = *x->mbmi_ext;
pc_tree->horizontal[0].skip_txfm[0] = x->skip_txfm[0];
pc_tree->horizontal[0].skip = x->skip;
@@ -3249,7 +3249,7 @@
&this_rdc, subsize,
&pc_tree->horizontal[1]);
- pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->horizontal[1].mic = *xd->mi[0];
pc_tree->horizontal[1].mbmi_ext = *x->mbmi_ext;
pc_tree->horizontal[1].skip_txfm[0] = x->skip_txfm[0];
pc_tree->horizontal[1].skip = x->skip;
@@ -3282,7 +3282,7 @@
pc_tree->vertical[0].pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
&pc_tree->vertical[0]);
- pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->vertical[0].mic = *xd->mi[0];
pc_tree->vertical[0].mbmi_ext = *x->mbmi_ext;
pc_tree->vertical[0].skip_txfm[0] = x->skip_txfm[0];
pc_tree->vertical[0].skip = x->skip;
@@ -3293,7 +3293,7 @@
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + ms,
&this_rdc, subsize,
&pc_tree->vertical[1]);
- pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->vertical[1].mic = *xd->mi[0];
pc_tree->vertical[1].mbmi_ext = *x->mbmi_ext;
pc_tree->vertical[1].skip_txfm[0] = x->skip_txfm[0];
pc_tree->vertical[1].skip = x->skip;
@@ -3365,7 +3365,7 @@
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
return;
- subsize = (bsize >= BLOCK_8X8) ? mi[0]->mbmi.sb_type : BLOCK_4X4;
+ subsize = (bsize >= BLOCK_8X8) ? mi[0]->sb_type : BLOCK_4X4;
partition = partition_lookup[bsl][subsize];
if (bsize == BLOCK_32X32 && subsize == BLOCK_32X32) {
@@ -3390,7 +3390,7 @@
pc_tree->none.pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, rd_cost,
subsize, &pc_tree->none);
- pc_tree->none.mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->none.mic = *xd->mi[0];
pc_tree->none.mbmi_ext = *x->mbmi_ext;
pc_tree->none.skip_txfm[0] = x->skip_txfm[0];
pc_tree->none.skip = x->skip;
@@ -3399,7 +3399,7 @@
pc_tree->vertical[0].pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, rd_cost,
subsize, &pc_tree->vertical[0]);
- pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->vertical[0].mic = *xd->mi[0];
pc_tree->vertical[0].mbmi_ext = *x->mbmi_ext;
pc_tree->vertical[0].skip_txfm[0] = x->skip_txfm[0];
pc_tree->vertical[0].skip = x->skip;
@@ -3407,7 +3407,7 @@
pc_tree->vertical[1].pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + hbs,
&this_rdc, subsize, &pc_tree->vertical[1]);
- pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->vertical[1].mic = *xd->mi[0];
pc_tree->vertical[1].mbmi_ext = *x->mbmi_ext;
pc_tree->vertical[1].skip_txfm[0] = x->skip_txfm[0];
pc_tree->vertical[1].skip = x->skip;
@@ -3422,7 +3422,7 @@
pc_tree->horizontal[0].pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, rd_cost,
subsize, &pc_tree->horizontal[0]);
- pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->horizontal[0].mic = *xd->mi[0];
pc_tree->horizontal[0].mbmi_ext = *x->mbmi_ext;
pc_tree->horizontal[0].skip_txfm[0] = x->skip_txfm[0];
pc_tree->horizontal[0].skip = x->skip;
@@ -3430,7 +3430,7 @@
pc_tree->horizontal[1].pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row + hbs, mi_col,
&this_rdc, subsize, &pc_tree->horizontal[1]);
- pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->horizontal[1].mic = *xd->mi[0];
pc_tree->horizontal[1].mbmi_ext = *x->mbmi_ext;
pc_tree->horizontal[1].skip_txfm[0] = x->skip_txfm[0];
pc_tree->horizontal[1].skip = x->skip;
@@ -3502,7 +3502,7 @@
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
return;
- subsize = (bsize >= BLOCK_8X8) ? mi[0]->mbmi.sb_type : BLOCK_4X4;
+ subsize = (bsize >= BLOCK_8X8) ? mi[0]->sb_type : BLOCK_4X4;
partition = partition_lookup[bsl][subsize];
if (output_enabled && bsize != BLOCK_4X4) {
@@ -3515,7 +3515,7 @@
pc_tree->none.pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, dummy_cost,
subsize, &pc_tree->none);
- pc_tree->none.mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->none.mic = *xd->mi[0];
pc_tree->none.mbmi_ext = *x->mbmi_ext;
pc_tree->none.skip_txfm[0] = x->skip_txfm[0];
pc_tree->none.skip = x->skip;
@@ -3526,7 +3526,7 @@
pc_tree->vertical[0].pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, dummy_cost,
subsize, &pc_tree->vertical[0]);
- pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->vertical[0].mic = *xd->mi[0];
pc_tree->vertical[0].mbmi_ext = *x->mbmi_ext;
pc_tree->vertical[0].skip_txfm[0] = x->skip_txfm[0];
pc_tree->vertical[0].skip = x->skip;
@@ -3536,7 +3536,7 @@
pc_tree->vertical[1].pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + hbs,
dummy_cost, subsize, &pc_tree->vertical[1]);
- pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->vertical[1].mic = *xd->mi[0];
pc_tree->vertical[1].mbmi_ext = *x->mbmi_ext;
pc_tree->vertical[1].skip_txfm[0] = x->skip_txfm[0];
pc_tree->vertical[1].skip = x->skip;
@@ -3548,7 +3548,7 @@
pc_tree->horizontal[0].pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, dummy_cost,
subsize, &pc_tree->horizontal[0]);
- pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->horizontal[0].mic = *xd->mi[0];
pc_tree->horizontal[0].mbmi_ext = *x->mbmi_ext;
pc_tree->horizontal[0].skip_txfm[0] = x->skip_txfm[0];
pc_tree->horizontal[0].skip = x->skip;
@@ -3559,7 +3559,7 @@
pc_tree->horizontal[1].pred_pixel_ready = 1;
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row + hbs, mi_col,
dummy_cost, subsize, &pc_tree->horizontal[1]);
- pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi;
+ pc_tree->horizontal[1].mic = *xd->mi[0];
pc_tree->horizontal[1].mbmi_ext = *x->mbmi_ext;
pc_tree->horizontal[1].skip_txfm[0] = x->skip_txfm[0];
pc_tree->horizontal[1].skip = x->skip;
@@ -3666,7 +3666,7 @@
case REFERENCE_PARTITION:
set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64);
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled &&
- xd->mi[0]->mbmi.segment_id) {
+ xd->mi[0]->segment_id) {
// Use lower max_partition_size for low resoultions.
if (cm->width <= 352 && cm->height <= 288)
x->max_partition_size = BLOCK_32X32;
@@ -4176,9 +4176,9 @@
}
static void sum_intra_stats(FRAME_COUNTS *counts, const MODE_INFO *mi) {
- const PREDICTION_MODE y_mode = mi->mbmi.mode;
- const PREDICTION_MODE uv_mode = mi->mbmi.uv_mode;
- const BLOCK_SIZE bsize = mi->mbmi.sb_type;
+ const PREDICTION_MODE y_mode = mi->mode;
+ const PREDICTION_MODE uv_mode = mi->uv_mode;
+ const BLOCK_SIZE bsize = mi->sb_type;
if (bsize < BLOCK_8X8) {
int idx, idy;
@@ -4203,14 +4203,13 @@
MACROBLOCKD *const xd = &x->e_mbd;
MODE_INFO **mi_8x8 = xd->mi;
MODE_INFO *mi = mi_8x8[0];
- MB_MODE_INFO *mbmi = &mi->mbmi;
- const int seg_skip = segfeature_active(&cm->seg, mbmi->segment_id,
+ const int seg_skip = segfeature_active(&cm->seg, mi->segment_id,
SEG_LVL_SKIP);
const int mis = cm->mi_stride;
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
const int mi_height = num_8x8_blocks_high_lookup[bsize];
- x->skip_recode = !x->select_tx_size && mbmi->sb_type >= BLOCK_8X8 &&
+ x->skip_recode = !x->select_tx_size && mi->sb_type >= BLOCK_8X8 &&
cpi->oxcf.aq_mode != COMPLEXITY_AQ &&
cpi->oxcf.aq_mode != CYCLIC_REFRESH_AQ &&
cpi->sf.allow_skip_recode;
@@ -4227,9 +4226,9 @@
if (x->skip_encode)
return;
- if (!is_inter_block(mbmi)) {
+ if (!is_inter_block(mi)) {
int plane;
- mbmi->skip = 1;
+ mi->skip = 1;
for (plane = 0; plane < MAX_MB_PLANE; ++plane)
vp9_encode_intra_block_plane(x, VPXMAX(bsize, BLOCK_8X8), plane);
if (output_enabled)
@@ -4237,11 +4236,11 @@
vp9_tokenize_sb(cpi, td, t, !output_enabled, VPXMAX(bsize, BLOCK_8X8));
} else {
int ref;
- const int is_compound = has_second_ref(mbmi);
- set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]);
+ const int is_compound = has_second_ref(mi);
+ set_ref_ptrs(cm, xd, mi->ref_frame[0], mi->ref_frame[1]);
for (ref = 0; ref < 1 + is_compound; ++ref) {
YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi,
- mbmi->ref_frame[ref]);
+ mi->ref_frame[ref]);
assert(cfg != NULL);
vp9_setup_pre_planes(xd, ref, cfg, mi_row, mi_col,
&xd->block_refs[ref]->sf);
@@ -4259,29 +4258,29 @@
if (output_enabled) {
if (cm->tx_mode == TX_MODE_SELECT &&
- mbmi->sb_type >= BLOCK_8X8 &&
- !(is_inter_block(mbmi) && (mbmi->skip || seg_skip))) {
+ mi->sb_type >= BLOCK_8X8 &&
+ !(is_inter_block(mi) && (mi->skip || seg_skip))) {
++get_tx_counts(max_txsize_lookup[bsize], get_tx_size_context(xd),
- &td->counts->tx)[mbmi->tx_size];
+ &td->counts->tx)[mi->tx_size];
} else {
int x, y;
TX_SIZE tx_size;
// The new intra coding scheme requires no change of transform size
- if (is_inter_block(&mi->mbmi)) {
+ if (is_inter_block(mi)) {
tx_size = VPXMIN(tx_mode_to_biggest_tx_size[cm->tx_mode],
max_txsize_lookup[bsize]);
} else {
- tx_size = (bsize >= BLOCK_8X8) ? mbmi->tx_size : TX_4X4;
+ tx_size = (bsize >= BLOCK_8X8) ? mi->tx_size : TX_4X4;
}
for (y = 0; y < mi_height; y++)
for (x = 0; x < mi_width; x++)
if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows)
- mi_8x8[mis * y + x]->mbmi.tx_size = tx_size;
+ mi_8x8[mis * y + x]->tx_size = tx_size;
}
- ++td->counts->tx.tx_totals[mbmi->tx_size];
- ++td->counts->tx.tx_totals[get_uv_tx_size(mbmi, &xd->plane[1])];
+ ++td->counts->tx.tx_totals[mi->tx_size];
+ ++td->counts->tx.tx_totals[get_uv_tx_size(mi, &xd->plane[1])];
if (cm->seg.enabled && cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ)
- vp9_cyclic_refresh_update_sb_postencode(cpi, mbmi, mi_row, mi_col, bsize);
+ vp9_cyclic_refresh_update_sb_postencode(cpi, mi, mi_row, mi_col, bsize);
}
}
diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c
index e345009..028d1da 100644
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -93,7 +93,7 @@
MACROBLOCKD *const xd = &mb->e_mbd;
struct macroblock_plane *const p = &mb->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
- const int ref = is_inter_block(&xd->mi[0]->mbmi);
+ const int ref = is_inter_block(xd->mi[0]);
vp9_token_state tokens[1025][2];
unsigned best_index[1025][2];
uint8_t token_cache[1024];
@@ -738,11 +738,11 @@
void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) {
MACROBLOCKD *const xd = &x->e_mbd;
struct optimize_ctx ctx;
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
- struct encode_b_args arg = {x, &ctx, &mbmi->skip};
+ MODE_INFO *mi = xd->mi[0];
+ struct encode_b_args arg = {x, &ctx, &mi->skip};
int plane;
- mbmi->skip = 1;
+ mi->skip = 1;
if (x->skip)
return;
@@ -753,7 +753,7 @@
if (x->optimize && (!x->skip_recode || !x->skip_optimize)) {
const struct macroblockd_plane* const pd = &xd->plane[plane];
- const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi, pd) : mbmi->tx_size;
+ const TX_SIZE tx_size = plane ? get_uv_tx_size(mi, pd) : mi->tx_size;
vp9_get_entropy_contexts(bsize, tx_size, pd,
ctx.ta[plane], ctx.tl[plane]);
}
@@ -768,7 +768,7 @@
struct encode_b_args* const args = arg;
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *mi = xd->mi[0];
struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
tran_low_t *coeff = BLOCK_OFFSET(p->coeff, block);
@@ -793,9 +793,9 @@
if (tx_size == TX_4X4) {
tx_type = get_tx_type_4x4(get_plane_type(plane), xd, block);
scan_order = &vp9_scan_orders[TX_4X4][tx_type];
- mode = plane == 0 ? get_y_mode(xd->mi[0], block) : mbmi->uv_mode;
+ mode = plane == 0 ? get_y_mode(xd->mi[0], block) : mi->uv_mode;
} else {
- mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
+ mode = plane == 0 ? mi->mode : mi->uv_mode;
if (tx_size == TX_32X32) {
scan_order = &vp9_default_scan_orders[TX_32X32];
} else {
@@ -970,7 +970,7 @@
void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
const MACROBLOCKD *const xd = &x->e_mbd;
- struct encode_b_args arg = {x, NULL, &xd->mi[0]->mbmi.skip};
+ struct encode_b_args arg = {x, NULL, &xd->mi[0]->skip};
vp9_foreach_transformed_block_in_plane(xd, bsize, plane,
vp9_encode_block_intra, &arg);
diff --git a/vp9/encoder/vp9_encodemv.c b/vp9/encoder/vp9_encodemv.c
index 109eba8..8f4d80c 100644
--- a/vp9/encoder/vp9_encodemv.c
+++ b/vp9/encoder/vp9_encodemv.c
@@ -231,13 +231,13 @@
build_nmv_component_cost_table(mvcost[1], &ctx->comps[1], usehp);
}
-static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext,
+static void inc_mvs(const MODE_INFO *mi, const MB_MODE_INFO_EXT *mbmi_ext,
const int_mv mvs[2],
nmv_context_counts *counts) {
int i;
- for (i = 0; i < 1 + has_second_ref(mbmi); ++i) {
- const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[i]][0].as_mv;
+ for (i = 0; i < 1 + has_second_ref(mi); ++i) {
+ const MV *ref = &mbmi_ext->ref_mvs[mi->ref_frame[i]][0].as_mv;
const MV diff = {mvs[i].as_mv.row - ref->row,
mvs[i].as_mv.col - ref->col};
vp9_inc_mv(&diff, counts);
@@ -247,24 +247,23 @@
void vp9_update_mv_count(ThreadData *td) {
const MACROBLOCKD *xd = &td->mb.e_mbd;
const MODE_INFO *mi = xd->mi[0];
- const MB_MODE_INFO *const mbmi = &mi->mbmi;
const MB_MODE_INFO_EXT *mbmi_ext = td->mb.mbmi_ext;
- if (mbmi->sb_type < BLOCK_8X8) {
- const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi->sb_type];
- const int num_4x4_h = num_4x4_blocks_high_lookup[mbmi->sb_type];
+ if (mi->sb_type < BLOCK_8X8) {
+ const int num_4x4_w = num_4x4_blocks_wide_lookup[mi->sb_type];
+ const int num_4x4_h = num_4x4_blocks_high_lookup[mi->sb_type];
int idx, idy;
for (idy = 0; idy < 2; idy += num_4x4_h) {
for (idx = 0; idx < 2; idx += num_4x4_w) {
const int i = idy * 2 + idx;
if (mi->bmi[i].as_mode == NEWMV)
- inc_mvs(mbmi, mbmi_ext, mi->bmi[i].as_mv, &td->counts->mv);
+ inc_mvs(mi, mbmi_ext, mi->bmi[i].as_mv, &td->counts->mv);
}
}
} else {
- if (mbmi->mode == NEWMV)
- inc_mvs(mbmi, mbmi_ext, mbmi->mv, &td->counts->mv);
+ if (mi->mode == NEWMV)
+ inc_mvs(mi, mbmi_ext, mi->mv, &td->counts->mv);
}
}
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 609344d..8c64693 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -609,7 +609,7 @@
MODE_INFO **mi_8x8 = mi_8x8_ptr;
uint8_t *cache = cache_ptr;
for (col = 0; col < cm->mi_cols; col++, mi_8x8++, cache++)
- cache[0] = mi_8x8[0]->mbmi.segment_id;
+ cache[0] = mi_8x8[0]->segment_id;
mi_8x8_ptr += cm->mi_stride;
cache_ptr += cm->mi_cols;
}
@@ -3318,6 +3318,11 @@
cpi->oxcf.content == VP9E_CONTENT_SCREEN)
vp9_avg_source_sad(cpi);
+ // TODO(wonkap/marpan): For 1 pass SVC, since only ZERMOV is allowed for
+ // upsampled reference frame (i.e, svc->force_zero_mode_spatial_ref = 0),
+ // we should be able to avoid this frame-level upsampling.
+ // Keeping it for now as there is an asan error in the multi-threaded SVC
+ // rate control test if this upsampling is removed.
if (frame_is_intra_only(cm) == 0) {
vp9_scale_references(cpi);
}
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 30738b5..5c49a54 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -396,7 +396,7 @@
MV tmp_mv = {0, 0};
MV ref_mv_full = {ref_mv->row >> 3, ref_mv->col >> 3};
int num00, tmp_err, n;
- const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
+ const BLOCK_SIZE bsize = xd->mi[0]->sb_type;
vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[bsize];
const int new_mv_mode_penalty = NEW_MV_MODE_PENALTY;
@@ -663,8 +663,8 @@
xd->plane[1].dst.buf = new_yv12->u_buffer + recon_uvoffset;
xd->plane[2].dst.buf = new_yv12->v_buffer + recon_uvoffset;
xd->left_available = (mb_col != 0);
- xd->mi[0]->mbmi.sb_type = bsize;
- xd->mi[0]->mbmi.ref_frame[0] = INTRA_FRAME;
+ xd->mi[0]->sb_type = bsize;
+ xd->mi[0]->ref_frame[0] = INTRA_FRAME;
set_mi_row_col(xd, &tile,
mb_row << 1, num_8x8_blocks_high_lookup[bsize],
mb_col << 1, num_8x8_blocks_wide_lookup[bsize],
@@ -672,8 +672,8 @@
// Do intra 16x16 prediction.
x->skip_encode = 0;
- xd->mi[0]->mbmi.mode = DC_PRED;
- xd->mi[0]->mbmi.tx_size = use_dc_pred ?
+ xd->mi[0]->mode = DC_PRED;
+ xd->mi[0]->tx_size = use_dc_pred ?
(bsize >= BLOCK_16X16 ? TX_16X16 : TX_8X8) : TX_4X4;
vp9_encode_intra_block_plane(x, bsize, 0);
this_error = vpx_get_mb_ss(x->plane[0].src_diff);
@@ -897,11 +897,11 @@
mv.row *= 8;
mv.col *= 8;
this_error = motion_error;
- xd->mi[0]->mbmi.mode = NEWMV;
- xd->mi[0]->mbmi.mv[0].as_mv = mv;
- xd->mi[0]->mbmi.tx_size = TX_4X4;
- xd->mi[0]->mbmi.ref_frame[0] = LAST_FRAME;
- xd->mi[0]->mbmi.ref_frame[1] = NONE;
+ xd->mi[0]->mode = NEWMV;
+ xd->mi[0]->mv[0].as_mv = mv;
+ xd->mi[0]->tx_size = TX_4X4;
+ xd->mi[0]->ref_frame[0] = LAST_FRAME;
+ xd->mi[0]->ref_frame[1] = NONE;
vp9_build_inter_predictors_sby(xd, mb_row << 1, mb_col << 1, bsize);
vp9_encode_sby_pass1(x, bsize);
sum_mvr += mv.row;
diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c
index 41b6d19..7ce86b4 100644
--- a/vp9/encoder/vp9_mbgraph.c
+++ b/vp9/encoder/vp9_mbgraph.c
@@ -69,8 +69,8 @@
&distortion, &sse, NULL, 0, 0);
}
- xd->mi[0]->mbmi.mode = NEWMV;
- xd->mi[0]->mbmi.mv[0].as_mv = *dst_mv;
+ xd->mi[0]->mode = NEWMV;
+ xd->mi[0]->mv[0].as_mv = *dst_mv;
vp9_build_inter_predictors_sby(xd, mb_row, mb_col, BLOCK_16X16);
@@ -147,7 +147,7 @@
for (mode = DC_PRED; mode <= TM_PRED; mode++) {
unsigned int err;
- xd->mi[0]->mbmi.mode = mode;
+ xd->mi[0]->mode = mode;
vp9_predict_intra_block(xd, 2, TX_16X16, mode,
x->plane[0].src.buf, x->plane[0].src.stride,
xd->plane[0].dst.buf, xd->plane[0].dst.stride,
@@ -254,9 +254,9 @@
xd->plane[0].pre[0].stride = buf->y_stride;
xd->plane[1].dst.stride = buf->uv_stride;
xd->mi[0] = &mi_local;
- mi_local.mbmi.sb_type = BLOCK_16X16;
- mi_local.mbmi.ref_frame[0] = LAST_FRAME;
- mi_local.mbmi.ref_frame[1] = NONE;
+ mi_local.sb_type = BLOCK_16X16;
+ mi_local.ref_frame[0] = LAST_FRAME;
+ mi_local.ref_frame[1] = NONE;
for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
MV gld_left_mv = gld_top_mv;
diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c
index eab07bc..84ef1b4 100644
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1825,7 +1825,7 @@
BLOCK_SIZE bsize,
int mi_row, int mi_col) {
MACROBLOCKD *xd = &x->e_mbd;
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *mi = xd->mi[0];
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}};
DECLARE_ALIGNED(16, int16_t, hbuf[128]);
DECLARE_ALIGNED(16, int16_t, vbuf[128]);
@@ -1839,12 +1839,12 @@
const int src_stride = x->plane[0].src.stride;
const int ref_stride = xd->plane[0].pre[0].stride;
uint8_t const *ref_buf, *src_buf;
- MV *tmp_mv = &xd->mi[0]->mbmi.mv[0].as_mv;
+ MV *tmp_mv = &xd->mi[0]->mv[0].as_mv;
unsigned int best_sad, tmp_sad, this_sad[4];
MV this_mv;
const int norm_factor = 3 + (bw >> 5);
const YV12_BUFFER_CONFIG *scaled_ref_frame =
- vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[0]);
+ vp9_get_scaled_ref_frame(cpi, mi->ref_frame[0]);
if (scaled_ref_frame) {
int i;
diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c
index ec70df6..a9c52b1 100644
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -40,16 +40,17 @@
int in_use;
} PRED_BUFFER;
-static int mv_refs_rt(const VP9_COMMON *cm, const MACROBLOCK *x,
+static int mv_refs_rt(VP9_COMP *cpi, const VP9_COMMON *cm,
+ const MACROBLOCK *x,
const MACROBLOCKD *xd,
const TileInfo *const tile,
MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
- int_mv *mv_ref_list,
- int mi_row, int mi_col) {
+ int_mv *mv_ref_list, int_mv *base_mv,
+ int mi_row, int mi_col, int use_base_mv) {
const int *ref_sign_bias = cm->ref_frame_sign_bias;
int i, refmv_count = 0;
- const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type];
+ const POSITION *const mv_ref_search = mv_ref_blocks[mi->sb_type];
int different_ref_found = 0;
int context_counter = 0;
@@ -66,12 +67,11 @@
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
const MODE_INFO *const candidate_mi = xd->mi[mv_ref->col + mv_ref->row *
xd->mi_stride];
- const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
// Keep counts for entropy encoding.
- context_counter += mode_2_counter[candidate->mode];
+ context_counter += mode_2_counter[candidate_mi->mode];
different_ref_found = 1;
- if (candidate->ref_frame[0] == ref_frame)
+ if (candidate_mi->ref_frame[0] == ref_frame)
ADD_MV_REF_LIST(get_sub_block_mv(candidate_mi, 0, mv_ref->col, -1),
refmv_count, mv_ref_list, Done);
}
@@ -85,12 +85,12 @@
for (; i < MVREF_NEIGHBOURS && !refmv_count; ++i) {
const POSITION *const mv_ref = &mv_ref_search[i];
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
- const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row *
- xd->mi_stride]->mbmi;
+ const MODE_INFO *const candidate_mi = xd->mi[mv_ref->col + mv_ref->row *
+ xd->mi_stride];
different_ref_found = 1;
- if (candidate->ref_frame[0] == ref_frame)
- ADD_MV_REF_LIST(candidate->mv[0], refmv_count, mv_ref_list, Done);
+ if (candidate_mi->ref_frame[0] == ref_frame)
+ ADD_MV_REF_LIST(candidate_mi->mv[0], refmv_count, mv_ref_list, Done);
}
}
@@ -101,15 +101,29 @@
for (i = 0; i < MVREF_NEIGHBOURS; ++i) {
const POSITION *mv_ref = &mv_ref_search[i];
if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) {
- const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row
- * xd->mi_stride]->mbmi;
+ const MODE_INFO *const candidate_mi = xd->mi[mv_ref->col + mv_ref->row
+ * xd->mi_stride];
// If the candidate is INTRA we don't want to consider its mv.
- IF_DIFF_REF_FRAME_ADD_MV(candidate, ref_frame, ref_sign_bias,
+ IF_DIFF_REF_FRAME_ADD_MV(candidate_mi, ref_frame, ref_sign_bias,
refmv_count, mv_ref_list, Done);
}
}
}
+ if (use_base_mv &&
+ !cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame &&
+ ref_frame == LAST_FRAME) {
+ // Get base layer mv.
+ MV_REF *candidate =
+ &cm->prev_frame->mvs[(mi_col>>1) + (mi_row>>1) * (cm->mi_cols>>1)];
+ if (candidate->mv[0].as_int != INVALID_MV) {
+ base_mv->as_mv.row = (candidate->mv[0].as_mv.row << 1);
+ base_mv->as_mv.col = (candidate->mv[0].as_mv.col << 1);
+ clamp_mv_ref(&base_mv->as_mv, xd);
+ } else {
+ base_mv->as_int = INVALID_MV;
+ }
+ }
Done:
@@ -125,15 +139,16 @@
static int combined_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bsize, int mi_row, int mi_col,
int_mv *tmp_mv, int *rate_mv,
- int64_t best_rd_sofar) {
+ int64_t best_rd_sofar, int use_base_mv) {
MACROBLOCKD *xd = &x->e_mbd;
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *mi = xd->mi[0];
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}};
const int step_param = cpi->sf.mv.fullpel_search_step_param;
const int sadpb = x->sadperbit16;
MV mvp_full;
- const int ref = mbmi->ref_frame[0];
+ const int ref = mi->ref_frame[0];
const MV ref_mv = x->mbmi_ext->ref_mvs[ref][0].as_mv;
+ MV center_mv;
int dis;
int rate_mode;
const int tmp_col_min = x->mv_col_min;
@@ -164,9 +179,14 @@
mvp_full.col >>= 3;
mvp_full.row >>= 3;
+ if (!use_base_mv)
+ center_mv = ref_mv;
+ else
+ center_mv = tmp_mv->as_mv;
+
vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb,
cond_cost_list(cpi, cost_list),
- &ref_mv, &tmp_mv->as_mv, INT_MAX, 0);
+ ¢er_mv, &tmp_mv->as_mv, INT_MAX, 0);
x->mv_col_min = tmp_col_min;
x->mv_col_max = tmp_col_max;
@@ -300,7 +320,7 @@
tx_size = TX_8X8;
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
- cyclic_refresh_segment_id_boosted(xd->mi[0]->mbmi.segment_id))
+ cyclic_refresh_segment_id_boosted(xd->mi[0]->segment_id))
tx_size = TX_8X8;
else if (tx_size > TX_16X16)
tx_size = TX_16X16;
@@ -310,7 +330,7 @@
}
assert(tx_size >= TX_8X8);
- xd->mi[0]->mbmi.tx_size = tx_size;
+ xd->mi[0]->tx_size = tx_size;
// Evaluate if the partition block is a skippable block in Y plane.
{
@@ -379,7 +399,7 @@
for (i = 1; i <= 2; i++) {
struct macroblock_plane *const p = &x->plane[i];
struct macroblockd_plane *const pd = &xd->plane[i];
- const TX_SIZE uv_tx_size = get_uv_tx_size(&xd->mi[0]->mbmi, pd);
+ const TX_SIZE uv_tx_size = get_uv_tx_size(xd->mi[0], pd);
const BLOCK_SIZE unit_size = txsize_to_bsize[uv_tx_size];
const BLOCK_SIZE uv_bsize = get_plane_block_size(bsize, pd);
const int uv_bw = b_width_log2_lookup[uv_bsize];
@@ -475,19 +495,19 @@
if (cpi->common.tx_mode == TX_MODE_SELECT) {
if (sse > (var << 2))
- xd->mi[0]->mbmi.tx_size =
+ xd->mi[0]->tx_size =
VPXMIN(max_txsize_lookup[bsize],
tx_mode_to_biggest_tx_size[cpi->common.tx_mode]);
else
- xd->mi[0]->mbmi.tx_size = TX_8X8;
+ xd->mi[0]->tx_size = TX_8X8;
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
- cyclic_refresh_segment_id_boosted(xd->mi[0]->mbmi.segment_id))
- xd->mi[0]->mbmi.tx_size = TX_8X8;
- else if (xd->mi[0]->mbmi.tx_size > TX_16X16)
- xd->mi[0]->mbmi.tx_size = TX_16X16;
+ cyclic_refresh_segment_id_boosted(xd->mi[0]->segment_id))
+ xd->mi[0]->tx_size = TX_8X8;
+ else if (xd->mi[0]->tx_size > TX_16X16)
+ xd->mi[0]->tx_size = TX_16X16;
} else {
- xd->mi[0]->mbmi.tx_size =
+ xd->mi[0]->tx_size =
VPXMIN(max_txsize_lookup[bsize],
tx_mode_to_biggest_tx_size[cpi->common.tx_mode]);
}
@@ -495,7 +515,7 @@
// Evaluate if the partition block is a skippable block in Y plane.
{
const BLOCK_SIZE unit_size =
- txsize_to_bsize[xd->mi[0]->mbmi.tx_size];
+ txsize_to_bsize[xd->mi[0]->tx_size];
const unsigned int num_blk_log2 =
(b_width_log2_lookup[bsize] - b_width_log2_lookup[unit_size]) +
(b_height_log2_lookup[bsize] - b_height_log2_lookup[unit_size]);
@@ -779,7 +799,7 @@
struct buf_2d yv12_mb[][MAX_MB_PLANE],
int *rate, int64_t *dist) {
MACROBLOCKD *xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
const BLOCK_SIZE uv_size = get_plane_block_size(bsize, &xd->plane[1]);
unsigned int var = var_y, sse = sse_y;
// Skipping threshold for ac.
@@ -787,10 +807,10 @@
// Skipping threshold for dc.
unsigned int thresh_dc;
int motion_low = 1;
- if (mbmi->mv[0].as_mv.row > 64 ||
- mbmi->mv[0].as_mv.row < -64 ||
- mbmi->mv[0].as_mv.col > 64 ||
- mbmi->mv[0].as_mv.col < -64)
+ if (mi->mv[0].as_mv.row > 64 ||
+ mi->mv[0].as_mv.row < -64 ||
+ mi->mv[0].as_mv.col > 64 ||
+ mi->mv[0].as_mv.col < -64)
motion_low = 0;
if (x->encode_breakout > 0 && motion_low == 1) {
// Set a maximum for threshold to avoid big PSNR loss in low bit rate
@@ -981,7 +1001,7 @@
void vp9_pick_intra_mode(VP9_COMP *cpi, MACROBLOCK *x, RD_COST *rd_cost,
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx) {
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
RD_COST this_rdc, best_rdc;
PREDICTION_MODE this_mode;
struct estimate_block_intra_args args = { cpi, x, DC_PRED, 0, 0 };
@@ -1000,9 +1020,9 @@
vp9_rd_cost_reset(&best_rdc);
vp9_rd_cost_reset(&this_rdc);
- mbmi->ref_frame[0] = INTRA_FRAME;
- mbmi->mv[0].as_int = INVALID_MV;
- mbmi->uv_mode = DC_PRED;
+ mi->ref_frame[0] = INTRA_FRAME;
+ mi->mv[0].as_int = INVALID_MV;
+ mi->uv_mode = DC_PRED;
memset(x->skip_txfm, 0, sizeof(x->skip_txfm));
// Change the limit of this loop to add other intra prediction
@@ -1011,7 +1031,7 @@
args.mode = this_mode;
args.rate = 0;
args.dist = 0;
- mbmi->tx_size = intra_tx_size;
+ mi->tx_size = intra_tx_size;
vp9_foreach_transformed_block_in_plane(xd, bsize, 0,
estimate_block_intra, &args);
this_rdc.rate = args.rate;
@@ -1022,7 +1042,7 @@
if (this_rdc.rdcost < best_rdc.rdcost) {
best_rdc = this_rdc;
- mbmi->mode = this_mode;
+ mi->mode = this_mode;
}
}
@@ -1086,8 +1106,50 @@
cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth) >> reduction_fac;
}
+static INLINE void find_predictors(VP9_COMP *cpi, MACROBLOCK *x,
+ MV_REFERENCE_FRAME ref_frame,
+ int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES],
+ int const_motion[MAX_REF_FRAMES],
+ int *ref_frame_skip_mask,
+ const int flag_list[4],
+ TileDataEnc *tile_data,
+ int mi_row, int mi_col,
+ struct buf_2d yv12_mb[4][MAX_MB_PLANE],
+ BLOCK_SIZE bsize) {
+ VP9_COMMON *const cm = &cpi->common;
+ MACROBLOCKD *const xd = &x->e_mbd;
+ const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame);
+ TileInfo *const tile_info = &tile_data->tile_info;
// TODO(jingning) placeholder for inter-frame non-RD mode decision.
+ x->pred_mv_sad[ref_frame] = INT_MAX;
+ frame_mv[NEWMV][ref_frame].as_int = INVALID_MV;
+ frame_mv[ZEROMV][ref_frame].as_int = 0;
// this needs various further optimizations. to be continued..
+ if ((cpi->ref_frame_flags & flag_list[ref_frame]) && (yv12 != NULL)) {
+ int_mv *const candidates = x->mbmi_ext->ref_mvs[ref_frame];
+ const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf;
+ vp9_setup_pred_block(xd, yv12_mb[ref_frame], yv12, mi_row, mi_col,
+ sf, sf);
+ if (cm->use_prev_frame_mvs)
+ vp9_find_mv_refs(cm, xd, xd->mi[0], ref_frame,
+ candidates, mi_row, mi_col,
+ x->mbmi_ext->mode_context);
+ else
+ const_motion[ref_frame] =
+ mv_refs_rt(cpi, cm, x, xd, tile_info, xd->mi[0], ref_frame,
+ candidates, &frame_mv[NEWMV][ref_frame], mi_row, mi_col,
+ (int)(cpi->svc.use_base_mv && cpi->svc.spatial_layer_id));
+ vp9_find_best_ref_mvs(xd, cm->allow_high_precision_mv, candidates,
+ &frame_mv[NEARESTMV][ref_frame],
+ &frame_mv[NEARMV][ref_frame]);
+ if (!vp9_is_scaled(sf) && bsize >= BLOCK_8X8) {
+ vp9_mv_pred(cpi, x, yv12_mb[ref_frame][0].buf, yv12->y_stride,
+ ref_frame, bsize);
+ }
+ } else {
+ *ref_frame_skip_mask |= (1 << ref_frame);
+ }
+}
void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
TileDataEnc *tile_data,
int mi_row, int mi_col, RD_COST *rd_cost,
@@ -1095,9 +1157,8 @@
VP9_COMMON *const cm = &cpi->common;
SPEED_FEATURES *const sf = &cpi->sf;
const SVC *const svc = &cpi->svc;
- TileInfo *const tile_info = &tile_data->tile_info;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
struct macroblockd_plane *const pd = &xd->plane[0];
PREDICTION_MODE best_mode = ZEROMV;
MV_REFERENCE_FRAME ref_frame, best_ref_frame = LAST_FRAME;
@@ -1114,9 +1175,9 @@
unsigned int var_y = UINT_MAX;
unsigned int sse_y = UINT_MAX;
const int intra_cost_penalty = set_intra_cost_penalty(cpi, bsize);
- const int64_t inter_mode_thresh = RDCOST(x->rdmult, x->rddiv,
+ int64_t inter_mode_thresh = RDCOST(x->rdmult, x->rddiv,
intra_cost_penalty, 0);
- const int *const rd_threshes = cpi->rd.threshes[mbmi->segment_id][bsize];
+ const int *const rd_threshes = cpi->rd.threshes[mi->segment_id][bsize];
const int *const rd_thresh_freq_fact = tile_data->thresh_freq_fact[bsize];
INTERP_FILTER filter_ref;
const int bsl = mi_width_log2_lookup[bsize];
@@ -1145,6 +1206,7 @@
int best_early_term = 0;
int ref_frame_cost[MAX_REF_FRAMES];
int svc_force_zero_mode[3] = {0};
+ int perform_intra_pred = 1;
#if CONFIG_VP9_TEMPORAL_DENOISING
int64_t zero_last_cost_orig = INT64_MAX;
#endif
@@ -1174,20 +1236,20 @@
x->skip = 0;
if (xd->up_available)
- filter_ref = xd->mi[-xd->mi_stride]->mbmi.interp_filter;
+ filter_ref = xd->mi[-xd->mi_stride]->interp_filter;
else if (xd->left_available)
- filter_ref = xd->mi[-1]->mbmi.interp_filter;
+ filter_ref = xd->mi[-1]->interp_filter;
else
filter_ref = cm->interp_filter;
// initialize mode decisions
vp9_rd_cost_reset(&best_rdc);
vp9_rd_cost_reset(rd_cost);
- mbmi->sb_type = bsize;
- mbmi->ref_frame[0] = NONE;
- mbmi->ref_frame[1] = NONE;
- mbmi->tx_size = VPXMIN(max_txsize_lookup[bsize],
- tx_mode_to_biggest_tx_size[cm->tx_mode]);
+ mi->sb_type = bsize;
+ mi->ref_frame[0] = NONE;
+ mi->ref_frame[1] = NONE;
+ mi->tx_size = VPXMIN(max_txsize_lookup[bsize],
+ tx_mode_to_biggest_tx_size[cm->tx_mode]);
#if CONFIG_VP9_TEMPORAL_DENOISING
vp9_denoiser_reset_frame_stats(ctx);
@@ -1210,38 +1272,9 @@
}
for (ref_frame = LAST_FRAME; ref_frame <= usable_ref_frame; ++ref_frame) {
- const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame);
-
- x->pred_mv_sad[ref_frame] = INT_MAX;
- frame_mv[NEWMV][ref_frame].as_int = INVALID_MV;
- frame_mv[ZEROMV][ref_frame].as_int = 0;
-
- if ((cpi->ref_frame_flags & flag_list[ref_frame]) && (yv12 != NULL)) {
- int_mv *const candidates = x->mbmi_ext->ref_mvs[ref_frame];
- const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf;
-
- vp9_setup_pred_block(xd, yv12_mb[ref_frame], yv12, mi_row, mi_col,
- sf, sf);
-
- if (cm->use_prev_frame_mvs)
- vp9_find_mv_refs(cm, xd, xd->mi[0], ref_frame,
- candidates, mi_row, mi_col, x->mbmi_ext->mode_context);
- else
- const_motion[ref_frame] = mv_refs_rt(cm, x, xd, tile_info,
- xd->mi[0],
- ref_frame, candidates,
- mi_row, mi_col);
-
- vp9_find_best_ref_mvs(xd, cm->allow_high_precision_mv, candidates,
- &frame_mv[NEARESTMV][ref_frame],
- &frame_mv[NEARMV][ref_frame]);
-
- if (!vp9_is_scaled(sf) && bsize >= BLOCK_8X8)
- vp9_mv_pred(cpi, x, yv12_mb[ref_frame][0].buf, yv12->y_stride,
- ref_frame, bsize);
- } else {
- ref_frame_skip_mask |= (1 << ref_frame);
- }
+ find_predictors(cpi, x, ref_frame, frame_mv, const_motion,
+ &ref_frame_skip_mask, flag_list, tile_data, mi_row, mi_col,
+ yv12_mb, bsize);
}
for (idx = 0; idx < RT_INTER_MODES; ++idx) {
@@ -1289,7 +1322,7 @@
for (i = 0; i < MAX_MB_PLANE; i++)
xd->plane[i].pre[0] = yv12_mb[ref_frame][i];
- mbmi->ref_frame[0] = ref_frame;
+ mi->ref_frame[0] = ref_frame;
set_ref_ptrs(cm, xd, ref_frame, NONE);
mode_index = mode_idx[ref_frame][INTER_OFFSET(this_mode)];
@@ -1314,7 +1347,7 @@
if (tmp_sad + (num_pels_log2_lookup[bsize] << 4) > best_pred_sad)
continue;
- frame_mv[NEWMV][ref_frame].as_int = mbmi->mv[0].as_int;
+ frame_mv[NEWMV][ref_frame].as_int = mi->mv[0].as_int;
rate_mv = vp9_mv_bit_cost(&frame_mv[NEWMV][ref_frame].as_mv,
&x->mbmi_ext->ref_mvs[ref_frame][0].as_mv,
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
@@ -1331,8 +1364,36 @@
cond_cost_list(cpi, cost_list),
x->nmvjointcost, x->mvcost, &dis,
&x->pred_sse[ref_frame], NULL, 0, 0);
+ } else if (svc->use_base_mv && svc->spatial_layer_id) {
+ if (frame_mv[NEWMV][ref_frame].as_int != INVALID_MV &&
+ frame_mv[NEWMV][ref_frame].as_int != 0) {
+ const int pre_stride = xd->plane[0].pre[0].stride;
+ int base_mv_sad = INT_MAX;
+ const uint8_t * const pre_buf = xd->plane[0].pre[0].buf +
+ (frame_mv[NEWMV][ref_frame].as_mv.row >> 3) * pre_stride +
+ (frame_mv[NEWMV][ref_frame].as_mv.col >> 3);
+ base_mv_sad = cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf,
+ x->plane[0].src.stride,
+ pre_buf, pre_stride);
+
+ // TODO(wonkap): make the decision to use base layer mv on RD;
+ // not just SAD.
+ if (base_mv_sad < x->pred_mv_sad[ref_frame]) {
+ // Base layer mv is good.
+ if (!combined_motion_search(cpi, x, bsize, mi_row, mi_col,
+ &frame_mv[NEWMV][ref_frame], &rate_mv, best_rdc.rdcost, 1)) {
+ continue;
+ }
+ } else if (!combined_motion_search(cpi, x, bsize, mi_row, mi_col,
+ &frame_mv[NEWMV][ref_frame], &rate_mv, best_rdc.rdcost, 0)) {
+ continue;
+ }
+ } else if (!combined_motion_search(cpi, x, bsize, mi_row, mi_col,
+ &frame_mv[NEWMV][ref_frame], &rate_mv, best_rdc.rdcost, 0)) {
+ continue;
+ }
} else if (!combined_motion_search(cpi, x, bsize, mi_row, mi_col,
- &frame_mv[NEWMV][ref_frame], &rate_mv, best_rdc.rdcost)) {
+ &frame_mv[NEWMV][ref_frame], &rate_mv, best_rdc.rdcost, 0)) {
continue;
}
}
@@ -1369,8 +1430,8 @@
frame_mv[NEARESTMV][ref_frame].as_int)
continue;
- mbmi->mode = this_mode;
- mbmi->mv[0].as_int = frame_mv[this_mode][ref_frame].as_int;
+ mi->mode = this_mode;
+ mi->mv[0].as_int = frame_mv[this_mode][ref_frame].as_int;
// Search for the best prediction filter type, when the resulting
// motion vector is at sub-pixel accuracy level for luma component, i.e.,
@@ -1388,7 +1449,7 @@
if ((this_mode == NEWMV || filter_ref == SWITCHABLE) && pred_filter_search
&& (ref_frame == LAST_FRAME ||
(ref_frame == GOLDEN_FRAME && cpi->use_svc))
- && (((mbmi->mv[0].as_mv.row | mbmi->mv[0].as_mv.col) & 0x07) != 0)) {
+ && (((mi->mv[0].as_mv.row | mi->mv[0].as_mv.col) & 0x07) != 0)) {
int pf_rate[3];
int64_t pf_dist[3];
unsigned int pf_var[3];
@@ -1400,13 +1461,13 @@
for (filter = EIGHTTAP; filter <= EIGHTTAP_SMOOTH; ++filter) {
int64_t cost;
- mbmi->interp_filter = filter;
+ mi->interp_filter = filter;
vp9_build_inter_predictors_sby(xd, mi_row, mi_col, bsize);
model_rd_for_sb_y(cpi, bsize, x, xd, &pf_rate[filter], &pf_dist[filter],
&pf_var[filter], &pf_sse[filter]);
pf_rate[filter] += vp9_get_switchable_rate(cpi, xd);
cost = RDCOST(x->rdmult, x->rddiv, pf_rate[filter], pf_dist[filter]);
- pf_tx_size[filter] = mbmi->tx_size;
+ pf_tx_size[filter] = mi->tx_size;
if (cost < best_cost) {
best_filter = filter;
best_cost = cost;
@@ -1430,8 +1491,8 @@
if (reuse_inter_pred && this_mode_pred != current_pred)
free_pred_buffer(current_pred);
- mbmi->interp_filter = best_filter;
- mbmi->tx_size = pf_tx_size[best_filter];
+ mi->interp_filter = best_filter;
+ mi->tx_size = pf_tx_size[best_filter];
this_rdc.rate = pf_rate[best_filter];
this_rdc.dist = pf_dist[best_filter];
var_y = pf_var[best_filter];
@@ -1442,12 +1503,12 @@
pd->dst.stride = this_mode_pred->stride;
}
} else {
- mbmi->interp_filter = (filter_ref == SWITCHABLE) ? EIGHTTAP : filter_ref;
+ mi->interp_filter = (filter_ref == SWITCHABLE) ? EIGHTTAP : filter_ref;
vp9_build_inter_predictors_sby(xd, mi_row, mi_col, bsize);
// For large partition blocks, extra testing is done.
if (bsize > BLOCK_32X32 &&
- !cyclic_refresh_segment_id_boosted(xd->mi[0]->mbmi.segment_id) &&
+ !cyclic_refresh_segment_id_boosted(xd->mi[0]->segment_id) &&
cm->base_qindex) {
model_rd_for_sb_y_large(cpi, bsize, x, xd, &this_rdc.rate,
&this_rdc.dist, &var_y, &sse_y, mi_row, mi_col,
@@ -1461,7 +1522,7 @@
if (!this_early_term) {
this_sse = (int64_t)sse_y;
block_yrd(cpi, x, &this_rdc.rate, &this_rdc.dist, &is_skippable,
- &this_sse, 0, bsize, VPXMIN(mbmi->tx_size, TX_16X16));
+ &this_sse, 0, bsize, VPXMIN(mi->tx_size, TX_16X16));
x->skip_txfm[0] = is_skippable;
if (is_skippable) {
this_rdc.rate = vp9_cost_bit(vp9_get_skip_prob(cm, xd), 1);
@@ -1477,7 +1538,7 @@
}
if (cm->interp_filter == SWITCHABLE) {
- if ((mbmi->mv[0].as_mv.row | mbmi->mv[0].as_mv.col) & 0x07)
+ if ((mi->mv[0].as_mv.row | mi->mv[0].as_mv.col) & 0x07)
this_rdc.rate += vp9_get_switchable_rate(cpi, xd);
}
} else {
@@ -1548,7 +1609,7 @@
#if CONFIG_VP9_TEMPORAL_DENOISING
if (cpi->oxcf.noise_sensitivity > 0) {
- vp9_denoiser_update_frame_stats(mbmi, sse_y, this_mode, ctx);
+ vp9_denoiser_update_frame_stats(mi, sse_y, this_mode, ctx);
// Keep track of zero_last cost.
if (ref_frame == LAST_FRAME && frame_mv[this_mode][ref_frame].as_int == 0)
zero_last_cost_orig = this_rdc.rdcost;
@@ -1560,8 +1621,8 @@
if (this_rdc.rdcost < best_rdc.rdcost || x->skip) {
best_rdc = this_rdc;
best_mode = this_mode;
- best_pred_filter = mbmi->interp_filter;
- best_tx_size = mbmi->tx_size;
+ best_pred_filter = mi->interp_filter;
+ best_tx_size = mi->tx_size;
best_ref_frame = ref_frame;
best_mode_skip_txfm = x->skip_txfm[0];
best_early_term = this_early_term;
@@ -1586,19 +1647,28 @@
}
}
- mbmi->mode = best_mode;
- mbmi->interp_filter = best_pred_filter;
- mbmi->tx_size = best_tx_size;
- mbmi->ref_frame[0] = best_ref_frame;
- mbmi->mv[0].as_int = frame_mv[best_mode][best_ref_frame].as_int;
- xd->mi[0]->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int;
+ mi->mode = best_mode;
+ mi->interp_filter = best_pred_filter;
+ mi->tx_size = best_tx_size;
+ mi->ref_frame[0] = best_ref_frame;
+ mi->mv[0].as_int = frame_mv[best_mode][best_ref_frame].as_int;
+ xd->mi[0]->bmi[0].as_mv[0].as_int = mi->mv[0].as_int;
x->skip_txfm[0] = best_mode_skip_txfm;
+ // Perform intra prediction only if base layer is chosen as the reference.
+ if (cpi->svc.spatial_layer_id) {
+ perform_intra_pred =
+ cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame ||
+ (!cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame
+ && svc_force_zero_mode[best_ref_frame]);
+ inter_mode_thresh = (inter_mode_thresh << 1) + inter_mode_thresh;
+ }
// Perform intra prediction search, if the best SAD is above a certain
// threshold.
- if (best_rdc.rdcost == INT64_MAX ||
+ if (perform_intra_pred &&
+ ((best_rdc.rdcost == INT64_MAX ||
(!x->skip && best_rdc.rdcost > inter_mode_thresh &&
- bsize <= cpi->sf.max_intra_bsize)) {
+ bsize <= cpi->sf.max_intra_bsize)))) {
struct estimate_block_intra_args args = { cpi, x, DC_PRED, 0, 0 };
int i;
TX_SIZE best_intra_tx_size = TX_SIZES;
@@ -1642,12 +1712,12 @@
rd_thresh_freq_fact[mode_index]))
continue;
- mbmi->mode = this_mode;
- mbmi->ref_frame[0] = INTRA_FRAME;
+ mi->mode = this_mode;
+ mi->ref_frame[0] = INTRA_FRAME;
args.mode = this_mode;
args.rate = 0;
args.dist = 0;
- mbmi->tx_size = intra_tx_size;
+ mi->tx_size = intra_tx_size;
vp9_foreach_transformed_block_in_plane(xd, bsize, 0,
estimate_block_intra, &args);
// Inter and intra RD will mismatch in scale for non-screen content.
@@ -1670,29 +1740,29 @@
if (this_rdc.rdcost < best_rdc.rdcost) {
best_rdc = this_rdc;
best_mode = this_mode;
- best_intra_tx_size = mbmi->tx_size;
+ best_intra_tx_size = mi->tx_size;
best_ref_frame = INTRA_FRAME;
- mbmi->uv_mode = this_mode;
- mbmi->mv[0].as_int = INVALID_MV;
+ mi->uv_mode = this_mode;
+ mi->mv[0].as_int = INVALID_MV;
best_mode_skip_txfm = x->skip_txfm[0];
}
}
// Reset mb_mode_info to the best inter mode.
if (best_ref_frame != INTRA_FRAME) {
- mbmi->tx_size = best_tx_size;
+ mi->tx_size = best_tx_size;
} else {
- mbmi->tx_size = best_intra_tx_size;
+ mi->tx_size = best_intra_tx_size;
}
}
pd->dst = orig_dst;
- mbmi->mode = best_mode;
- mbmi->ref_frame[0] = best_ref_frame;
+ mi->mode = best_mode;
+ mi->ref_frame[0] = best_ref_frame;
x->skip_txfm[0] = best_mode_skip_txfm;
if (reuse_inter_pred && best_pred != NULL) {
- if (best_pred->data != orig_dst.buf && is_inter_mode(mbmi->mode)) {
+ if (best_pred->data != orig_dst.buf && is_inter_mode(mi->mode)) {
#if CONFIG_VP9_HIGHBITDEPTH
if (cm->use_highbitdepth)
vpx_highbd_convolve_copy(best_pred->data, best_pred->stride,
@@ -1727,11 +1797,11 @@
// Check if we should pick ZEROMV on denoised signal.
int rate = 0;
int64_t dist = 0;
- mbmi->mode = ZEROMV;
- mbmi->ref_frame[0] = LAST_FRAME;
- mbmi->ref_frame[1] = NONE;
- mbmi->mv[0].as_int = 0;
- mbmi->interp_filter = EIGHTTAP;
+ mi->mode = ZEROMV;
+ mi->ref_frame[0] = LAST_FRAME;
+ mi->ref_frame[1] = NONE;
+ mi->mv[0].as_int = 0;
+ mi->interp_filter = EIGHTTAP;
xd->plane[0].pre[0] = yv12_mb[LAST_FRAME][0];
vp9_build_inter_predictors_sby(xd, mi_row, mi_col, bsize);
model_rd_for_sb_y(cpi, bsize, x, xd, &rate, &dist, &var_y, &sse_y);
@@ -1744,19 +1814,19 @@
// is lower than best_ref mode (on original source).
if (this_rdc.rdcost > best_rdc.rdcost) {
this_rdc = best_rdc;
- mbmi->mode = best_mode;
- mbmi->ref_frame[0] = best_ref_frame;
- mbmi->interp_filter = best_pred_filter;
+ mi->mode = best_mode;
+ mi->ref_frame[0] = best_ref_frame;
+ mi->interp_filter = best_pred_filter;
if (best_ref_frame == INTRA_FRAME)
- mbmi->mv[0].as_int = INVALID_MV;
+ mi->mv[0].as_int = INVALID_MV;
else if (best_ref_frame == GOLDEN_FRAME) {
- mbmi->mv[0].as_int = frame_mv[best_mode][best_ref_frame].as_int;
+ mi->mv[0].as_int = frame_mv[best_mode][best_ref_frame].as_int;
if (reuse_inter_pred) {
xd->plane[0].pre[0] = yv12_mb[GOLDEN_FRAME][0];
vp9_build_inter_predictors_sby(xd, mi_row, mi_col, bsize);
}
}
- mbmi->tx_size = best_tx_size;
+ mi->tx_size = best_tx_size;
x->skip_txfm[0] = best_mode_skip_txfm;
} else {
best_ref_frame = LAST_FRAME;
@@ -1767,7 +1837,7 @@
#endif
if (cpi->sf.adaptive_rd_thresh) {
- THR_MODES best_mode_idx = mode_idx[best_ref_frame][mode_offset(mbmi->mode)];
+ THR_MODES best_mode_idx = mode_idx[best_ref_frame][mode_offset(mi->mode)];
if (best_ref_frame == INTRA_FRAME) {
// Only consider the modes that are included in the intra_mode_list.
@@ -1801,12 +1871,12 @@
VP9_COMMON *const cm = &cpi->common;
SPEED_FEATURES *const sf = &cpi->sf;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
const struct segmentation *const seg = &cm->seg;
MV_REFERENCE_FRAME ref_frame, second_ref_frame = NONE;
MV_REFERENCE_FRAME best_ref_frame = NONE;
- unsigned char segment_id = mbmi->segment_id;
+ unsigned char segment_id = mi->segment_id;
struct buf_2d yv12_mb[4][MAX_MB_PLANE];
static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
VP9_ALT_FLAG };
@@ -1841,13 +1911,13 @@
}
}
- mbmi->sb_type = bsize;
- mbmi->tx_size = TX_4X4;
- mbmi->uv_mode = DC_PRED;
- mbmi->ref_frame[0] = LAST_FRAME;
- mbmi->ref_frame[1] = NONE;
- mbmi->interp_filter = cm->interp_filter == SWITCHABLE ? EIGHTTAP
- : cm->interp_filter;
+ mi->sb_type = bsize;
+ mi->tx_size = TX_4X4;
+ mi->uv_mode = DC_PRED;
+ mi->ref_frame[0] = LAST_FRAME;
+ mi->ref_frame[1] = NONE;
+ mi->interp_filter = cm->interp_filter == SWITCHABLE ? EIGHTTAP
+ : cm->interp_filter;
for (ref_frame = LAST_FRAME; ref_frame <= GOLDEN_FRAME; ++ref_frame) {
int64_t this_rd = 0;
@@ -1875,7 +1945,7 @@
get_segdata(seg, segment_id, SEG_LVL_REF_FRAME) != (int)ref_frame)
continue;
- mbmi->ref_frame[0] = ref_frame;
+ mi->ref_frame[0] = ref_frame;
x->skip = 0;
set_ref_ptrs(cm, xd, ref_frame, second_ref_frame);
@@ -1992,7 +2062,7 @@
&xd->block_refs[0]->sf,
4 * num_4x4_blocks_wide,
4 * num_4x4_blocks_high, 0,
- vp9_filter_kernels[mbmi->interp_filter],
+ vp9_filter_kernels[mi->interp_filter],
MV_PRECISION_Q3,
mi_col * MI_SIZE + 4 * (i & 0x01),
mi_row * MI_SIZE + 4 * (i >> 1), xd->bd);
@@ -2004,7 +2074,7 @@
&xd->block_refs[0]->sf,
4 * num_4x4_blocks_wide,
4 * num_4x4_blocks_high, 0,
- vp9_filter_kernels[mbmi->interp_filter],
+ vp9_filter_kernels[mi->interp_filter],
MV_PRECISION_Q3,
mi_col * MI_SIZE + 4 * (i & 0x01),
mi_row * MI_SIZE + 4 * (i >> 1));
@@ -2046,8 +2116,8 @@
}
} // reference frames
- mbmi->tx_size = TX_4X4;
- mbmi->ref_frame[0] = best_ref_frame;
+ mi->tx_size = TX_4X4;
+ mi->ref_frame[0] = best_ref_frame;
for (idy = 0; idy < 2; idy += num_4x4_blocks_high) {
for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
const int block = idy * 2 + idx;
@@ -2058,7 +2128,7 @@
xd->mi[0]->bmi[block + 2] = bsi[best_ref_frame][block];
}
}
- mbmi->mode = xd->mi[0]->bmi[3].as_mode;
+ mi->mode = xd->mi[0]->bmi[3].as_mode;
ctx->mic = *(xd->mi[0]);
ctx->mbmi_ext = *x->mbmi_ext;
ctx->skip_txfm[0] = SKIP_TXFM_NONE;
diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c
index cb3e21a..980a49f 100644
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -308,7 +308,7 @@
const VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
QUANTS *const quants = &cpi->quants;
- const int segment_id = xd->mi[0]->mbmi.segment_id;
+ const int segment_id = xd->mi[0]->segment_id;
const int qindex = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex);
const int rdmult = vp9_compute_rd_mult(cpi, qindex + cm->y_dc_delta_q);
int i;
diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c
index 6431b03..a8a939e 100644
--- a/vp9/encoder/vp9_rd.c
+++ b/vp9/encoder/vp9_rd.c
@@ -557,10 +557,10 @@
}
int vp9_get_switchable_rate(const VP9_COMP *cpi, const MACROBLOCKD *const xd) {
- const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ const MODE_INFO *const mi = xd->mi[0];
const int ctx = vp9_get_pred_context_switchable_interp(xd);
return SWITCHABLE_INTERP_RATE_FACTOR *
- cpi->switchable_interp_costs[ctx][mbmi->interp_filter];
+ cpi->switchable_interp_costs[ctx][mi->interp_filter];
}
void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index ca04561..ff3112c 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -165,7 +165,7 @@
int i;
int64_t rate_sum = 0;
int64_t dist_sum = 0;
- const int ref = xd->mi[0]->mbmi.ref_frame[0];
+ const int ref = xd->mi[0]->ref_frame[0];
unsigned int sse;
unsigned int var = 0;
unsigned int sum_sse = 0;
@@ -361,14 +361,14 @@
const int16_t *scan, const int16_t *nb,
int use_fast_coef_costing) {
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *mi = xd->mi[0];
const struct macroblock_plane *p = &x->plane[plane];
const PLANE_TYPE type = get_plane_type(plane);
const int16_t *band_count = &band_counts[tx_size][1];
const int eob = p->eobs[block];
const tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
unsigned int (*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] =
- x->token_costs[tx_size][type][is_inter_block(mbmi)];
+ x->token_costs[tx_size][type][is_inter_block(mi)];
uint8_t token_cache[32 * 32];
int pt = combine_entropy_contexts(*A, *L);
int c, cost;
@@ -379,8 +379,8 @@
#endif
// Check for consistency of tx_size with mode info
- assert(type == PLANE_TYPE_Y ? mbmi->tx_size == tx_size :
- get_uv_tx_size(mbmi, &xd->plane[plane]) == tx_size);
+ assert(type == PLANE_TYPE_Y ? mi->tx_size == tx_size :
+ get_uv_tx_size(mi, &xd->plane[plane]) == tx_size);
if (eob == 0) {
// single eob token
@@ -461,7 +461,7 @@
#endif // CONFIG_VP9_HIGHBITDEPTH
*out_sse = this_sse >> shift;
- if (x->skip_encode && !is_inter_block(&xd->mi[0]->mbmi)) {
+ if (x->skip_encode && !is_inter_block(xd->mi[0])) {
// TODO(jingning): tune the model to better capture the distortion.
int64_t p = (pd->dequant[1] * pd->dequant[1] *
(1 << ss_txfrm_size)) >>
@@ -491,7 +491,7 @@
struct rdcost_block_args *args = arg;
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
int64_t rd1, rd2, rd;
int rate;
int64_t dist;
@@ -500,8 +500,8 @@
if (args->exit_early)
return;
- if (!is_inter_block(mbmi)) {
- struct encode_b_args arg = {x, NULL, &mbmi->skip};
+ if (!is_inter_block(mi)) {
+ struct encode_b_args arg = {x, NULL, &mi->skip};
vp9_encode_block_intra(plane, block, plane_bsize, tx_size, &arg);
dist_block(x, plane, block, tx_size, &dist, &sse);
} else if (max_txsize_lookup[plane_bsize] == tx_size) {
@@ -588,7 +588,7 @@
args.skippable = 1;
if (plane == 0)
- xd->mi[0]->mbmi.tx_size = tx_size;
+ xd->mi[0]->tx_size = tx_size;
vp9_get_entropy_contexts(bsize, tx_size, pd, args.t_above, args.t_left);
@@ -618,13 +618,13 @@
VP9_COMMON *const cm = &cpi->common;
const TX_SIZE largest_tx_size = tx_mode_to_biggest_tx_size[cm->tx_mode];
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
- mbmi->tx_size = VPXMIN(max_tx_size, largest_tx_size);
+ mi->tx_size = VPXMIN(max_tx_size, largest_tx_size);
txfm_rd_in_plane(x, rate, distortion, skip,
sse, ref_best_rd, 0, bs,
- mbmi->tx_size, cpi->sf.use_fast_coef_costing);
+ mi->tx_size, cpi->sf.use_fast_coef_costing);
}
static void choose_tx_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x,
@@ -637,7 +637,7 @@
const TX_SIZE max_tx_size = max_txsize_lookup[bs];
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
vpx_prob skip_prob = vp9_get_skip_prob(cm, xd);
int r[TX_SIZES][2], s[TX_SIZES];
int64_t d[TX_SIZES], sse[TX_SIZES];
@@ -684,7 +684,7 @@
if (d[n] == INT64_MAX || r[n][0] == INT_MAX) {
rd[n][0] = rd[n][1] = INT64_MAX;
} else if (s[n]) {
- if (is_inter_block(mbmi)) {
+ if (is_inter_block(mi)) {
rd[n][0] = rd[n][1] = RDCOST(x->rdmult, x->rddiv, s1, sse[n]);
r[n][1] -= r_tx_size;
} else {
@@ -696,7 +696,7 @@
rd[n][1] = RDCOST(x->rdmult, x->rddiv, r[n][1] + s0, d[n]);
}
- if (is_inter_block(mbmi) && !xd->lossless && !s[n] && sse[n] != INT64_MAX) {
+ if (is_inter_block(mi) && !xd->lossless && !s[n] && sse[n] != INT64_MAX) {
rd[n][0] = VPXMIN(rd[n][0], RDCOST(x->rdmult, x->rddiv, s1, sse[n]));
rd[n][1] = VPXMIN(rd[n][1], RDCOST(x->rdmult, x->rddiv, s1, sse[n]));
}
@@ -713,12 +713,12 @@
best_rd = rd[n][1];
}
}
- mbmi->tx_size = best_tx;
+ mi->tx_size = best_tx;
- *distortion = d[mbmi->tx_size];
- *rate = r[mbmi->tx_size][cm->tx_mode == TX_MODE_SELECT];
- *skip = s[mbmi->tx_size];
- *psse = sse[mbmi->tx_size];
+ *distortion = d[mi->tx_size];
+ *rate = r[mi->tx_size][cm->tx_mode == TX_MODE_SELECT];
+ *skip = s[mi->tx_size];
+ *psse = sse[mi->tx_size];
}
static void super_block_yrd(VP9_COMP *cpi, MACROBLOCK *x, int *rate,
@@ -729,7 +729,7 @@
int64_t sse;
int64_t *ret_sse = psse ? psse : &sse;
- assert(bs == xd->mi[0]->mbmi.sb_type);
+ assert(bs == xd->mi[0]->sb_type);
if (cpi->sf.tx_size_search_method == USE_LARGESTALL || xd->lossless) {
choose_largest_tx_size(cpi, x, rate, distortion, skip, ret_sse, ref_best_rd,
@@ -790,7 +790,7 @@
memcpy(ta, a, sizeof(ta));
memcpy(tl, l, sizeof(tl));
- xd->mi[0]->mbmi.tx_size = TX_4X4;
+ xd->mi[0]->tx_size = TX_4X4;
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
@@ -1005,7 +1005,7 @@
MODE_INFO *const mic = xd->mi[0];
const MODE_INFO *above_mi = xd->above_mi;
const MODE_INFO *left_mi = xd->left_mi;
- const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
+ const BLOCK_SIZE bsize = xd->mi[0]->sb_type;
const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
int idx, idy;
@@ -1058,7 +1058,7 @@
*rate = cost;
*rate_y = tot_rate_y;
*distortion = total_distortion;
- mic->mbmi.mode = mic->bmi[3].as_mode;
+ mic->mode = mic->bmi[3].as_mode;
return RDCOST(mb->rdmult, mb->rddiv, cost, total_distortion);
}
@@ -1095,7 +1095,7 @@
break;
}
- mic->mbmi.mode = mode;
+ mic->mode = mode;
super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion,
&s, NULL, bsize, best_rd);
@@ -1109,7 +1109,7 @@
if (this_rd < best_rd) {
mode_selected = mode;
best_rd = this_rd;
- best_tx = mic->mbmi.tx_size;
+ best_tx = mic->tx_size;
*rate = this_rate;
*rate_tokenonly = this_rate_tokenonly;
*distortion = this_distortion;
@@ -1117,8 +1117,8 @@
}
}
- mic->mbmi.mode = mode_selected;
- mic->mbmi.tx_size = best_tx;
+ mic->mode = mode_selected;
+ mic->tx_size = best_tx;
return best_rd;
}
@@ -1130,8 +1130,8 @@
int64_t *sse, BLOCK_SIZE bsize,
int64_t ref_best_rd) {
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
- const TX_SIZE uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]);
+ MODE_INFO *const mi = xd->mi[0];
+ const TX_SIZE uv_tx_size = get_uv_tx_size(mi, &xd->plane[1]);
int plane;
int pnrate = 0, pnskip = 1;
int64_t pndist = 0, pnsse = 0;
@@ -1140,7 +1140,7 @@
if (ref_best_rd < 0)
is_cost_valid = 0;
- if (is_inter_block(mbmi) && is_cost_valid) {
+ if (is_inter_block(mi) && is_cost_valid) {
int plane;
for (plane = 1; plane < MAX_MB_PLANE; ++plane)
vp9_subtract_plane(x, bsize, plane);
@@ -1193,14 +1193,14 @@
if (!(cpi->sf.intra_uv_mode_mask[max_tx_size] & (1 << mode)))
continue;
- xd->mi[0]->mbmi.uv_mode = mode;
+ xd->mi[0]->uv_mode = mode;
if (!super_block_uvrd(cpi, x, &this_rate_tokenonly,
&this_distortion, &s, &this_sse, bsize, best_rd))
continue;
this_rate = this_rate_tokenonly +
cpi->intra_uv_mode_cost[cpi->common.frame_type]
- [xd->mi[0]->mbmi.mode][mode];
+ [xd->mi[0]->mode][mode];
this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion);
if (this_rd < best_rd) {
@@ -1215,7 +1215,7 @@
}
}
- xd->mi[0]->mbmi.uv_mode = mode_selected;
+ xd->mi[0]->uv_mode = mode_selected;
return best_rd;
}
@@ -1226,13 +1226,13 @@
const VP9_COMMON *cm = &cpi->common;
int64_t unused;
- x->e_mbd.mi[0]->mbmi.uv_mode = DC_PRED;
+ x->e_mbd.mi[0]->uv_mode = DC_PRED;
memset(x->skip_txfm, SKIP_TXFM_NONE, sizeof(x->skip_txfm));
super_block_uvrd(cpi, x, rate_tokenonly, distortion,
skippable, &unused, bsize, INT64_MAX);
*rate = *rate_tokenonly +
cpi->intra_uv_mode_cost[cm->frame_type]
- [x->e_mbd.mi[0]->mbmi.mode][DC_PRED];
+ [x->e_mbd.mi[0]->mode][DC_PRED];
return RDCOST(x->rdmult, x->rddiv, *rate, *distortion);
}
@@ -1254,7 +1254,7 @@
rate_uv, rate_uv_tokenonly, dist_uv, skip_uv,
bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, max_tx_size);
}
- *mode_uv = x->e_mbd.mi[0]->mbmi.uv_mode;
+ *mode_uv = x->e_mbd.mi[0]->uv_mode;
}
static int cost_mv_ref(const VP9_COMP *cpi, PREDICTION_MODE mode,
@@ -1270,31 +1270,30 @@
int_mv seg_mvs[MAX_REF_FRAMES],
int_mv *best_ref_mv[2], const int *mvjcost,
int *mvcost[2]) {
- MODE_INFO *const mic = xd->mi[0];
- const MB_MODE_INFO *const mbmi = &mic->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
const MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
int thismvcost = 0;
int idx, idy;
- const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[mbmi->sb_type];
- const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[mbmi->sb_type];
- const int is_compound = has_second_ref(mbmi);
+ const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[mi->sb_type];
+ const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[mi->sb_type];
+ const int is_compound = has_second_ref(mi);
switch (mode) {
case NEWMV:
- this_mv[0].as_int = seg_mvs[mbmi->ref_frame[0]].as_int;
+ this_mv[0].as_int = seg_mvs[mi->ref_frame[0]].as_int;
thismvcost += vp9_mv_bit_cost(&this_mv[0].as_mv, &best_ref_mv[0]->as_mv,
mvjcost, mvcost, MV_COST_WEIGHT_SUB);
if (is_compound) {
- this_mv[1].as_int = seg_mvs[mbmi->ref_frame[1]].as_int;
+ this_mv[1].as_int = seg_mvs[mi->ref_frame[1]].as_int;
thismvcost += vp9_mv_bit_cost(&this_mv[1].as_mv, &best_ref_mv[1]->as_mv,
mvjcost, mvcost, MV_COST_WEIGHT_SUB);
}
break;
case NEARMV:
case NEARESTMV:
- this_mv[0].as_int = frame_mv[mode][mbmi->ref_frame[0]].as_int;
+ this_mv[0].as_int = frame_mv[mode][mi->ref_frame[0]].as_int;
if (is_compound)
- this_mv[1].as_int = frame_mv[mode][mbmi->ref_frame[1]].as_int;
+ this_mv[1].as_int = frame_mv[mode][mi->ref_frame[1]].as_int;
break;
case ZEROMV:
this_mv[0].as_int = 0;
@@ -1305,17 +1304,17 @@
break;
}
- mic->bmi[i].as_mv[0].as_int = this_mv[0].as_int;
+ mi->bmi[i].as_mv[0].as_int = this_mv[0].as_int;
if (is_compound)
- mic->bmi[i].as_mv[1].as_int = this_mv[1].as_int;
+ mi->bmi[i].as_mv[1].as_int = this_mv[1].as_int;
- mic->bmi[i].as_mode = mode;
+ mi->bmi[i].as_mode = mode;
for (idy = 0; idy < num_4x4_blocks_high; ++idy)
for (idx = 0; idx < num_4x4_blocks_wide; ++idx)
- memmove(&mic->bmi[i + idy * 2 + idx], &mic->bmi[i], sizeof(mic->bmi[i]));
+ memmove(&mi->bmi[i + idy * 2 + idx], &mi->bmi[i], sizeof(mi->bmi[i]));
- return cost_mv_ref(cpi, mode, mbmi_ext->mode_context[mbmi->ref_frame[0]]) +
+ return cost_mv_ref(cpi, mode, mbmi_ext->mode_context[mi->ref_frame[0]]) +
thismvcost;
}
@@ -1333,7 +1332,7 @@
struct macroblockd_plane *const pd = &xd->plane[0];
struct macroblock_plane *const p = &x->plane[0];
MODE_INFO *const mi = xd->mi[0];
- const BLOCK_SIZE plane_bsize = get_plane_block_size(mi->mbmi.sb_type, pd);
+ const BLOCK_SIZE plane_bsize = get_plane_block_size(mi->sb_type, pd);
const int width = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
const int height = 4 * num_4x4_blocks_high_lookup[plane_bsize];
int idx, idy;
@@ -1345,8 +1344,8 @@
int64_t thisdistortion = 0, thissse = 0;
int thisrate = 0, ref;
const scan_order *so = &vp9_default_scan_orders[TX_4X4];
- const int is_compound = has_second_ref(&mi->mbmi);
- const InterpKernel *kernel = vp9_filter_kernels[mi->mbmi.interp_filter];
+ const int is_compound = has_second_ref(mi);
+ const InterpKernel *kernel = vp9_filter_kernels[mi->interp_filter];
for (ref = 0; ref < 1 + is_compound; ++ref) {
const int bw = b_width_log2_lookup[BLOCK_8X8];
@@ -1484,7 +1483,7 @@
}
static INLINE void mi_buf_shift(MACROBLOCK *x, int i) {
- MB_MODE_INFO *const mbmi = &x->e_mbd.mi[0]->mbmi;
+ MODE_INFO *const mi = x->e_mbd.mi[0];
struct macroblock_plane *const p = &x->plane[0];
struct macroblockd_plane *const pd = &x->e_mbd.plane[0];
@@ -1493,17 +1492,17 @@
assert(((intptr_t)pd->pre[0].buf & 0x7) == 0);
pd->pre[0].buf = &pd->pre[0].buf[vp9_raster_block_offset(BLOCK_8X8, i,
pd->pre[0].stride)];
- if (has_second_ref(mbmi))
+ if (has_second_ref(mi))
pd->pre[1].buf = &pd->pre[1].buf[vp9_raster_block_offset(BLOCK_8X8, i,
pd->pre[1].stride)];
}
static INLINE void mi_buf_restore(MACROBLOCK *x, struct buf_2d orig_src,
struct buf_2d orig_pre[2]) {
- MB_MODE_INFO *mbmi = &x->e_mbd.mi[0]->mbmi;
+ MODE_INFO *mi = x->e_mbd.mi[0];
x->plane[0].src = orig_src;
x->e_mbd.plane[0].pre[0] = orig_pre[0];
- if (has_second_ref(mbmi))
+ if (has_second_ref(mi))
x->e_mbd.plane[0].pre[1] = orig_pre[1];
}
@@ -1558,20 +1557,20 @@
const int pw = 4 * num_4x4_blocks_wide_lookup[bsize];
const int ph = 4 * num_4x4_blocks_high_lookup[bsize];
MACROBLOCKD *xd = &x->e_mbd;
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
- const int refs[2] = {mbmi->ref_frame[0],
- mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]};
+ MODE_INFO *mi = xd->mi[0];
+ const int refs[2] = {mi->ref_frame[0],
+ mi->ref_frame[1] < 0 ? 0 : mi->ref_frame[1]};
int_mv ref_mv[2];
int ite, ref;
- const InterpKernel *kernel = vp9_filter_kernels[mbmi->interp_filter];
+ const InterpKernel *kernel = vp9_filter_kernels[mi->interp_filter];
struct scale_factors sf;
// Do joint motion search in compound mode to get more accurate mv.
struct buf_2d backup_yv12[2][MAX_MB_PLANE];
int last_besterr[2] = {INT_MAX, INT_MAX};
const YV12_BUFFER_CONFIG *const scaled_ref_frame[2] = {
- vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[0]),
- vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[1])
+ vp9_get_scaled_ref_frame(cpi, mi->ref_frame[0]),
+ vp9_get_scaled_ref_frame(cpi, mi->ref_frame[1])
};
// Prediction buffer from second frame.
@@ -1747,7 +1746,6 @@
BEST_SEG_INFO *bsi = bsi_buf + filter_idx;
MACROBLOCKD *xd = &x->e_mbd;
MODE_INFO *mi = xd->mi[0];
- MB_MODE_INFO *mbmi = &mi->mbmi;
int mode_idx;
int k, br = 0, idx, idy;
int64_t bd = 0, block_sse = 0;
@@ -1759,13 +1757,13 @@
int64_t this_segment_rd = 0;
int label_mv_thresh;
int segmentyrate = 0;
- const BLOCK_SIZE bsize = mbmi->sb_type;
+ const BLOCK_SIZE bsize = mi->sb_type;
const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
ENTROPY_CONTEXT t_above[2], t_left[2];
int subpelmv = 1, have_ref = 0;
SPEED_FEATURES *const sf = &cpi->sf;
- const int has_second_rf = has_second_ref(mbmi);
+ const int has_second_rf = has_second_ref(mi);
const int inter_mode_mask = sf->inter_mode_mask[bsize];
MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
@@ -1802,7 +1800,7 @@
int ref;
for (ref = 0; ref < 1 + has_second_rf; ++ref) {
- const MV_REFERENCE_FRAME frame = mbmi->ref_frame[ref];
+ const MV_REFERENCE_FRAME frame = mi->ref_frame[ref];
frame_mv[ZEROMV][frame].as_int = 0;
vp9_append_sub8x8_mvs_for_idx(cm, xd, i, ref, mi_row, mi_col,
&frame_mv[NEARESTMV][frame],
@@ -1821,7 +1819,7 @@
continue;
if (!check_best_zero_mv(cpi, mbmi_ext->mode_context, frame_mv,
- this_mode, mbmi->ref_frame))
+ this_mode, mi->ref_frame))
continue;
memcpy(orig_pre, pd->pre, sizeof(orig_pre));
@@ -1832,7 +1830,7 @@
// motion search for newmv (single predictor case only)
if (!has_second_rf && this_mode == NEWMV &&
- seg_mvs[i][mbmi->ref_frame[0]].as_int == INVALID_MV) {
+ seg_mvs[i][mi->ref_frame[0]].as_int == INVALID_MV) {
MV *const new_mv = &mode_mv[NEWMV][0].as_mv;
int step_param = 0;
int bestsme = INT_MAX;
@@ -1855,7 +1853,7 @@
}
}
if (i == 0)
- max_mv = x->max_mv_context[mbmi->ref_frame[0]];
+ max_mv = x->max_mv_context[mi->ref_frame[0]];
else
max_mv =
VPXMAX(abs(bsi->mvp.as_mv.row), abs(bsi->mvp.as_mv.col)) >> 3;
@@ -1874,8 +1872,8 @@
mvp_full.col = bsi->mvp.as_mv.col >> 3;
if (sf->adaptive_motion_search) {
- mvp_full.row = x->pred_mv[mbmi->ref_frame[0]].row >> 3;
- mvp_full.col = x->pred_mv[mbmi->ref_frame[0]].col >> 3;
+ mvp_full.row = x->pred_mv[mi->ref_frame[0]].row >> 3;
+ mvp_full.col = x->pred_mv[mi->ref_frame[0]].col >> 3;
step_param = VPXMAX(step_param, 8);
}
@@ -1903,28 +1901,28 @@
cond_cost_list(cpi, cost_list),
x->nmvjointcost, x->mvcost,
&distortion,
- &x->pred_sse[mbmi->ref_frame[0]],
+ &x->pred_sse[mi->ref_frame[0]],
NULL, 0, 0);
// save motion search result for use in compound prediction
- seg_mvs[i][mbmi->ref_frame[0]].as_mv = *new_mv;
+ seg_mvs[i][mi->ref_frame[0]].as_mv = *new_mv;
}
if (sf->adaptive_motion_search)
- x->pred_mv[mbmi->ref_frame[0]] = *new_mv;
+ x->pred_mv[mi->ref_frame[0]] = *new_mv;
// restore src pointers
mi_buf_restore(x, orig_src, orig_pre);
}
if (has_second_rf) {
- if (seg_mvs[i][mbmi->ref_frame[1]].as_int == INVALID_MV ||
- seg_mvs[i][mbmi->ref_frame[0]].as_int == INVALID_MV)
+ if (seg_mvs[i][mi->ref_frame[1]].as_int == INVALID_MV ||
+ seg_mvs[i][mi->ref_frame[0]].as_int == INVALID_MV)
continue;
}
if (has_second_rf && this_mode == NEWMV &&
- mbmi->interp_filter == EIGHTTAP) {
+ mi->interp_filter == EIGHTTAP) {
// adjust src pointers
mi_buf_shift(x, i);
if (sf->comp_inter_joint_search_thresh <= bsize) {
@@ -1932,10 +1930,10 @@
joint_motion_search(cpi, x, bsize, frame_mv[this_mode],
mi_row, mi_col, seg_mvs[i],
&rate_mv);
- seg_mvs[i][mbmi->ref_frame[0]].as_int =
- frame_mv[this_mode][mbmi->ref_frame[0]].as_int;
- seg_mvs[i][mbmi->ref_frame[1]].as_int =
- frame_mv[this_mode][mbmi->ref_frame[1]].as_int;
+ seg_mvs[i][mi->ref_frame[0]].as_int =
+ frame_mv[this_mode][mi->ref_frame[0]].as_int;
+ seg_mvs[i][mi->ref_frame[1]].as_int =
+ frame_mv[this_mode][mi->ref_frame[1]].as_int;
}
// restore src pointers
mi_buf_restore(x, orig_src, orig_pre);
@@ -2077,7 +2075,7 @@
for (i = 0; i < 4; i++) {
mode_idx = INTER_OFFSET(bsi->modes[i]);
mi->bmi[i].as_mv[0].as_int = bsi->rdstat[i][mode_idx].mvs[0].as_int;
- if (has_second_ref(mbmi))
+ if (has_second_ref(mi))
mi->bmi[i].as_mv[1].as_int = bsi->rdstat[i][mode_idx].mvs[1].as_int;
x->plane[0].eobs[i] = bsi->rdstat[i][mode_idx].eobs;
mi->bmi[i].as_mode = bsi->modes[i];
@@ -2091,7 +2089,7 @@
*returnyrate = bsi->segment_yrate;
*skippable = vp9_is_skippable_in_plane(x, BLOCK_8X8, 0);
*psse = bsi->sse;
- mbmi->mode = bsi->modes[3];
+ mi->mode = bsi->modes[3];
return bsi->segment_rd;
}
@@ -2223,13 +2221,13 @@
int_mv *tmp_mv, int *rate_mv) {
MACROBLOCKD *xd = &x->e_mbd;
const VP9_COMMON *cm = &cpi->common;
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *mi = xd->mi[0];
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}};
int bestsme = INT_MAX;
int step_param;
int sadpb = x->sadperbit16;
MV mvp_full;
- int ref = mbmi->ref_frame[0];
+ int ref = mi->ref_frame[0];
MV ref_mv = x->mbmi_ext->ref_mvs[ref][0].as_mv;
int tmp_col_min = x->mv_col_min;
@@ -2395,14 +2393,14 @@
int64_t filter_cache[]) {
VP9_COMMON *cm = &cpi->common;
MACROBLOCKD *xd = &x->e_mbd;
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *mi = xd->mi[0];
MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
- const int is_comp_pred = has_second_ref(mbmi);
- const int this_mode = mbmi->mode;
+ const int is_comp_pred = has_second_ref(mi);
+ const int this_mode = mi->mode;
int_mv *frame_mv = mode_mv[this_mode];
int i;
- int refs[2] = { mbmi->ref_frame[0],
- (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) };
+ int refs[2] = { mi->ref_frame[0],
+ (mi->ref_frame[1] < 0 ? 0 : mi->ref_frame[1]) };
int_mv cur_mv[2];
#if CONFIG_VP9_HIGHBITDEPTH
DECLARE_ALIGNED(16, uint16_t, tmp_buf16[MAX_MB_PLANE * 64 * 64]);
@@ -2441,9 +2439,9 @@
if (pred_filter_search) {
INTERP_FILTER af = SWITCHABLE, lf = SWITCHABLE;
if (xd->up_available)
- af = xd->mi[-xd->mi_stride]->mbmi.interp_filter;
+ af = xd->mi[-xd->mi_stride]->interp_filter;
if (xd->left_available)
- lf = xd->mi[-1]->mbmi.interp_filter;
+ lf = xd->mi[-1]->interp_filter;
if ((this_mode != NEWMV) || (af == lf))
best_filter = af;
@@ -2511,7 +2509,7 @@
if (mv_check_bounds(x, &cur_mv[i].as_mv))
return INT64_MAX;
- mbmi->mv[i].as_int = cur_mv[i].as_int;
+ mi->mv[i].as_int = cur_mv[i].as_int;
}
// do first prediction into the destination buffer. Do the next
@@ -2541,14 +2539,14 @@
}
if (RDCOST(x->rdmult, x->rddiv, *rate2, 0) > ref_best_rd &&
- mbmi->mode != NEARESTMV)
+ mi->mode != NEARESTMV)
return INT64_MAX;
pred_exists = 0;
// Are all MVs integer pel for Y and UV
- intpel_mv = !mv_has_subpel(&mbmi->mv[0].as_mv);
+ intpel_mv = !mv_has_subpel(&mi->mv[0].as_mv);
if (is_comp_pred)
- intpel_mv &= !mv_has_subpel(&mbmi->mv[1].as_mv);
+ intpel_mv &= !mv_has_subpel(&mi->mv[1].as_mv);
// Search for best switchable filter by checking the variance of
// pred error irrespective of whether the filter will be used
@@ -2569,7 +2567,7 @@
int tmp_skip_sb = 0;
int64_t tmp_skip_sse = INT64_MAX;
- mbmi->interp_filter = i;
+ mi->interp_filter = i;
rs = vp9_get_switchable_rate(cpi, xd);
rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0);
@@ -2594,7 +2592,7 @@
if ((cm->interp_filter == SWITCHABLE &&
(!i || best_needs_copy)) ||
(cm->interp_filter != SWITCHABLE &&
- (cm->interp_filter == mbmi->interp_filter ||
+ (cm->interp_filter == mi->interp_filter ||
(i == 0 && intpel_mv)))) {
restore_dst_buf(xd, orig_dst, orig_dst_stride);
} else {
@@ -2631,14 +2629,14 @@
if (newbest) {
best_rd = rd;
- best_filter = mbmi->interp_filter;
+ best_filter = mi->interp_filter;
if (cm->interp_filter == SWITCHABLE && i && !intpel_mv)
best_needs_copy = !best_needs_copy;
}
if ((cm->interp_filter == SWITCHABLE && newbest) ||
(cm->interp_filter != SWITCHABLE &&
- cm->interp_filter == mbmi->interp_filter)) {
+ cm->interp_filter == mi->interp_filter)) {
pred_exists = 1;
tmp_rd = best_rd;
@@ -2652,7 +2650,7 @@
}
}
// Set the appropriate filter
- mbmi->interp_filter = cm->interp_filter != SWITCHABLE ?
+ mi->interp_filter = cm->interp_filter != SWITCHABLE ?
cm->interp_filter : best_filter;
rs = cm->interp_filter == SWITCHABLE ? vp9_get_switchable_rate(cpi, xd) : 0;
@@ -2680,7 +2678,7 @@
}
if (!is_comp_pred)
- single_filter[this_mode][refs[0]] = mbmi->interp_filter;
+ single_filter[this_mode][refs[0]] = mi->interp_filter;
if (cpi->sf.adaptive_mode_search)
if (is_comp_pred)
@@ -2767,8 +2765,8 @@
TX_SIZE max_uv_tx_size;
x->skip_encode = 0;
ctx->skip = 0;
- xd->mi[0]->mbmi.ref_frame[0] = INTRA_FRAME;
- xd->mi[0]->mbmi.ref_frame[1] = NONE;
+ xd->mi[0]->ref_frame[0] = INTRA_FRAME;
+ xd->mi[0]->ref_frame[1] = NONE;
if (bsize >= BLOCK_8X8) {
if (rd_pick_intra_sby_mode(cpi, x, &rate_y, &rate_y_tokenonly,
@@ -2785,7 +2783,7 @@
return;
}
}
- max_uv_tx_size = get_uv_tx_size_impl(xd->mi[0]->mbmi.tx_size, bsize,
+ max_uv_tx_size = get_uv_tx_size_impl(xd->mi[0]->tx_size, bsize,
pd[1].subsampling_x,
pd[1].subsampling_y);
rd_pick_intra_sbuv_mode(cpi, x, ctx, &rate_uv, &rate_uv_tokenonly,
@@ -2949,12 +2947,12 @@
RD_OPT *const rd_opt = &cpi->rd;
SPEED_FEATURES *const sf = &cpi->sf;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
const struct segmentation *const seg = &cm->seg;
PREDICTION_MODE this_mode;
MV_REFERENCE_FRAME ref_frame, second_ref_frame;
- unsigned char segment_id = mbmi->segment_id;
+ unsigned char segment_id = mi->segment_id;
int comp_pred, i, k;
int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES];
struct buf_2d yv12_mb[4][MAX_MB_PLANE];
@@ -2968,7 +2966,7 @@
int64_t best_pred_rd[REFERENCE_MODES];
int64_t best_filter_rd[SWITCHABLE_FILTER_CONTEXTS];
int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS];
- MB_MODE_INFO best_mbmode;
+ MODE_INFO best_mbmode;
int best_mode_skippable = 0;
int midx, best_mode_index = -1;
unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES];
@@ -3186,7 +3184,7 @@
const int bsl = mi_width_log2_lookup[bsize];
int cb_partition_search_ctrl = (((mi_row + mi_col) >> bsl)
+ get_chessboard_index(cm->current_video_frame)) & 0x1;
- MB_MODE_INFO *ref_mbmi;
+ MODE_INFO *ref_mi;
int const_motion = 1;
int skip_ref_frame = !cb_partition_search_ctrl;
MV_REFERENCE_FRAME rf = NONE;
@@ -3194,26 +3192,26 @@
ref_mv.as_int = INVALID_MV;
if ((mi_row - 1) >= tile_info->mi_row_start) {
- ref_mv = xd->mi[-xd->mi_stride]->mbmi.mv[0];
- rf = xd->mi[-xd->mi_stride]->mbmi.ref_frame[0];
+ ref_mv = xd->mi[-xd->mi_stride]->mv[0];
+ rf = xd->mi[-xd->mi_stride]->ref_frame[0];
for (i = 0; i < mi_width; ++i) {
- ref_mbmi = &xd->mi[-xd->mi_stride + i]->mbmi;
- const_motion &= (ref_mv.as_int == ref_mbmi->mv[0].as_int) &&
- (ref_frame == ref_mbmi->ref_frame[0]);
- skip_ref_frame &= (rf == ref_mbmi->ref_frame[0]);
+ ref_mi = xd->mi[-xd->mi_stride + i];
+ const_motion &= (ref_mv.as_int == ref_mi->mv[0].as_int) &&
+ (ref_frame == ref_mi->ref_frame[0]);
+ skip_ref_frame &= (rf == ref_mi->ref_frame[0]);
}
}
if ((mi_col - 1) >= tile_info->mi_col_start) {
if (ref_mv.as_int == INVALID_MV)
- ref_mv = xd->mi[-1]->mbmi.mv[0];
+ ref_mv = xd->mi[-1]->mv[0];
if (rf == NONE)
- rf = xd->mi[-1]->mbmi.ref_frame[0];
+ rf = xd->mi[-1]->ref_frame[0];
for (i = 0; i < mi_height; ++i) {
- ref_mbmi = &xd->mi[i * xd->mi_stride - 1]->mbmi;
- const_motion &= (ref_mv.as_int == ref_mbmi->mv[0].as_int) &&
- (ref_frame == ref_mbmi->ref_frame[0]);
- skip_ref_frame &= (rf == ref_mbmi->ref_frame[0]);
+ ref_mi = xd->mi[i * xd->mi_stride - 1];
+ const_motion &= (ref_mv.as_int == ref_mi->mv[0].as_int) &&
+ (ref_frame == ref_mi->ref_frame[0]);
+ skip_ref_frame &= (rf == ref_mi->ref_frame[0]);
}
}
@@ -3284,15 +3282,15 @@
continue;
}
- mbmi->mode = this_mode;
- mbmi->uv_mode = DC_PRED;
- mbmi->ref_frame[0] = ref_frame;
- mbmi->ref_frame[1] = second_ref_frame;
+ mi->mode = this_mode;
+ mi->uv_mode = DC_PRED;
+ mi->ref_frame[0] = ref_frame;
+ mi->ref_frame[1] = second_ref_frame;
// Evaluate all sub-pel filters irrespective of whether we can use
// them for this frame.
- mbmi->interp_filter = cm->interp_filter == SWITCHABLE ? EIGHTTAP
+ mi->interp_filter = cm->interp_filter == SWITCHABLE ? EIGHTTAP
: cm->interp_filter;
- mbmi->mv[0].as_int = mbmi->mv[1].as_int = 0;
+ mi->mv[0].as_int = mi->mv[1].as_int = 0;
x->skip = 0;
set_ref_ptrs(cm, xd, ref_frame, second_ref_frame);
@@ -3313,7 +3311,7 @@
if (rate_y == INT_MAX)
continue;
- uv_tx = get_uv_tx_size_impl(mbmi->tx_size, bsize, pd->subsampling_x,
+ uv_tx = get_uv_tx_size_impl(mi->tx_size, bsize, pd->subsampling_x,
pd->subsampling_y);
if (rate_uv_intra[uv_tx] == INT_MAX) {
choose_intra_uv_mode(cpi, x, ctx, bsize, uv_tx,
@@ -3324,9 +3322,9 @@
rate_uv = rate_uv_tokenonly[uv_tx];
distortion_uv = dist_uv[uv_tx];
skippable = skippable && skip_uv[uv_tx];
- mbmi->uv_mode = mode_uv[uv_tx];
+ mi->uv_mode = mode_uv[uv_tx];
- rate2 = rate_y + cpi->mbmode_cost[mbmi->mode] + rate_uv_intra[uv_tx];
+ rate2 = rate_y + cpi->mbmode_cost[mi->mode] + rate_uv_intra[uv_tx];
if (this_mode != DC_PRED && this_mode != TM_PRED)
rate2 += intra_cost_penalty;
distortion2 = distortion_y + distortion_uv;
@@ -3394,7 +3392,7 @@
// Keep record of best intra rd
if (this_rd < best_intra_rd) {
best_intra_rd = this_rd;
- best_intra_mode = mbmi->mode;
+ best_intra_mode = mi->mode;
}
}
@@ -3414,7 +3412,7 @@
if (ref_frame == INTRA_FRAME) {
/* required for left and above block mv */
- mbmi->mv[0].as_int = 0;
+ mi->mv[0].as_int = 0;
max_plane = 1;
} else {
best_pred_sse = x->pred_sse[ref_frame];
@@ -3424,13 +3422,13 @@
rd_cost->dist = distortion2;
rd_cost->rdcost = this_rd;
best_rd = this_rd;
- best_mbmode = *mbmi;
+ best_mbmode = *mi;
best_skip2 = this_skip2;
best_mode_skippable = skippable;
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
- memcpy(ctx->zcoeff_blk, x->zcoeff_blk[mbmi->tx_size],
+ memcpy(ctx->zcoeff_blk, x->zcoeff_blk[mi->tx_size],
sizeof(ctx->zcoeff_blk[0]) * ctx->num_4x4_blk);
// TODO(debargha): enhance this test with a better distortion prediction
@@ -3546,8 +3544,8 @@
// Do Intra UV best rd mode selection if best mode choice above was intra.
if (best_mbmode.ref_frame[0] == INTRA_FRAME) {
TX_SIZE uv_tx_size;
- *mbmi = best_mbmode;
- uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]);
+ *mi = best_mbmode;
+ uv_tx_size = get_uv_tx_size(mi, &xd->plane[1]);
rd_pick_intra_sbuv_mode(cpi, x, ctx, &rate_uv_intra[uv_tx_size],
&rate_uv_tokenonly[uv_tx_size],
&dist_uv[uv_tx_size],
@@ -3566,7 +3564,7 @@
sf->adaptive_rd_thresh, bsize, best_mode_index);
// macroblock modes
- *mbmi = best_mbmode;
+ *mi = best_mbmode;
x->skip |= best_skip2;
for (i = 0; i < REFERENCE_MODES; ++i) {
@@ -3596,7 +3594,7 @@
if (!x->skip && !x->select_tx_size) {
int has_high_freq_coeff = 0;
int plane;
- int max_plane = is_inter_block(&xd->mi[0]->mbmi)
+ int max_plane = is_inter_block(xd->mi[0])
? MAX_MB_PLANE : 1;
for (plane = 0; plane < max_plane; ++plane) {
x->plane[plane].eobs = ctx->eobs_pbuf[plane][1];
@@ -3626,8 +3624,8 @@
int64_t best_rd_so_far) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
- unsigned char segment_id = mbmi->segment_id;
+ MODE_INFO *const mi = xd->mi[0];
+ unsigned char segment_id = mi->segment_id;
const int comp_pred = 0;
int i;
int64_t best_pred_diff[REFERENCE_MODES];
@@ -3653,11 +3651,11 @@
assert(segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP));
- mbmi->mode = ZEROMV;
- mbmi->uv_mode = DC_PRED;
- mbmi->ref_frame[0] = LAST_FRAME;
- mbmi->ref_frame[1] = NONE;
- mbmi->mv[0].as_int = 0;
+ mi->mode = ZEROMV;
+ mi->uv_mode = DC_PRED;
+ mi->ref_frame[0] = LAST_FRAME;
+ mi->ref_frame[1] = NONE;
+ mi->mv[0].as_int = 0;
x->skip = 1;
if (cm->interp_filter != BILINEAR) {
@@ -3667,21 +3665,21 @@
int rs;
int best_rs = INT_MAX;
for (i = 0; i < SWITCHABLE_FILTERS; ++i) {
- mbmi->interp_filter = i;
+ mi->interp_filter = i;
rs = vp9_get_switchable_rate(cpi, xd);
if (rs < best_rs) {
best_rs = rs;
- best_filter = mbmi->interp_filter;
+ best_filter = mi->interp_filter;
}
}
}
}
// Set the appropriate filter
if (cm->interp_filter == SWITCHABLE) {
- mbmi->interp_filter = best_filter;
+ mi->interp_filter = best_filter;
rate2 += vp9_get_switchable_rate(cpi, xd);
} else {
- mbmi->interp_filter = cm->interp_filter;
+ mi->interp_filter = cm->interp_filter;
}
if (cm->reference_mode == REFERENCE_MODE_SELECT)
@@ -3703,7 +3701,7 @@
}
assert((cm->interp_filter == SWITCHABLE) ||
- (cm->interp_filter == mbmi->interp_filter));
+ (cm->interp_filter == mi->interp_filter));
vp9_update_rd_thresh_fact(tile_data->thresh_freq_fact,
cpi->sf.adaptive_rd_thresh, bsize, THR_ZEROMV);
@@ -3729,10 +3727,10 @@
RD_OPT *const rd_opt = &cpi->rd;
SPEED_FEATURES *const sf = &cpi->sf;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
const struct segmentation *const seg = &cm->seg;
MV_REFERENCE_FRAME ref_frame, second_ref_frame;
- unsigned char segment_id = mbmi->segment_id;
+ unsigned char segment_id = mi->segment_id;
int comp_pred, i;
int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES];
struct buf_2d yv12_mb[4][MAX_MB_PLANE];
@@ -3744,7 +3742,7 @@
int64_t best_pred_rd[REFERENCE_MODES];
int64_t best_filter_rd[SWITCHABLE_FILTER_CONTEXTS];
int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS];
- MB_MODE_INFO best_mbmode;
+ MODE_INFO best_mbmode;
int ref_index, best_ref_index = 0;
unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES];
vpx_prob comp_mode_p;
@@ -3903,14 +3901,14 @@
continue;
}
- mbmi->tx_size = TX_4X4;
- mbmi->uv_mode = DC_PRED;
- mbmi->ref_frame[0] = ref_frame;
- mbmi->ref_frame[1] = second_ref_frame;
+ mi->tx_size = TX_4X4;
+ mi->uv_mode = DC_PRED;
+ mi->ref_frame[0] = ref_frame;
+ mi->ref_frame[1] = second_ref_frame;
// Evaluate all sub-pel filters irrespective of whether we can use
// them for this frame.
- mbmi->interp_filter = cm->interp_filter == SWITCHABLE ? EIGHTTAP
- : cm->interp_filter;
+ mi->interp_filter = cm->interp_filter == SWITCHABLE ? EIGHTTAP
+ : cm->interp_filter;
x->skip = 0;
set_ref_ptrs(cm, xd, ref_frame, second_ref_frame);
@@ -3941,7 +3939,7 @@
rate_uv = rate_uv_tokenonly;
distortion2 += dist_uv;
distortion_uv = dist_uv;
- mbmi->uv_mode = mode_uv;
+ mi->uv_mode = mode_uv;
} else {
int rate;
int64_t distortion;
@@ -3954,7 +3952,7 @@
int_mv *second_ref = comp_pred ?
&x->mbmi_ext->ref_mvs[second_ref_frame][0] : NULL;
b_mode_info tmp_best_bmodes[16];
- MB_MODE_INFO tmp_best_mbmode;
+ MODE_INFO tmp_best_mbmode;
BEST_SEG_INFO bsi[SWITCHABLE_FILTERS];
int pred_exists = 0;
int uv_skippable;
@@ -3963,8 +3961,8 @@
int ref;
for (ref = 0; ref < 2; ++ref) {
- scaled_ref_frame[ref] = mbmi->ref_frame[ref] > INTRA_FRAME ?
- vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[ref]) : NULL;
+ scaled_ref_frame[ref] = mi->ref_frame[ref] > INTRA_FRAME ?
+ vp9_get_scaled_ref_frame(cpi, mi->ref_frame[ref]) : NULL;
if (scaled_ref_frame[ref]) {
int i;
@@ -4003,7 +4001,7 @@
int newbest, rs;
int64_t rs_rd;
MB_MODE_INFO_EXT *mbmi_ext = x->mbmi_ext;
- mbmi->interp_filter = switchable_filter_index;
+ mi->interp_filter = switchable_filter_index;
tmp_rd = rd_pick_best_sub8x8_mode(cpi, x,
&mbmi_ext->ref_mvs[ref_frame][0],
second_ref, best_yrd, &rate,
@@ -4027,11 +4025,11 @@
newbest = (tmp_rd < tmp_best_rd);
if (newbest) {
- tmp_best_filter = mbmi->interp_filter;
+ tmp_best_filter = mi->interp_filter;
tmp_best_rd = tmp_rd;
}
if ((newbest && cm->interp_filter == SWITCHABLE) ||
- (mbmi->interp_filter == cm->interp_filter &&
+ (mi->interp_filter == cm->interp_filter &&
cm->interp_filter != SWITCHABLE)) {
tmp_best_rdu = tmp_rd;
tmp_best_rate = rate;
@@ -4039,7 +4037,7 @@
tmp_best_distortion = distortion;
tmp_best_sse = total_sse;
tmp_best_skippable = skippable;
- tmp_best_mbmode = *mbmi;
+ tmp_best_mbmode = *mi;
for (i = 0; i < 4; i++) {
tmp_best_bmodes[i] = xd->mi[0]->bmi[i];
x->zcoeff_blk[TX_4X4][i] = !x->plane[0].eobs[i];
@@ -4051,7 +4049,7 @@
if (tmp_best_rdu / 2 > best_rd) {
// skip searching the other filters if the first is
// already substantially larger than the best so far
- tmp_best_filter = mbmi->interp_filter;
+ tmp_best_filter = mi->interp_filter;
tmp_best_rdu = INT64_MAX;
break;
}
@@ -4064,8 +4062,8 @@
if (tmp_best_rdu == INT64_MAX && pred_exists)
continue;
- mbmi->interp_filter = (cm->interp_filter == SWITCHABLE ?
- tmp_best_filter : cm->interp_filter);
+ mi->interp_filter = (cm->interp_filter == SWITCHABLE ?
+ tmp_best_filter : cm->interp_filter);
if (!pred_exists) {
// Handles the special case when a filter that is not in the
// switchable list (bilinear, 6-tap) is indicated at the frame level
@@ -4083,7 +4081,7 @@
rate_y = tmp_best_ratey;
distortion = tmp_best_distortion;
skippable = tmp_best_skippable;
- *mbmi = tmp_best_mbmode;
+ *mi = tmp_best_mbmode;
for (i = 0; i < 4; i++)
xd->mi[0]->bmi[i] = tmp_best_bmodes[i];
}
@@ -4193,7 +4191,7 @@
if (ref_frame == INTRA_FRAME) {
/* required for left and above block mv */
- mbmi->mv[0].as_int = 0;
+ mi->mv[0].as_int = 0;
max_plane = 1;
}
@@ -4203,7 +4201,7 @@
best_rd = this_rd;
best_yrd = best_rd -
RDCOST(x->rdmult, x->rddiv, rate_uv, distortion_uv);
- best_mbmode = *mbmi;
+ best_mbmode = *mi;
best_skip2 = this_skip2;
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
@@ -4301,7 +4299,7 @@
if (sf->use_uv_intra_rd_estimate) {
// Do Intra UV best rd mode selection if best mode choice above was intra.
if (best_mbmode.ref_frame[0] == INTRA_FRAME) {
- *mbmi = best_mbmode;
+ *mi = best_mbmode;
rd_pick_intra_sbuv_mode(cpi, x, ctx, &rate_uv_intra,
&rate_uv_tokenonly,
&dist_uv,
@@ -4325,7 +4323,7 @@
sf->adaptive_rd_thresh, bsize, best_ref_index);
// macroblock modes
- *mbmi = best_mbmode;
+ *mi = best_mbmode;
x->skip |= best_skip2;
if (!is_inter_block(&best_mbmode)) {
for (i = 0; i < 4; i++)
@@ -4334,8 +4332,8 @@
for (i = 0; i < 4; ++i)
memcpy(&xd->mi[0]->bmi[i], &best_bmodes[i], sizeof(b_mode_info));
- mbmi->mv[0].as_int = xd->mi[0]->bmi[3].as_mv[0].as_int;
- mbmi->mv[1].as_int = xd->mi[0]->bmi[3].as_mv[1].as_int;
+ mi->mv[0].as_int = xd->mi[0]->bmi[3].as_mv[0].as_int;
+ mi->mv[1].as_int = xd->mi[0]->bmi[3].as_mv[1].as_int;
}
for (i = 0; i < REFERENCE_MODES; ++i) {
diff --git a/vp9/encoder/vp9_segmentation.c b/vp9/encoder/vp9_segmentation.c
index c5c50a2..5a0a23d 100644
--- a/vp9/encoder/vp9_segmentation.c
+++ b/vp9/encoder/vp9_segmentation.c
@@ -118,7 +118,7 @@
return;
xd->mi = mi;
- segment_id = xd->mi[0]->mbmi.segment_id;
+ segment_id = xd->mi[0]->segment_id;
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
@@ -127,7 +127,7 @@
// Temporal prediction not allowed on key frames
if (cm->frame_type != KEY_FRAME) {
- const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
+ const BLOCK_SIZE bsize = xd->mi[0]->sb_type;
// Test to see if the segment id matches the predicted value.
const int pred_segment_id = get_segment_id(cm, cm->last_frame_seg_map,
bsize, mi_row, mi_col);
@@ -136,7 +136,7 @@
// Store the prediction status for this mb and update counts
// as appropriate
- xd->mi[0]->mbmi.seg_id_predicted = pred_flag;
+ xd->mi[0]->seg_id_predicted = pred_flag;
temporal_predictor_count[pred_context][pred_flag]++;
// Update the "unpredicted" segment count
@@ -159,8 +159,8 @@
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
return;
- bw = num_8x8_blocks_wide_lookup[mi[0]->mbmi.sb_type];
- bh = num_8x8_blocks_high_lookup[mi[0]->mbmi.sb_type];
+ bw = num_8x8_blocks_wide_lookup[mi[0]->sb_type];
+ bh = num_8x8_blocks_high_lookup[mi[0]->sb_type];
if (bw == bs && bh == bs) {
count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count,
diff --git a/vp9/encoder/vp9_svc_layercontext.c b/vp9/encoder/vp9_svc_layercontext.c
index 30a7d10..e0236aa 100644
--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -33,6 +33,7 @@
svc->first_spatial_layer_to_encode = 0;
svc->rc_drop_superframe = 0;
svc->force_zero_mode_spatial_ref = 0;
+ svc->use_base_mv = 0;
svc->current_superframe = 0;
for (i = 0; i < REF_FRAMES; ++i)
svc->ref_frame_index[i] = -1;
@@ -416,7 +417,9 @@
cpi->ref_frame_flags = VP9_LAST_FLAG;
} else if (cpi->svc.layer_context[temporal_id].is_key_frame) {
// base layer is a key frame.
- cpi->ref_frame_flags = VP9_GOLD_FLAG;
+ cpi->ref_frame_flags = VP9_LAST_FLAG;
+ cpi->ext_refresh_last_frame = 0;
+ cpi->ext_refresh_golden_frame = 1;
} else {
cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG;
}
@@ -431,7 +434,13 @@
} else {
if (frame_num_within_temporal_struct == 1) {
// the first tl2 picture
- if (!spatial_id) {
+ if (spatial_id == cpi->svc.number_spatial_layers - 1) { // top layer
+ cpi->ext_refresh_frame_flags_pending = 1;
+ if (!spatial_id)
+ cpi->ref_frame_flags = VP9_LAST_FLAG;
+ else
+ cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG;
+ } else if (!spatial_id) {
cpi->ext_refresh_frame_flags_pending = 1;
cpi->ext_refresh_alt_ref_frame = 1;
cpi->ref_frame_flags = VP9_LAST_FLAG;
@@ -439,32 +448,38 @@
cpi->ext_refresh_frame_flags_pending = 1;
cpi->ext_refresh_alt_ref_frame = 1;
cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG;
- } else { // Top layer
- cpi->ext_refresh_frame_flags_pending = 0;
- cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG;
}
} else {
// The second tl2 picture
- if (!spatial_id) {
+ if (spatial_id == cpi->svc.number_spatial_layers - 1) { // top layer
+ cpi->ext_refresh_frame_flags_pending = 1;
+ if (!spatial_id)
+ cpi->ref_frame_flags = VP9_LAST_FLAG;
+ else
+ cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG;
+ } else if (!spatial_id) {
cpi->ext_refresh_frame_flags_pending = 1;
cpi->ref_frame_flags = VP9_LAST_FLAG;
- cpi->ext_refresh_last_frame = 1;
- } else if (spatial_id < cpi->svc.number_spatial_layers - 1) {
+ cpi->ext_refresh_alt_ref_frame = 1;
+ } else { // top layer
cpi->ext_refresh_frame_flags_pending = 1;
cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG;
- cpi->ext_refresh_last_frame = 1;
- } else { // top layer
- cpi->ext_refresh_frame_flags_pending = 0;
- cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG;
+ cpi->ext_refresh_alt_ref_frame = 1;
}
}
}
if (temporal_id == 0) {
cpi->lst_fb_idx = spatial_id;
- if (spatial_id)
+ if (spatial_id) {
+ if (cpi->svc.layer_context[temporal_id].is_key_frame) {
+ cpi->lst_fb_idx = spatial_id - 1;
+ cpi->gld_fb_idx = spatial_id;
+ } else {
cpi->gld_fb_idx = spatial_id - 1;
- else
+ }
+ } else {
cpi->gld_fb_idx = 0;
+ }
cpi->alt_fb_idx = 0;
} else if (temporal_id == 1) {
cpi->lst_fb_idx = spatial_id;
@@ -477,7 +492,7 @@
} else {
cpi->lst_fb_idx = cpi->svc.number_spatial_layers + spatial_id;
cpi->gld_fb_idx = cpi->svc.number_spatial_layers + spatial_id - 1;
- cpi->alt_fb_idx = 0;
+ cpi->alt_fb_idx = cpi->svc.number_spatial_layers + spatial_id;
}
}
@@ -499,7 +514,9 @@
cpi->ref_frame_flags = VP9_LAST_FLAG;
} else if (cpi->svc.layer_context[temporal_id].is_key_frame) {
// base layer is a key frame.
- cpi->ref_frame_flags = VP9_GOLD_FLAG;
+ cpi->ref_frame_flags = VP9_LAST_FLAG;
+ cpi->ext_refresh_last_frame = 0;
+ cpi->ext_refresh_golden_frame = 1;
} else {
cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG;
}
@@ -515,10 +532,16 @@
if (temporal_id == 0) {
cpi->lst_fb_idx = spatial_id;
- if (spatial_id)
+ if (spatial_id) {
+ if (cpi->svc.layer_context[temporal_id].is_key_frame) {
+ cpi->lst_fb_idx = spatial_id - 1;
+ cpi->gld_fb_idx = spatial_id;
+ } else {
cpi->gld_fb_idx = spatial_id - 1;
- else
+ }
+ } else {
cpi->gld_fb_idx = 0;
+ }
cpi->alt_fb_idx = 0;
} else if (temporal_id == 1) {
cpi->lst_fb_idx = spatial_id;
@@ -540,20 +563,30 @@
if (!spatial_id) {
cpi->ref_frame_flags = VP9_LAST_FLAG;
} else if (cpi->svc.layer_context[0].is_key_frame) {
- cpi->ref_frame_flags = VP9_GOLD_FLAG;
+ cpi->ref_frame_flags = VP9_LAST_FLAG;
+ cpi->ext_refresh_last_frame = 0;
+ cpi->ext_refresh_golden_frame = 1;
} else {
cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG;
}
cpi->lst_fb_idx = spatial_id;
- if (spatial_id)
+ if (spatial_id) {
+ if (cpi->svc.layer_context[0].is_key_frame) {
+ cpi->lst_fb_idx = spatial_id - 1;
+ cpi->gld_fb_idx = spatial_id;
+ } else {
cpi->gld_fb_idx = spatial_id - 1;
- else
+ }
+ } else {
cpi->gld_fb_idx = 0;
+ }
}
int vp9_one_pass_cbr_svc_start_layer(VP9_COMP *const cpi) {
int width = 0, height = 0;
LAYER_CONTEXT *lc = NULL;
+ if (cpi->svc.number_spatial_layers > 1)
+ cpi->svc.use_base_mv = 1;
cpi->svc.force_zero_mode_spatial_ref = 1;
if (cpi->svc.temporal_layering_mode == VP9E_TEMPORAL_LAYERING_MODE_0212) {
diff --git a/vp9/encoder/vp9_svc_layercontext.h b/vp9/encoder/vp9_svc_layercontext.h
index 1f446d7..4e18640 100644
--- a/vp9/encoder/vp9_svc_layercontext.h
+++ b/vp9/encoder/vp9_svc_layercontext.h
@@ -86,6 +86,7 @@
int ref_frame_index[REF_FRAMES];
int force_zero_mode_spatial_ref;
int current_superframe;
+ int use_base_mv;
} SVC;
struct VP9_COMP;
diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c
index 015dbc0..82f566b 100644
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -46,7 +46,7 @@
const int which_mv = 0;
const MV mv = { mv_row, mv_col };
const InterpKernel *const kernel =
- vp9_filter_kernels[xd->mi[0]->mbmi.interp_filter];
+ vp9_filter_kernels[xd->mi[0]->interp_filter];
enum mv_precision mv_precision_uv;
int uv_stride;
diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c
index 9ac8048..666f68a 100644
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -468,17 +468,17 @@
uint8_t token_cache[32 * 32];
struct macroblock_plane *p = &x->plane[plane];
struct macroblockd_plane *pd = &xd->plane[plane];
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *mi = xd->mi[0];
int pt; /* near block/prev token context index */
int c;
TOKENEXTRA *t = *tp; /* store tokens starting here */
int eob = p->eobs[block];
const PLANE_TYPE type = get_plane_type(plane);
const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
- const int segment_id = mbmi->segment_id;
+ const int segment_id = mi->segment_id;
const int16_t *scan, *nb;
const scan_order *so;
- const int ref = is_inter_block(mbmi);
+ const int ref = is_inter_block(mi);
unsigned int (*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
td->rd_counts.coef_counts[tx_size][type][ref];
vpx_prob (*const coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
@@ -585,12 +585,12 @@
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
- MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ MODE_INFO *const mi = xd->mi[0];
const int ctx = vp9_get_skip_context(xd);
- const int skip_inc = !segfeature_active(&cm->seg, mbmi->segment_id,
+ const int skip_inc = !segfeature_active(&cm->seg, mi->segment_id,
SEG_LVL_SKIP);
struct tokenize_b_args arg = {cpi, td, t};
- if (mbmi->skip) {
+ if (mi->skip) {
if (!dry_run)
td->counts->skip[ctx][1] += skip_inc;
reset_skip_context(xd, bsize);
diff --git a/vpx/src/svc_encodeframe.c b/vpx/src/svc_encodeframe.c
index 5c3fe93..628afca 100644
--- a/vpx/src/svc_encodeframe.c
+++ b/vpx/src/svc_encodeframe.c
@@ -322,8 +322,7 @@
for (sl = 0; sl < svc_ctx->spatial_layers; ++sl) {
if (si->svc_params.scaling_factor_den[sl] > 0) {
- alloc_ratio[sl] = (float)(si->svc_params.scaling_factor_num[sl] *
- 1.0 / si->svc_params.scaling_factor_den[sl]);
+ alloc_ratio[sl] = (float)( (sl+1) );
total += alloc_ratio[sl];
}
}
@@ -334,9 +333,9 @@
alloc_ratio[sl] / total);
if (svc_ctx->temporal_layering_mode == 3) {
enc_cfg->layer_target_bitrate[sl * svc_ctx->temporal_layers] =
- spatial_layer_target >> 1;
+ (spatial_layer_target*6)/10; // 60%
enc_cfg->layer_target_bitrate[sl * svc_ctx->temporal_layers + 1] =
- (spatial_layer_target >> 1) + (spatial_layer_target >> 2);
+ (spatial_layer_target*8)/10; // 80%
enc_cfg->layer_target_bitrate[sl * svc_ctx->temporal_layers + 2] =
spatial_layer_target;
} else if (svc_ctx->temporal_layering_mode == 2 ||
@@ -398,11 +397,13 @@
si->width = enc_cfg->g_w;
si->height = enc_cfg->g_h;
- if (enc_cfg->kf_max_dist < 2) {
+// wonkap: why is this necessary?
+ /*if (enc_cfg->kf_max_dist < 2) {
svc_log(svc_ctx, SVC_LOG_ERROR, "key frame distance too small: %d\n",
enc_cfg->kf_max_dist);
return VPX_CODEC_INVALID_PARAM;
- }
+ }*/
+
si->kf_dist = enc_cfg->kf_max_dist;
if (svc_ctx->spatial_layers == 0)
@@ -577,6 +578,27 @@
}
#endif
#endif
+ case VPX_CODEC_PSNR_PKT:
+ {
+#if VPX_ENCODER_ABI_VERSION > (5 + VPX_CODEC_ABI_VERSION)
+ int j;
+ svc_log(svc_ctx, SVC_LOG_DEBUG,
+ "frame: %d, layer: %d, PSNR(Total/Y/U/V): "
+ "%2.3f %2.3f %2.3f %2.3f \n",
+ si->psnr_pkt_received, 0,
+ cx_pkt->data.layer_psnr[0].psnr[0],
+ cx_pkt->data.layer_psnr[0].psnr[1],
+ cx_pkt->data.layer_psnr[0].psnr[2],
+ cx_pkt->data.layer_psnr[0].psnr[3]);
+ for (j = 0; j < COMPONENTS; ++j) {
+ si->psnr_sum[0][j] +=
+ cx_pkt->data.layer_psnr[0].psnr[j];
+ si->sse_sum[0][j] += cx_pkt->data.layer_psnr[0].sse[j];
+ }
+#endif
+ }
+ ++si->psnr_pkt_received;
+ break;
default: {
break;
}
diff --git a/vpxenc.c b/vpxenc.c
index db8fcaf..8798e69 100644
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -2074,6 +2074,8 @@
if (!global.have_framerate) {
global.framerate.num = input.framerate.numerator;
global.framerate.den = input.framerate.denominator;
+ FOREACH_STREAM(stream->config.cfg.g_timebase.den = global.framerate.num;
+ stream->config.cfg.g_timebase.num = global.framerate.den);
}
FOREACH_STREAM(set_default_kf_interval(stream, &global));