From 902529c595afbe70a95fc45bb80e7df58d37f72f Mon Sep 17 00:00:00 2001 From: Alexander Voronov Date: Thu, 11 Sep 2014 17:14:23 +0400 Subject: [PATCH] Reinitialize dequantizer when switching from 10/12 bit to 8 bit. Change-Id: Id294cf8d314a3f8aaf4ca2a6b3da052cc898a78c --- vp9/common/vp9_onyxc_int.h | 1 + vp9/decoder/vp9_decodeframe.c | 6 +++--- vp9/decoder/vp9_decoder.c | 1 + vpx/vpx_codec.h | 12 +++++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index ac80803f9..58553b8d8 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -185,6 +185,7 @@ typedef struct VP9Common { // VPX_BITS_8 in versions 0 and 1, VPX_BITS_10/VPX_BITS_12 in version 2 vpx_bit_depth_t bit_depth; + vpx_bit_depth_t dequant_bit_depth; #if CONFIG_VP9_POSTPROC struct postproc_state postproc_state; diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c index 2e551b72d..75c2ad956 100644 --- a/vp9/decoder/vp9_decodeframe.c +++ b/vp9/decoder/vp9_decodeframe.c @@ -646,10 +646,10 @@ static void setup_quantization(VP9_COMMON *const cm, MACROBLOCKD *const xd, update |= read_delta_q(rb, &cm->uv_dc_delta_q); update |= read_delta_q(rb, &cm->uv_ac_delta_q); - // TODO(peter.derivaz): Don't really want to call this for every frame - // for high-bit-depth, but need the bit depth to init dequantizers - if (update || cm->profile >= PROFILE_2) + if (update || cm->bit_depth != cm->dequant_bit_depth) { vp9_init_dequantizer(cm); + cm->dequant_bit_depth = cm->bit_depth; + } xd->lossless = cm->base_qindex == 0 && cm->y_dc_delta_q == 0 && diff --git a/vp9/decoder/vp9_decoder.c b/vp9/decoder/vp9_decoder.c index 3a0e97744..a77117341 100644 --- a/vp9/decoder/vp9_decoder.c +++ b/vp9/decoder/vp9_decoder.c @@ -66,6 +66,7 @@ VP9Decoder *vp9_decoder_create() { vpx_memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map)); cm->current_video_frame = 0; + cm->dequant_bit_depth = VPX_BITS_NOT_SET; pbi->ready_for_new_data = 1; // vp9_init_dequantizer() is first called here. Add check in diff --git a/vpx/vpx_codec.h b/vpx/vpx_codec.h index eefa559e9..31835419f 100644 --- a/vpx/vpx_codec.h +++ b/vpx/vpx_codec.h @@ -43,6 +43,8 @@ extern "C" { #endif +#include + #include "./vpx_config.h" #include "./vpx_integer.h" #include "./vpx_image.h" @@ -216,9 +218,10 @@ extern "C" { * This enumeration determines the bit depth of the codec. */ typedef enum vpx_bit_depth { - VPX_BITS_8 = 8, /**< 8 bits */ - VPX_BITS_10 = 10, /**< 10 bits */ - VPX_BITS_12 = 12 /**< 12 bits */ + VPX_BITS_8 = 8, /**< 8 bits */ + VPX_BITS_10 = 10, /**< 10 bits */ + VPX_BITS_12 = 12, /**< 12 bits */ + VPX_BITS_NOT_SET = 0xFF /**< Invalid value */ } vpx_bit_depth_t; /* @@ -481,6 +484,9 @@ static INLINE unsigned int vpx_bit_depth_to_bps(vpx_bit_depth_t bit_depth) { case VPX_BITS_12: bps = 12; break; + case VPX_BITS_NOT_SET: + assert(0 && "Bit depth is not initialized."); + break; } return bps; }