Commit 22171319 authored by David Barker's avatar David Barker Committed by Debargha Mukherjee
Browse files

superres + frame-size: Fix experiment combination

The current code has two issues with this combination:
i) The frame_size_override_flag was being set based on the downscaled
   frame size rather than the upscaled frame size
ii) This flag was then being ignored in write_frame_size(), and we
    would always write a 16-bit size, even if the flag was 0.
    This lead to an encode/decode mismatch.

This patch fixes these two issues, and rewrites write_frame_size()
to be much clearer and more closely match setup_frame_size() from
the decoder.

Change-Id: Id6b8e51ef10f3285f8318e4acd8606060f29e9cb
parent 1ee07323
...@@ -3298,30 +3298,36 @@ static void write_superres_scale(const AV1_COMMON *const cm, ...@@ -3298,30 +3298,36 @@ static void write_superres_scale(const AV1_COMMON *const cm,
#if CONFIG_FRAME_SIZE #if CONFIG_FRAME_SIZE
static void write_frame_size(const AV1_COMMON *cm, int frame_size_override, static void write_frame_size(const AV1_COMMON *cm, int frame_size_override,
struct aom_write_bit_buffer *wb) { struct aom_write_bit_buffer *wb)
#else #else
static void write_frame_size(const AV1_COMMON *cm, static void write_frame_size(const AV1_COMMON *cm,
struct aom_write_bit_buffer *wb) { struct aom_write_bit_buffer *wb)
#endif #endif
{
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
(void)frame_size_override; const int coded_width = cm->superres_upscaled_width - 1;
aom_wb_write_literal(wb, cm->superres_upscaled_width - 1, 16); const int coded_height = cm->superres_upscaled_height - 1;
aom_wb_write_literal(wb, cm->superres_upscaled_height - 1, 16);
write_superres_scale(cm, wb);
#else #else
const int coded_width = cm->width - 1;
const int coded_height = cm->height - 1;
#endif
#if CONFIG_FRAME_SIZE #if CONFIG_FRAME_SIZE
if (frame_size_override) { if (frame_size_override) {
const SequenceHeader *seq_params = &cm->seq_params; const SequenceHeader *seq_params = &cm->seq_params;
int num_bits_width = seq_params->num_bits_width; int num_bits_width = seq_params->num_bits_width;
int num_bits_height = seq_params->num_bits_height; int num_bits_height = seq_params->num_bits_height;
aom_wb_write_literal(wb, cm->width - 1, num_bits_width); aom_wb_write_literal(wb, coded_width, num_bits_width);
aom_wb_write_literal(wb, cm->height - 1, num_bits_height); aom_wb_write_literal(wb, coded_height, num_bits_height);
} }
#else #else
aom_wb_write_literal(wb, cm->width - 1, 16); aom_wb_write_literal(wb, coded_width, 16);
aom_wb_write_literal(wb, cm->height - 1, 16); aom_wb_write_literal(wb, coded_height, 16);
#endif
#if CONFIG_FRAME_SUPERRES
write_superres_scale(cm, wb);
#endif #endif
#endif // CONFIG_FRAME_SUPERRES
write_render_size(cm, wb); write_render_size(cm, wb);
} }
...@@ -3651,9 +3657,16 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi, ...@@ -3651,9 +3657,16 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM, aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
"Frame dimensions are larger than the maximum values"); "Frame dimensions are larger than the maximum values");
} }
#if CONFIG_FRAME_SUPERRES
const int coded_width = cm->superres_upscaled_width;
const int coded_height = cm->superres_upscaled_height;
#else
const int coded_width = cm->width;
const int coded_height = cm->height;
#endif
int frame_size_override_flag = int frame_size_override_flag =
(cm->width != cm->seq_params.max_frame_width || (coded_width != cm->seq_params.max_frame_width ||
cm->height != cm->seq_params.max_frame_height); coded_height != cm->seq_params.max_frame_height);
aom_wb_write_bit(wb, frame_size_override_flag); aom_wb_write_bit(wb, frame_size_override_flag);
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment