Commit 94ad3707 authored by Urvang Joshi's avatar Urvang Joshi

Merge FRAME_SUPERRES into HORZONLY_FRAME_SUPERRES.

Change-Id: I5fc45fa9fe6a354ae34001f48850eb68364a5a79
parent a0bba1b2
......@@ -303,7 +303,7 @@ static const arg_def_t resize_denominator =
ARG_DEF(NULL, "resize-denominator", 1, "Frame resize denominator");
static const arg_def_t resize_kf_denominator = ARG_DEF(
NULL, "resize-kf-denominator", 1, "Frame resize keyframe denominator");
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
static const arg_def_t superres_mode =
ARG_DEF(NULL, "superres-mode", 1, "Frame super-resolution mode");
static const arg_def_t superres_denominator = ARG_DEF(
......@@ -316,7 +316,7 @@ static const arg_def_t superres_qthresh = ARG_DEF(
static const arg_def_t superres_kf_qthresh =
ARG_DEF(NULL, "superres-kf-qthresh", 1,
"Frame super-resolution keyframe qindex threshold");
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
static const struct arg_enum_list end_usage_enum[] = { { "vbr", AOM_VBR },
{ "cbr", AOM_CBR },
{ "cq", AOM_CQ },
......@@ -344,13 +344,13 @@ static const arg_def_t *rc_args[] = { &dropframe_thresh,
&resize_mode,
&resize_denominator,
&resize_kf_denominator,
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
&superres_mode,
&superres_denominator,
&superres_kf_denominator,
&superres_qthresh,
&superres_kf_qthresh,
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
&end_usage,
&target_bitrate,
&min_quantizer,
......@@ -1119,7 +1119,7 @@ static int parse_stream_params(struct AvxEncoderConfig *global,
config->cfg.rc_resize_denominator = arg_parse_uint(&arg);
} else if (arg_match(&arg, &resize_kf_denominator, argi)) {
config->cfg.rc_resize_kf_denominator = arg_parse_uint(&arg);
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
} else if (arg_match(&arg, &superres_mode, argi)) {
config->cfg.rc_superres_mode = arg_parse_uint(&arg);
} else if (arg_match(&arg, &superres_denominator, argi)) {
......@@ -1130,7 +1130,7 @@ static int parse_stream_params(struct AvxEncoderConfig *global,
config->cfg.rc_superres_qthresh = arg_parse_uint(&arg);
} else if (arg_match(&arg, &superres_kf_qthresh, argi)) {
config->cfg.rc_superres_kf_qthresh = arg_parse_uint(&arg);
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
} else if (arg_match(&arg, &end_usage, argi)) {
config->cfg.rc_end_usage = arg_parse_enum_or_int(&arg);
} else if (arg_match(&arg, &target_bitrate, argi)) {
......@@ -1346,13 +1346,13 @@ static void show_stream_config(struct stream_state *stream,
SHOW(rc_resize_mode);
SHOW(rc_resize_denominator);
SHOW(rc_resize_kf_denominator);
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
SHOW(rc_superres_mode);
SHOW(rc_superres_denominator);
SHOW(rc_superres_kf_denominator);
SHOW(rc_superres_qthresh);
SHOW(rc_superres_kf_qthresh);
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
SHOW(rc_end_usage);
SHOW(rc_target_bitrate);
SHOW(rc_min_quantizer);
......
......@@ -253,7 +253,7 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
SCALE_NUMERATOR << 1);
RANGE_CHECK(cfg, rc_resize_kf_denominator, SCALE_NUMERATOR,
SCALE_NUMERATOR << 1);
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
RANGE_CHECK_HI(cfg, rc_superres_mode, SUPERRES_MODES - 1);
RANGE_CHECK(cfg, rc_superres_denominator, SCALE_NUMERATOR,
SCALE_NUMERATOR << 1);
......@@ -261,7 +261,7 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
SCALE_NUMERATOR << 1);
RANGE_CHECK(cfg, rc_superres_qthresh, 1, 63);
RANGE_CHECK(cfg, rc_superres_kf_qthresh, 1, 63);
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
// AV1 does not support a lower bound on the keyframe interval in
// automatic keyframe placement mode.
......@@ -534,7 +534,7 @@ static aom_codec_err_t set_encoder_config(
oxcf->resize_kf_scale_denominator == SCALE_NUMERATOR)
oxcf->resize_mode = RESIZE_NONE;
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
oxcf->superres_mode = (SUPERRES_MODE)cfg->rc_superres_mode;
oxcf->superres_scale_denominator = (uint8_t)cfg->rc_superres_denominator;
oxcf->superres_kf_scale_denominator =
......@@ -553,7 +553,7 @@ static aom_codec_err_t set_encoder_config(
if (oxcf->superres_mode == SUPERRES_QTHRESH &&
oxcf->superres_qthresh == 255 && oxcf->superres_kf_qthresh == 255)
oxcf->superres_mode = SUPERRES_NONE;
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
oxcf->maximum_buffer_size_ms = is_vbr ? 240000 : cfg->rc_buf_sz;
oxcf->starting_buffer_level_ms = is_vbr ? 60000 : cfg->rc_buf_initial_sz;
......
......@@ -141,11 +141,11 @@ void av1_alloc_restoration_buffers(AV1_COMMON *cm) {
// Now we need to allocate enough space to store the line buffers for the
// stripes
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
const int frame_w = cm->superres_upscaled_width;
#else
const int frame_w = cm->width;
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_HIGHBITDEPTH
const int use_highbd = cm->use_highbitdepth ? 1 : 0;
#else
......
......@@ -58,7 +58,7 @@ specialize qw/av1_convolve_horiz ssse3/;
add_proto qw/void av1_convolve_vert/, "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const InterpFilterParams fp, const int subpel_x_q4, int x_step_q4, ConvolveParams *conv_params";
specialize qw/av1_convolve_vert ssse3/;
if (aom_config("CONFIG_FRAME_SUPERRES") eq "yes") {
if (aom_config("CONFIG_HORZONLY_FRAME_SUPERRES") eq "yes") {
add_proto qw/void av1_convolve_horiz_rs/, "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, const int16_t *x_filters, int interp_taps, const int x0_qn, const int x_step_qn";
if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
add_proto qw/void av1_highbd_convolve_horiz_rs/, "const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, const int16_t *x_filters, int interp_taps, const int x0_qn, const int x_step_qn, int bd";
......
......@@ -25,7 +25,7 @@
#define MAX_BLOCK_HEIGHT (MAX_SB_SIZE)
#define MAX_STEP (32)
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
#define UPSCALE_PROC_UNIT 64 // Source step (roughly)
#define UPSCALE_PROC_UNIT_SCALE (UPSCALE_PROC_UNIT / SCALE_NUMERATOR)
......@@ -77,7 +77,7 @@ void av1_highbd_convolve_horiz_rs_c(const uint16_t *src, int src_stride,
}
}
#endif // CONFIG_HIGHBITDEPTH
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
void av1_convolve_horiz_c(const uint8_t *src, int src_stride, uint8_t *dst,
int dst_stride, int w, int h,
......
......@@ -693,10 +693,10 @@ typedef enum ATTRIBUTE_PACKED {
} RestorationType;
#endif // CONFIG_LOOP_RESTORATION
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
#define SUPERRES_SCALE_BITS 3
#define SUPERRES_SCALE_DENOMINATOR_MIN (SCALE_NUMERATOR + 1)
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#ifdef __cplusplus
} // extern "C"
......
......@@ -404,12 +404,12 @@ typedef struct AV1Common {
InterpFilter interp_filter;
loop_filter_info_n lf_info;
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
// The denominator of the superres scale; the numerator is fixed.
uint8_t superres_scale_denominator;
int superres_upscaled_width;
int superres_upscaled_height;
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_LOOP_RESTORATION
RestorationInfo rst_info[MAX_MB_PLANE];
......
This diff is collapsed.
......@@ -71,7 +71,7 @@ void av1_resize_and_extend_frame(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst);
#endif // CONFIG_HIGHBITDEPTH
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_HIGHBITDEPTH
void av1_upscale_normative_and_extend_frame(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst,
......@@ -81,7 +81,7 @@ void av1_upscale_normative_and_extend_frame(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst,
int superres_denom);
#endif // CONFIG_HIGHBITDEPTH
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled,
......@@ -91,7 +91,7 @@ YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
// resize scale denominator.
void av1_calculate_scaled_size(int *width, int *height, int resize_denom);
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
// Similar to above, but calculates scaled dimensions after superres from the
// given original dimensions and superres scale denominator.
void av1_calculate_scaled_superres_size(int *width, int *height,
......@@ -108,20 +108,16 @@ void av1_superres_upscale(AV1_COMMON *cm, BufferPool *const pool);
static INLINE int av1_superres_unscaled(const AV1_COMMON *cm) {
return (cm->superres_scale_denominator == SCALE_NUMERATOR);
}
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_FRAME_SUPERRES && CONFIG_LOOP_RESTORATION
#if CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES && CONFIG_LOOP_RESTORATION
#define UPSCALE_NORMATIVE_TAPS 8
#else
#define UPSCALE_NORMATIVE_TAPS 6
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
extern const int16_t av1_resize_filter_normative[1 << RS_SUBPEL_BITS]
[UPSCALE_NORMATIVE_TAPS];
int32_t av1_get_upscale_convolve_step(int in_length, int out_length);
#endif
#endif // CONFIG_HORZONLY_FRAME_SUPERRES && CONFIG_LOOP_RESTORATION
#ifdef __cplusplus
} // extern "C"
......
......@@ -17,7 +17,7 @@
#include "./aom_scale_rtcd.h"
#include "aom_mem/aom_mem.h"
#include "av1/common/onyxc_int.h"
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
#include "av1/common/resize.h"
#endif
#include "av1/common/restoration.h"
......@@ -1616,7 +1616,7 @@ int av1_loop_restoration_corners_in_sb(const struct AV1Common *cm, int plane,
const int mi_size_x = MI_SIZE >> ss_x;
const int mi_size_y = MI_SIZE >> ss_y;
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
// Write m for the relative mi column or row, D for the superres denominator
// and N for the superres numerator. If u is the upscaled (called "unscaled"
// elsewhere) pixel offset then we can write the downscaled pixel offset in
......@@ -1626,17 +1626,15 @@ int av1_loop_restoration_corners_in_sb(const struct AV1Common *cm, int plane,
//
// from which we get u = D * MI_SIZE * m / N
const int mi_to_num_x = mi_size_x * cm->superres_scale_denominator;
const int mi_to_num_y =
mi_size_y *
(CONFIG_HORZONLY_FRAME_SUPERRES ? 1 : cm->superres_scale_denominator);
const int mi_to_num_y = mi_size_y;
const int denom_x = size * SCALE_NUMERATOR;
const int denom_y = CONFIG_HORZONLY_FRAME_SUPERRES ? size : denom_x;
const int denom_y = size;
#else
const int mi_to_num_x = mi_size_x;
const int mi_to_num_y = mi_size_y;
const int denom_x = size;
const int denom_y = size;
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
const int rnd_x = denom_x - 1;
const int rnd_y = denom_y - 1;
......@@ -1707,7 +1705,7 @@ static void save_deblock_boundary_lines(
assert(row + RESTORATION_CTX_VERT <= src_height);
#endif // NDEBUG
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
const int ss_x = is_uv && cm->subsampling_x;
const int upscaled_width = (cm->superres_upscaled_width + ss_x) >> ss_x;
const int step = av1_get_upscale_convolve_step(src_width, upscaled_width);
......@@ -1731,7 +1729,7 @@ static void save_deblock_boundary_lines(
for (int i = 0; i < RESTORATION_CTX_VERT; i++) {
memcpy(bdry_rows + i * bdry_stride, src_rows + i * src_stride, line_bytes);
}
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
extend_lines(bdry_rows, upscaled_width, RESTORATION_CTX_VERT, bdry_stride,
RESTORATION_EXTRA_HORZ, use_highbd);
}
......@@ -1751,7 +1749,7 @@ static void save_cdef_boundary_lines(const YV12_BUFFER_CONFIG *frame,
const int bdry_stride = boundaries->stripe_boundary_stride << use_highbd;
uint8_t *bdry_rows = bdry_start + RESTORATION_CTX_VERT * stripe * bdry_stride;
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
// At the point where this function is called, we've already applied
// superres. So we don't need to extend the lines here, we can just
// pull directly from the topmost row of the upscaled frame.
......@@ -1761,7 +1759,7 @@ static void save_cdef_boundary_lines(const YV12_BUFFER_CONFIG *frame,
(void)cm;
const int src_width = frame->crop_widths[is_uv];
const int upscaled_width = src_width;
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
const int line_bytes = upscaled_width << use_highbd;
for (int i = 0; i < RESTORATION_CTX_VERT; i++) {
// Copy the line at 'row' into both context lines. This is because
......
......@@ -11,9 +11,9 @@
#include "av1/common/tile_common.h"
#include "av1/common/onyxc_int.h"
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
#include "av1/common/resize.h"
#endif
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#include "aom_dsp/aom_dsp_common.h"
#if CONFIG_DEPENDENT_HORZTILES
......@@ -252,7 +252,7 @@ AV1PixelRect av1_get_tile_rect(const TileInfo *tile_info, const AV1_COMMON *cm,
r.top = (tile_info->mi_row_start * MI_SIZE + ss_y) >> ss_y;
r.bottom = (tile_info->mi_row_end * MI_SIZE + ss_y) >> ss_y;
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
// If upscaling is enabled, the tile limits need scaling to match the
// upscaled frame where the restoration tiles live. To do this, scale up the
// top-left and bottom-right of the tile.
......@@ -268,7 +268,7 @@ AV1PixelRect av1_get_tile_rect(const TileInfo *tile_info, const AV1_COMMON *cm,
#else
const int frame_w = cm->width;
const int frame_h = cm->height;
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
const int plane_w = (frame_w + ss_x) >> ss_x;
const int plane_h = (frame_h + ss_y) >> ss_y;
......
......@@ -48,9 +48,9 @@
#include "av1/common/quant_common.h"
#include "av1/common/reconinter.h"
#include "av1/common/reconintra.h"
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
#include "av1/common/resize.h"
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#include "av1/common/seg_common.h"
#include "av1/common/thread_common.h"
#include "av1/common/tile_common.h"
......@@ -1234,13 +1234,13 @@ static InterpFilter read_frame_interp_filter(struct aom_read_bit_buffer *rb) {
}
static void setup_render_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
cm->render_width = cm->superres_upscaled_width;
cm->render_height = cm->superres_upscaled_height;
#else
cm->render_width = cm->width;
cm->render_height = cm->height;
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
if (aom_rb_read_bit(rb))
#if CONFIG_FRAME_SIZE
av1_read_frame_size(rb, 16, 16, &cm->render_width, &cm->render_height);
......@@ -1249,7 +1249,7 @@ static void setup_render_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
#endif
}
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
// TODO(afergs): make "struct aom_read_bit_buffer *const rb"?
static void setup_superres(AV1_COMMON *const cm, struct aom_read_bit_buffer *rb,
int *width, int *height) {
......@@ -1268,7 +1268,7 @@ static void setup_superres(AV1_COMMON *const cm, struct aom_read_bit_buffer *rb,
cm->superres_scale_denominator = SCALE_NUMERATOR;
}
}
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_SEGMENT_PRED_LAST
static void resize_segmap_buffer(AV1_COMMON *cm) {
aom_free(cm->cur_frame->seg_map);
......@@ -1342,9 +1342,9 @@ static void setup_frame_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
#else
av1_read_frame_size(rb, &width, &height);
#endif
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
setup_superres(cm, rb, &width, &height);
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
resize_context_buffers(cm, width, height);
setup_render_size(cm, rb);
......@@ -1409,9 +1409,9 @@ static void setup_frame_size_with_refs(AV1_COMMON *cm,
height = buf->y_crop_height;
cm->render_width = buf->render_width;
cm->render_height = buf->render_height;
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
setup_superres(cm, rb, &width, &height);
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
resize_context_buffers(cm, width, height);
found = 1;
break;
......@@ -1426,9 +1426,9 @@ static void setup_frame_size_with_refs(AV1_COMMON *cm,
#else
av1_read_frame_size(rb, &width, &height);
#endif
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
setup_superres(cm, rb, &width, &height);
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
resize_context_buffers(cm, width, height);
setup_render_size(cm, rb);
}
......@@ -3138,13 +3138,13 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
}
#else
cm->use_prev_frame_mvs = !cm->error_resilient_mode && cm->prev_frame &&
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
cm->width == cm->last_width &&
cm->height == cm->last_height &&
#else
cm->width == cm->prev_frame->buf.y_crop_width &&
cm->height == cm->prev_frame->buf.y_crop_height &&
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
!cm->last_intra_only && cm->last_show_frame &&
(cm->last_frame_type != KEY_FRAME);
#endif // CONFIG_TEMPMV_SIGNALING
......@@ -3265,7 +3265,7 @@ static void make_update_tile_list_dec(AV1Decoder *pbi, int start_tile,
ec_ctxs[i - start_tile] = &pbi->tile_data[i].tctx;
}
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
void superres_post_decode(AV1Decoder *pbi) {
AV1_COMMON *const cm = &pbi->common;
BufferPool *const pool = cm->buffer_pool;
......@@ -3276,7 +3276,7 @@ void superres_post_decode(AV1Decoder *pbi) {
av1_superres_upscale(cm, pool);
unlock_buffer_pool(pool);
}
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
static void dec_setup_frame_boundary_info(AV1_COMMON *const cm) {
// Note: When LOOPFILTERING_ACROSS_TILES is enabled, we need to clear the
......@@ -3394,13 +3394,13 @@ size_t av1_decode_frame_headers_and_setup(AV1Decoder *pbi, const uint8_t *data,
}
#else
cm->use_prev_frame_mvs = !cm->error_resilient_mode && cm->prev_frame &&
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
cm->width == cm->last_width &&
cm->height == cm->last_height &&
#else
cm->width == cm->prev_frame->buf.y_crop_width &&
cm->height == cm->prev_frame->buf.y_crop_height &&
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
!cm->last_intra_only && cm->last_show_frame &&
(cm->last_frame_type != KEY_FRAME);
#endif // CONFIG_TEMPMV_SIGNALING
......@@ -3533,15 +3533,15 @@ void av1_decode_tg_tiles_and_wrapup(AV1Decoder *pbi, const uint8_t *data,
}
#if CONFIG_STRIPED_LOOP_RESTORATION
#if CONFIG_FRAME_SUPERRES && CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
if (!av1_superres_unscaled(cm)) aom_extend_frame_borders(&pbi->cur_buf->buf);
#endif
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
if (cm->rst_info[0].frame_restoration_type != RESTORE_NONE ||
cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
cm->rst_info[2].frame_restoration_type != RESTORE_NONE) {
av1_loop_restoration_save_boundary_lines(&pbi->cur_buf->buf, cm, 0);
}
#endif
#endif // CONFIG_STRIPED_LOOP_RESTORATION
if (!cm->skip_loop_filter &&
#if CONFIG_INTRABC
......@@ -3552,9 +3552,9 @@ void av1_decode_tg_tiles_and_wrapup(AV1Decoder *pbi, const uint8_t *data,
av1_cdef_frame(&pbi->cur_buf->buf, cm, &pbi->mb);
}
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
superres_post_decode(pbi);
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_LOOP_RESTORATION
if (cm->rst_info[0].frame_restoration_type != RESTORE_NONE ||
......
......@@ -3356,7 +3356,7 @@ static void write_render_size(const AV1_COMMON *cm,
}
}
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
static void write_superres_scale(const AV1_COMMON *const cm,
struct aom_write_bit_buffer *wb) {
// First bit is whether to to scale or not
......@@ -3372,7 +3372,7 @@ static void write_superres_scale(const AV1_COMMON *const cm,
SUPERRES_SCALE_BITS);
}
}
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_FRAME_SIZE
static void write_frame_size(const AV1_COMMON *cm, int frame_size_override,
......@@ -3382,13 +3382,13 @@ static void write_frame_size(const AV1_COMMON *cm,
struct aom_write_bit_buffer *wb)
#endif
{
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
const int coded_width = cm->superres_upscaled_width - 1;
const int coded_height = cm->superres_upscaled_height - 1;
#else
const int coded_width = cm->width - 1;
const int coded_height = cm->height - 1;
#endif
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_FRAME_SIZE
if (frame_size_override) {
......@@ -3403,9 +3403,9 @@ static void write_frame_size(const AV1_COMMON *cm,
aom_wb_write_literal(wb, coded_height, 16);
#endif
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
write_superres_scale(cm, wb);
#endif
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
write_render_size(cm, wb);
}
......@@ -3419,21 +3419,21 @@ static void write_frame_size_with_refs(AV1_COMP *cpi,
YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, ref_frame);
if (cfg != NULL) {
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
found = cm->superres_upscaled_width == cfg->y_crop_width &&
cm->superres_upscaled_height == cfg->y_crop_height;
#else
found =
cm->width == cfg->y_crop_width && cm->height == cfg->y_crop_height;
#endif
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
found &= cm->render_width == cfg->render_width &&
cm->render_height == cfg->render_height;
}
aom_wb_write_bit(wb, found);
if (found) {
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
write_superres_scale(cm, wb);
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
break;
}
}
......@@ -3739,13 +3739,13 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
"Frame dimensions are larger than the maximum values");
}
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_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
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
int frame_size_override_flag =
(coded_width != cm->seq_params.max_frame_width ||
coded_height != cm->seq_params.max_frame_height);
......
......@@ -3995,13 +3995,13 @@ static void encode_frame_internal(AV1_COMP *cpi) {
#else
if (cm->prev_frame) {
cm->use_prev_frame_mvs = !cm->error_resilient_mode &&
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
cm->width == cm->last_width &&
cm->height == cm->last_height &&
#else
cm->width == cm->prev_frame->buf.y_crop_width &&
cm->height == cm->prev_frame->buf.y_crop_height &&
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
!cm->intra_only && cm->last_show_frame;
} else {
cm->use_prev_frame_mvs = 0;
......
......@@ -789,11 +789,11 @@ static void alloc_util_frame_buffers(AV1_COMP *cpi) {
#if CONFIG_LOOP_RESTORATION
if (aom_realloc_frame_buffer(
&cpi->trial_frame_rst,
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
cm->superres_upscaled_width, cm->superres_upscaled_height,
#else
cm->width, cm->height,
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
cm->subsampling_x, cm->subsampling_y,
#if CONFIG_HIGHBITDEPTH
cm->use_highbitdepth,
......@@ -3150,11 +3150,11 @@ AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
#endif
av1_loop_filter_init(cm);
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
cm->superres_scale_denominator = SCALE_NUMERATOR;
cm->superres_upscaled_width = oxcf->width;
cm->superres_upscaled_height = oxcf->height;
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_LOOP_RESTORATION
av1_loop_restoration_precal();
#endif // CONFIG_LOOP_RESTORATION
......@@ -4366,13 +4366,13 @@ static void set_frame_size(AV1_COMP *cpi, int width, int height) {
"Failed to allocate frame buffer");
#if CONFIG_LOOP_RESTORATION
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
const int frame_width = cm->superres_upscaled_width;
const int frame_height = cm->superres_upscaled_height;
#else
const int frame_width = cm->width;
const int frame_height = cm->height;
#endif
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
set_restoration_unit_size(frame_width, frame_height, cm->subsampling_x,
cm->subsampling_y, cm->rst_info);
for (int i = 0; i < MAX_MB_PLANE; ++i)
......@@ -4442,7 +4442,7 @@ static uint8_t calculate_next_resize_scale(const AV1_COMP *cpi) {
return new_denom;
}
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
static uint8_t calculate_next_superres_scale(AV1_COMP *cpi) {
// Choose an arbitrary random number
......@@ -4486,9 +4486,9 @@ static int dimension_is_ok(int orig_dim, int resized_dim, int denom) {
}
static int dimensions_are_ok(int owidth, int oheight, size_params_type *rsz) {
return dimension_is_ok(owidth, rsz->resize_width, rsz->superres_denom) &&
(CONFIG_HORZONLY_FRAME_SUPERRES ||
dimension_is_ok(oheight, rsz->resize_height, rsz->superres_denom));
// Only need to check the width, as scaling is horizontal only.
(void)oheight;
return dimension_is_ok(owidth, rsz->resize_width, rsz->superres_denom);
}
static int validate_size_scales(RESIZE_MODE resize_mode,
......@@ -4546,7 +4546,7 @@ static int validate_size_scales(RESIZE_MODE resize_mode,
}
return dimensions_are_ok(owidth, oheight, rsz);
}
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
// Calculates resize and superres params for next frame
size_params_type av1_calculate_next_size_params(AV1_COMP *cpi) {
......@@ -4554,9 +4554,9 @@ size_params_type av1_calculate_next_size_params(AV1_COMP *cpi) {
size_params_type rsz = {
oxcf->width,
oxcf->height,
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
SCALE_NUMERATOR
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
};
int resize_denom;
if (oxcf->pass == 1) return rsz;
......@@ -4571,12 +4571,12 @@ size_params_type av1_calculate_next_size_params(AV1_COMP *cpi) {
av1_calculate_scaled_size(&rsz.resize_width, &rsz.resize_height,
resize_denom);
}
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
rsz.superres_denom = calculate_next_superres_scale(cpi);
if (!validate_size_scales(oxcf->resize_mode, oxcf->superres_mode, oxcf->width,
oxcf->height, &rsz))
assert(0 && "Invalid scale parameters");
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
return rsz;
}
......@@ -4584,14 +4584,14 @@ static void setup_frame_size_from_params(AV1_COMP *cpi, size_params_type *rsz) {
int encode_width = rsz->resize_width;
int encode_height = rsz->resize_height;
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
AV1_COMMON *cm = &cpi->common;
cm->superres_upscaled_width = encode_width;
cm->superres_upscaled_height = encode_height;
cm->superres_scale_denominator = rsz->superres_denom;
av1_calculate_scaled_superres_size(&encode_width, &encode_height,
rsz->superres_denom);
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
set_frame_size(cpi, encode_width, encode_height);
}
......@@ -4600,7 +4600,7 @@ static void setup_frame_size(AV1_COMP *cpi) {
setup_frame_size_from_params(cpi, &rsz);
}
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
static void superres_post_encode(AV1_COMP *cpi) {
AV1_COMMON *cm = &cpi->common;
......@@ -4639,7 +4639,7 @@ static void superres_post_encode(AV1_COMP *cpi) {
cpi->source = &cpi->scaled_source;
}
}
#endif // CONFIG_FRAME_SUPERRES
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
MACROBLOCKD *xd = &cpi->td.mb.e_mbd;
......@@ -4728,12 +4728,12 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
}
#if CONFIG_STRIPED_LOOP_RESTORATION
#if CONFIG_FRAME_SUPERRES && CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
if (!av1_superres_unscaled(cm)) aom_extend_frame_borders(cm->frame_to_show);
#endif
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
if (!no_restoration)
av1_loop_restoration_save_boundary_lines(cm->frame_to_show, cm, 0);
#endif
#endif // CONFIG_STRIPED_LOOP_RESTORATION
if (no_cdef) {
cm->cdef_bits = 0;
......@@ -4749,9 +4749,9 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
av1_cdef_frame(cm->frame_to_show, cm, xd);
}
#if CONFIG_FRAME_SUPERRES
#if CONFIG_HORZONLY_FRAME_SUPERRES
superres_post_encode(cpi);