Commit 846d67dd authored by Fergus Simpson's avatar Fergus Simpson

frame_superres: Send scale every frame

The superres scale was accidentally only sent if the current frame was
a key frame or if the current resolution was not used by any of the
reference frames. This patch separates the superres scale from the
current resolution to simplify its coding and makes sure that it is
written for every frame.

Change-Id: I419912c833cdc9670fc5a8ea1d67393d72ce402d
parent 02c79741
......@@ -2778,25 +2778,12 @@ static void setup_render_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
#if CONFIG_FRAME_SUPERRES
// TODO(afergs): make "struct aom_read_bit_buffer *const rb"?
static void setup_superres_size(AV1_COMMON *const cm,
struct aom_read_bit_buffer *rb, int *width,
int *height) {
cm->superres_width = cm->width;
cm->superres_height = cm->height;
static void setup_superres_scale(AV1_COMMON *const cm,
struct aom_read_bit_buffer *rb) {
if (aom_rb_read_bit(rb)) {
cm->superres_scale_numerator =
(uint8_t)aom_rb_read_literal(rb, SUPERRES_SCALE_BITS);
cm->superres_scale_numerator += SUPERRES_SCALE_NUMERATOR_MIN;
// Don't edit cm->width or cm->height directly, or the buffers won't get
// resized correctly
// TODO(afergs): Should the render resolution not be modified? It's the same
// by default (ie. when it isn't sent)...
// resize_context_buffers() will change cm->width to equal cm->render_width,
// then they'll be the same again
*width =
cm->width * cm->superres_scale_numerator / SUPERRES_SCALE_DENOMINATOR;
*height =
cm->height * cm->superres_scale_numerator / SUPERRES_SCALE_DENOMINATOR;
} else {
// 1:1 scaling - ie. no scaling, scale not provided
cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR;
......@@ -2849,11 +2836,8 @@ static void setup_frame_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
int width, height;
BufferPool *const pool = cm->buffer_pool;
av1_read_frame_size(rb, &width, &height);
setup_render_size(cm, rb);
#if CONFIG_FRAME_SUPERRES
setup_superres_size(cm, rb, &width, &height);
#endif // CONFIG_FRAME_SUPERRES
resize_context_buffers(cm, width, height);
setup_render_size(cm, rb);
lock_buffer_pool(pool);
if (aom_realloc_frame_buffer(
......@@ -4301,6 +4285,9 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
set_sb_size(cm, BLOCK_64X64);
#endif // CONFIG_EXT_PARTITION
#if CONFIG_FRAME_SUPERRES
setup_superres_scale(cm, rb);
#endif // CONFIG_FRAME_SUPERRES
setup_loopfilter(cm, rb);
#if CONFIG_CDEF
setup_cdef(cm, rb);
......
......@@ -4230,7 +4230,7 @@ static void write_superres_scale(const AV1_COMMON *const cm,
aom_wb_write_bit(wb, 0); // no scaling
} else {
aom_wb_write_bit(wb, 1); // scaling, write scale factor
// TODO(afergs): write factor to the compressed header instead
// TODO(afergs): write factor to the compressed header instead?
aom_wb_write_literal(
wb, cm->superres_scale_numerator - SUPERRES_SCALE_NUMERATOR_MIN,
SUPERRES_SCALE_BITS);
......@@ -4240,27 +4240,10 @@ static void write_superres_scale(const AV1_COMMON *const cm,
static void write_frame_size(const AV1_COMMON *cm,
struct aom_write_bit_buffer *wb) {
#if CONFIG_FRAME_SUPERRES
// If SUPERRES scaling is happening, write the full resolution instead of the
// downscaled resolution. The decoder will reduce this resolution itself.
if (cm->superres_scale_numerator != SUPERRES_SCALE_DENOMINATOR) {
aom_wb_write_literal(wb, cm->superres_width - 1, 16);
aom_wb_write_literal(wb, cm->superres_height - 1, 16);
} else {
#endif // CONFIG_FRAME_SUPERRES
aom_wb_write_literal(wb, cm->width - 1, 16);
aom_wb_write_literal(wb, cm->height - 1, 16);
#if CONFIG_FRAME_SUPERRES
}
#endif // CONFIG_FRAME_SUPERRES
aom_wb_write_literal(wb, cm->width - 1, 16);
aom_wb_write_literal(wb, cm->height - 1, 16);
// TODO(afergs): Also write something different to render_size?
// When superres scales, they'll be almost guaranteed to be
// different on the other side.
write_render_size(cm, wb);
#if CONFIG_FRAME_SUPERRES
write_superres_scale(cm, wb);
#endif // CONFIG_FRAME_SUPERRES
}
static void write_frame_size_with_refs(AV1_COMP *cpi,
......@@ -4540,6 +4523,9 @@ static void write_uncompressed_header(AV1_COMP *cpi,
assert(cm->sb_size == BLOCK_64X64);
#endif // CONFIG_EXT_PARTITION
#if CONFIG_FRAME_SUPERRES
write_superres_scale(cm, wb);
#endif // CONFIG_FRAME_SUPERRES
encode_loopfilter(cm, wb);
#if CONFIG_CDEF
encode_cdef(cm, wb);
......
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