Move profile and color config to SequenceHeader.
Cherry-picked from aom/master:
https://aomedia.googlesource.com/aom/+/20cf30e6d6675769093566591c4a61187b47924b
- Firstly, as per the spec, profile and color config are part of the
sequence_header_obu(), so these variables belong in SequenceHeader
struct.
- Also, this automatically enforces the rule from the spec that, if
we encounter multiple sequence headers within a coded video sequence,
the profiles and color configs inside them are bit-exact (along with
most of other sequence header variables) through the existing
are_seq_headers_consistent() function.
ResizeCspTest was fixed to use same profile and image format for the
whole sequence.
BUG=oss-fuzz:9474
BUG=oss-fuzz:9323
BUG=aomedia:1875
Change-Id: I3bb3194fe2e85d27dc72615dbb53d2f9ba4f5fe7
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 71294cb..7a4c9aa 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -722,7 +722,7 @@
ctx->cfg = *cfg;
set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg);
// On profile change, request a key frame
- force_key |= ctx->cpi->common.profile != ctx->oxcf.profile;
+ force_key |= ctx->cpi->common.seq_params.profile != ctx->oxcf.profile;
av1_change_config(ctx->cpi, &ctx->oxcf);
}
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index b21d0d1..f425720 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -1019,7 +1019,7 @@
FrameWorkerData *const frame_worker_data =
(FrameWorkerData *)worker->data1;
const AV1_COMMON *const cm = &frame_worker_data->pbi->common;
- *bit_depth = cm->bit_depth;
+ *bit_depth = cm->seq_params.bit_depth;
return AOM_CODEC_OK;
} else {
return AOM_CODEC_ERROR;
@@ -1055,8 +1055,9 @@
(FrameWorkerData *)worker->data1;
const AV1_COMMON *const cm = &frame_worker_data->pbi->common;
- *img_fmt = get_img_format(cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth);
+ *img_fmt = get_img_format(cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_y,
+ cm->seq_params.use_highbitdepth);
return AOM_CODEC_OK;
} else {
return AOM_CODEC_ERROR;
diff --git a/av1/common/alloccommon.c b/av1/common/alloccommon.c
index 49902cc..1bf81c9 100644
--- a/av1/common/alloccommon.c
+++ b/av1/common/alloccommon.c
@@ -137,11 +137,11 @@
// Now we need to allocate enough space to store the line buffers for the
// stripes
const int frame_w = cm->superres_upscaled_width;
- const int use_highbd = cm->use_highbitdepth ? 1 : 0;
+ const int use_highbd = cm->seq_params.use_highbitdepth ? 1 : 0;
for (int p = 0; p < num_planes; ++p) {
const int is_uv = p > 0;
- const int ss_x = is_uv && cm->subsampling_x;
+ const int ss_x = is_uv && cm->seq_params.subsampling_x;
const int plane_w = ((frame_w + ss_x) >> ss_x) + 2 * RESTORATION_EXTRA_HORZ;
const int stride = ALIGN_POWER_OF_TWO(plane_w, 5);
const int buf_size = num_stripes * stride * RESTORATION_CTX_VERT
diff --git a/av1/common/av1_loopfilter.c b/av1/common/av1_loopfilter.c
index 738290f..9d68b87 100644
--- a/av1/common/av1_loopfilter.c
+++ b/av1/common/av1_loopfilter.c
@@ -1308,7 +1308,7 @@
end <<= MI_SIZE_LOG2;
uint8_t *ref0 = ref_buf;
uint8_t *dst0 = dst_buf;
- if (cm->use_highbitdepth) {
+ if (cm->seq_params.use_highbitdepth) {
const uint16_t *ref16 = CONVERT_TO_SHORTPTR(ref_buf);
const uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst_buf);
for (int j = 0; j < 4; ++j) {
@@ -1404,11 +1404,11 @@
uint64_t mask_8x8_1 = (mask_8x8 >> shift_next) & mask_cutoff;
uint64_t mask_4x4_1 = (mask_4x4 >> shift_next) & mask_cutoff;
- if (cm->use_highbitdepth)
+ if (cm->seq_params.use_highbitdepth)
highbd_filter_selectively_vert_row2(
ssx, CONVERT_TO_SHORTPTR(dst->buf), dst->stride, pl, mask_16x16_0,
mask_8x8_0, mask_4x4_0, mask_16x16_1, mask_8x8_1, mask_4x4_1,
- &cm->lf_info, lfl, lfl2, (int)cm->bit_depth);
+ &cm->lf_info, lfl, lfl2, (int)cm->seq_params.bit_depth);
else
filter_selectively_vert_row2(ssx, dst->buf, dst->stride, pl,
mask_16x16_0, mask_8x8_0, mask_4x4_0,
@@ -1474,10 +1474,11 @@
mask_8x8 = (mask_8x8 >> shift) & mask_cutoff;
mask_4x4 = (mask_4x4 >> shift) & mask_cutoff;
- if (cm->use_highbitdepth)
- highbd_filter_selectively_horiz(
- CONVERT_TO_SHORTPTR(dst->buf), dst->stride, pl, ssx, mask_16x16,
- mask_8x8, mask_4x4, &cm->lf_info, lfl, (int)cm->bit_depth);
+ if (cm->seq_params.use_highbitdepth)
+ highbd_filter_selectively_horiz(CONVERT_TO_SHORTPTR(dst->buf),
+ dst->stride, pl, ssx, mask_16x16,
+ mask_8x8, mask_4x4, &cm->lf_info, lfl,
+ (int)cm->seq_params.bit_depth);
else
filter_selectively_horiz(dst->buf, dst->stride, pl, ssx, mask_16x16,
mask_8x8, mask_4x4, &cm->lf_info, lfl);
@@ -1652,6 +1653,8 @@
const int dst_stride = plane_ptr->dst.stride;
const int y_range = (MAX_MIB_SIZE >> scale_vert);
const int x_range = (MAX_MIB_SIZE >> scale_horz);
+ const int use_highbitdepth = cm->seq_params.use_highbitdepth;
+ const aom_bit_depth_t bit_depth = cm->seq_params.bit_depth;
for (int y = 0; y < y_range; y += row_step) {
uint8_t *p = dst_ptr + y * MI_SIZE * dst_stride;
for (int x = 0; x < x_range;) {
@@ -1677,40 +1680,40 @@
switch (params.filter_length) {
// apply 4-tap filtering
case 4:
- if (cm->use_highbitdepth)
+ if (use_highbitdepth)
aom_highbd_lpf_vertical_4(CONVERT_TO_SHORTPTR(p), dst_stride,
params.mblim, params.lim, params.hev_thr,
- cm->bit_depth);
+ bit_depth);
else
aom_lpf_vertical_4(p, dst_stride, params.mblim, params.lim,
params.hev_thr);
break;
case 6: // apply 6-tap filter for chroma plane only
assert(plane != 0);
- if (cm->use_highbitdepth)
+ if (use_highbitdepth)
aom_highbd_lpf_vertical_6(CONVERT_TO_SHORTPTR(p), dst_stride,
params.mblim, params.lim, params.hev_thr,
- cm->bit_depth);
+ bit_depth);
else
aom_lpf_vertical_6(p, dst_stride, params.mblim, params.lim,
params.hev_thr);
break;
// apply 8-tap filtering
case 8:
- if (cm->use_highbitdepth)
+ if (use_highbitdepth)
aom_highbd_lpf_vertical_8(CONVERT_TO_SHORTPTR(p), dst_stride,
params.mblim, params.lim, params.hev_thr,
- cm->bit_depth);
+ bit_depth);
else
aom_lpf_vertical_8(p, dst_stride, params.mblim, params.lim,
params.hev_thr);
break;
// apply 14-tap filtering
case 14:
- if (cm->use_highbitdepth)
+ if (use_highbitdepth)
aom_highbd_lpf_vertical_14(CONVERT_TO_SHORTPTR(p), dst_stride,
params.mblim, params.lim, params.hev_thr,
- cm->bit_depth);
+ bit_depth);
else
aom_lpf_vertical_14(p, dst_stride, params.mblim, params.lim,
params.hev_thr);
@@ -1737,6 +1740,8 @@
const int dst_stride = plane_ptr->dst.stride;
const int y_range = (MAX_MIB_SIZE >> scale_vert);
const int x_range = (MAX_MIB_SIZE >> scale_horz);
+ const int use_highbitdepth = cm->seq_params.use_highbitdepth;
+ const aom_bit_depth_t bit_depth = cm->seq_params.bit_depth;
for (int x = 0; x < x_range; x += col_step) {
uint8_t *p = dst_ptr + x * MI_SIZE;
for (int y = 0; y < y_range;) {
@@ -1762,10 +1767,10 @@
switch (params.filter_length) {
// apply 4-tap filtering
case 4:
- if (cm->use_highbitdepth)
+ if (use_highbitdepth)
aom_highbd_lpf_horizontal_4(CONVERT_TO_SHORTPTR(p), dst_stride,
params.mblim, params.lim,
- params.hev_thr, cm->bit_depth);
+ params.hev_thr, bit_depth);
else
aom_lpf_horizontal_4(p, dst_stride, params.mblim, params.lim,
params.hev_thr);
@@ -1773,30 +1778,30 @@
// apply 6-tap filtering
case 6:
assert(plane != 0);
- if (cm->use_highbitdepth)
+ if (use_highbitdepth)
aom_highbd_lpf_horizontal_6(CONVERT_TO_SHORTPTR(p), dst_stride,
params.mblim, params.lim,
- params.hev_thr, cm->bit_depth);
+ params.hev_thr, bit_depth);
else
aom_lpf_horizontal_6(p, dst_stride, params.mblim, params.lim,
params.hev_thr);
break;
// apply 8-tap filtering
case 8:
- if (cm->use_highbitdepth)
+ if (use_highbitdepth)
aom_highbd_lpf_horizontal_8(CONVERT_TO_SHORTPTR(p), dst_stride,
params.mblim, params.lim,
- params.hev_thr, cm->bit_depth);
+ params.hev_thr, bit_depth);
else
aom_lpf_horizontal_8(p, dst_stride, params.mblim, params.lim,
params.hev_thr);
break;
// apply 14-tap filtering
case 14:
- if (cm->use_highbitdepth)
+ if (use_highbitdepth)
aom_highbd_lpf_horizontal_14(CONVERT_TO_SHORTPTR(p), dst_stride,
params.mblim, params.lim,
- params.hev_thr, cm->bit_depth);
+ params.hev_thr, bit_depth);
else
aom_lpf_horizontal_14(p, dst_stride, params.mblim, params.lim,
params.hev_thr);
diff --git a/av1/common/cdef.c b/av1/common/cdef.c
index c9b9749..e9e2b0e 100644
--- a/av1/common/cdef.c
+++ b/av1/common/cdef.c
@@ -110,7 +110,7 @@
static void copy_sb8_16(AOM_UNUSED AV1_COMMON *cm, uint16_t *dst, int dstride,
const uint8_t *src, int src_voffset, int src_hoffset,
int sstride, int vsize, int hsize) {
- if (cm->use_highbitdepth) {
+ if (cm->seq_params.use_highbitdepth) {
const uint16_t *base =
&CONVERT_TO_SHORTPTR(src)[src_voffset * sstride + src_hoffset];
copy_rect8_16bit_to_16bit(dst, dstride, base, sstride, vsize, hsize);
@@ -153,7 +153,7 @@
int mi_high_l2[3];
int xdec[3];
int ydec[3];
- int coeff_shift = AOMMAX(cm->bit_depth - 8, 0);
+ int coeff_shift = AOMMAX(cm->seq_params.bit_depth - 8, 0);
const int nvfb = (cm->mi_rows + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
const int nhfb = (cm->mi_cols + MI_SIZE_64X64 - 1) / MI_SIZE_64X64;
av1_setup_dst_planes(xd->plane, cm->seq_params.sb_size, frame, 0, 0, 0,
@@ -363,7 +363,7 @@
vsize + 2 * CDEF_VBORDER, CDEF_HBORDER, CDEF_VERY_LARGE);
}
- if (cm->use_highbitdepth) {
+ if (cm->seq_params.use_highbitdepth) {
cdef_filter_fb(
NULL,
&CONVERT_TO_SHORTPTR(
diff --git a/av1/common/cfl.c b/av1/common/cfl.c
index 3e46bf4..ccc59b4 100644
--- a/av1/common/cfl.c
+++ b/av1/common/cfl.c
@@ -15,14 +15,14 @@
#include "config/av1_rtcd.h"
-void cfl_init(CFL_CTX *cfl, AV1_COMMON *cm) {
+void cfl_init(CFL_CTX *cfl, const SequenceHeader *seq_params) {
assert(block_size_wide[CFL_MAX_BLOCK_SIZE] == CFL_BUF_LINE);
assert(block_size_high[CFL_MAX_BLOCK_SIZE] == CFL_BUF_LINE);
memset(&cfl->recon_buf_q3, 0, sizeof(cfl->recon_buf_q3));
memset(&cfl->ac_buf_q3, 0, sizeof(cfl->ac_buf_q3));
- cfl->subsampling_x = cm->subsampling_x;
- cfl->subsampling_y = cm->subsampling_y;
+ cfl->subsampling_x = seq_params->subsampling_x;
+ cfl->subsampling_y = seq_params->subsampling_y;
cfl->are_parameters_computed = 0;
cfl->store_y = 0;
// The DC_PRED cache is disabled by default and is only enabled in
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index f8d8e1f..32bffea 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -184,7 +184,10 @@
uint8_t minor;
} BitstreamLevel;
-/* Initial version of sequence header structure */
+// Sequence header structure.
+// Note: All syntax elements of sequence_header_obu that need to be
+// bit-identical across multiple sequence headers must be part of this struct,
+// so that consistency is checked by are_seq_headers_consistent() function.
typedef struct SequenceHeader {
int num_bits_width;
int num_bits_height;
@@ -205,7 +208,6 @@
// 2 - adaptive
int still_picture; // Video is a single frame still picture
int reduced_still_picture_hdr; // Use reduced header for still picture
- int monochrome; // Monochorme video
int enable_filter_intra; // enables/disables filterintra
int enable_intra_edge_filter; // enables/disables corner/edge/upsampling
int enable_interintra_compound; // enables/disables interintra_compound
@@ -229,6 +231,9 @@
// enabled for that frame.
int enable_cdef; // To turn on/off CDEF
int enable_restoration; // To turn on/off loop restoration
+ BITSTREAM_PROFILE profile;
+
+ // Operating point info.
int operating_points_cnt_minus_1;
int operating_point_idc[MAX_NUM_OPERATING_POINTS];
int display_model_info_present_flag;
@@ -236,15 +241,24 @@
BitstreamLevel level[MAX_NUM_OPERATING_POINTS];
uint8_t tier[MAX_NUM_OPERATING_POINTS]; // seq_tier in the spec. One bit: 0
// or 1.
+
+ // Color config.
+ aom_bit_depth_t bit_depth; // AOM_BITS_8 in profile 0 or 1,
+ // AOM_BITS_10 or AOM_BITS_12 in profile 2 or 3.
+ int use_highbitdepth; // If true, we need to use 16bit frame buffers.
+ int monochrome; // Monochorme video
+ aom_color_primaries_t color_primaries;
+ aom_transfer_characteristics_t transfer_characteristics;
+ aom_matrix_coefficients_t matrix_coefficients;
+ int color_range;
+ int subsampling_x; // Chroma subsampling for x
+ int subsampling_y; // Chroma subsampling for y
+ aom_chroma_sample_position_t chroma_sample_position;
+ int separate_uv_delta_q;
} SequenceHeader;
typedef struct AV1Common {
struct aom_internal_error_info error;
- aom_color_primaries_t color_primaries;
- aom_transfer_characteristics_t transfer_characteristics;
- aom_matrix_coefficients_t matrix_coefficients;
- aom_chroma_sample_position_t chroma_sample_position;
- int color_range;
int width;
int height;
int render_width;
@@ -259,12 +273,6 @@
aom_op_timing_info_t op_frame_timing[MAX_NUM_OPERATING_POINTS + 1];
uint32_t frame_presentation_time;
- // TODO(jkoleszar): this implies chroma ss right now, but could vary per
- // plane. Revisit as part of the future change to YV12_BUFFER_CONFIG to
- // support additional planes.
- int subsampling_x;
- int subsampling_y;
-
int largest_tile_id;
size_t largest_tile_size;
int context_update_tile_id;
@@ -272,8 +280,6 @@
// Scale of the current frame with respect to itself.
struct scale_factors sf_identity;
- // Marks if we need to use 16bit frame buffers (1: yes, 0: no).
- int use_highbitdepth;
YV12_BUFFER_CONFIG *frame_to_show;
RefCntBuffer *prev_frame;
@@ -341,8 +347,6 @@
int u_ac_delta_q;
int v_ac_delta_q;
- int separate_uv_delta_q;
-
// The dequantizers below are true dequntizers used only in the
// dequantization process. They have the same coefficient
// shift/scale as TX.
@@ -446,10 +450,7 @@
unsigned int frame_offset;
unsigned int current_video_frame;
- BITSTREAM_PROFILE profile;
- // AOM_BITS_8 in profile 0 or 1, AOM_BITS_10 or AOM_BITS_12 in profile 2 or 3.
- aom_bit_depth_t bit_depth;
aom_bit_depth_t dequant_bit_depth; // bit_depth of current dequantizer
int error_resilient_mode;
@@ -690,7 +691,7 @@
return ALIGN_POWER_OF_TWO(cm->mi_rows, cm->seq_params.mib_size_log2);
}
-void cfl_init(CFL_CTX *cfl, AV1_COMMON *cm);
+void cfl_init(CFL_CTX *cfl, const SequenceHeader *seq_params);
static INLINE int av1_num_planes(const AV1_COMMON *cm) {
return cm->seq_params.monochrome ? 1 : MAX_MB_PLANE;
@@ -733,7 +734,7 @@
}
xd->mi_stride = cm->mi_stride;
xd->error_info = &cm->error;
- cfl_init(&xd->cfl, cm);
+ cfl_init(&xd->cfl, &cm->seq_params);
}
static INLINE void set_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col,
@@ -1067,15 +1068,16 @@
static INLINE void av1_zero_above_context(AV1_COMMON *const cm, const MACROBLOCKD *xd,
int mi_col_start, int mi_col_end, const int tile_row) {
+ const SequenceHeader *const seq_params = &cm->seq_params;
const int num_planes = av1_num_planes(cm);
const int width = mi_col_end - mi_col_start;
const int aligned_width =
- ALIGN_POWER_OF_TWO(width, cm->seq_params.mib_size_log2);
+ ALIGN_POWER_OF_TWO(width, seq_params->mib_size_log2);
const int offset_y = mi_col_start;
const int width_y = aligned_width;
- const int offset_uv = offset_y >> cm->subsampling_x;
- const int width_uv = width_y >> cm->subsampling_x;
+ const int offset_uv = offset_y >> seq_params->subsampling_x;
+ const int width_uv = width_y >> seq_params->subsampling_x;
av1_zero_array(cm->above_context[0][tile_row] + offset_y, width_y);
if (num_planes > 1) {
diff --git a/av1/common/resize.c b/av1/common/resize.c
index 17e6823..93d6229 100644
--- a/av1/common/resize.c
+++ b/av1/common/resize.c
@@ -1100,7 +1100,7 @@
int src_stride, uint8_t *dst, int dst_stride,
int plane, int rows) {
const int is_uv = (plane > 0);
- const int ss_x = is_uv && cm->subsampling_x;
+ const int ss_x = is_uv && cm->seq_params.subsampling_x;
const int downscaled_plane_width = ROUND_POWER_OF_TWO(cm->width, ss_x);
const int upscaled_plane_width =
ROUND_POWER_OF_TWO(cm->superres_upscaled_width, ss_x);
@@ -1141,10 +1141,11 @@
const int pad_left = (j == 0);
const int pad_right = (j == cm->tile_cols - 1);
- if (cm->use_highbitdepth)
- highbd_upscale_normative_rect(
- src_ptr, rows, src_width, src_stride, dst_ptr, rows, dst_width,
- dst_stride, x_step_qn, x0_qn, pad_left, pad_right, cm->bit_depth);
+ if (cm->seq_params.use_highbitdepth)
+ highbd_upscale_normative_rect(src_ptr, rows, src_width, src_stride,
+ dst_ptr, rows, dst_width, dst_stride,
+ x_step_qn, x0_qn, pad_left, pad_right,
+ cm->seq_params.bit_depth);
else
upscale_normative_rect(src_ptr, rows, src_width, src_stride, dst_ptr,
rows, dst_width, dst_stride, x_step_qn, x0_qn,
@@ -1175,7 +1176,7 @@
const int num_planes = av1_num_planes(cm);
if (cm->width != unscaled->y_crop_width ||
cm->height != unscaled->y_crop_height) {
- av1_resize_and_extend_frame(unscaled, scaled, (int)cm->bit_depth,
+ av1_resize_and_extend_frame(unscaled, scaled, (int)cm->seq_params.bit_depth,
num_planes);
return scaled;
} else {
@@ -1232,6 +1233,7 @@
void av1_superres_upscale(AV1_COMMON *cm, BufferPool *const pool) {
const int num_planes = av1_num_planes(cm);
if (!av1_superres_scaled(cm)) return;
+ const SequenceHeader *const seq_params = &cm->seq_params;
YV12_BUFFER_CONFIG copy_buffer;
memset(©_buffer, 0, sizeof(copy_buffer));
@@ -1239,10 +1241,10 @@
YV12_BUFFER_CONFIG *const frame_to_show = get_frame_new_buffer(cm);
const int aligned_width = ALIGN_POWER_OF_TWO(cm->width, 3);
- if (aom_alloc_frame_buffer(©_buffer, aligned_width, cm->height,
- cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
- cm->byte_alignment))
+ if (aom_alloc_frame_buffer(
+ ©_buffer, aligned_width, cm->height, seq_params->subsampling_x,
+ seq_params->subsampling_y, seq_params->use_highbitdepth,
+ AOM_BORDER_IN_PIXELS, cm->byte_alignment))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate copy buffer for superres upscaling");
@@ -1269,11 +1271,11 @@
"Failed to free current frame buffer before superres upscaling");
// aom_realloc_frame_buffer() leaves config data for frame_to_show intact
- if (aom_realloc_frame_buffer(frame_to_show, cm->superres_upscaled_width,
- cm->superres_upscaled_height,
- cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
- cm->byte_alignment, fb, cb, cb_priv))
+ if (aom_realloc_frame_buffer(
+ frame_to_show, cm->superres_upscaled_width,
+ cm->superres_upscaled_height, seq_params->subsampling_x,
+ seq_params->subsampling_y, seq_params->use_highbitdepth,
+ AOM_BORDER_IN_PIXELS, cm->byte_alignment, fb, cb, cb_priv))
aom_internal_error(
&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate current frame buffer for superres upscaling");
@@ -1283,10 +1285,11 @@
// Don't use callbacks on the encoder.
// aom_alloc_frame_buffer() clears the config data for frame_to_show
- if (aom_alloc_frame_buffer(frame_to_show, cm->superres_upscaled_width,
- cm->superres_upscaled_height, cm->subsampling_x,
- cm->subsampling_y, cm->use_highbitdepth,
- AOM_BORDER_IN_PIXELS, cm->byte_alignment))
+ if (aom_alloc_frame_buffer(
+ frame_to_show, cm->superres_upscaled_width,
+ cm->superres_upscaled_height, seq_params->subsampling_x,
+ seq_params->subsampling_y, seq_params->use_highbitdepth,
+ AOM_BORDER_IN_PIXELS, cm->byte_alignment))
aom_internal_error(
&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to reallocate current frame buffer for superres upscaling");
diff --git a/av1/common/restoration.c b/av1/common/restoration.c
index 2972782..6329679 100644
--- a/av1/common/restoration.c
+++ b/av1/common/restoration.c
@@ -42,8 +42,8 @@
AV1PixelRect av1_whole_frame_rect(const AV1_COMMON *cm, int is_uv) {
AV1PixelRect rect;
- int ss_x = is_uv && cm->subsampling_x;
- int ss_y = is_uv && cm->subsampling_y;
+ int ss_x = is_uv && cm->seq_params.subsampling_x;
+ int ss_y = is_uv && cm->seq_params.subsampling_y;
rect.top = 0;
rect.bottom = ROUND_POWER_OF_TWO(cm->height, ss_y);
@@ -1146,16 +1146,17 @@
YV12_BUFFER_CONFIG *frame,
AV1_COMMON *cm, int optimized_lr,
int num_planes) {
- const int bit_depth = cm->bit_depth;
- const int highbd = cm->use_highbitdepth;
+ const SequenceHeader *const seq_params = &cm->seq_params;
+ const int bit_depth = seq_params->bit_depth;
+ const int highbd = seq_params->use_highbitdepth;
lr_ctxt->dst = &cm->rst_frame;
const int frame_width = frame->crop_widths[0];
const int frame_height = frame->crop_heights[0];
- if (aom_realloc_frame_buffer(lr_ctxt->dst, frame_width, frame_height,
- cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
- cm->byte_alignment, NULL, NULL, NULL) < 0)
+ if (aom_realloc_frame_buffer(
+ lr_ctxt->dst, frame_width, frame_height, seq_params->subsampling_x,
+ seq_params->subsampling_y, highbd, AOM_BORDER_IN_PIXELS,
+ cm->byte_alignment, NULL, NULL, NULL) < 0)
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate restoration dst buffer");
@@ -1180,8 +1181,8 @@
highbd);
lr_plane_ctxt->rsi = rsi;
- lr_plane_ctxt->ss_x = is_uv && cm->subsampling_x;
- lr_plane_ctxt->ss_y = is_uv && cm->subsampling_y;
+ lr_plane_ctxt->ss_x = is_uv && seq_params->subsampling_x;
+ lr_plane_ctxt->ss_y = is_uv && seq_params->subsampling_y;
lr_plane_ctxt->highbd = highbd;
lr_plane_ctxt->bit_depth = bit_depth;
lr_plane_ctxt->data8 = frame->buffers[plane];
@@ -1337,7 +1338,7 @@
int32_t *tmpbuf,
RestorationLineBuffers *rlbs) {
const int is_uv = plane > 0;
- const int ss_y = is_uv && cm->subsampling_y;
+ const int ss_y = is_uv && cm->seq_params.subsampling_y;
const RestorationInfo *rsi = &cm->rst_info[plane];
@@ -1383,8 +1384,8 @@
const int vert_units = av1_lr_count_units_in_tile(size, tile_h);
// The size of an MI-unit on this plane of the image
- const int ss_x = is_uv && cm->subsampling_x;
- const int ss_y = is_uv && cm->subsampling_y;
+ const int ss_x = is_uv && cm->seq_params.subsampling_x;
+ const int ss_y = is_uv && cm->seq_params.subsampling_y;
const int mi_size_x = MI_SIZE >> ss_x;
const int mi_size_y = MI_SIZE >> ss_y;
@@ -1465,7 +1466,7 @@
int upscaled_width;
int line_bytes;
if (av1_superres_scaled(cm)) {
- const int ss_x = is_uv && cm->subsampling_x;
+ const int ss_x = is_uv && cm->seq_params.subsampling_x;
upscaled_width = (cm->superres_upscaled_width + ss_x) >> ss_x;
line_bytes = upscaled_width << use_highbd;
if (use_highbd)
@@ -1512,7 +1513,7 @@
// 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.
- const int ss_x = is_uv && cm->subsampling_x;
+ const int ss_x = is_uv && cm->seq_params.subsampling_x;
const int upscaled_width = av1_superres_scaled(cm)
? (cm->superres_upscaled_width + ss_x) >> ss_x
: src_width;
@@ -1532,7 +1533,7 @@
int use_highbd, int plane,
AV1_COMMON *cm, int after_cdef) {
const int is_uv = plane > 0;
- const int ss_y = is_uv && cm->subsampling_y;
+ const int ss_y = is_uv && cm->seq_params.subsampling_y;
const int stripe_height = RESTORATION_PROC_UNIT_SIZE >> ss_y;
const int stripe_off = RESTORATION_UNIT_OFFSET >> ss_y;
@@ -1597,7 +1598,7 @@
void av1_loop_restoration_save_boundary_lines(const YV12_BUFFER_CONFIG *frame,
AV1_COMMON *cm, int after_cdef) {
const int num_planes = av1_num_planes(cm);
- const int use_highbd = cm->use_highbitdepth;
+ const int use_highbd = cm->seq_params.use_highbitdepth;
for (int p = 0; p < num_planes; ++p) {
save_tile_row_boundary_lines(frame, use_highbd, p, cm, after_cdef);
}
diff --git a/av1/common/thread_common.c b/av1/common/thread_common.c
index 3fa998a..f9b734b 100644
--- a/av1/common/thread_common.c
+++ b/av1/common/thread_common.c
@@ -572,7 +572,7 @@
for (int plane = 0; plane < num_planes; plane++) {
if (cm->rst_info[plane].frame_restoration_type == RESTORE_NONE) continue;
const int is_uv = plane > 0;
- const int ss_y = is_uv && cm->subsampling_y;
+ const int ss_y = is_uv && cm->seq_params.subsampling_y;
AV1PixelRect tile_rect = ctxt[plane].tile_rect;
const int unit_size = ctxt[plane].rsi->restoration_unit_size;
diff --git a/av1/common/tile_common.c b/av1/common/tile_common.c
index 9a43ab2..026c904 100644
--- a/av1/common/tile_common.c
+++ b/av1/common/tile_common.c
@@ -179,8 +179,8 @@
r.bottom = AOMMIN(r.bottom, frame_h);
// Convert to coordinates in the appropriate plane
- const int ss_x = is_uv && cm->subsampling_x;
- const int ss_y = is_uv && cm->subsampling_y;
+ const int ss_x = is_uv && cm->seq_params.subsampling_x;
+ const int ss_y = is_uv && cm->seq_params.subsampling_y;
r.left = ROUND_POWER_OF_TWO(r.left, ss_x);
r.right = ROUND_POWER_OF_TWO(r.right, ss_x);
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index d286fbc..f2e93ba 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -84,15 +84,15 @@
}
// Use only_chroma = 1 to only set the chroma planes
-static void set_planes_to_neutral_grey(AV1_COMMON *const cm,
+static void set_planes_to_neutral_grey(const SequenceHeader *const seq_params,
const YV12_BUFFER_CONFIG *const buf,
int only_chroma) {
- const int val = 1 << (cm->bit_depth - 1);
+ const int val = 1 << (seq_params->bit_depth - 1);
for (int plane = only_chroma; plane < MAX_MB_PLANE; plane++) {
const int is_uv = plane > 0;
for (int row_idx = 0; row_idx < buf->crop_heights[is_uv]; row_idx++) {
- if (cm->use_highbitdepth) {
+ if (seq_params->use_highbitdepth) {
// TODO(yaowu): replace this with aom_memset16() for speed
for (int col_idx = 0; col_idx < buf->crop_widths[is_uv]; col_idx++) {
uint16_t *base = CONVERT_TO_SHORTPTR(buf->buffers[plane]);
@@ -368,6 +368,7 @@
int mi_row, int mi_col, aom_reader *r,
PARTITION_TYPE partition, BLOCK_SIZE bsize) {
AV1_COMMON *const cm = &pbi->common;
+ const SequenceHeader *const seq_params = &cm->seq_params;
const int bw = mi_size_wide[bsize];
const int bh = mi_size_high[bsize];
const int x_mis = AOMMIN(bw, cm->mi_cols - mi_col);
@@ -379,9 +380,11 @@
set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
xd->mi[0]->partition = partition;
av1_read_mode_info(pbi, xd, mi_row, mi_col, r, x_mis, y_mis);
- if (bsize >= BLOCK_8X8 && (cm->subsampling_x || cm->subsampling_y)) {
+ if (bsize >= BLOCK_8X8 &&
+ (seq_params->subsampling_x || seq_params->subsampling_y)) {
const BLOCK_SIZE uv_subsize =
- ss_size_lookup[bsize][cm->subsampling_x][cm->subsampling_y];
+ ss_size_lookup[bsize][seq_params->subsampling_x]
+ [seq_params->subsampling_y];
if (uv_subsize == BLOCK_INVALID)
aom_internal_error(xd->error_info, AOM_CODEC_CORRUPT_FRAME,
"Invalid block size.");
@@ -1369,10 +1372,10 @@
: (j == 1 ? cm->u_dc_delta_q : cm->v_dc_delta_q);
const int ac_delta_q =
j == 0 ? 0 : (j == 1 ? cm->u_ac_delta_q : cm->v_ac_delta_q);
- xd->plane[j].seg_dequant_QTX[i][0] =
- av1_dc_quant_QTX(current_qindex, dc_delta_q, cm->bit_depth);
- xd->plane[j].seg_dequant_QTX[i][1] =
- av1_ac_quant_QTX(current_qindex, ac_delta_q, cm->bit_depth);
+ xd->plane[j].seg_dequant_QTX[i][0] = av1_dc_quant_QTX(
+ current_qindex, dc_delta_q, cm->seq_params.bit_depth);
+ xd->plane[j].seg_dequant_QTX[i][1] = av1_ac_quant_QTX(
+ current_qindex, ac_delta_q, cm->seq_params.bit_depth);
}
}
}
@@ -1711,7 +1714,7 @@
}
if (num_planes > 1) {
- int s = AOMMIN(cm->subsampling_x, cm->subsampling_y);
+ int s = AOMMIN(cm->seq_params.subsampling_x, cm->seq_params.subsampling_y);
if (s && !chroma_none) {
cm->rst_info[1].restoration_unit_size =
cm->rst_info[0].restoration_unit_size >> (aom_rb_read_bit(rb) * s);
@@ -1933,12 +1936,13 @@
static void setup_quantization(AV1_COMMON *const cm,
struct aom_read_bit_buffer *rb) {
+ const SequenceHeader *const seq_params = &cm->seq_params;
const int num_planes = av1_num_planes(cm);
cm->base_qindex = aom_rb_read_literal(rb, QINDEX_BITS);
cm->y_dc_delta_q = read_delta_q(rb);
if (num_planes > 1) {
int diff_uv_delta = 0;
- if (cm->separate_uv_delta_q) diff_uv_delta = aom_rb_read_bit(rb);
+ if (seq_params->separate_uv_delta_q) diff_uv_delta = aom_rb_read_bit(rb);
cm->u_dc_delta_q = read_delta_q(rb);
cm->u_ac_delta_q = read_delta_q(rb);
if (diff_uv_delta) {
@@ -1949,12 +1953,12 @@
cm->v_ac_delta_q = cm->u_ac_delta_q;
}
}
- cm->dequant_bit_depth = cm->bit_depth;
+ cm->dequant_bit_depth = seq_params->bit_depth;
cm->using_qmatrix = aom_rb_read_bit(rb);
if (cm->using_qmatrix) {
cm->qm_y = aom_rb_read_literal(rb, QM_LEVEL_BITS);
cm->qm_u = aom_rb_read_literal(rb, QM_LEVEL_BITS);
- if (!cm->separate_uv_delta_q)
+ if (!seq_params->separate_uv_delta_q)
cm->qm_v = cm->qm_u;
else
cm->qm_v = aom_rb_read_literal(rb, QM_LEVEL_BITS);
@@ -1967,6 +1971,7 @@
// Build y/uv dequant values based on segmentation.
static void setup_segmentation_dequant(AV1_COMMON *const cm) {
+ const int bit_depth = cm->seq_params.bit_depth;
const int using_qm = cm->using_qmatrix;
// When segmentation is disabled, only the first value is used. The
// remaining are don't cares.
@@ -1974,16 +1979,16 @@
for (int i = 0; i < max_segments; ++i) {
const int qindex = av1_get_qindex(&cm->seg, i, cm->base_qindex);
cm->y_dequant_QTX[i][0] =
- av1_dc_quant_QTX(qindex, cm->y_dc_delta_q, cm->bit_depth);
- cm->y_dequant_QTX[i][1] = av1_ac_quant_QTX(qindex, 0, cm->bit_depth);
+ av1_dc_quant_QTX(qindex, cm->y_dc_delta_q, bit_depth);
+ cm->y_dequant_QTX[i][1] = av1_ac_quant_QTX(qindex, 0, bit_depth);
cm->u_dequant_QTX[i][0] =
- av1_dc_quant_QTX(qindex, cm->u_dc_delta_q, cm->bit_depth);
+ av1_dc_quant_QTX(qindex, cm->u_dc_delta_q, bit_depth);
cm->u_dequant_QTX[i][1] =
- av1_ac_quant_QTX(qindex, cm->u_ac_delta_q, cm->bit_depth);
+ av1_ac_quant_QTX(qindex, cm->u_ac_delta_q, bit_depth);
cm->v_dequant_QTX[i][0] =
- av1_dc_quant_QTX(qindex, cm->v_dc_delta_q, cm->bit_depth);
+ av1_dc_quant_QTX(qindex, cm->v_dc_delta_q, bit_depth);
cm->v_dequant_QTX[i][1] =
- av1_ac_quant_QTX(qindex, cm->v_ac_delta_q, cm->bit_depth);
+ av1_ac_quant_QTX(qindex, cm->v_ac_delta_q, bit_depth);
const int lossless = qindex == 0 && cm->y_dc_delta_q == 0 &&
cm->u_dc_delta_q == 0 && cm->u_ac_delta_q == 0 &&
cm->v_dc_delta_q == 0 && cm->v_ac_delta_q == 0;
@@ -2079,21 +2084,22 @@
static void setup_frame_size(AV1_COMMON *cm, int frame_size_override_flag,
struct aom_read_bit_buffer *rb) {
+ const SequenceHeader *const seq_params = &cm->seq_params;
int width, height;
BufferPool *const pool = cm->buffer_pool;
if (frame_size_override_flag) {
- int num_bits_width = cm->seq_params.num_bits_width;
- int num_bits_height = cm->seq_params.num_bits_height;
+ int num_bits_width = seq_params->num_bits_width;
+ int num_bits_height = seq_params->num_bits_height;
av1_read_frame_size(rb, num_bits_width, num_bits_height, &width, &height);
- if (width > cm->seq_params.max_frame_width ||
- height > cm->seq_params.max_frame_height) {
+ if (width > seq_params->max_frame_width ||
+ height > seq_params->max_frame_height) {
aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
"Frame dimensions are larger than the maximum values");
}
} else {
- width = cm->seq_params.max_frame_width;
- height = cm->seq_params.max_frame_height;
+ width = seq_params->max_frame_width;
+ height = seq_params->max_frame_height;
}
setup_superres(cm, rb, &width, &height);
@@ -2102,8 +2108,9 @@
lock_buffer_pool(pool);
if (aom_realloc_frame_buffer(
- get_frame_new_buffer(cm), cm->width, cm->height, cm->subsampling_x,
- cm->subsampling_y, cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
+ get_frame_new_buffer(cm), cm->width, cm->height,
+ seq_params->subsampling_x, seq_params->subsampling_y,
+ seq_params->use_highbitdepth, AOM_BORDER_IN_PIXELS,
cm->byte_alignment,
&pool->frame_bufs[cm->new_fb_idx].raw_frame_buffer, pool->get_fb_cb,
pool->cb_priv)) {
@@ -2113,18 +2120,22 @@
}
unlock_buffer_pool(pool);
- pool->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x;
- pool->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y;
- pool->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
- pool->frame_bufs[cm->new_fb_idx].buf.color_primaries = cm->color_primaries;
+ pool->frame_bufs[cm->new_fb_idx].buf.subsampling_x =
+ seq_params->subsampling_x;
+ pool->frame_bufs[cm->new_fb_idx].buf.subsampling_y =
+ seq_params->subsampling_y;
+ pool->frame_bufs[cm->new_fb_idx].buf.bit_depth =
+ (unsigned int)seq_params->bit_depth;
+ pool->frame_bufs[cm->new_fb_idx].buf.color_primaries =
+ seq_params->color_primaries;
pool->frame_bufs[cm->new_fb_idx].buf.transfer_characteristics =
- cm->transfer_characteristics;
+ seq_params->transfer_characteristics;
pool->frame_bufs[cm->new_fb_idx].buf.matrix_coefficients =
- cm->matrix_coefficients;
- pool->frame_bufs[cm->new_fb_idx].buf.monochrome = cm->seq_params.monochrome;
+ seq_params->matrix_coefficients;
+ pool->frame_bufs[cm->new_fb_idx].buf.monochrome = seq_params->monochrome;
pool->frame_bufs[cm->new_fb_idx].buf.chroma_sample_position =
- cm->chroma_sample_position;
- pool->frame_bufs[cm->new_fb_idx].buf.color_range = cm->color_range;
+ seq_params->chroma_sample_position;
+ pool->frame_bufs[cm->new_fb_idx].buf.color_range = seq_params->color_range;
pool->frame_bufs[cm->new_fb_idx].buf.render_width = cm->render_width;
pool->frame_bufs[cm->new_fb_idx].buf.render_height = cm->render_height;
}
@@ -2162,9 +2173,10 @@
}
}
+ const SequenceHeader *const seq_params = &cm->seq_params;
if (!found) {
- int num_bits_width = cm->seq_params.num_bits_width;
- int num_bits_height = cm->seq_params.num_bits_height;
+ int num_bits_width = seq_params->num_bits_width;
+ int num_bits_height = seq_params->num_bits_height;
av1_read_frame_size(rb, num_bits_width, num_bits_height, &width, &height);
setup_superres(cm, rb, &width, &height);
@@ -2189,18 +2201,19 @@
"Referenced frame has invalid size");
for (int i = 0; i < INTER_REFS_PER_FRAME; ++i) {
RefBuffer *const ref_frame = &cm->frame_refs[i];
- if (!valid_ref_frame_img_fmt(ref_frame->buf->bit_depth,
- ref_frame->buf->subsampling_x,
- ref_frame->buf->subsampling_y, cm->bit_depth,
- cm->subsampling_x, cm->subsampling_y))
+ if (!valid_ref_frame_img_fmt(
+ ref_frame->buf->bit_depth, ref_frame->buf->subsampling_x,
+ ref_frame->buf->subsampling_y, seq_params->bit_depth,
+ seq_params->subsampling_x, seq_params->subsampling_y))
aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
"Referenced frame has incompatible color format");
}
lock_buffer_pool(pool);
if (aom_realloc_frame_buffer(
- get_frame_new_buffer(cm), cm->width, cm->height, cm->subsampling_x,
- cm->subsampling_y, cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
+ get_frame_new_buffer(cm), cm->width, cm->height,
+ seq_params->subsampling_x, seq_params->subsampling_y,
+ seq_params->use_highbitdepth, AOM_BORDER_IN_PIXELS,
cm->byte_alignment,
&pool->frame_bufs[cm->new_fb_idx].raw_frame_buffer, pool->get_fb_cb,
pool->cb_priv)) {
@@ -2210,18 +2223,22 @@
}
unlock_buffer_pool(pool);
- pool->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x;
- pool->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y;
- pool->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
- pool->frame_bufs[cm->new_fb_idx].buf.color_primaries = cm->color_primaries;
+ pool->frame_bufs[cm->new_fb_idx].buf.subsampling_x =
+ seq_params->subsampling_x;
+ pool->frame_bufs[cm->new_fb_idx].buf.subsampling_y =
+ seq_params->subsampling_y;
+ pool->frame_bufs[cm->new_fb_idx].buf.bit_depth =
+ (unsigned int)seq_params->bit_depth;
+ pool->frame_bufs[cm->new_fb_idx].buf.color_primaries =
+ seq_params->color_primaries;
pool->frame_bufs[cm->new_fb_idx].buf.transfer_characteristics =
- cm->transfer_characteristics;
+ seq_params->transfer_characteristics;
pool->frame_bufs[cm->new_fb_idx].buf.matrix_coefficients =
- cm->matrix_coefficients;
- pool->frame_bufs[cm->new_fb_idx].buf.monochrome = cm->seq_params.monochrome;
+ seq_params->matrix_coefficients;
+ pool->frame_bufs[cm->new_fb_idx].buf.monochrome = seq_params->monochrome;
pool->frame_bufs[cm->new_fb_idx].buf.chroma_sample_position =
- cm->chroma_sample_position;
- pool->frame_bufs[cm->new_fb_idx].buf.color_range = cm->color_range;
+ seq_params->chroma_sample_position;
+ pool->frame_bufs[cm->new_fb_idx].buf.color_range = seq_params->color_range;
pool->frame_bufs[cm->new_fb_idx].buf.render_width = cm->render_width;
pool->frame_bufs[cm->new_fb_idx].buf.render_height = cm->render_height;
}
@@ -3487,7 +3504,7 @@
thread_data->error_info.setjmp = 0;
}
}
- const int use_highbd = cm->use_highbitdepth ? 1 : 0;
+ const int use_highbd = cm->seq_params.use_highbitdepth ? 1 : 0;
const int buf_size = MC_TEMP_BUF_PELS << use_highbd;
for (worker_idx = 0; worker_idx < pbi->max_threads - 1; ++worker_idx) {
DecWorkerData *const thread_data = pbi->thread_data + worker_idx;
@@ -3813,17 +3830,20 @@
}
// Reads the high_bitdepth and twelve_bit fields in color_config() and sets
-// cm->bit_depth based on the values of those fields and cm->profile. Reports
-// errors by calling rb->error_handler() or aom_internal_error().
-static void av1_read_bitdepth(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
+// seq_params->bit_depth based on the values of those fields and
+// seq_params->profile. Reports errors by calling rb->error_handler() or
+// aom_internal_error().
+static void read_bitdepth(struct aom_read_bit_buffer *rb,
+ SequenceHeader *seq_params,
+ struct aom_internal_error_info *error_info) {
const int high_bitdepth = aom_rb_read_bit(rb);
- if (cm->profile == PROFILE_2 && high_bitdepth) {
+ if (seq_params->profile == PROFILE_2 && high_bitdepth) {
const int twelve_bit = aom_rb_read_bit(rb);
- cm->bit_depth = twelve_bit ? AOM_BITS_12 : AOM_BITS_10;
- } else if (cm->profile <= PROFILE_2) {
- cm->bit_depth = high_bitdepth ? AOM_BITS_10 : AOM_BITS_8;
+ seq_params->bit_depth = twelve_bit ? AOM_BITS_12 : AOM_BITS_10;
+ } else if (seq_params->profile <= PROFILE_2) {
+ seq_params->bit_depth = high_bitdepth ? AOM_BITS_10 : AOM_BITS_8;
} else {
- aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
+ aom_internal_error(error_info, AOM_CODEC_UNSUP_BITSTREAM,
"Unsupported profile/bit-depth combination");
}
}
@@ -3831,6 +3851,7 @@
void av1_read_film_grain_params(AV1_COMMON *cm,
struct aom_read_bit_buffer *rb) {
aom_film_grain_t *pars = &cm->film_grain_params;
+ const SequenceHeader *const seq_params = &cm->seq_params;
pars->apply_grain = aom_rb_read_bit(rb);
if (!pars->apply_grain) {
@@ -3844,7 +3865,7 @@
else
pars->update_parameters = 1;
- pars->bit_depth = cm->bit_depth;
+ pars->bit_depth = seq_params->bit_depth;
if (!pars->update_parameters) {
// inherit parameters from a previous reference frame
@@ -3880,11 +3901,11 @@
pars->scaling_points_y[i][1] = aom_rb_read_literal(rb, 8);
}
- if (!cm->seq_params.monochrome)
+ if (!seq_params->monochrome)
pars->chroma_scaling_from_luma = aom_rb_read_bit(rb);
- if (cm->seq_params.monochrome || pars->chroma_scaling_from_luma ||
- ((cm->subsampling_x == 1) && (cm->subsampling_y == 1) &&
+ if (seq_params->monochrome || pars->chroma_scaling_from_luma ||
+ ((seq_params->subsampling_x == 1) && (seq_params->subsampling_y == 1) &&
(pars->num_y_points == 0))) {
pars->num_cb_points = 0;
pars->num_cr_points = 0;
@@ -3919,7 +3940,7 @@
pars->scaling_points_cr[i][1] = aom_rb_read_literal(rb, 8);
}
- if ((cm->subsampling_x == 1) && (cm->subsampling_y == 1) &&
+ if ((seq_params->subsampling_x == 1) && (seq_params->subsampling_y == 1) &&
(((pars->num_cb_points == 0) && (pars->num_cr_points != 0)) ||
((pars->num_cb_points != 0) && (pars->num_cr_points == 0))))
aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
@@ -3978,84 +3999,87 @@
} else {
memset(&cm->film_grain_params, 0, sizeof(cm->film_grain_params));
}
- cm->film_grain_params.bit_depth = cm->bit_depth;
+ cm->film_grain_params.bit_depth = cm->seq_params.bit_depth;
memcpy(&cm->cur_frame->film_grain_params, &cm->film_grain_params,
sizeof(aom_film_grain_t));
}
-void av1_read_color_config(AV1_COMMON *cm, struct aom_read_bit_buffer *rb,
- int allow_lowbitdepth, SequenceHeader *seq_params) {
- av1_read_bitdepth(cm, rb);
+void av1_read_color_config(struct aom_read_bit_buffer *rb,
+ int allow_lowbitdepth, SequenceHeader *seq_params,
+ struct aom_internal_error_info *error_info) {
+ read_bitdepth(rb, seq_params, error_info);
- cm->use_highbitdepth = cm->bit_depth > AOM_BITS_8 || !allow_lowbitdepth;
+ seq_params->use_highbitdepth =
+ seq_params->bit_depth > AOM_BITS_8 || !allow_lowbitdepth;
// monochrome bit (not needed for PROFILE_1)
- const int is_monochrome = cm->profile != PROFILE_1 ? aom_rb_read_bit(rb) : 0;
+ const int is_monochrome =
+ seq_params->profile != PROFILE_1 ? aom_rb_read_bit(rb) : 0;
seq_params->monochrome = is_monochrome;
int color_description_present_flag = aom_rb_read_bit(rb);
if (color_description_present_flag) {
- cm->color_primaries = aom_rb_read_literal(rb, 8);
- cm->transfer_characteristics = aom_rb_read_literal(rb, 8);
- cm->matrix_coefficients = aom_rb_read_literal(rb, 8);
+ seq_params->color_primaries = aom_rb_read_literal(rb, 8);
+ seq_params->transfer_characteristics = aom_rb_read_literal(rb, 8);
+ seq_params->matrix_coefficients = aom_rb_read_literal(rb, 8);
} else {
- cm->color_primaries = AOM_CICP_CP_UNSPECIFIED;
- cm->transfer_characteristics = AOM_CICP_TC_UNSPECIFIED;
- cm->matrix_coefficients = AOM_CICP_MC_UNSPECIFIED;
+ seq_params->color_primaries = AOM_CICP_CP_UNSPECIFIED;
+ seq_params->transfer_characteristics = AOM_CICP_TC_UNSPECIFIED;
+ seq_params->matrix_coefficients = AOM_CICP_MC_UNSPECIFIED;
}
if (is_monochrome) {
// [16,235] (including xvycc) vs [0,255] range
- cm->color_range = aom_rb_read_bit(rb);
- cm->subsampling_y = cm->subsampling_x = 1;
- cm->chroma_sample_position = AOM_CSP_UNKNOWN;
- cm->separate_uv_delta_q = 0;
+ seq_params->color_range = aom_rb_read_bit(rb);
+ seq_params->subsampling_y = seq_params->subsampling_x = 1;
+ seq_params->chroma_sample_position = AOM_CSP_UNKNOWN;
+ seq_params->separate_uv_delta_q = 0;
return;
}
- if (cm->color_primaries == AOM_CICP_CP_BT_709 &&
- cm->transfer_characteristics == AOM_CICP_TC_SRGB &&
- cm->matrix_coefficients == AOM_CICP_MC_IDENTITY) { // it would be better
- // to remove this
- // dependency too
- cm->subsampling_y = cm->subsampling_x = 0;
- cm->color_range = 1; // assume full color-range
- if (!(cm->profile == PROFILE_1 ||
- (cm->profile == PROFILE_2 && cm->bit_depth == AOM_BITS_12))) {
+ if (seq_params->color_primaries == AOM_CICP_CP_BT_709 &&
+ seq_params->transfer_characteristics == AOM_CICP_TC_SRGB &&
+ seq_params->matrix_coefficients == AOM_CICP_MC_IDENTITY) {
+ // It would be good to remove this dependency.
+ seq_params->subsampling_y = seq_params->subsampling_x = 0;
+ seq_params->color_range = 1; // assume full color-range
+ if (!(seq_params->profile == PROFILE_1 ||
+ (seq_params->profile == PROFILE_2 &&
+ seq_params->bit_depth == AOM_BITS_12))) {
aom_internal_error(
- &cm->error, AOM_CODEC_UNSUP_BITSTREAM,
+ error_info, AOM_CODEC_UNSUP_BITSTREAM,
"sRGB colorspace not compatible with specified profile");
}
} else {
// [16,235] (including xvycc) vs [0,255] range
- cm->color_range = aom_rb_read_bit(rb);
- if (cm->profile == PROFILE_0) {
+ seq_params->color_range = aom_rb_read_bit(rb);
+ if (seq_params->profile == PROFILE_0) {
// 420 only
- cm->subsampling_x = cm->subsampling_y = 1;
- } else if (cm->profile == PROFILE_1) {
+ seq_params->subsampling_x = seq_params->subsampling_y = 1;
+ } else if (seq_params->profile == PROFILE_1) {
// 444 only
- cm->subsampling_x = cm->subsampling_y = 0;
+ seq_params->subsampling_x = seq_params->subsampling_y = 0;
} else {
- assert(cm->profile == PROFILE_2);
- if (cm->bit_depth == AOM_BITS_12) {
- cm->subsampling_x = aom_rb_read_bit(rb);
- if (cm->subsampling_x)
- cm->subsampling_y = aom_rb_read_bit(rb); // 422 or 420
+ assert(seq_params->profile == PROFILE_2);
+ if (seq_params->bit_depth == AOM_BITS_12) {
+ seq_params->subsampling_x = aom_rb_read_bit(rb);
+ if (seq_params->subsampling_x)
+ seq_params->subsampling_y = aom_rb_read_bit(rb); // 422 or 420
else
- cm->subsampling_y = 0; // 444
+ seq_params->subsampling_y = 0; // 444
} else {
// 422
- cm->subsampling_x = 1;
- cm->subsampling_y = 0;
+ seq_params->subsampling_x = 1;
+ seq_params->subsampling_y = 0;
}
}
- if (cm->matrix_coefficients == AOM_CICP_MC_IDENTITY &&
- (cm->subsampling_x || cm->subsampling_y)) {
+ if (seq_params->matrix_coefficients == AOM_CICP_MC_IDENTITY &&
+ (seq_params->subsampling_x || seq_params->subsampling_y)) {
aom_internal_error(
- &cm->error, AOM_CODEC_UNSUP_BITSTREAM,
+ error_info, AOM_CODEC_UNSUP_BITSTREAM,
"Identity CICP Matrix incompatible with non 4:4:4 color sampling");
}
- if (cm->subsampling_x && cm->subsampling_y) {
- cm->chroma_sample_position = aom_rb_read_literal(rb, 2);
+ if (seq_params->subsampling_x && seq_params->subsampling_y) {
+ seq_params->chroma_sample_position = aom_rb_read_literal(rb, 2);
}
}
- cm->separate_uv_delta_q = aom_rb_read_bit(rb);
+ seq_params->separate_uv_delta_q = aom_rb_read_bit(rb);
}
void av1_read_timing_info_header(AV1_COMMON *cm,
@@ -4390,6 +4414,7 @@
static int read_uncompressed_header(AV1Decoder *pbi,
struct aom_read_bit_buffer *rb) {
AV1_COMMON *const cm = &pbi->common;
+ const SequenceHeader *const seq_params = &cm->seq_params;
MACROBLOCKD *const xd = &pbi->mb;
BufferPool *const pool = cm->buffer_pool;
RefCntBuffer *const frame_bufs = pool->frame_bufs;
@@ -4405,7 +4430,7 @@
// NOTE: By default all coded frames to be used as a reference
cm->is_reference_frame = 1;
- if (cm->seq_params.reduced_still_picture_hdr) {
+ if (seq_params->reduced_still_picture_hdr) {
cm->show_existing_frame = 0;
cm->show_frame = 1;
cm->frame_type = KEY_FRAME;
@@ -4418,12 +4443,12 @@
// Show an existing frame directly.
const int existing_frame_idx = aom_rb_read_literal(rb, 3);
const int frame_to_show = cm->ref_frame_map[existing_frame_idx];
- if (cm->seq_params.decoder_model_info_present_flag &&
+ if (seq_params->decoder_model_info_present_flag &&
cm->timing_info.equal_picture_interval == 0) {
av1_read_temporal_point_info(cm, rb);
}
- if (cm->seq_params.frame_id_numbers_present_flag) {
- int frame_id_length = cm->seq_params.frame_id_length;
+ if (seq_params->frame_id_numbers_present_flag) {
+ int frame_id_length = seq_params->frame_id_length;
int display_frame_id = aom_rb_read_literal(rb, frame_id_length);
/* Compare display_frame_id with ref_frame_id and check valid for
* referencing */
@@ -4466,14 +4491,14 @@
cm->frame_type = (FRAME_TYPE)aom_rb_read_literal(rb, 2); // 2 bits
cm->show_frame = aom_rb_read_bit(rb);
- if (cm->seq_params.still_picture &&
+ if (seq_params->still_picture &&
(cm->frame_type != KEY_FRAME || !cm->show_frame)) {
aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
"Still pictures must be coded as shown keyframes");
}
cm->showable_frame = cm->frame_type != KEY_FRAME;
if (cm->show_frame) {
- if (cm->seq_params.decoder_model_info_present_flag &&
+ if (seq_params->decoder_model_info_present_flag &&
cm->timing_info.equal_picture_interval == 0)
av1_read_temporal_point_info(cm, rb);
} else {
@@ -4489,17 +4514,17 @@
}
cm->disable_cdf_update = aom_rb_read_bit(rb);
- if (cm->seq_params.force_screen_content_tools == 2) {
+ if (seq_params->force_screen_content_tools == 2) {
cm->allow_screen_content_tools = aom_rb_read_bit(rb);
} else {
- cm->allow_screen_content_tools = cm->seq_params.force_screen_content_tools;
+ cm->allow_screen_content_tools = seq_params->force_screen_content_tools;
}
if (cm->allow_screen_content_tools) {
- if (cm->seq_params.force_integer_mv == 2) {
+ if (seq_params->force_integer_mv == 2) {
cm->cur_frame_force_integer_mv = aom_rb_read_bit(rb);
} else {
- cm->cur_frame_force_integer_mv = cm->seq_params.force_integer_mv;
+ cm->cur_frame_force_integer_mv = seq_params->force_integer_mv;
}
} else {
cm->cur_frame_force_integer_mv = 0;
@@ -4510,10 +4535,10 @@
cm->allow_intrabc = 0;
cm->primary_ref_frame = PRIMARY_REF_NONE;
- if (!cm->seq_params.reduced_still_picture_hdr) {
- if (cm->seq_params.frame_id_numbers_present_flag) {
- int frame_id_length = cm->seq_params.frame_id_length;
- int diff_len = cm->seq_params.delta_frame_id_length;
+ if (!seq_params->reduced_still_picture_hdr) {
+ if (seq_params->frame_id_numbers_present_flag) {
+ int frame_id_length = seq_params->frame_id_length;
+ int diff_len = seq_params->delta_frame_id_length;
int prev_frame_id = 0;
int have_prev_frame_id = !pbi->decoding_first_frame &&
!(cm->frame_type == KEY_FRAME && cm->show_frame);
@@ -4558,7 +4583,7 @@
frame_is_sframe(cm) ? 1 : aom_rb_read_literal(rb, 1);
cm->frame_offset =
- aom_rb_read_literal(rb, cm->seq_params.order_hint_bits_minus_1 + 1);
+ aom_rb_read_literal(rb, seq_params->order_hint_bits_minus_1 + 1);
cm->current_video_frame = cm->frame_offset;
if (!cm->error_resilient_mode && !frame_is_intra_only(cm)) {
@@ -4566,19 +4591,19 @@
}
}
- if (cm->seq_params.decoder_model_info_present_flag) {
+ if (seq_params->decoder_model_info_present_flag) {
cm->buffer_removal_time_present = aom_rb_read_bit(rb);
if (cm->buffer_removal_time_present) {
for (int op_num = 0;
- op_num < cm->seq_params.operating_points_cnt_minus_1 + 1; op_num++) {
+ op_num < seq_params->operating_points_cnt_minus_1 + 1; op_num++) {
if (cm->op_params[op_num].decoder_model_param_present_flag) {
- if ((((cm->seq_params.operating_point_idc[op_num] >>
+ if ((((seq_params->operating_point_idc[op_num] >>
cm->temporal_layer_id) &
0x1) &&
- ((cm->seq_params.operating_point_idc[op_num] >>
+ ((seq_params->operating_point_idc[op_num] >>
(cm->spatial_layer_id + 8)) &
0x1)) ||
- cm->seq_params.operating_point_idc[op_num] == 0) {
+ seq_params->operating_point_idc[op_num] == 0) {
cm->op_frame_timing[op_num].buffer_removal_time =
aom_rb_read_unsigned_literal(
rb, cm->buffer_model.buffer_removal_time_length);
@@ -4629,11 +4654,11 @@
if (!frame_is_intra_only(cm) || pbi->refresh_frame_flags != 0xFF) {
// Read all ref frame order hints if error_resilient_mode == 1
- if (cm->error_resilient_mode && cm->seq_params.enable_order_hint) {
+ if (cm->error_resilient_mode && seq_params->enable_order_hint) {
for (int ref_idx = 0; ref_idx < REF_FRAMES; ref_idx++) {
// Read order hint from bit stream
unsigned int frame_offset =
- aom_rb_read_literal(rb, cm->seq_params.order_hint_bits_minus_1 + 1);
+ aom_rb_read_literal(rb, seq_params->order_hint_bits_minus_1 + 1);
// Get buffer index
int buf_idx = cm->ref_frame_map[ref_idx];
assert(buf_idx < FRAME_BUFFERS);
@@ -4653,10 +4678,10 @@
}
lock_buffer_pool(pool);
if (aom_realloc_frame_buffer(
- &frame_bufs[buf_idx].buf, cm->seq_params.max_frame_width,
- cm->seq_params.max_frame_height, cm->subsampling_x,
- cm->subsampling_y, cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
- cm->byte_alignment,
+ &frame_bufs[buf_idx].buf, seq_params->max_frame_width,
+ seq_params->max_frame_height, seq_params->subsampling_x,
+ seq_params->subsampling_y, seq_params->use_highbitdepth,
+ AOM_BORDER_IN_PIXELS, cm->byte_alignment,
&pool->frame_bufs[buf_idx].raw_frame_buffer, pool->get_fb_cb,
pool->cb_priv)) {
unlock_buffer_pool(pool);
@@ -4664,7 +4689,8 @@
"Failed to allocate frame buffer");
}
unlock_buffer_pool(pool);
- set_planes_to_neutral_grey(cm, &frame_bufs[buf_idx].buf, 0);
+ set_planes_to_neutral_grey(&cm->seq_params, &frame_bufs[buf_idx].buf,
+ 0);
cm->ref_frame_map[ref_idx] = buf_idx;
frame_bufs[buf_idx].cur_frame_offset = frame_offset;
@@ -4692,7 +4718,7 @@
} else if (pbi->need_resync != 1) { /* Skip if need resync */
// Frame refs short signaling is off when error resilient mode is on.
- if (cm->seq_params.enable_order_hint)
+ if (seq_params->enable_order_hint)
cm->frame_refs_short_signaling = aom_rb_read_bit(rb);
if (cm->frame_refs_short_signaling) {
@@ -4746,9 +4772,9 @@
cm->ref_frame_sign_bias[LAST_FRAME + i] = 0;
- if (cm->seq_params.frame_id_numbers_present_flag) {
- int frame_id_length = cm->seq_params.frame_id_length;
- int diff_len = cm->seq_params.delta_frame_id_length;
+ if (seq_params->frame_id_numbers_present_flag) {
+ int frame_id_length = seq_params->frame_id_length;
+ int diff_len = seq_params->delta_frame_id_length;
int delta_frame_id_minus_1 = aom_rb_read_literal(rb, diff_len);
int ref_frame_id =
((cm->current_frame_id - (delta_frame_id_minus_1 + 1) +
@@ -4811,7 +4837,7 @@
cm->cur_frame->intra_only = cm->frame_type == KEY_FRAME || cm->intra_only;
cm->cur_frame->frame_type = cm->frame_type;
- if (cm->seq_params.frame_id_numbers_present_flag) {
+ if (seq_params->frame_id_numbers_present_flag) {
/* If bitmask is set, update reference frame id values and
mark frames as valid for reference */
int refresh_frame_flags = pbi->refresh_frame_flags;
@@ -4824,7 +4850,7 @@
}
const int might_bwd_adapt =
- !(cm->seq_params.reduced_still_picture_hdr) && !(cm->disable_cdf_update);
+ !(seq_params->reduced_still_picture_hdr) && !(cm->disable_cdf_update);
if (might_bwd_adapt) {
cm->refresh_frame_context = aom_rb_read_bit(rb)
? REFRESH_FRAME_CONTEXT_DISABLED
@@ -4833,14 +4859,16 @@
cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_DISABLED;
}
- get_frame_new_buffer(cm)->bit_depth = cm->bit_depth;
- get_frame_new_buffer(cm)->color_primaries = cm->color_primaries;
+ get_frame_new_buffer(cm)->bit_depth = seq_params->bit_depth;
+ get_frame_new_buffer(cm)->color_primaries = seq_params->color_primaries;
get_frame_new_buffer(cm)->transfer_characteristics =
- cm->transfer_characteristics;
- get_frame_new_buffer(cm)->matrix_coefficients = cm->matrix_coefficients;
- get_frame_new_buffer(cm)->monochrome = cm->seq_params.monochrome;
- get_frame_new_buffer(cm)->chroma_sample_position = cm->chroma_sample_position;
- get_frame_new_buffer(cm)->color_range = cm->color_range;
+ seq_params->transfer_characteristics;
+ get_frame_new_buffer(cm)->matrix_coefficients =
+ seq_params->matrix_coefficients;
+ get_frame_new_buffer(cm)->monochrome = seq_params->monochrome;
+ get_frame_new_buffer(cm)->chroma_sample_position =
+ seq_params->chroma_sample_position;
+ get_frame_new_buffer(cm)->color_range = seq_params->color_range;
get_frame_new_buffer(cm)->render_width = cm->render_width;
get_frame_new_buffer(cm)->render_height = cm->render_height;
@@ -4892,7 +4920,7 @@
read_tile_info(pbi, rb);
setup_quantization(cm, rb);
- xd->bd = (int)cm->bit_depth;
+ xd->bd = (int)seq_params->bit_depth;
if (cm->num_allocated_above_context_planes < av1_num_planes(cm) ||
cm->num_allocated_above_context_mi_col < cm->mi_cols ||
@@ -4943,22 +4971,22 @@
cm->lf.filter_level[0] = 0;
cm->lf.filter_level[1] = 0;
}
- if (cm->coded_lossless || !cm->seq_params.enable_cdef) {
+ if (cm->coded_lossless || !seq_params->enable_cdef) {
cm->cdef_bits = 0;
cm->cdef_strengths[0] = 0;
cm->cdef_uv_strengths[0] = 0;
}
- if (cm->all_lossless || !cm->seq_params.enable_restoration) {
+ if (cm->all_lossless || !seq_params->enable_restoration) {
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;
}
setup_loopfilter(cm, rb);
- if (!cm->coded_lossless && cm->seq_params.enable_cdef) {
+ if (!cm->coded_lossless && seq_params->enable_cdef) {
setup_cdef(cm, rb);
}
- if (!cm->all_lossless && cm->seq_params.enable_restoration) {
+ if (!cm->all_lossless && seq_params->enable_restoration) {
decode_restoration_mode(cm, rb);
}
@@ -5092,7 +5120,8 @@
av1_setup_motion_field(cm);
- av1_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y, num_planes);
+ av1_setup_block_planes(xd, cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_y, num_planes);
if (cm->primary_ref_frame == PRIMARY_REF_NONE) {
// use the default frame context values
*cm->fc = cm->frame_contexts[FRAME_CONTEXT_DEFAULTS];
@@ -5116,7 +5145,7 @@
cm->rst_info[2].frame_restoration_type != RESTORE_NONE) {
av1_alloc_restoration_buffers(cm);
}
- const int use_highbd = cm->use_highbitdepth ? 1 : 0;
+ const int use_highbd = cm->seq_params.use_highbitdepth ? 1 : 0;
const int buf_size = MC_TEMP_BUF_PELS << use_highbd;
if (pbi->td.mc_buf_size != buf_size) {
av1_free_mc_tmp_buf(&pbi->td, use_highbd);
@@ -5146,7 +5175,9 @@
const int num_planes = av1_num_planes(cm);
// If the bit stream is monochrome, set the U and V buffers to a constant.
- if (num_planes < 3) set_planes_to_neutral_grey(cm, xd->cur_buf, 1);
+ if (num_planes < 3) {
+ set_planes_to_neutral_grey(&cm->seq_params, xd->cur_buf, 1);
+ }
if (end_tile != cm->tile_rows * cm->tile_cols - 1) {
return;
diff --git a/av1/decoder/decodeframe.h b/av1/decoder/decodeframe.h
index 1aaf5fa..d289b31 100644
--- a/av1/decoder/decodeframe.h
+++ b/av1/decoder/decodeframe.h
@@ -51,8 +51,9 @@
// Implements the color_config() function in the spec. Reports errors by
// calling rb->error_handler() or aom_internal_error().
-void av1_read_color_config(AV1_COMMON *cm, struct aom_read_bit_buffer *rb,
- int allow_lowbitdepth, SequenceHeader *seq_params);
+void av1_read_color_config(struct aom_read_bit_buffer *rb,
+ int allow_lowbitdepth, SequenceHeader *seq_params,
+ struct aom_internal_error_info *error_info);
// Implements the timing_info() function in the spec. Reports errors by calling
// rb->error_handler().
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index b771ff9..5e920b1 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -573,7 +573,7 @@
aom_read_symbol(r, xd->tile_ctx->palette_y_size_cdf[bsize_ctx],
PALETTE_SIZES, ACCT_STR) +
2;
- read_palette_colors_y(xd, cm->bit_depth, pmi, r);
+ read_palette_colors_y(xd, cm->seq_params.bit_depth, pmi, r);
}
}
if (num_planes > 1 && mbmi->uv_mode == UV_DC_PRED &&
@@ -587,7 +587,7 @@
aom_read_symbol(r, xd->tile_ctx->palette_uv_size_cdf[bsize_ctx],
PALETTE_SIZES, ACCT_STR) +
2;
- read_palette_colors_uv(xd, cm->bit_depth, pmi, r);
+ read_palette_colors_uv(xd, cm->seq_params.bit_depth, pmi, r);
}
}
}
@@ -1480,8 +1480,9 @@
}
}
- xd->cfl.is_chroma_reference = is_chroma_reference(
- mi_row, mi_col, bsize, cm->subsampling_x, cm->subsampling_y);
+ xd->cfl.is_chroma_reference =
+ is_chroma_reference(mi_row, mi_col, bsize, cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_y);
xd->cfl.store_y = store_cfl_required(cm, xd);
#if DEC_MISMATCH_DEBUG
diff --git a/av1/decoder/decoder.c b/av1/decoder/decoder.c
index d65e88c..d48114f 100644
--- a/av1/decoder/decoder.c
+++ b/av1/decoder/decoder.c
@@ -109,7 +109,7 @@
pbi->decoding_first_frame = 1;
pbi->common.buffer_pool = pool;
- cm->bit_depth = AOM_BITS_8;
+ cm->seq_params.bit_depth = AOM_BITS_8;
cm->dequant_bit_depth = AOM_BITS_8;
cm->alloc_mi = av1_dec_alloc_mi;
@@ -168,7 +168,7 @@
if (pbi->thread_data) {
for (int worker_idx = 0; worker_idx < pbi->max_threads - 1; worker_idx++) {
DecWorkerData *const thread_data = pbi->thread_data + worker_idx;
- const int use_highbd = pbi->common.use_highbitdepth ? 1 : 0;
+ const int use_highbd = pbi->common.seq_params.use_highbitdepth ? 1 : 0;
av1_free_mc_tmp_buf(thread_data->td, use_highbd);
aom_free(thread_data->td);
}
@@ -206,7 +206,7 @@
#if CONFIG_ACCOUNTING
aom_accounting_clear(&pbi->accounting);
#endif
- const int use_highbd = pbi->common.use_highbitdepth ? 1 : 0;
+ const int use_highbd = pbi->common.seq_params.use_highbitdepth ? 1 : 0;
av1_free_mc_tmp_buf(&pbi->td, use_highbd);
aom_free(pbi);
diff --git a/av1/decoder/dthread.c b/av1/decoder/dthread.c
index ff03502..3946c78 100644
--- a/av1/decoder/dthread.c
+++ b/av1/decoder/dthread.c
@@ -157,8 +157,8 @@
dst_worker_data->pbi->need_resync = src_worker_data->pbi->need_resync;
av1_frameworker_unlock_stats(src_worker);
- dst_cm->bit_depth = src_cm->bit_depth;
- dst_cm->use_highbitdepth = src_cm->use_highbitdepth;
+ dst_cm->seq_params.bit_depth = src_cm->seq_params.bit_depth;
+ dst_cm->seq_params.use_highbitdepth = src_cm->seq_params.use_highbitdepth;
// TODO(zoeliu): To handle parallel decoding
dst_cm->prev_frame =
src_cm->show_existing_frame ? src_cm->prev_frame : src_cm->cur_frame;
@@ -166,8 +166,8 @@
!src_cm->show_existing_frame ? src_cm->width : src_cm->last_width;
dst_cm->last_height =
!src_cm->show_existing_frame ? src_cm->height : src_cm->last_height;
- dst_cm->subsampling_x = src_cm->subsampling_x;
- dst_cm->subsampling_y = src_cm->subsampling_y;
+ dst_cm->seq_params.subsampling_x = src_cm->seq_params.subsampling_x;
+ dst_cm->seq_params.subsampling_y = src_cm->seq_params.subsampling_y;
dst_cm->frame_type = src_cm->frame_type;
dst_cm->last_show_frame = !src_cm->show_existing_frame
? src_cm->show_frame
diff --git a/av1/decoder/obu.c b/av1/decoder/obu.c
index 025e643..2c5ec85 100644
--- a/av1/decoder/obu.c
+++ b/av1/decoder/obu.c
@@ -202,17 +202,17 @@
// Verify rb has been configured to report errors.
assert(rb->error_handler);
- cm->profile = av1_read_profile(rb);
- if (cm->profile > PROFILE_2) {
- cm->error.error_code = AOM_CODEC_UNSUP_BITSTREAM;
- return 0;
- }
-
// Use a local variable to store the information as we decode. At the end,
// if no errors have occurred, cm->seq_params is updated.
SequenceHeader sh = cm->seq_params;
SequenceHeader *const seq_params = &sh;
+ seq_params->profile = av1_read_profile(rb);
+ if (seq_params->profile > PROFILE_2) {
+ cm->error.error_code = AOM_CODEC_UNSUP_BITSTREAM;
+ return 0;
+ }
+
// Still picture or not
seq_params->still_picture = aom_rb_read_bit(rb);
seq_params->reduced_still_picture_hdr = aom_rb_read_bit(rb);
@@ -273,7 +273,8 @@
(cm->timing_info.equal_picture_interval ||
cm->op_params[i].decoder_model_param_present_flag)) {
cm->op_params[i].bitrate = max_level_bitrate(
- cm->profile, major_minor_to_seq_level_idx(seq_params->level[i]),
+ seq_params->profile,
+ major_minor_to_seq_level_idx(seq_params->level[i]),
seq_params->tier[i]);
// Level with seq_level_idx = 31 returns a high "dummy" bitrate to pass
// the check
@@ -328,14 +329,14 @@
av1_read_sequence_header(cm, rb, seq_params);
- av1_read_color_config(cm, rb, pbi->allow_lowbitdepth, seq_params);
- if (!(cm->subsampling_x == 0 && cm->subsampling_y == 0) &&
- !(cm->subsampling_x == 1 && cm->subsampling_y == 1) &&
- !(cm->subsampling_x == 1 && cm->subsampling_y == 0)) {
+ av1_read_color_config(rb, pbi->allow_lowbitdepth, seq_params, &cm->error);
+ if (!(seq_params->subsampling_x == 0 && seq_params->subsampling_y == 0) &&
+ !(seq_params->subsampling_x == 1 && seq_params->subsampling_y == 1) &&
+ !(seq_params->subsampling_x == 1 && seq_params->subsampling_y == 0)) {
aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
"Only 4:4:4, 4:2:2 and 4:2:0 are currently supported, "
"%d %d subsampling is not supported.\n",
- cm->subsampling_x, cm->subsampling_y);
+ seq_params->subsampling_x, seq_params->subsampling_y);
}
cm->film_grain_params_present = aom_rb_read_bit(rb);
@@ -435,15 +436,15 @@
AV1_COMMON *const cm = &pbi->common;
const int tile_width_in_pixels = cm->tile_width * MI_SIZE;
const int tile_height_in_pixels = cm->tile_height * MI_SIZE;
- const int ssy = cm->subsampling_y;
- const int ssx = cm->subsampling_x;
+ const int ssy = cm->seq_params.subsampling_y;
+ const int ssx = cm->seq_params.subsampling_x;
const int num_planes = av1_num_planes(cm);
const size_t yplane_tile_size = tile_height_in_pixels * tile_width_in_pixels;
const size_t uvplane_tile_size =
(num_planes > 1)
? (tile_height_in_pixels >> ssy) * (tile_width_in_pixels >> ssx)
: 0;
- const size_t tile_size = (cm->use_highbitdepth ? 2 : 1) *
+ const size_t tile_size = (cm->seq_params.use_highbitdepth ? 2 : 1) *
(yplane_tile_size + 2 * uvplane_tile_size);
pbi->tile_list_size = tile_size * (pbi->tile_count_minus_1 + 1);
@@ -464,8 +465,8 @@
AV1_COMMON *const cm = &pbi->common;
const int tile_width_in_pixels = cm->tile_width * MI_SIZE;
const int tile_height_in_pixels = cm->tile_height * MI_SIZE;
- const int ssy = cm->subsampling_y;
- const int ssx = cm->subsampling_x;
+ const int ssy = cm->seq_params.subsampling_y;
+ const int ssx = cm->seq_params.subsampling_x;
const int num_planes = av1_num_planes(cm);
// Copy decoded tile to the tile list output buffer.
diff --git a/av1/encoder/aq_complexity.c b/av1/encoder/aq_complexity.c
index c5a6bc8..b721b6d 100644
--- a/av1/encoder/aq_complexity.c
+++ b/av1/encoder/aq_complexity.c
@@ -66,7 +66,8 @@
cpi->refresh_alt_ref_frame ||
(cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) {
int segment;
- const int aq_strength = get_aq_c_strength(cm->base_qindex, cm->bit_depth);
+ const int aq_strength =
+ get_aq_c_strength(cm->base_qindex, cm->seq_params.bit_depth);
// Clear down the segment map.
memset(cpi->segmentation_map, DEFAULT_AQ2_SEG, cm->mi_rows * cm->mi_cols);
@@ -93,7 +94,7 @@
qindex_delta = av1_compute_qdelta_by_rate(
&cpi->rc, cm->frame_type, cm->base_qindex,
- aq_c_q_adj_factor[aq_strength][segment], cm->bit_depth);
+ aq_c_q_adj_factor[aq_strength][segment], cm->seq_params.bit_depth);
// For AQ complexity mode, we dont allow Q0 in a segment if the base
// Q is not 0. Q0 (lossless) implies 4x4 only and in AQ mode 2 a segment
@@ -138,7 +139,8 @@
const int target_rate = (int)(num / denom);
double logvar;
double low_var_thresh;
- const int aq_strength = get_aq_c_strength(cm->base_qindex, cm->bit_depth);
+ const int aq_strength =
+ get_aq_c_strength(cm->base_qindex, cm->seq_params.bit_depth);
aom_clear_system_state();
low_var_thresh = (cpi->oxcf.pass == 2) ? AOMMAX(cpi->twopass.mb_av_energy,
diff --git a/av1/encoder/aq_cyclicrefresh.c b/av1/encoder/aq_cyclicrefresh.c
index a1fe37d..dec2c73 100644
--- a/av1/encoder/aq_cyclicrefresh.c
+++ b/av1/encoder/aq_cyclicrefresh.c
@@ -137,8 +137,9 @@
static int compute_deltaq(const AV1_COMP *cpi, int q, double rate_factor) {
const CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
const RATE_CONTROL *const rc = &cpi->rc;
- int deltaq = av1_compute_qdelta_by_rate(rc, cpi->common.frame_type, q,
- rate_factor, cpi->common.bit_depth);
+ int deltaq =
+ av1_compute_qdelta_by_rate(rc, cpi->common.frame_type, q, rate_factor,
+ cpi->common.seq_params.bit_depth);
if ((-deltaq) > cr->max_qdelta_perc * q / 100) {
deltaq = -cr->max_qdelta_perc * q / 100;
}
@@ -164,15 +165,16 @@
estimated_bits =
(int)((1.0 - weight_segment1 - weight_segment2) *
av1_estimate_bits_at_q(cm->frame_type, cm->base_qindex, mbs,
- correction_factor, cm->bit_depth) +
- weight_segment1 *
- av1_estimate_bits_at_q(cm->frame_type,
- cm->base_qindex + cr->qindex_delta[1],
- mbs, correction_factor, cm->bit_depth) +
- weight_segment2 *
- av1_estimate_bits_at_q(cm->frame_type,
- cm->base_qindex + cr->qindex_delta[2],
- mbs, correction_factor, cm->bit_depth));
+ correction_factor,
+ cm->seq_params.bit_depth) +
+ weight_segment1 * av1_estimate_bits_at_q(
+ cm->frame_type,
+ cm->base_qindex + cr->qindex_delta[1], mbs,
+ correction_factor, cm->seq_params.bit_depth) +
+ weight_segment2 * av1_estimate_bits_at_q(
+ cm->frame_type,
+ cm->base_qindex + cr->qindex_delta[2], mbs,
+ correction_factor, cm->seq_params.bit_depth));
return estimated_bits;
}
@@ -197,12 +199,13 @@
// Compute delta-q corresponding to qindex i.
int deltaq = compute_deltaq(cpi, i, cr->rate_ratio_qdelta);
// Take segment weighted average for bits per mb.
- bits_per_mb = (int)((1.0 - weight_segment) *
- av1_rc_bits_per_mb(cm->frame_type, i,
- correction_factor, cm->bit_depth) +
- weight_segment *
- av1_rc_bits_per_mb(cm->frame_type, i + deltaq,
- correction_factor, cm->bit_depth));
+ bits_per_mb =
+ (int)((1.0 - weight_segment) *
+ av1_rc_bits_per_mb(cm->frame_type, i, correction_factor,
+ cm->seq_params.bit_depth) +
+ weight_segment * av1_rc_bits_per_mb(cm->frame_type, i + deltaq,
+ correction_factor,
+ cm->seq_params.bit_depth));
return bits_per_mb;
}
@@ -507,7 +510,8 @@
} else {
int qindex_delta = 0;
int qindex2;
- const double q = av1_convert_qindex_to_q(cm->base_qindex, cm->bit_depth);
+ const double q =
+ av1_convert_qindex_to_q(cm->base_qindex, cm->seq_params.bit_depth);
aom_clear_system_state();
// Set rate threshold to some multiple (set to 2 for now) of the target
// rate (target is given by sb64_target_rate and scaled by 256).
diff --git a/av1/encoder/aq_variance.c b/av1/encoder/aq_variance.c
index 29a3114..6cb6adc 100644
--- a/av1/encoder/aq_variance.c
+++ b/av1/encoder/aq_variance.c
@@ -71,7 +71,7 @@
for (i = 0; i < MAX_SEGMENTS; ++i) {
int qindex_delta =
av1_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex,
- rate_ratio[i], cm->bit_depth);
+ rate_ratio[i], cm->seq_params.bit_depth);
// We don't allow qindex 0 in a segment if the base value is not 0.
// Q index 0 (lossless) implies 4x4 encoding only and in AQ mode a segment
@@ -235,9 +235,9 @@
const int rate_level = SEGMENT_ID(block_var_level);
const AV1_COMMON *const cm = &cpi->common;
- int qindex_delta =
- av1_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex,
- rate_ratio[rate_level], cm->bit_depth);
+ int qindex_delta = av1_compute_qdelta_by_rate(
+ &cpi->rc, cm->frame_type, cm->base_qindex, rate_ratio[rate_level],
+ cm->seq_params.bit_depth);
if ((cm->base_qindex != 0) && ((cm->base_qindex + qindex_delta) == 0)) {
qindex_delta = -cm->base_qindex + 1;
diff --git a/av1/encoder/av1_quantize.c b/av1/encoder/av1_quantize.c
index 1c5bdeb..d0477b3 100644
--- a/av1/encoder/av1_quantize.c
+++ b/av1/encoder/av1_quantize.c
@@ -613,9 +613,9 @@
AV1_COMMON *const cm = &cpi->common;
QUANTS *const quants = &cpi->quants;
Dequants *const dequants = &cpi->dequants;
- av1_build_quantizer(cm->bit_depth, cm->y_dc_delta_q, cm->u_dc_delta_q,
- cm->u_ac_delta_q, cm->v_dc_delta_q, cm->v_ac_delta_q,
- quants, dequants);
+ av1_build_quantizer(cm->seq_params.bit_depth, cm->y_dc_delta_q,
+ cm->u_dc_delta_q, cm->u_ac_delta_q, cm->v_dc_delta_q,
+ cm->v_ac_delta_q, quants, dequants);
}
void av1_init_plane_quantizers(const AV1_COMP *cpi, MACROBLOCK *x,
@@ -713,7 +713,7 @@
cm->qm_u = aom_get_qmlevel(cm->base_qindex + cm->u_ac_delta_q,
cm->min_qmlevel, cm->max_qmlevel);
- if (!cm->separate_uv_delta_q)
+ if (!cm->seq_params.separate_uv_delta_q)
cm->qm_v = cm->qm_u;
else
cm->qm_v = aom_get_qmlevel(cm->base_qindex + cm->v_ac_delta_q,
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 163b759..c246c1a 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -769,7 +769,7 @@
aom_write_symbol(w, n - PALETTE_MIN_SIZE,
xd->tile_ctx->palette_y_size_cdf[bsize_ctx],
PALETTE_SIZES);
- write_palette_colors_y(xd, pmi, cm->bit_depth, w);
+ write_palette_colors_y(xd, pmi, cm->seq_params.bit_depth, w);
}
}
@@ -786,7 +786,7 @@
aom_write_symbol(w, n - PALETTE_MIN_SIZE,
xd->tile_ctx->palette_uv_size_cdf[bsize_ctx],
PALETTE_SIZES);
- write_palette_colors_uv(xd, pmi, cm->bit_depth, w);
+ write_palette_colors_uv(xd, pmi, cm->seq_params.bit_depth, w);
}
}
}
@@ -1421,8 +1421,8 @@
for (blk_col = col >> pd->subsampling_x; blk_col < unit_width;
blk_col += bkw) {
pack_txb_tokens(w, cm, x, tok, tok_end, xd, mbmi, plane, plane_bsize,
- cm->bit_depth, *block, blk_row, blk_col, max_tx_size,
- token_stats);
+ cm->seq_params.bit_depth, *block, blk_row, blk_col,
+ max_tx_size, token_stats);
*block += step;
}
}
@@ -1778,7 +1778,7 @@
}
if (num_planes > 1) {
- int s = AOMMIN(cm->subsampling_x, cm->subsampling_y);
+ int s = AOMMIN(cm->seq_params.subsampling_x, cm->seq_params.subsampling_y);
if (s && !chroma_none) {
aom_wb_write_bit(wb, cm->rst_info[1].restoration_unit_size !=
cm->rst_info[0].restoration_unit_size);
@@ -2019,7 +2019,7 @@
if (num_planes > 1) {
int diff_uv_delta = (cm->u_dc_delta_q != cm->v_dc_delta_q) ||
(cm->u_ac_delta_q != cm->v_ac_delta_q);
- if (cm->separate_uv_delta_q) aom_wb_write_bit(wb, diff_uv_delta);
+ if (cm->seq_params.separate_uv_delta_q) aom_wb_write_bit(wb, diff_uv_delta);
write_delta_q(wb, cm->u_dc_delta_q);
write_delta_q(wb, cm->u_ac_delta_q);
if (diff_uv_delta) {
@@ -2031,7 +2031,7 @@
if (cm->using_qmatrix) {
aom_wb_write_literal(wb, cm->qm_y, QM_LEVEL_BITS);
aom_wb_write_literal(wb, cm->qm_u, QM_LEVEL_BITS);
- if (!cm->separate_uv_delta_q)
+ if (!cm->seq_params.separate_uv_delta_q)
assert(cm->qm_u == cm->qm_v);
else
aom_wb_write_literal(wb, cm->qm_v, QM_LEVEL_BITS);
@@ -2425,80 +2425,82 @@
aom_wb_write_literal(wb, profile, PROFILE_BITS);
}
-static void write_bitdepth(AV1_COMMON *const cm,
+static void write_bitdepth(const SequenceHeader *const seq_params,
struct aom_write_bit_buffer *wb) {
// Profile 0/1: [0] for 8 bit, [1] 10-bit
// Profile 2: [0] for 8 bit, [10] 10-bit, [11] - 12-bit
- aom_wb_write_bit(wb, cm->bit_depth == AOM_BITS_8 ? 0 : 1);
- if (cm->profile == PROFILE_2 && cm->bit_depth != AOM_BITS_8) {
- aom_wb_write_bit(wb, cm->bit_depth == AOM_BITS_10 ? 0 : 1);
+ aom_wb_write_bit(wb, seq_params->bit_depth == AOM_BITS_8 ? 0 : 1);
+ if (seq_params->profile == PROFILE_2 && seq_params->bit_depth != AOM_BITS_8) {
+ aom_wb_write_bit(wb, seq_params->bit_depth == AOM_BITS_10 ? 0 : 1);
}
}
-static void write_color_config(AV1_COMMON *const cm,
+static void write_color_config(const SequenceHeader *const seq_params,
struct aom_write_bit_buffer *wb) {
- write_bitdepth(cm, wb);
- const int is_monochrome = cm->seq_params.monochrome;
+ write_bitdepth(seq_params, wb);
+ const int is_monochrome = seq_params->monochrome;
// monochrome bit
- if (cm->profile != PROFILE_1)
+ if (seq_params->profile != PROFILE_1)
aom_wb_write_bit(wb, is_monochrome);
else
assert(!is_monochrome);
- if (cm->color_primaries == AOM_CICP_CP_UNSPECIFIED &&
- cm->transfer_characteristics == AOM_CICP_TC_UNSPECIFIED &&
- cm->matrix_coefficients == AOM_CICP_MC_UNSPECIFIED) {
+ if (seq_params->color_primaries == AOM_CICP_CP_UNSPECIFIED &&
+ seq_params->transfer_characteristics == AOM_CICP_TC_UNSPECIFIED &&
+ seq_params->matrix_coefficients == AOM_CICP_MC_UNSPECIFIED) {
aom_wb_write_bit(wb, 0); // No color description present
} else {
aom_wb_write_bit(wb, 1); // Color description present
- aom_wb_write_literal(wb, cm->color_primaries, 8);
- aom_wb_write_literal(wb, cm->transfer_characteristics, 8);
- aom_wb_write_literal(wb, cm->matrix_coefficients, 8);
+ aom_wb_write_literal(wb, seq_params->color_primaries, 8);
+ aom_wb_write_literal(wb, seq_params->transfer_characteristics, 8);
+ aom_wb_write_literal(wb, seq_params->matrix_coefficients, 8);
}
if (is_monochrome) {
// 0: [16, 235] (i.e. xvYCC), 1: [0, 255]
- aom_wb_write_bit(wb, cm->color_range);
+ aom_wb_write_bit(wb, seq_params->color_range);
return;
}
- if (cm->color_primaries == AOM_CICP_CP_BT_709 &&
- cm->transfer_characteristics == AOM_CICP_TC_SRGB &&
- cm->matrix_coefficients ==
+ if (seq_params->color_primaries == AOM_CICP_CP_BT_709 &&
+ seq_params->transfer_characteristics == AOM_CICP_TC_SRGB &&
+ seq_params->matrix_coefficients ==
AOM_CICP_MC_IDENTITY) { // it would be better to remove this
// dependency too
- assert(cm->subsampling_x == 0 && cm->subsampling_y == 0);
- assert(cm->profile == PROFILE_1 ||
- (cm->profile == PROFILE_2 && cm->bit_depth == AOM_BITS_12));
+ assert(seq_params->subsampling_x == 0 && seq_params->subsampling_y == 0);
+ assert(seq_params->profile == PROFILE_1 ||
+ (seq_params->profile == PROFILE_2 &&
+ seq_params->bit_depth == AOM_BITS_12));
} else {
// 0: [16, 235] (i.e. xvYCC), 1: [0, 255]
- aom_wb_write_bit(wb, cm->color_range);
- if (cm->profile == PROFILE_0) {
+ aom_wb_write_bit(wb, seq_params->color_range);
+ if (seq_params->profile == PROFILE_0) {
// 420 only
- assert(cm->subsampling_x == 1 && cm->subsampling_y == 1);
- } else if (cm->profile == PROFILE_1) {
+ assert(seq_params->subsampling_x == 1 && seq_params->subsampling_y == 1);
+ } else if (seq_params->profile == PROFILE_1) {
// 444 only
- assert(cm->subsampling_x == 0 && cm->subsampling_y == 0);
- } else if (cm->profile == PROFILE_2) {
- if (cm->bit_depth == AOM_BITS_12) {
+ assert(seq_params->subsampling_x == 0 && seq_params->subsampling_y == 0);
+ } else if (seq_params->profile == PROFILE_2) {
+ if (seq_params->bit_depth == AOM_BITS_12) {
// 420, 444 or 422
- aom_wb_write_bit(wb, cm->subsampling_x);
- if (cm->subsampling_x == 0) {
- assert(cm->subsampling_y == 0 &&
+ aom_wb_write_bit(wb, seq_params->subsampling_x);
+ if (seq_params->subsampling_x == 0) {
+ assert(seq_params->subsampling_y == 0 &&
"4:4:0 subsampling not allowed in AV1");
} else {
- aom_wb_write_bit(wb, cm->subsampling_y);
+ aom_wb_write_bit(wb, seq_params->subsampling_y);
}
} else {
// 422 only
- assert(cm->subsampling_x == 1 && cm->subsampling_y == 0);
+ assert(seq_params->subsampling_x == 1 &&
+ seq_params->subsampling_y == 0);
}
}
- if (cm->matrix_coefficients == AOM_CICP_MC_IDENTITY) {
- assert(cm->subsampling_x == 0 && cm->subsampling_y == 0);
+ if (seq_params->matrix_coefficients == AOM_CICP_MC_IDENTITY) {
+ assert(seq_params->subsampling_x == 0 && seq_params->subsampling_y == 0);
}
- if (cm->subsampling_x == 1 && cm->subsampling_y == 1) {
- aom_wb_write_literal(wb, cm->chroma_sample_position, 2);
+ if (seq_params->subsampling_x == 1 && seq_params->subsampling_y == 1) {
+ aom_wb_write_literal(wb, seq_params->chroma_sample_position, 2);
}
}
- aom_wb_write_bit(wb, cm->separate_uv_delta_q);
+ aom_wb_write_bit(wb, seq_params->separate_uv_delta_q);
}
static void write_timing_info_header(AV1_COMMON *const cm,
@@ -2609,8 +2611,8 @@
pars->chroma_scaling_from_luma = 0; // for monochrome override to 0
if (cm->seq_params.monochrome || pars->chroma_scaling_from_luma ||
- ((cm->subsampling_x == 1) && (cm->subsampling_y == 1) &&
- (pars->num_y_points == 0))) {
+ ((cm->seq_params.subsampling_x == 1) &&
+ (cm->seq_params.subsampling_y == 1) && (pars->num_y_points == 0))) {
pars->num_cb_points = 0;
pars->num_cr_points = 0;
} else {
@@ -3509,7 +3511,7 @@
struct aom_write_bit_buffer wb = { dst, 0 };
uint32_t size = 0;
- write_profile(cm->profile, &wb);
+ write_profile(cm->seq_params.profile, &wb);
// Still picture or not
aom_wb_write_bit(&wb, cm->seq_params.still_picture);
@@ -3563,7 +3565,7 @@
}
write_sequence_header(cpi, &wb);
- write_color_config(cm, &wb);
+ write_color_config(&cm->seq_params, &wb);
aom_wb_write_bit(&wb, cm->film_grain_params_present);
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 00f008b..02907d1 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4037,7 +4037,8 @@
// Copy data over into macro block data structures.
av1_setup_src_planes(x, cpi->source, 0, 0, num_planes);
- av1_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y, num_planes);
+ av1_setup_block_planes(xd, cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_y, num_planes);
}
static MV_REFERENCE_FRAME get_frame_type(const AV1_COMP *cpi) {
@@ -4135,7 +4136,7 @@
this_tile->tctx = *cm->fc;
td->mb.e_mbd.tile_ctx = &this_tile->tctx;
- cfl_init(&td->mb.e_mbd.cfl, cm);
+ cfl_init(&td->mb.e_mbd.cfl, &cm->seq_params);
av1_crc32c_calculator_init(&td->mb.mb_rd_record.crc_calculator);
@@ -4678,8 +4679,9 @@
}
compute_global_motion_feature_based(
- model, cpi->source, ref_buf[frame], cpi->common.bit_depth,
- inliers_by_motion, params_by_motion, RANSAC_NUM_MOTIONS);
+ model, cpi->source, ref_buf[frame],
+ cpi->common.seq_params.bit_depth, inliers_by_motion,
+ params_by_motion, RANSAC_NUM_MOTIONS);
for (i = 0; i < RANSAC_NUM_MOTIONS; ++i) {
if (inliers_by_motion[i] == 0) continue;
@@ -5088,8 +5090,9 @@
}
if (!is_inter) {
- xd->cfl.is_chroma_reference = is_chroma_reference(
- mi_row, mi_col, bsize, cm->subsampling_x, cm->subsampling_y);
+ xd->cfl.is_chroma_reference =
+ is_chroma_reference(mi_row, mi_col, bsize, cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_y);
xd->cfl.store_y = store_cfl_required(cm, xd);
mbmi->skip = 1;
for (int plane = 0; plane < num_planes; ++plane) {
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 9296837..14d0412 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -461,8 +461,8 @@
film_grain_test_vectors + oxcf->film_grain_test_vector - 1,
sizeof(cm->film_grain_params));
- cm->film_grain_params.bit_depth = cm->bit_depth;
- if (cm->color_range == AOM_CR_FULL_RANGE) {
+ cm->film_grain_params.bit_depth = cm->seq_params.bit_depth;
+ if (cm->seq_params.color_range == AOM_CR_FULL_RANGE) {
cm->film_grain_params.clip_to_restricted_range = 0;
}
}
@@ -614,8 +614,8 @@
seg->update_map = 1;
seg->update_data = 1;
- qi_delta =
- av1_compute_qdelta(rc, rc->avg_q, rc->avg_q * 0.875, cm->bit_depth);
+ qi_delta = av1_compute_qdelta(rc, rc->avg_q, rc->avg_q * 0.875,
+ cm->seq_params.bit_depth);
av1_set_segdata(seg, 1, SEG_LVL_ALT_Q, qi_delta - 2);
av1_set_segdata(seg, 1, SEG_LVL_ALT_LF_Y_H, -2);
av1_set_segdata(seg, 1, SEG_LVL_ALT_LF_Y_V, -2);
@@ -639,8 +639,8 @@
seg->update_map = 0;
seg->update_data = 1;
- qi_delta =
- av1_compute_qdelta(rc, rc->avg_q, rc->avg_q * 1.125, cm->bit_depth);
+ qi_delta = av1_compute_qdelta(rc, rc->avg_q, rc->avg_q * 1.125,
+ cm->seq_params.bit_depth);
av1_set_segdata(seg, 1, SEG_LVL_ALT_Q, qi_delta + 2);
av1_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);
@@ -723,53 +723,58 @@
static void alloc_raw_frame_buffers(AV1_COMP *cpi) {
AV1_COMMON *cm = &cpi->common;
+ const SequenceHeader *const seq_params = &cm->seq_params;
const AV1EncoderConfig *oxcf = &cpi->oxcf;
if (!cpi->lookahead)
- cpi->lookahead = av1_lookahead_init(
- oxcf->width, oxcf->height, cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, oxcf->lag_in_frames);
+ cpi->lookahead =
+ av1_lookahead_init(oxcf->width, oxcf->height, seq_params->subsampling_x,
+ seq_params->subsampling_y,
+ seq_params->use_highbitdepth, oxcf->lag_in_frames);
if (!cpi->lookahead)
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate lag buffers");
// TODO(agrange) Check if ARF is enabled and skip allocation if not.
- if (aom_realloc_frame_buffer(&cpi->alt_ref_buffer, oxcf->width, oxcf->height,
- cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
- cm->byte_alignment, NULL, NULL, NULL))
+ if (aom_realloc_frame_buffer(
+ &cpi->alt_ref_buffer, oxcf->width, oxcf->height,
+ seq_params->subsampling_x, seq_params->subsampling_y,
+ seq_params->use_highbitdepth, AOM_BORDER_IN_PIXELS,
+ cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate altref buffer");
}
static void alloc_util_frame_buffers(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
- if (aom_realloc_frame_buffer(&cpi->last_frame_uf, cm->width, cm->height,
- cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
- cm->byte_alignment, NULL, NULL, NULL))
+ const SequenceHeader *const seq_params = &cm->seq_params;
+ if (aom_realloc_frame_buffer(
+ &cpi->last_frame_uf, cm->width, cm->height, seq_params->subsampling_x,
+ seq_params->subsampling_y, seq_params->use_highbitdepth,
+ AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate last frame buffer");
if (aom_realloc_frame_buffer(
&cpi->trial_frame_rst, cm->superres_upscaled_width,
- cm->superres_upscaled_height, cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL,
- NULL, NULL))
+ cm->superres_upscaled_height, seq_params->subsampling_x,
+ seq_params->subsampling_y, seq_params->use_highbitdepth,
+ AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate trial restored frame buffer");
- if (aom_realloc_frame_buffer(&cpi->scaled_source, cm->width, cm->height,
- cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
- cm->byte_alignment, NULL, NULL, NULL))
+ if (aom_realloc_frame_buffer(
+ &cpi->scaled_source, cm->width, cm->height, seq_params->subsampling_x,
+ seq_params->subsampling_y, seq_params->use_highbitdepth,
+ AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate scaled source buffer");
- if (aom_realloc_frame_buffer(&cpi->scaled_last_source, cm->width, cm->height,
- cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
- cm->byte_alignment, NULL, NULL, NULL))
+ if (aom_realloc_frame_buffer(
+ &cpi->scaled_last_source, cm->width, cm->height,
+ seq_params->subsampling_x, seq_params->subsampling_y,
+ seq_params->use_highbitdepth, AOM_BORDER_IN_PIXELS,
+ cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate scaled last source buffer");
}
@@ -957,7 +962,8 @@
// Set the maximum parameters for bitrate and buffer size for this profile,
// level, and tier
cm->op_params[i].bitrate = max_level_bitrate(
- cm->profile, major_minor_to_seq_level_idx(seq->level[i]), seq->tier[i]);
+ cm->seq_params.profile, major_minor_to_seq_level_idx(seq->level[i]),
+ seq->tier[i]);
// Level with seq_level_idx = 31 returns a high "dummy" bitrate to pass the
// check
if (cm->op_params[i].bitrate == 0)
@@ -1022,15 +1028,15 @@
cpi->oxcf = *oxcf;
cpi->framerate = oxcf->init_framerate;
- cm->profile = oxcf->profile;
- cm->bit_depth = oxcf->bit_depth;
- cm->use_highbitdepth = oxcf->use_highbitdepth;
- cm->color_primaries = oxcf->color_primaries;
- cm->transfer_characteristics = oxcf->transfer_characteristics;
- cm->matrix_coefficients = oxcf->matrix_coefficients;
+ cm->seq_params.profile = oxcf->profile;
+ cm->seq_params.bit_depth = oxcf->bit_depth;
+ cm->seq_params.use_highbitdepth = oxcf->use_highbitdepth;
+ cm->seq_params.color_primaries = oxcf->color_primaries;
+ cm->seq_params.transfer_characteristics = oxcf->transfer_characteristics;
+ cm->seq_params.matrix_coefficients = oxcf->matrix_coefficients;
cm->seq_params.monochrome = oxcf->monochrome;
- cm->chroma_sample_position = oxcf->chroma_sample_position;
- cm->color_range = oxcf->color_range;
+ cm->seq_params.chroma_sample_position = oxcf->chroma_sample_position;
+ cm->seq_params.color_range = oxcf->color_range;
cm->timing_info_present = oxcf->timing_info_present;
cm->timing_info.num_units_in_display_tick =
oxcf->timing_info.num_units_in_display_tick;
@@ -1381,8 +1387,8 @@
static void highbd_set_var_fns(AV1_COMP *const cpi) {
AV1_COMMON *const cm = &cpi->common;
- if (cm->use_highbitdepth) {
- switch (cm->bit_depth) {
+ if (cm->seq_params.use_highbitdepth) {
+ switch (cm->seq_params.bit_depth) {
case AOM_BITS_8:
HIGHBD_BFP(BLOCK_64X16, aom_highbd_sad64x16_bits8,
aom_highbd_sad64x16_avg_bits8, aom_highbd_8_variance64x16,
@@ -2242,7 +2248,7 @@
default:
assert(0 &&
- "cm->bit_depth should be AOM_BITS_8, "
+ "cm->seq_params.bit_depth should be AOM_BITS_8, "
"AOM_BITS_10 or AOM_BITS_12");
}
}
@@ -2269,20 +2275,22 @@
void av1_change_config(struct AV1_COMP *cpi, const AV1EncoderConfig *oxcf) {
AV1_COMMON *const cm = &cpi->common;
+ SequenceHeader *const seq_params = &cm->seq_params;
const int num_planes = av1_num_planes(cm);
RATE_CONTROL *const rc = &cpi->rc;
MACROBLOCK *const x = &cpi->td.mb;
- if (cm->profile != oxcf->profile) cm->profile = oxcf->profile;
- cm->bit_depth = oxcf->bit_depth;
- cm->color_primaries = oxcf->color_primaries;
- cm->transfer_characteristics = oxcf->transfer_characteristics;
- cm->matrix_coefficients = oxcf->matrix_coefficients;
- cm->seq_params.monochrome = oxcf->monochrome;
- cm->chroma_sample_position = oxcf->chroma_sample_position;
- cm->color_range = oxcf->color_range;
+ if (seq_params->profile != oxcf->profile) seq_params->profile = oxcf->profile;
+ seq_params->bit_depth = oxcf->bit_depth;
+ seq_params->color_primaries = oxcf->color_primaries;
+ seq_params->transfer_characteristics = oxcf->transfer_characteristics;
+ seq_params->matrix_coefficients = oxcf->matrix_coefficients;
+ seq_params->monochrome = oxcf->monochrome;
+ seq_params->chroma_sample_position = oxcf->chroma_sample_position;
+ seq_params->color_range = oxcf->color_range;
- assert(IMPLIES(cm->profile <= PROFILE_1, cm->bit_depth <= AOM_BITS_10));
+ assert(IMPLIES(seq_params->profile <= PROFILE_1,
+ seq_params->bit_depth <= AOM_BITS_10));
cm->timing_info_present = oxcf->timing_info_present;
cm->timing_info.num_units_in_display_tick =
@@ -2293,9 +2301,9 @@
cm->timing_info.num_ticks_per_picture =
oxcf->timing_info.num_ticks_per_picture;
- cm->seq_params.display_model_info_present_flag =
+ seq_params->display_model_info_present_flag =
oxcf->display_model_info_present_flag;
- cm->seq_params.decoder_model_info_present_flag =
+ seq_params->decoder_model_info_present_flag =
oxcf->decoder_model_info_present_flag;
if (oxcf->decoder_model_info_present_flag) {
// set the decoder model parameters in schedule mode
@@ -2306,7 +2314,7 @@
set_dec_model_op_parameters(&cm->op_params[0]);
} else if (cm->timing_info_present &&
cm->timing_info.equal_picture_interval &&
- !cm->seq_params.decoder_model_info_present_flag) {
+ !seq_params->decoder_model_info_present_flag) {
// set the decoder model parameters in resource availability mode
set_resource_availability_parameters(&cm->op_params[0]);
} else {
@@ -2318,7 +2326,7 @@
cpi->oxcf = *oxcf;
cpi->common.options = oxcf->cfg;
- x->e_mbd.bd = (int)cm->bit_depth;
+ x->e_mbd.bd = (int)seq_params->bit_depth;
x->e_mbd.global_motion = cm->global_motion;
if ((oxcf->pass == 0) && (oxcf->rc_mode == AOM_Q)) {
@@ -2376,15 +2384,15 @@
cm->width = cpi->oxcf.width;
cm->height = cpi->oxcf.height;
- int sb_size = cm->seq_params.sb_size;
+ int sb_size = seq_params->sb_size;
// Superblock size should not be updated after the first key frame.
if (!cpi->seq_params_locked) {
set_sb_size(&cm->seq_params, select_sb_size(cpi));
}
- if (cpi->initial_width || sb_size != cm->seq_params.sb_size) {
+ if (cpi->initial_width || sb_size != seq_params->sb_size) {
if (cm->width > cpi->initial_width || cm->height > cpi->initial_height ||
- cm->seq_params.sb_size != sb_size) {
+ seq_params->sb_size != sb_size) {
av1_free_context_buffers(cm);
av1_free_pc_tree(&cpi->td, num_planes);
alloc_compressor_data(cpi);
@@ -2411,7 +2419,7 @@
// Init sequence level coding tools
// This should not be called after the first key frame.
if (!cpi->seq_params_locked) {
- cm->seq_params.operating_points_cnt_minus_1 =
+ seq_params->operating_points_cnt_minus_1 =
cm->number_spatial_layers > 1 ? cm->number_spatial_layers - 1 : 0;
init_seq_coding_tools(&cm->seq_params, cm, oxcf);
}
@@ -3673,13 +3681,14 @@
if (force_scaling || new_fb_ptr->buf.y_crop_width != cm->width ||
new_fb_ptr->buf.y_crop_height != cm->height) {
if (aom_realloc_frame_buffer(
- &new_fb_ptr->buf, cm->width, cm->height, cm->subsampling_x,
- cm->subsampling_y, cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
+ &new_fb_ptr->buf, cm->width, cm->height,
+ cm->seq_params.subsampling_x, cm->seq_params.subsampling_y,
+ cm->seq_params.use_highbitdepth, AOM_BORDER_IN_PIXELS,
cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
- av1_resize_and_extend_frame(ref, &new_fb_ptr->buf, (int)cm->bit_depth,
- num_planes);
+ av1_resize_and_extend_frame(
+ ref, &new_fb_ptr->buf, (int)cm->seq_params.bit_depth, num_planes);
cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
alloc_frame_mvs(cm, new_fb);
}
@@ -3824,13 +3833,14 @@
static void check_initial_width(AV1_COMP *cpi, int use_highbitdepth,
int subsampling_x, int subsampling_y) {
AV1_COMMON *const cm = &cpi->common;
+ SequenceHeader *const seq_params = &cm->seq_params;
- if (!cpi->initial_width || cm->use_highbitdepth != use_highbitdepth ||
- cm->subsampling_x != subsampling_x ||
- cm->subsampling_y != subsampling_y) {
- cm->subsampling_x = subsampling_x;
- cm->subsampling_y = subsampling_y;
- cm->use_highbitdepth = use_highbitdepth;
+ if (!cpi->initial_width || seq_params->use_highbitdepth != use_highbitdepth ||
+ seq_params->subsampling_x != subsampling_x ||
+ seq_params->subsampling_y != subsampling_y) {
+ seq_params->subsampling_x = subsampling_x;
+ seq_params->subsampling_y = subsampling_y;
+ seq_params->use_highbitdepth = use_highbitdepth;
alloc_raw_frame_buffers(cpi);
init_ref_frame_bufs(cm);
@@ -3848,8 +3858,9 @@
static int set_size_literal(AV1_COMP *cpi, int width, int height) {
AV1_COMMON *cm = &cpi->common;
const int num_planes = av1_num_planes(cm);
- check_initial_width(cpi, cm->use_highbitdepth, cm->subsampling_x,
- cm->subsampling_y);
+ check_initial_width(cpi, cm->seq_params.use_highbitdepth,
+ cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_y);
if (width <= 0 || height <= 0) return 1;
@@ -3871,6 +3882,7 @@
static void set_frame_size(AV1_COMP *cpi, int width, int height) {
AV1_COMMON *const cm = &cpi->common;
+ const SequenceHeader *const seq_params = &cm->seq_params;
const int num_planes = av1_num_planes(cm);
MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
int ref_frame;
@@ -3900,17 +3912,19 @@
}
// Reset the frame pointers to the current frame size.
- if (aom_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height,
- cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, AOM_BORDER_IN_PIXELS,
- cm->byte_alignment, NULL, NULL, NULL))
+ if (aom_realloc_frame_buffer(
+ get_frame_new_buffer(cm), cm->width, cm->height,
+ seq_params->subsampling_x, seq_params->subsampling_y,
+ seq_params->use_highbitdepth, AOM_BORDER_IN_PIXELS,
+ cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
const int frame_width = cm->superres_upscaled_width;
const int frame_height = cm->superres_upscaled_height;
- set_restoration_unit_size(frame_width, frame_height, cm->subsampling_x,
- cm->subsampling_y, cm->rst_info);
+ set_restoration_unit_size(frame_width, frame_height,
+ seq_params->subsampling_x,
+ seq_params->subsampling_y, cm->rst_info);
for (int i = 0; i < num_planes; ++i)
cm->rst_info[i].frame_restoration_type = RESTORE_NONE;
@@ -4156,16 +4170,16 @@
// av1_superres_upscale
if (aom_realloc_frame_buffer(
&cpi->scaled_source, cm->superres_upscaled_width,
- cm->superres_upscaled_height, cm->subsampling_x, cm->subsampling_y,
- cm->use_highbitdepth, AOM_BORDER_IN_PIXELS, cm->byte_alignment,
- NULL, NULL, NULL))
+ cm->superres_upscaled_height, cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_y, cm->seq_params.use_highbitdepth,
+ AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL))
aom_internal_error(
&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to reallocate scaled source buffer for superres");
assert(cpi->scaled_source.y_crop_width == cm->superres_upscaled_width);
assert(cpi->scaled_source.y_crop_height == cm->superres_upscaled_height);
av1_resize_and_extend_frame(cpi->unscaled_source, &cpi->scaled_source,
- (int)cm->bit_depth, num_planes);
+ (int)cm->seq_params.bit_depth, num_planes);
cpi->source = &cpi->scaled_source;
}
}
@@ -4449,7 +4463,7 @@
int64_t high_err_target = cpi->ambient_err;
int64_t low_err_target = cpi->ambient_err >> 1;
- if (cm->use_highbitdepth) {
+ if (cm->seq_params.use_highbitdepth) {
kf_err = aom_highbd_get_y_sse(cpi->source, get_frame_new_buffer(cm));
} else {
kf_err = aom_get_y_sse(cpi->source, get_frame_new_buffer(cm));
@@ -4857,6 +4871,7 @@
int skip_adapt,
unsigned int *frame_flags) {
AV1_COMMON *const cm = &cpi->common;
+ SequenceHeader *const seq_params = &cm->seq_params;
const AV1EncoderConfig *const oxcf = &cpi->oxcf;
struct segmentation *const seg = &cm->seg;
@@ -4872,7 +4887,7 @@
cm->large_scale_tile = cpi->oxcf.large_scale_tile;
cm->single_tile_decoding = cpi->oxcf.single_tile_decoding;
- if (cm->large_scale_tile) cm->seq_params.frame_id_numbers_present_flag = 0;
+ if (cm->large_scale_tile) seq_params->frame_id_numbers_present_flag = 0;
cm->allow_ref_frame_mvs &= frame_might_allow_ref_frame_mvs(cm);
// cm->allow_ref_frame_mvs needs to be written into the frame header while
@@ -5026,7 +5041,7 @@
MAX_MODES * sizeof(*cpi->mode_chosen_counts));
#endif
- if (cm->seq_params.frame_id_numbers_present_flag) {
+ if (seq_params->frame_id_numbers_present_flag) {
/* Non-normative definition of current_frame_id ("frame counter" with
* wraparound) */
const int frame_id_length = FRAME_ID_LENGTH;
@@ -5072,7 +5087,7 @@
(frame_is_intra_only(cm) || !cm->show_frame) ? 0 : 1;
break;
}
- cm->timing_info_present &= !cm->seq_params.reduced_still_picture_hdr;
+ cm->timing_info_present &= !seq_params->reduced_still_picture_hdr;
if (cpi->sf.recode_loop == DISALLOW_RECODE) {
if (encode_without_recode_loop(cpi) != AOM_CODEC_OK) return AOM_CODEC_ERROR;
@@ -5094,7 +5109,7 @@
// fixed interval. Note the reconstruction error if it is the frame before
// the force key frame
if (cpi->rc.next_key_frame_forced && cpi->rc.frames_to_key == 1) {
- if (cm->use_highbitdepth) {
+ if (seq_params->use_highbitdepth) {
cpi->ambient_err =
aom_highbd_get_y_sse(cpi->source, get_frame_new_buffer(cm));
} else {
@@ -5108,12 +5123,14 @@
}
cm->frame_to_show = get_frame_new_buffer(cm);
- cm->frame_to_show->color_primaries = cm->color_primaries;
- cm->frame_to_show->transfer_characteristics = cm->transfer_characteristics;
- cm->frame_to_show->matrix_coefficients = cm->matrix_coefficients;
- cm->frame_to_show->monochrome = cm->seq_params.monochrome;
- cm->frame_to_show->chroma_sample_position = cm->chroma_sample_position;
- cm->frame_to_show->color_range = cm->color_range;
+ cm->frame_to_show->color_primaries = seq_params->color_primaries;
+ cm->frame_to_show->transfer_characteristics =
+ seq_params->transfer_characteristics;
+ cm->frame_to_show->matrix_coefficients = seq_params->matrix_coefficients;
+ cm->frame_to_show->monochrome = seq_params->monochrome;
+ cm->frame_to_show->chroma_sample_position =
+ seq_params->chroma_sample_position;
+ cm->frame_to_show->color_range = seq_params->color_range;
cm->frame_to_show->render_width = cm->render_width;
cm->frame_to_show->render_height = cm->render_height;
@@ -5151,7 +5168,7 @@
if (skip_adapt) return AOM_CODEC_OK;
- if (cm->seq_params.frame_id_numbers_present_flag) {
+ if (seq_params->frame_id_numbers_present_flag) {
int i;
// Update reference frame id values based on the value of refresh_frame_mask
for (i = 0; i < REF_FRAMES; i++) {
@@ -5317,8 +5334,8 @@
int64_t time_stamp, int64_t end_time) {
AV1_COMMON *const cm = &cpi->common;
if (!cpi->denoise_and_model) {
- cpi->denoise_and_model =
- aom_denoise_and_model_alloc(cm->bit_depth, block_size, noise_level);
+ cpi->denoise_and_model = aom_denoise_and_model_alloc(
+ cm->seq_params.bit_depth, block_size, noise_level);
if (!cpi->denoise_and_model) {
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Error allocating denoise and model");
@@ -5349,6 +5366,7 @@
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
int64_t end_time) {
AV1_COMMON *const cm = &cpi->common;
+ const SequenceHeader *const seq_params = &cm->seq_params;
struct aom_usec_timer timer;
int res = 0;
const int subsampling_x = sd->subsampling_x;
@@ -5372,19 +5390,20 @@
aom_usec_timer_mark(&timer);
cpi->time_receive_data += aom_usec_timer_elapsed(&timer);
- if ((cm->profile == PROFILE_0) && !cm->seq_params.monochrome &&
+ if ((seq_params->profile == PROFILE_0) && !seq_params->monochrome &&
(subsampling_x != 1 || subsampling_y != 1)) {
aom_internal_error(&cm->error, AOM_CODEC_INVALID_PARAM,
"Non-4:2:0 color format requires profile 1 or 2");
res = -1;
}
- if ((cm->profile == PROFILE_1) &&
+ if ((seq_params->profile == PROFILE_1) &&
!(subsampling_x == 0 && subsampling_y == 0)) {
aom_internal_error(&cm->error, AOM_CODEC_INVALID_PARAM,
"Profile 1 requires 4:4:4 color format");
res = -1;
}
- if ((cm->profile == PROFILE_2) && (cm->bit_depth <= AOM_BITS_10) &&
+ if ((seq_params->profile == PROFILE_2) &&
+ (seq_params->bit_depth <= AOM_BITS_10) &&
!(subsampling_x == 1 && subsampling_y == 0)) {
aom_internal_error(&cm->error, AOM_CODEC_INVALID_PARAM,
"Profile 2 bit-depth < 10 requires 4:2:2 color format");
@@ -5556,9 +5575,9 @@
#endif
cpi->bytes += frame_bytes;
- if (cm->use_highbitdepth) {
+ if (cm->seq_params.use_highbitdepth) {
in_bit_depth = cpi->oxcf.input_bit_depth;
- bit_depth = cm->bit_depth;
+ bit_depth = cm->seq_params.bit_depth;
}
if (cm->show_frame) {
const YV12_BUFFER_CONFIG *orig = cpi->source;
@@ -5579,7 +5598,7 @@
cpi->total_samples += psnr.samples[0];
samples = psnr.samples[0];
// TODO(yaowu): unify these two versions into one.
- if (cm->use_highbitdepth)
+ if (cm->seq_params.use_highbitdepth)
frame_ssim2 =
aom_highbd_calc_ssim(orig, recon, &weight, bit_depth, in_bit_depth);
else
@@ -5604,7 +5623,7 @@
#endif
}
if (cpi->b_calculate_blockiness) {
- if (!cm->use_highbitdepth) {
+ if (!cm->seq_params.use_highbitdepth) {
const double frame_blockiness =
av1_get_blockiness(orig->y_buffer, orig->y_stride, recon->y_buffer,
recon->y_stride, orig->y_width, orig->y_height);
@@ -5613,7 +5632,7 @@
}
if (cpi->b_calculate_consistency) {
- if (!cm->use_highbitdepth) {
+ if (!cm->seq_params.use_highbitdepth) {
const double this_inconsistency = aom_get_ssim_metrics(
orig->y_buffer, orig->y_stride, recon->y_buffer, recon->y_stride,
orig->y_width, orig->y_height, cpi->ssim_vars, &cpi->metrics, 1);
@@ -6201,8 +6220,8 @@
*dest = *cm->frame_to_show;
dest->y_width = cm->width;
dest->y_height = cm->height;
- dest->uv_width = cm->width >> cm->subsampling_x;
- dest->uv_height = cm->height >> cm->subsampling_y;
+ dest->uv_width = cm->width >> cm->seq_params.subsampling_x;
+ dest->uv_height = cm->height >> cm->seq_params.subsampling_y;
ret = 0;
} else {
ret = -1;
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index f81169c..ef0800c 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -486,6 +486,7 @@
int mb_row, mb_col;
MACROBLOCK *const x = &cpi->td.mb;
AV1_COMMON *const cm = &cpi->common;
+ const SequenceHeader *const seq_params = &cm->seq_params;
const int num_planes = av1_num_planes(cm);
MACROBLOCKD *const xd = &x->e_mbd;
TileInfo tile;
@@ -524,7 +525,7 @@
double intra_factor;
double brightness_factor;
BufferPool *const pool = cm->buffer_pool;
- const int qindex = find_fp_qindex(cm->bit_depth);
+ const int qindex = find_fp_qindex(seq_params->bit_depth);
const int mb_scale = mi_size_wide[BLOCK_16X16];
int *raw_motion_err_list;
@@ -555,11 +556,11 @@
set_first_pass_params(cpi);
av1_set_quantizer(cm, qindex);
- av1_setup_block_planes(&x->e_mbd, cm->subsampling_x, cm->subsampling_y,
- num_planes);
+ av1_setup_block_planes(&x->e_mbd, seq_params->subsampling_x,
+ seq_params->subsampling_y, num_planes);
av1_setup_src_planes(x, cpi->source, 0, 0, num_planes);
- av1_setup_dst_planes(xd->plane, cm->seq_params.sb_size, new_yv12, 0, 0, 0,
+ av1_setup_dst_planes(xd->plane, seq_params->sb_size, new_yv12, 0, 0, 0,
num_planes);
if (!frame_is_intra_only(cm)) {
@@ -654,14 +655,14 @@
image_data_start_row = mb_row;
}
- if (cm->use_highbitdepth) {
- switch (cm->bit_depth) {
+ if (seq_params->use_highbitdepth) {
+ switch (seq_params->bit_depth) {
case AOM_BITS_8: break;
case AOM_BITS_10: this_error >>= 4; break;
case AOM_BITS_12: this_error >>= 8; break;
default:
assert(0 &&
- "cm->bit_depth should be AOM_BITS_8, "
+ "seq_params->bit_depth should be AOM_BITS_8, "
"AOM_BITS_10 or AOM_BITS_12");
return;
}
@@ -674,7 +675,7 @@
else
intra_factor += 1.0;
- if (cm->use_highbitdepth)
+ if (seq_params->use_highbitdepth)
level_sample = CONVERT_TO_SHORTPTR(x->plane[0].src.buf)[0];
else
level_sample = x->plane[0].src.buf[0];
@@ -1156,10 +1157,10 @@
for (q = rc->best_quality; q < rc->worst_quality; ++q) {
const double factor = calc_correction_factor(
av_err_per_mb, ERR_DIVISOR - ediv_size_correction, FACTOR_PT_LOW,
- FACTOR_PT_HIGH, q, cpi->common.bit_depth);
+ FACTOR_PT_HIGH, q, cpi->common.seq_params.bit_depth);
const int bits_per_mb = av1_rc_bits_per_mb(
INTER_FRAME, q, factor * speed_term * group_weight_factor,
- cpi->common.bit_depth);
+ cpi->common.seq_params.bit_depth);
if (bits_per_mb <= target_norm_bits_per_mb) break;
}
@@ -1377,7 +1378,7 @@
double this_frame_mv_in_out, double max_boost) {
double frame_boost;
const double lq = av1_convert_qindex_to_q(
- cpi->rc.avg_frame_qindex[INTER_FRAME], cpi->common.bit_depth);
+ cpi->rc.avg_frame_qindex[INTER_FRAME], cpi->common.seq_params.bit_depth);
const double boost_q_correction = AOMMIN((0.5 + (lq * 0.015)), 1.5);
int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE) ? cpi->initial_mbs
: cpi->common.MBs;
@@ -2905,10 +2906,10 @@
// Set a maximum and minimum interval for the GF group.
// If the image appears almost completely static we can extend beyond this.
{
- int int_max_q = (int)(av1_convert_qindex_to_q(twopass->active_worst_quality,
- cpi->common.bit_depth));
- int int_lbq = (int)(av1_convert_qindex_to_q(rc->last_boosted_qindex,
- cpi->common.bit_depth));
+ int int_max_q = (int)(av1_convert_qindex_to_q(
+ twopass->active_worst_quality, cpi->common.seq_params.bit_depth));
+ int int_lbq = (int)(av1_convert_qindex_to_q(
+ rc->last_boosted_qindex, cpi->common.seq_params.bit_depth));
active_min_gf_interval = rc->min_gf_interval + AOMMIN(2, int_max_q / 200);
if (active_min_gf_interval > rc->max_gf_interval)
@@ -3909,7 +3910,7 @@
twopass->baseline_active_worst_quality = tmp_q;
rc->ni_av_qi = tmp_q;
rc->last_q[INTER_FRAME] = tmp_q;
- rc->avg_q = av1_convert_qindex_to_q(tmp_q, cm->bit_depth);
+ rc->avg_q = av1_convert_qindex_to_q(tmp_q, cm->seq_params.bit_depth);
rc->avg_frame_qindex[INTER_FRAME] = tmp_q;
rc->last_q[KEY_FRAME] = (tmp_q + cpi->oxcf.best_allowed_q) / 2;
rc->avg_frame_qindex[KEY_FRAME] = rc->last_q[KEY_FRAME];
diff --git a/av1/encoder/pickcdef.c b/av1/encoder/pickcdef.c
index 4f62656..6d154a7 100644
--- a/av1/encoder/pickcdef.c
+++ b/av1/encoder/pickcdef.c
@@ -296,7 +296,7 @@
int ydec[3];
int pli;
int cdef_count;
- int coeff_shift = AOMMAX(cm->bit_depth - 8, 0);
+ int coeff_shift = AOMMAX(cm->seq_params.bit_depth - 8, 0);
uint64_t best_tot_mse = (uint64_t)1 << 63;
uint64_t tot_mse;
int sb_count;
@@ -317,8 +317,8 @@
DECLARE_ALIGNED(32, uint16_t, inbuf[CDEF_INBUF_SIZE]);
uint16_t *in;
DECLARE_ALIGNED(32, uint16_t, tmp_dst[1 << (MAX_SB_SIZE_LOG2 * 2)]);
- quantizer =
- av1_ac_quant_Q3(cm->base_qindex, 0, cm->bit_depth) >> (cm->bit_depth - 8);
+ quantizer = av1_ac_quant_Q3(cm->base_qindex, 0, cm->seq_params.bit_depth) >>
+ (cm->seq_params.bit_depth - 8);
lambda = .12 * quantizer * quantizer / 256.;
av1_setup_dst_planes(xd->plane, cm->seq_params.sb_size, frame, 0, 0, 0,
@@ -361,7 +361,7 @@
for (r = 0; r < frame_height; ++r) {
for (c = 0; c < frame_width; ++c) {
- if (cm->use_highbitdepth) {
+ if (cm->seq_params.use_highbitdepth) {
src[pli][r * stride[pli] + c] = CONVERT_TO_SHORTPTR(
xd->plane[pli].dst.buf)[r * xd->plane[pli].dst.stride + c];
ref_coeff[pli][r * stride[pli] + c] =
diff --git a/av1/encoder/picklpf.c b/av1/encoder/picklpf.c
index 5f802a7..461c3af 100644
--- a/av1/encoder/picklpf.c
+++ b/av1/encoder/picklpf.c
@@ -82,10 +82,8 @@
plane + 1, partial_frame);
#endif
- int highbd = 0;
- highbd = cm->use_highbitdepth;
-
- filt_err = aom_get_sse_plane(sd, cm->frame_to_show, plane, highbd);
+ filt_err = aom_get_sse_plane(sd, cm->frame_to_show, plane,
+ cm->seq_params.use_highbitdepth);
// Re-instate the unfiltered frame
yv12_copy_plane(&cpi->last_frame_uf, cm->frame_to_show, plane);
@@ -202,7 +200,7 @@
} else if (method >= LPF_PICK_FROM_Q) {
const int min_filter_level = 0;
const int max_filter_level = av1_get_max_filter_level(cpi);
- const int q = av1_ac_quant_Q3(cm->base_qindex, 0, cm->bit_depth);
+ const int q = av1_ac_quant_Q3(cm->base_qindex, 0, cm->seq_params.bit_depth);
// These values were determined by linear fitting the result of the
// searched level for 8 bit depth:
// Keyframes: filt_guess = q * 0.06699 - 1.60817
@@ -211,7 +209,7 @@
// And high bit depth separately:
// filt_guess = q * 0.316206 + 3.87252
int filt_guess;
- switch (cm->bit_depth) {
+ switch (cm->seq_params.bit_depth) {
case AOM_BITS_8:
filt_guess = (cm->frame_type == KEY_FRAME)
? ROUND_POWER_OF_TWO(q * 17563 - 421574, 18)
@@ -229,7 +227,7 @@
"or AOM_BITS_12");
return;
}
- if (cm->bit_depth != AOM_BITS_8 && cm->frame_type == KEY_FRAME)
+ if (cm->seq_params.bit_depth != AOM_BITS_8 && cm->frame_type == KEY_FRAME)
filt_guess -= 4;
// TODO(chengchen): retrain the model for Y, U, V filter levels
lf->filter_level[0] = clamp(filt_guess, min_filter_level, max_filter_level);
diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index 93ea096..28b693b 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -163,8 +163,8 @@
const int is_uv = plane > 0;
const RestorationInfo *rsi = &cm->rst_info[plane];
RestorationLineBuffers rlbs;
- const int bit_depth = cm->bit_depth;
- const int highbd = cm->use_highbitdepth;
+ const int bit_depth = cm->seq_params.bit_depth;
+ const int highbd = cm->seq_params.use_highbitdepth;
const YV12_BUFFER_CONFIG *fts = cm->frame_to_show;
// TODO(yunqing): For now, only use optimized LR filter in decoder. Can be
@@ -173,7 +173,8 @@
av1_loop_restoration_filter_unit(
limits, rui, &rsi->boundaries, &rlbs, tile_rect, rsc->tile_stripe0,
- is_uv && cm->subsampling_x, is_uv && cm->subsampling_y, highbd, bit_depth,
+ is_uv && cm->seq_params.subsampling_x,
+ is_uv && cm->seq_params.subsampling_y, highbd, bit_depth,
fts->buffers[plane], fts->strides[is_uv], rsc->dst->buffers[plane],
rsc->dst->strides[is_uv], cm->rst_tmpbuf, optimized_lr);
@@ -540,8 +541,8 @@
const MACROBLOCK *const x = rsc->x;
const AV1_COMMON *const cm = rsc->cm;
- const int highbd = cm->use_highbitdepth;
- const int bit_depth = cm->bit_depth;
+ const int highbd = cm->seq_params.use_highbitdepth;
+ const int bit_depth = cm->seq_params.bit_depth;
uint8_t *dgd_start =
rsc->dgd_buffer + limits->v_start * rsc->dgd_stride + limits->h_start;
@@ -549,8 +550,8 @@
rsc->src_buffer + limits->v_start * rsc->src_stride + limits->h_start;
const int is_uv = rsc->plane > 0;
- const int ss_x = is_uv && cm->subsampling_x;
- const int ss_y = is_uv && cm->subsampling_y;
+ const int ss_x = is_uv && cm->seq_params.subsampling_x;
+ const int ss_y = is_uv && cm->seq_params.subsampling_y;
const int procunit_width = RESTORATION_PROC_UNIT_SIZE >> ss_x;
const int procunit_height = RESTORATION_PROC_UNIT_SIZE >> ss_y;
@@ -1067,7 +1068,7 @@
double vfilterd[WIENER_WIN], hfilterd[WIENER_WIN];
const AV1_COMMON *const cm = rsc->cm;
- if (cm->use_highbitdepth) {
+ if (cm->seq_params.use_highbitdepth) {
compute_stats_highbd(wiener_win, rsc->dgd_buffer, rsc->src_buffer,
limits->h_start, limits->h_end, limits->v_start,
limits->v_end, rsc->dgd_stride, rsc->src_stride, M, H);
@@ -1149,7 +1150,7 @@
RestSearchCtxt *rsc = (RestSearchCtxt *)priv;
RestUnitSearchInfo *rusi = &rsc->rusi[rest_unit_idx];
- const int highbd = rsc->cm->use_highbitdepth;
+ const int highbd = rsc->cm->seq_params.use_highbitdepth;
rusi->sse[RESTORE_NONE] = sse_restoration_unit(
limits, rsc->src, rsc->cm->frame_to_show, rsc->plane, highbd);
@@ -1280,7 +1281,7 @@
double best_cost = 0;
RestorationType best_rtype = RESTORE_NONE;
- const int highbd = rsc.cm->use_highbitdepth;
+ const int highbd = rsc.cm->seq_params.use_highbitdepth;
extend_frame(rsc.dgd_buffer, rsc.plane_width, rsc.plane_height,
rsc.dgd_stride, RESTORATION_BORDER, RESTORATION_BORDER,
highbd);
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index f59f0e7..3aae014 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -421,9 +421,9 @@
projected_size_based_on_q =
av1_cyclic_refresh_estimate_bits_at_q(cpi, rate_correction_factor);
} else {
- projected_size_based_on_q =
- av1_estimate_bits_at_q(cpi->common.frame_type, cm->base_qindex, MBs,
- rate_correction_factor, cm->bit_depth);
+ projected_size_based_on_q = av1_estimate_bits_at_q(
+ cpi->common.frame_type, cm->base_qindex, MBs, rate_correction_factor,
+ cm->seq_params.bit_depth);
}
// Work out a size correction factor.
if (projected_size_based_on_q > FRAME_OVERHEAD_BITS)
@@ -495,7 +495,7 @@
(int)av1_cyclic_refresh_rc_bits_per_mb(cpi, i, correction_factor);
} else {
bits_per_mb_at_this_q = (int)av1_rc_bits_per_mb(
- cm->frame_type, i, correction_factor, cm->bit_depth);
+ cm->frame_type, i, correction_factor, cm->seq_params.bit_depth);
}
if (bits_per_mb_at_this_q <= target_bits_per_mb) {
@@ -643,7 +643,8 @@
int active_worst_quality = calc_active_worst_quality_one_pass_cbr(cpi);
int q;
int *rtc_minq;
- ASSIGN_MINQ_TABLE(cm->bit_depth, rtc_minq);
+ const int bit_depth = cm->seq_params.bit_depth;
+ ASSIGN_MINQ_TABLE(bit_depth, rtc_minq);
if (frame_is_intra_only(cm)) {
active_best_quality = rc->best_quality;
@@ -652,17 +653,17 @@
// based on the ambient Q to reduce the risk of popping.
if (rc->this_key_frame_forced) {
int qindex = rc->last_boosted_qindex;
- double last_boosted_q = av1_convert_qindex_to_q(qindex, cm->bit_depth);
- int delta_qindex = av1_compute_qdelta(
- rc, last_boosted_q, (last_boosted_q * 0.75), cm->bit_depth);
+ double last_boosted_q = av1_convert_qindex_to_q(qindex, bit_depth);
+ int delta_qindex = av1_compute_qdelta(rc, last_boosted_q,
+ (last_boosted_q * 0.75), bit_depth);
active_best_quality = AOMMAX(qindex + delta_qindex, rc->best_quality);
} else if (cm->current_video_frame > 0) {
// not first frame of one pass and kf_boost is set
double q_adj_factor = 1.0;
double q_val;
- active_best_quality = get_kf_active_quality(
- rc, rc->avg_frame_qindex[KEY_FRAME], cm->bit_depth);
+ active_best_quality =
+ get_kf_active_quality(rc, rc->avg_frame_qindex[KEY_FRAME], bit_depth);
// Allow somewhat lower kf minq with small image formats.
if ((width * height) <= (352 * 288)) {
@@ -671,9 +672,9 @@
// Convert the adjustment factor to a qindex delta
// on active_best_quality.
- q_val = av1_convert_qindex_to_q(active_best_quality, cm->bit_depth);
+ q_val = av1_convert_qindex_to_q(active_best_quality, bit_depth);
active_best_quality +=
- av1_compute_qdelta(rc, q_val, q_val * q_adj_factor, cm->bit_depth);
+ av1_compute_qdelta(rc, q_val, q_val * q_adj_factor, bit_depth);
}
} else if (!rc->is_src_frame_alt_ref &&
(cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) {
@@ -686,7 +687,7 @@
} else {
q = active_worst_quality;
}
- active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth);
+ active_best_quality = get_gf_active_quality(rc, q, bit_depth);
} else {
// Use the lower of active_worst_quality and recent/average Q.
if (cm->current_video_frame > 1) {
@@ -716,8 +717,8 @@
!(cm->current_video_frame == 0)) {
int qdelta = 0;
aom_clear_system_state();
- qdelta = av1_compute_qdelta_by_rate(
- &cpi->rc, cm->frame_type, active_worst_quality, 2.0, cm->bit_depth);
+ qdelta = av1_compute_qdelta_by_rate(&cpi->rc, cm->frame_type,
+ active_worst_quality, 2.0, bit_depth);
*top_index = active_worst_quality + qdelta;
*top_index = AOMMAX(*top_index, *bottom_index);
}
@@ -768,27 +769,27 @@
int active_worst_quality = calc_active_worst_quality_one_pass_vbr(cpi);
int q;
int *inter_minq;
- ASSIGN_MINQ_TABLE(cm->bit_depth, inter_minq);
+ const int bit_depth = cm->seq_params.bit_depth;
+ ASSIGN_MINQ_TABLE(bit_depth, inter_minq);
if (frame_is_intra_only(cm)) {
if (oxcf->rc_mode == AOM_Q) {
const int qindex = cq_level;
- const double q_val = av1_convert_qindex_to_q(qindex, cm->bit_depth);
+ const double q_val = av1_convert_qindex_to_q(qindex, bit_depth);
const int delta_qindex =
- av1_compute_qdelta(rc, q_val, q_val * 0.25, cm->bit_depth);
+ av1_compute_qdelta(rc, q_val, q_val * 0.25, bit_depth);
active_best_quality = AOMMAX(qindex + delta_qindex, rc->best_quality);
} else if (rc->this_key_frame_forced) {
const int qindex = rc->last_boosted_qindex;
- const double last_boosted_q =
- av1_convert_qindex_to_q(qindex, cm->bit_depth);
+ const double last_boosted_q = av1_convert_qindex_to_q(qindex, bit_depth);
const int delta_qindex = av1_compute_qdelta(
- rc, last_boosted_q, last_boosted_q * 0.75, cm->bit_depth);
+ rc, last_boosted_q, last_boosted_q * 0.75, bit_depth);
active_best_quality = AOMMAX(qindex + delta_qindex, rc->best_quality);
} else { // not first frame of one pass and kf_boost is set
double q_adj_factor = 1.0;
- active_best_quality = get_kf_active_quality(
- rc, rc->avg_frame_qindex[KEY_FRAME], cm->bit_depth);
+ active_best_quality =
+ get_kf_active_quality(rc, rc->avg_frame_qindex[KEY_FRAME], bit_depth);
// Allow somewhat lower kf minq with small image formats.
if ((width * height) <= (352 * 288)) {
@@ -798,9 +799,9 @@
// Convert the adjustment factor to a qindex delta on active_best_quality.
{
const double q_val =
- av1_convert_qindex_to_q(active_best_quality, cm->bit_depth);
+ av1_convert_qindex_to_q(active_best_quality, bit_depth);
active_best_quality +=
- av1_compute_qdelta(rc, q_val, q_val * q_adj_factor, cm->bit_depth);
+ av1_compute_qdelta(rc, q_val, q_val * q_adj_factor, bit_depth);
}
}
} else if (!rc->is_src_frame_alt_ref &&
@@ -815,30 +816,30 @@
// For constrained quality dont allow Q less than the cq level
if (oxcf->rc_mode == AOM_CQ) {
if (q < cq_level) q = cq_level;
- active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth);
+ active_best_quality = get_gf_active_quality(rc, q, bit_depth);
// Constrained quality use slightly lower active best.
active_best_quality = active_best_quality * 15 / 16;
} else if (oxcf->rc_mode == AOM_Q) {
const int qindex = cq_level;
- const double q_val = av1_convert_qindex_to_q(qindex, cm->bit_depth);
+ const double q_val = av1_convert_qindex_to_q(qindex, bit_depth);
const int delta_qindex =
(cpi->refresh_alt_ref_frame)
- ? av1_compute_qdelta(rc, q_val, q_val * 0.40, cm->bit_depth)
- : av1_compute_qdelta(rc, q_val, q_val * 0.50, cm->bit_depth);
+ ? av1_compute_qdelta(rc, q_val, q_val * 0.40, bit_depth)
+ : av1_compute_qdelta(rc, q_val, q_val * 0.50, bit_depth);
active_best_quality = AOMMAX(qindex + delta_qindex, rc->best_quality);
} else {
- active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth);
+ active_best_quality = get_gf_active_quality(rc, q, bit_depth);
}
} else {
if (oxcf->rc_mode == AOM_Q) {
const int qindex = cq_level;
- const double q_val = av1_convert_qindex_to_q(qindex, cm->bit_depth);
+ const double q_val = av1_convert_qindex_to_q(qindex, bit_depth);
const double delta_rate[FIXED_GF_INTERVAL] = { 0.50, 1.0, 0.85, 1.0,
0.70, 1.0, 0.85, 1.0 };
const int delta_qindex = av1_compute_qdelta(
rc, q_val,
q_val * delta_rate[cm->current_video_frame % FIXED_GF_INTERVAL],
- cm->bit_depth);
+ bit_depth);
active_best_quality = AOMMAX(qindex + delta_qindex, rc->best_quality);
} else {
// Use the lower of active_worst_quality and recent/average Q.
@@ -868,12 +869,12 @@
aom_clear_system_state();
if (cm->frame_type == KEY_FRAME && !rc->this_key_frame_forced &&
!(cm->current_video_frame == 0)) {
- qdelta = av1_compute_qdelta_by_rate(
- &cpi->rc, cm->frame_type, active_worst_quality, 2.0, cm->bit_depth);
+ qdelta = av1_compute_qdelta_by_rate(&cpi->rc, cm->frame_type,
+ active_worst_quality, 2.0, bit_depth);
} else if (!rc->is_src_frame_alt_ref &&
(cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) {
qdelta = av1_compute_qdelta_by_rate(
- &cpi->rc, cm->frame_type, active_worst_quality, 1.75, cm->bit_depth);
+ &cpi->rc, cm->frame_type, active_worst_quality, 1.75, bit_depth);
}
*top_index = active_worst_quality + qdelta;
*top_index = AOMMAX(*top_index, *bottom_index);
@@ -908,9 +909,9 @@
INTER_FRAME, INTER_FRAME, INTER_FRAME, INTER_FRAME, INTER_FRAME, KEY_FRAME
};
const AV1_COMMON *const cm = &cpi->common;
- int qdelta =
- av1_compute_qdelta_by_rate(&cpi->rc, frame_type[rf_level], q,
- rate_factor_deltas[rf_level], cm->bit_depth);
+ int qdelta = av1_compute_qdelta_by_rate(&cpi->rc, frame_type[rf_level], q,
+ rate_factor_deltas[rf_level],
+ cm->seq_params.bit_depth);
return qdelta;
}
@@ -927,7 +928,8 @@
int active_worst_quality = cpi->twopass.active_worst_quality;
int q;
int *inter_minq;
- ASSIGN_MINQ_TABLE(cm->bit_depth, inter_minq);
+ const int bit_depth = cm->seq_params.bit_depth;
+ ASSIGN_MINQ_TABLE(bit_depth, inter_minq);
#if CUSTOMIZED_GF
const int is_intrl_arf_boost =
@@ -948,16 +950,16 @@
if (cpi->twopass.last_kfgroup_zeromotion_pct >= STATIC_MOTION_THRESH) {
qindex = AOMMIN(rc->last_kf_qindex, rc->last_boosted_qindex);
active_best_quality = qindex;
- last_boosted_q = av1_convert_qindex_to_q(qindex, cm->bit_depth);
+ last_boosted_q = av1_convert_qindex_to_q(qindex, bit_depth);
delta_qindex = av1_compute_qdelta(rc, last_boosted_q,
- last_boosted_q * 1.25, cm->bit_depth);
+ last_boosted_q * 1.25, bit_depth);
active_worst_quality =
AOMMIN(qindex + delta_qindex, active_worst_quality);
} else {
qindex = rc->last_boosted_qindex;
- last_boosted_q = av1_convert_qindex_to_q(qindex, cm->bit_depth);
+ last_boosted_q = av1_convert_qindex_to_q(qindex, bit_depth);
delta_qindex = av1_compute_qdelta(rc, last_boosted_q,
- last_boosted_q * 0.75, cm->bit_depth);
+ last_boosted_q * 0.75, bit_depth);
active_best_quality = AOMMAX(qindex + delta_qindex, rc->best_quality);
}
} else {
@@ -967,7 +969,7 @@
// Baseline value derived from cpi->active_worst_quality and kf boost.
active_best_quality =
- get_kf_active_quality(rc, active_worst_quality, cm->bit_depth);
+ get_kf_active_quality(rc, active_worst_quality, bit_depth);
// Allow somewhat lower kf minq with small image formats.
if ((width * height) <= (352 * 288)) {
@@ -979,9 +981,9 @@
// Convert the adjustment factor to a qindex delta
// on active_best_quality.
- q_val = av1_convert_qindex_to_q(active_best_quality, cm->bit_depth);
+ q_val = av1_convert_qindex_to_q(active_best_quality, bit_depth);
active_best_quality +=
- av1_compute_qdelta(rc, q_val, q_val * q_adj_factor, cm->bit_depth);
+ av1_compute_qdelta(rc, q_val, q_val * q_adj_factor, bit_depth);
}
} else if (!rc->is_src_frame_alt_ref &&
(cpi->refresh_golden_frame || is_intrl_arf_boost ||
@@ -999,7 +1001,7 @@
if (oxcf->rc_mode == AOM_CQ) {
if (q < cq_level) q = cq_level;
- active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth);
+ active_best_quality = get_gf_active_quality(rc, q, bit_depth);
// Constrained quality use slightly lower active best.
active_best_quality = active_best_quality * 15 / 16;
@@ -1008,7 +1010,7 @@
if (!cpi->refresh_alt_ref_frame && !is_intrl_arf_boost) {
active_best_quality = cq_level;
} else {
- active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth);
+ active_best_quality = get_gf_active_quality(rc, q, bit_depth);
#if USE_SYMM_MULTI_LAYER
if (cpi->new_bwdref_update_rule && is_intrl_arf_boost) {
int this_height = gf_group->pyramid_level[gf_group->index];
@@ -1027,7 +1029,7 @@
#endif
}
} else {
- active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth);
+ active_best_quality = get_gf_active_quality(rc, q, bit_depth);
#if USE_SYMM_MULTI_LAYER
if (cpi->new_bwdref_update_rule && is_intrl_arf_boost) {
int this_height = gf_group->pyramid_level[gf_group->index];
@@ -1084,7 +1086,7 @@
// Modify active_best_quality for downscaled normal frames.
if (av1_frame_scaled(cm) && !frame_is_kf_gf_arf(cpi)) {
int qdelta = av1_compute_qdelta_by_rate(
- rc, cm->frame_type, active_best_quality, 2.0, cm->bit_depth);
+ rc, cm->frame_type, active_best_quality, 2.0, bit_depth);
active_best_quality =
AOMMAX(active_best_quality + qdelta, rc->best_quality);
}
@@ -1266,7 +1268,7 @@
rc->avg_frame_qindex[INTER_FRAME] =
ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[INTER_FRAME] + qindex, 2);
rc->ni_frames++;
- rc->tot_q += av1_convert_qindex_to_q(qindex, cm->bit_depth);
+ rc->tot_q += av1_convert_qindex_to_q(qindex, cm->seq_params.bit_depth);
rc->avg_q = rc->tot_q / rc->ni_frames;
// Calculate the average Q for normal inter frames (not key or GFU
// frames).
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 9f8be95..c4d4777 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -354,9 +354,10 @@
};
int av1_compute_rd_mult(const AV1_COMP *cpi, int qindex) {
- const int64_t q = av1_dc_quant_Q3(qindex, 0, cpi->common.bit_depth);
+ const int64_t q =
+ av1_dc_quant_Q3(qindex, 0, cpi->common.seq_params.bit_depth);
int64_t rdmult = 0;
- switch (cpi->common.bit_depth) {
+ switch (cpi->common.seq_params.bit_depth) {
case AOM_BITS_8: rdmult = 88 * q * q / 24; break;
case AOM_BITS_10: rdmult = ROUND_POWER_OF_TWO(88 * q * q / 24, 4); break;
case AOM_BITS_12: rdmult = ROUND_POWER_OF_TWO(88 * q * q / 24, 8); break;
@@ -391,7 +392,7 @@
}
void av1_initialize_me_consts(const AV1_COMP *cpi, MACROBLOCK *x, int qindex) {
- switch (cpi->common.bit_depth) {
+ switch (cpi->common.seq_params.bit_depth) {
case AOM_BITS_8:
x->sadperbit16 = sad_per_bit16lut_8[qindex];
x->sadperbit4 = sad_per_bit4lut_8[qindex];
@@ -417,7 +418,7 @@
clamp(av1_get_qindex(&cm->seg, segment_id, cm->base_qindex) +
cm->y_dc_delta_q,
0, MAXQ);
- const int q = compute_rd_thresh_factor(qindex, cm->bit_depth);
+ const int q = compute_rd_thresh_factor(qindex, cm->seq_params.bit_depth);
for (bsize = 0; bsize < BLOCK_SIZES_ALL; ++bsize) {
// Threshold here seems unnecessarily harsh but fine given actual
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index d66c4c3..fef6d28 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1157,7 +1157,7 @@
assert(bw <= 32);
assert(bh <= 32);
assert(((bw - 1) >> w_shift) + (((bh - 1) >> h_shift) << 2) == 15);
- if (cpi->common.use_highbitdepth) {
+ if (cpi->common.seq_params.use_highbitdepth) {
const uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
const uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
for (int i = 0; i < bh; ++i)
@@ -3342,7 +3342,7 @@
const int n_cache = av1_get_palette_cache(xd, 0, color_cache);
palette_mode_cost +=
av1_palette_color_cost_y(&mbmi->palette_mode_info, color_cache,
- n_cache, cpi->common.bit_depth);
+ n_cache, cpi->common.seq_params.bit_depth);
palette_mode_cost +=
av1_cost_color_map(x, 0, bsize, mbmi->tx_size, PALETTE_MAP);
total_rate += palette_mode_cost;
@@ -3393,8 +3393,8 @@
write_uniform_cost(plt_size, color_map[0]);
uint16_t color_cache[2 * PALETTE_MAX_SIZE];
const int n_cache = av1_get_palette_cache(xd, 1, color_cache);
- palette_mode_cost += av1_palette_color_cost_uv(pmi, color_cache, n_cache,
- cpi->common.bit_depth);
+ palette_mode_cost += av1_palette_color_cost_uv(
+ pmi, color_cache, n_cache, cpi->common.seq_params.bit_depth);
palette_mode_cost +=
av1_cost_color_map(x, 1, bsize, mbmi->tx_size, PALETTE_MAP);
total_rate += palette_mode_cost;
@@ -3534,10 +3534,10 @@
return;
}
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
- if (cpi->common.use_highbitdepth)
+ if (cpi->common.seq_params.use_highbitdepth)
for (int i = 0; i < k; ++i)
- pmi->palette_colors[i] =
- clip_pixel_highbd((int)centroids[i], cpi->common.bit_depth);
+ pmi->palette_colors[i] = clip_pixel_highbd(
+ (int)centroids[i], cpi->common.seq_params.bit_depth);
else
for (int i = 0; i < k; ++i)
pmi->palette_colors[i] = clip_pixel(centroids[i]);
@@ -3590,6 +3590,7 @@
MB_MODE_INFO *const mbmi = xd->mi[0];
assert(!is_inter_block(mbmi));
assert(av1_allow_palette(cpi->common.allow_screen_content_tools, bsize));
+ const SequenceHeader *const seq_params = &cpi->common.seq_params;
int colors, n;
const int src_stride = x->plane[0].src.stride;
const uint8_t *const src = x->plane[0].src.buf;
@@ -3599,9 +3600,9 @@
&cols);
int count_buf[1 << 12]; // Maximum (1 << 12) color levels.
- if (cpi->common.use_highbitdepth)
+ if (seq_params->use_highbitdepth)
colors = av1_count_colors_highbd(src, src_stride, rows, cols,
- cpi->common.bit_depth, count_buf);
+ seq_params->bit_depth, count_buf);
else
colors = av1_count_colors(src, src_stride, rows, cols, count_buf);
mbmi->filter_intra_mode_info.use_filter_intra = 0;
@@ -3613,12 +3614,12 @@
int centroids[PALETTE_MAX_SIZE];
int lb, ub, val;
uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
- if (cpi->common.use_highbitdepth)
+ if (seq_params->use_highbitdepth)
lb = ub = src16[0];
else
lb = ub = src[0];
- if (cpi->common.use_highbitdepth) {
+ if (seq_params->use_highbitdepth) {
for (r = 0; r < rows; ++r) {
for (c = 0; c < cols; ++c) {
val = src16[r * src_stride + c];
@@ -3652,7 +3653,7 @@
int top_colors[PALETTE_MAX_SIZE] = { 0 };
for (i = 0; i < AOMMIN(colors, PALETTE_MAX_SIZE); ++i) {
int max_count = 0;
- for (int j = 0; j < (1 << cpi->common.bit_depth); ++j) {
+ for (int j = 0; j < (1 << seq_params->bit_depth); ++j) {
if (count_buf[j] > max_count) {
max_count = count_buf[j];
top_colors[i] = j;
@@ -5581,6 +5582,7 @@
av1_allow_palette(cpi->common.allow_screen_content_tools, mbmi->sb_type));
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
const BLOCK_SIZE bsize = mbmi->sb_type;
+ const SequenceHeader *const seq_params = &cpi->common.seq_params;
int this_rate;
int64_t this_rd;
int colors_u, colors_v, colors;
@@ -5596,11 +5598,11 @@
mbmi->uv_mode = UV_DC_PRED;
int count_buf[1 << 12]; // Maximum (1 << 12) color levels.
- if (cpi->common.use_highbitdepth) {
+ if (seq_params->use_highbitdepth) {
colors_u = av1_count_colors_highbd(src_u, src_stride, rows, cols,
- cpi->common.bit_depth, count_buf);
+ seq_params->bit_depth, count_buf);
colors_v = av1_count_colors_highbd(src_v, src_stride, rows, cols,
- cpi->common.bit_depth, count_buf);
+ seq_params->bit_depth, count_buf);
} else {
colors_u = av1_count_colors(src_u, src_stride, rows, cols, count_buf);
colors_v = av1_count_colors(src_v, src_stride, rows, cols, count_buf);
@@ -5620,7 +5622,7 @@
uint16_t *src_u16 = CONVERT_TO_SHORTPTR(src_u);
uint16_t *src_v16 = CONVERT_TO_SHORTPTR(src_v);
- if (cpi->common.use_highbitdepth) {
+ if (seq_params->use_highbitdepth) {
lb_u = src_u16[0];
ub_u = src_u16[0];
lb_v = src_v16[0];
@@ -5634,7 +5636,7 @@
for (r = 0; r < rows; ++r) {
for (c = 0; c < cols; ++c) {
- if (cpi->common.use_highbitdepth) {
+ if (seq_params->use_highbitdepth) {
val_u = src_u16[r * src_stride + c];
val_v = src_v16[r * src_stride + c];
data[(r * cols + c) * 2] = val_u;
@@ -5683,9 +5685,9 @@
pmi->palette_size[1] = n;
for (i = 1; i < 3; ++i) {
for (j = 0; j < n; ++j) {
- if (cpi->common.use_highbitdepth)
+ if (seq_params->use_highbitdepth)
pmi->palette_colors[i * PALETTE_MAX_SIZE + j] = clip_pixel_highbd(
- (int)centroids[j * 2 + i - 1], cpi->common.bit_depth);
+ (int)centroids[j * 2 + i - 1], seq_params->bit_depth);
else
pmi->palette_colors[i * PALETTE_MAX_SIZE + j] =
clip_pixel((int)centroids[j * 2 + i - 1]);
@@ -6033,8 +6035,9 @@
*mode_uv = UV_DC_PRED;
return;
}
- xd->cfl.is_chroma_reference = is_chroma_reference(
- mi_row, mi_col, bsize, cm->subsampling_x, cm->subsampling_y);
+ xd->cfl.is_chroma_reference =
+ is_chroma_reference(mi_row, mi_col, bsize, cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_y);
bsize = scale_chroma_bsize(bsize, xd->plane[AOM_PLANE_U].subsampling_x,
xd->plane[AOM_PLANE_U].subsampling_y);
// Only store reconstructed luma when there's chroma RDO. When there's no
@@ -9305,8 +9308,9 @@
if (intra_yrd < best_rd) {
// Only store reconstructed luma when there's chroma RDO. When there's no
// chroma RDO, the reconstructed luma will be stored in encode_superblock().
- xd->cfl.is_chroma_reference = is_chroma_reference(
- mi_row, mi_col, bsize, cm->subsampling_x, cm->subsampling_y);
+ xd->cfl.is_chroma_reference =
+ is_chroma_reference(mi_row, mi_col, bsize, cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_y);
xd->cfl.store_y = store_cfl_required_rdo(cm, x);
if (xd->cfl.store_y) {
// Restore reconstructed luma values.
@@ -9373,7 +9377,7 @@
for (r = 0; r < rows; ++r) {
for (c = 0; c < cols; ++c) {
- if (cpi->common.use_highbitdepth) {
+ if (cpi->common.seq_params.use_highbitdepth) {
data[(r * cols + c) * 2] = src_u16[r * src_stride + c];
data[(r * cols + c) * 2 + 1] = src_v16[r * src_stride + c];
} else {
@@ -10151,7 +10155,7 @@
av1_allow_palette(cm->allow_screen_content_tools, mbmi->sb_type);
const int *const intra_mode_cost = x->mbmode_cost[size_group_lookup[bsize]];
const int intra_cost_penalty = av1_get_intra_cost_penalty(
- cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth);
+ cm->base_qindex, cm->y_dc_delta_q, cm->seq_params.bit_depth);
const int rows = block_size_high[bsize];
const int cols = block_size_wide[bsize];
const int num_planes = av1_num_planes(cm);
diff --git a/av1/encoder/temporal_filter.c b/av1/encoder/temporal_filter.c
index 250feab..d7e4f4e 100644
--- a/av1/encoder/temporal_filter.c
+++ b/av1/encoder/temporal_filter.c
@@ -535,10 +535,10 @@
// Adjust the strength based on active max q.
if (cpi->common.current_video_frame > 1)
q = ((int)av1_convert_qindex_to_q(cpi->rc.avg_frame_qindex[INTER_FRAME],
- cpi->common.bit_depth));
+ cpi->common.seq_params.bit_depth));
else
q = ((int)av1_convert_qindex_to_q(cpi->rc.avg_frame_qindex[KEY_FRAME],
- cpi->common.bit_depth));
+ cpi->common.seq_params.bit_depth));
if (q > 16) {
strength = oxcf->arnr_strength;
} else {
diff --git a/test/resize_test.cc b/test/resize_test.cc
index e1c4e9f..b270b83 100644
--- a/test/resize_test.cc
+++ b/test/resize_test.cc
@@ -546,12 +546,6 @@
#endif
}
-aom_img_fmt_t CspForFrameNumber(int frame) {
- if (frame < 10) return AOM_IMG_FMT_I420;
- if (frame < 20) return AOM_IMG_FMT_I444;
- return AOM_IMG_FMT_I420;
-}
-
class ResizeCspTest : public ResizeTest {
protected:
#if WRITE_COMPRESSED_STREAM
@@ -580,20 +574,6 @@
#endif
}
- virtual void PreEncodeFrameHook(libaom_test::VideoSource *video,
- libaom_test::Encoder *encoder) {
- if (CspForFrameNumber(video->frame()) != AOM_IMG_FMT_I420 &&
- cfg_.g_profile != 1) {
- cfg_.g_profile = 1;
- encoder->Config(&cfg_);
- }
- if (CspForFrameNumber(video->frame()) == AOM_IMG_FMT_I420 &&
- cfg_.g_profile != 0) {
- cfg_.g_profile = 0;
- encoder->Config(&cfg_);
- }
- }
-
virtual void PSNRPktHook(const aom_codec_cx_pkt_t *pkt) {
if (frame0_psnr_ == 0.) frame0_psnr_ = pkt->data.psnr.psnr[0];
EXPECT_NEAR(pkt->data.psnr.psnr[0], frame0_psnr_, 2.0);
@@ -621,19 +601,13 @@
class ResizingCspVideoSource : public ::libaom_test::DummyVideoSource {
public:
- ResizingCspVideoSource() {
+ explicit ResizingCspVideoSource(aom_img_fmt_t image_format) {
SetSize(kInitialWidth, kInitialHeight);
+ SetImageFormat(image_format);
limit_ = 30;
}
virtual ~ResizingCspVideoSource() {}
-
- protected:
- virtual void Next() {
- ++frame_;
- SetImageFormat(CspForFrameNumber(frame_));
- FillFrame();
- }
};
#if (defined(DISABLE_TRELLISQ_SEARCH) && DISABLE_TRELLISQ_SEARCH)
@@ -641,14 +615,19 @@
#else
TEST_P(ResizeCspTest, TestResizeCspWorks) {
#endif
- ResizingCspVideoSource video;
- init_flags_ = AOM_CODEC_USE_PSNR;
- cfg_.rc_min_quantizer = cfg_.rc_max_quantizer = 48;
- cfg_.g_lag_in_frames = 0;
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+ const aom_img_fmt_t image_formats[] = { AOM_IMG_FMT_I420, AOM_IMG_FMT_I444 };
+ for (size_t i = 0; i < GTEST_ARRAY_SIZE_(image_formats); ++i) {
+ ResizingCspVideoSource video(image_formats[i]);
+ init_flags_ = AOM_CODEC_USE_PSNR;
+ cfg_.rc_min_quantizer = cfg_.rc_max_quantizer = 48;
+ cfg_.g_lag_in_frames = 0;
+ cfg_.g_profile = (image_formats[i] == AOM_IMG_FMT_I420) ? 0 : 1;
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- // Check we decoded the same number of frames as we attempted to encode
- ASSERT_EQ(frame_info_list_.size(), video.limit());
+ // Check we decoded the same number of frames as we attempted to encode
+ ASSERT_EQ(frame_info_list_.size(), video.limit());
+ frame_info_list_.clear();
+ }
}
AV1_INSTANTIATE_TEST_CASE(ResizeTest,