From 8b7a4e16cb0df12911651e19a25021e4620816df Mon Sep 17 00:00:00 2001 From: Sebastien Alaiwan Date: Tue, 13 Jun 2017 11:25:57 +0200 Subject: [PATCH] Fix unit tests with --disable-lowbitdepth This moves up to the main the decision of which coding path to use, aligning the decoder's logic on the encoder's logic. Change-Id: I61c709ca1160aefb156d0be25cab8bb1c20ff92a --- aom/aom_decoder.h | 3 ++- aomdec.c | 2 +- aomenc.c | 2 +- av1/av1_dx_iface.c | 2 ++ av1/decoder/decodeframe.c | 9 +++++---- av1/decoder/decoder.h | 1 + test/encode_test_driver.cc | 1 + 7 files changed, 13 insertions(+), 7 deletions(-) diff --git a/aom/aom_decoder.h b/aom/aom_decoder.h index c90cbb113..509b875d3 100644 --- a/aom/aom_decoder.h +++ b/aom/aom_decoder.h @@ -107,7 +107,8 @@ typedef struct aom_codec_dec_cfg { unsigned int threads; /**< Maximum number of threads to use, default 1 */ unsigned int w; /**< Width */ unsigned int h; /**< Height */ -} aom_codec_dec_cfg_t; /**< alias for struct aom_codec_dec_cfg */ + unsigned int allow_lowbitdepth; /**< Allow use of low-bitdepth coding path */ +} aom_codec_dec_cfg_t; /**< alias for struct aom_codec_dec_cfg */ /*!\brief Initialize a decoder instance * diff --git a/aomdec.c b/aomdec.c index 289776141..035572c70 100644 --- a/aomdec.c +++ b/aomdec.c @@ -519,7 +519,7 @@ static int main_loop(int argc, const char **argv_) { int use_y4m = 1; int opt_yv12 = 0; int opt_i420 = 0; - aom_codec_dec_cfg_t cfg = { 0, 0, 0 }; + aom_codec_dec_cfg_t cfg = { 0, 0, 0, CONFIG_LOWBITDEPTH }; #if CONFIG_HIGHBITDEPTH unsigned int output_bit_depth = 0; #endif diff --git a/aomenc.c b/aomenc.c index c6a4e706e..d2b7d9848 100644 --- a/aomenc.c +++ b/aomenc.c @@ -1363,7 +1363,7 @@ static void initialize_encoder(struct stream_state *stream, #if CONFIG_AV1_DECODER if (global->test_decode != TEST_DECODE_OFF) { const AvxInterface *decoder = get_aom_decoder_by_name(global->codec->name); - aom_codec_dec_cfg_t cfg = { 0, 0, 0 }; + aom_codec_dec_cfg_t cfg = { 0, 0, 0, CONFIG_LOWBITDEPTH }; aom_codec_dec_init(&stream->decoder, decoder->codec_interface(), &cfg, 0); #if CONFIG_EXT_TILE diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c index ea2a957fb..b8e05bb60 100644 --- a/av1/av1_dx_iface.c +++ b/av1/av1_dx_iface.c @@ -443,6 +443,8 @@ static aom_codec_err_t init_decoder(aom_codec_alg_priv_t *ctx) { return AOM_CODEC_MEM_ERROR; } #endif + frame_worker_data->pbi->allow_lowbitdepth = ctx->cfg.allow_lowbitdepth; + // If decoding in serial mode, FrameWorker thread could create tile worker // thread or loopfilter thread. frame_worker_data->pbi->max_threads = diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index d39d84232..69806622b 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c @@ -4216,7 +4216,8 @@ static void error_handler(void *data) { } static void read_bitdepth_colorspace_sampling(AV1_COMMON *cm, - struct aom_read_bit_buffer *rb) { + struct aom_read_bit_buffer *rb, + int allow_lowbitdepth) { if (cm->profile >= PROFILE_2) { cm->bit_depth = aom_rb_read_bit(rb) ? AOM_BITS_12 : AOM_BITS_10; } else { @@ -4224,7 +4225,7 @@ static void read_bitdepth_colorspace_sampling(AV1_COMMON *cm, } #if CONFIG_HIGHBITDEPTH - cm->use_highbitdepth = cm->bit_depth > AOM_BITS_8 || !CONFIG_LOWBITDEPTH; + cm->use_highbitdepth = cm->bit_depth > AOM_BITS_8 || !allow_lowbitdepth; #endif #if CONFIG_COLORSPACE_HEADERS cm->color_space = aom_rb_read_literal(rb, 5); @@ -4459,7 +4460,7 @@ static size_t read_uncompressed_header(AV1Decoder *pbi, aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM, "Invalid frame sync code"); - read_bitdepth_colorspace_sampling(cm, rb); + read_bitdepth_colorspace_sampling(cm, rb, pbi->allow_lowbitdepth); pbi->refresh_frame_flags = (1 << REF_FRAMES) - 1; for (i = 0; i < INTER_REFS_PER_FRAME; ++i) { @@ -4515,7 +4516,7 @@ static size_t read_uncompressed_header(AV1Decoder *pbi, aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM, "Invalid frame sync code"); - read_bitdepth_colorspace_sampling(cm, rb); + read_bitdepth_colorspace_sampling(cm, rb, pbi->allow_lowbitdepth); pbi->refresh_frame_flags = aom_rb_read_literal(rb, REF_FRAMES); setup_frame_size(cm, rb); diff --git a/av1/decoder/decoder.h b/av1/decoder/decoder.h index 139fde1c0..e5342b3ca 100644 --- a/av1/decoder/decoder.h +++ b/av1/decoder/decoder.h @@ -122,6 +122,7 @@ typedef struct AV1Decoder { aom_decrypt_cb decrypt_cb; void *decrypt_state; + int allow_lowbitdepth; int max_threads; int inv_tile_order; int need_resync; // wait for key/intra-only frame. diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc index 77a2c0cf9..ec168e969 100644 --- a/test/encode_test_driver.cc +++ b/test/encode_test_driver.cc @@ -210,6 +210,7 @@ void EncoderTest::MismatchHook(const aom_image_t *img_enc, void EncoderTest::RunLoop(VideoSource *video) { aom_codec_dec_cfg_t dec_cfg = aom_codec_dec_cfg_t(); + dec_cfg.allow_lowbitdepth = 1; stats_.Reset(); -- GitLab