static int FUNC(obu_header)(CodedBitstreamContext *ctx, RWContext *rw,
AV1RawOBUHeader *current)
{
+ CodedBitstreamAV1Context *priv = ctx->priv_data;
int err;
- av_unused int zero = 0;
HEADER("OBU header");
fb(3, temporal_id);
fb(2, spatial_id);
fc(3, extension_header_reserved_3bits, 0, 0);
+ } else {
+ infer(temporal_id, 0);
+ infer(spatial_id, 0);
}
+ priv->temporal_id = current->temporal_id;
+ priv->spatial_id = current->spatial_id;
+
return 0;
}
flag(enable_intra_edge_filter);
if (current->reduced_still_picture_header) {
- infer(enable_intraintra_compound, 0);
+ infer(enable_interintra_compound, 0);
infer(enable_masked_compound, 0);
infer(enable_warped_motion, 0);
infer(enable_dual_filter, 0);
infer(seq_force_integer_mv,
AV1_SELECT_INTEGER_MV);
} else {
- flag(enable_intraintra_compound);
+ flag(enable_interintra_compound);
flag(enable_masked_compound);
flag(enable_warped_motion);
flag(enable_dual_filter);
for (i = 0; i < AV1_NUM_REF_FRAMES; i++)
shifted_order_hints[i] = cur_frame_hint +
cbs_av1_get_relative_dist(seq, priv->ref[i].order_hint,
- current->order_hint);
+ priv->order_hint);
latest_order_hint = shifted_order_hints[current->last_frame_idx];
earliest_order_hint = shifted_order_hints[current->golden_frame_idx];
if (current->frame_size_override_flag) {
fb(seq->frame_width_bits_minus_1 + 1, frame_width_minus_1);
fb(seq->frame_height_bits_minus_1 + 1, frame_height_minus_1);
-
- priv->frame_width = current->frame_width_minus_1 + 1;
- priv->frame_height = current->frame_height_minus_1 + 1;
} else {
- priv->frame_width = seq->max_frame_width_minus_1 + 1;
- priv->frame_height = seq->max_frame_height_minus_1 + 1;
+ infer(frame_width_minus_1, seq->max_frame_width_minus_1);
+ infer(frame_height_minus_1, seq->max_frame_height_minus_1);
}
+ priv->frame_width = current->frame_width_minus_1 + 1;
+ priv->frame_height = current->frame_height_minus_1 + 1;
+
CHECK(FUNC(superres_params)(ctx, rw, current));
return 0;
if (current->render_and_frame_size_different) {
fb(16, render_width_minus_1);
fb(16, render_height_minus_1);
-
- priv->render_width = current->render_width_minus_1 + 1;
- priv->render_height = current->render_height_minus_1 + 1;
} else {
- priv->render_width = priv->upscaled_width;
- priv->render_height = priv->frame_height;
+ infer(render_width_minus_1, current->frame_width_minus_1);
+ infer(render_height_minus_1, current->frame_height_minus_1);
}
+ priv->render_width = current->render_width_minus_1 + 1;
+ priv->render_height = current->render_height_minus_1 + 1;
+
return 0;
}
return AVERROR_INVALIDDATA;
}
+ infer(frame_width_minus_1, ref->upscaled_width - 1);
+ infer(frame_height_minus_1, ref->frame_height - 1);
+ infer(render_width_minus_1, ref->render_width - 1);
+ infer(render_height_minus_1, ref->render_height - 1);
+
priv->upscaled_width = ref->upscaled_width;
- priv->frame_width = ref->frame_width;
+ priv->frame_width = priv->upscaled_width;
priv->frame_height = ref->frame_height;
priv->render_width = ref->render_width;
priv->render_height = ref->render_height;
current->tile_rows_log2;
current->tile_rows = (sb_rows + tile_height_sb - 1) / tile_height_sb;
+ for (i = 0; i < current->tile_cols - 1; i++)
+ infer(width_in_sbs_minus_1[i], tile_width_sb - 1);
+ infer(width_in_sbs_minus_1[i],
+ sb_cols - (current->tile_cols - 1) * tile_width_sb - 1);
+ for (i = 0; i < current->tile_rows - 1; i++)
+ infer(height_in_sbs_minus_1[i], tile_height_sb - 1);
+ infer(height_in_sbs_minus_1[i],
+ sb_rows - (current->tile_rows - 1) * tile_height_sb - 1);
+
} else {
int widest_tile_sb, start_sb, size_sb, max_width, max_height;
for (i = 0; i < priv->num_planes; i++) {
fbs(2, lr_type[i], 1, i);
- if (current->lr_type[i] != 0) {
+ if (current->lr_type[i] != AV1_RESTORE_NONE) {
uses_lr = 1;
if (i > 0)
uses_chroma_lr = 1;
for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
ref_hint = priv->ref[current->ref_frame_idx[i]].order_hint;
dist = cbs_av1_get_relative_dist(seq, ref_hint,
- current->order_hint);
+ priv->order_hint);
if (dist < 0) {
if (forward_idx < 0 ||
cbs_av1_get_relative_dist(seq, ref_hint,
return 0;
}
- fb(4, num_y_points);
+ fc(4, num_y_points, 0, 14);
for (i = 0; i < current->num_y_points; i++) {
- fbs(8, point_y_value[i], 1, i);
+ fcs(8, point_y_value[i],
+ i ? current->point_y_value[i - 1] + 1 : 0,
+ MAX_UINT_BITS(8) - (current->num_y_points - i - 1),
+ 1, i);
fbs(8, point_y_scaling[i], 1, i);
}
infer(num_cb_points, 0);
infer(num_cr_points, 0);
} else {
- fb(4, num_cb_points);
+ fc(4, num_cb_points, 0, 10);
for (i = 0; i < current->num_cb_points; i++) {
- fbs(8, point_cb_value[i], 1, i);
+ fcs(8, point_cb_value[i],
+ i ? current->point_cb_value[i - 1] + 1 : 0,
+ MAX_UINT_BITS(8) - (current->num_cb_points - i - 1),
+ 1, i);
fbs(8, point_cb_scaling[i], 1, i);
}
- fb(4, num_cr_points);
+ fc(4, num_cr_points, 0, 10);
for (i = 0; i < current->num_cr_points; i++) {
- fbs(8, point_cr_value[i], 1, i);
+ fcs(8, point_cr_value[i],
+ i ? current->point_cr_value[i - 1] + 1 : 0,
+ MAX_UINT_BITS(8) - (current->num_cr_points - i - 1),
+ 1, i);
fbs(8, point_cr_scaling[i], 1, i);
}
}
flag(show_existing_frame);
if (current->show_existing_frame) {
- AV1ReferenceFrameState *frame;
+ AV1ReferenceFrameState *ref;
fb(3, frame_to_show_map_idx);
- frame = &priv->ref[current->frame_to_show_map_idx];
+ ref = &priv->ref[current->frame_to_show_map_idx];
+
+ if (!ref->valid) {
+ av_log(ctx->log_ctx, AV_LOG_ERROR, "Missing reference frame needed for "
+ "show_existing_frame (frame_to_show_map_idx = %d).\n",
+ current->frame_to_show_map_idx);
+ return AVERROR_INVALIDDATA;
+ }
if (seq->decoder_model_info_present_flag &&
!seq->timing_info.equal_picture_interval) {
if (seq->frame_id_numbers_present_flag)
fb(id_len, display_frame_id);
- if (frame->frame_type == AV1_FRAME_KEY)
+ infer(frame_type, ref->frame_type);
+ if (current->frame_type == AV1_FRAME_KEY) {
infer(refresh_frame_flags, all_frames);
- else
+
+ // Section 7.21
+ infer(current_frame_id, ref->frame_id);
+ priv->upscaled_width = ref->upscaled_width;
+ priv->frame_width = ref->frame_width;
+ priv->frame_height = ref->frame_height;
+ priv->render_width = ref->render_width;
+ priv->render_height = ref->render_height;
+ priv->bit_depth = ref->bit_depth;
+ priv->order_hint = ref->order_hint;
+ } else
infer(refresh_frame_flags, 0);
- return 0;
+ infer(frame_width_minus_1, ref->upscaled_width - 1);
+ infer(frame_height_minus_1, ref->frame_height - 1);
+ infer(render_width_minus_1, ref->render_width - 1);
+ infer(render_height_minus_1, ref->render_height - 1);
+
+ // Section 7.20
+ goto update_refs;
}
fb(2, frame_type);
fb(order_hint_bits, order_hint);
else
infer(order_hint, 0);
+ priv->order_hint = current->order_hint;
if (frame_is_intra || current->error_resilient_mode)
infer(primary_ref_frame, AV1_PRIMARY_REF_NONE);
int in_temporal_layer = (op_pt_idc >> priv->temporal_id ) & 1;
int in_spatial_layer = (op_pt_idc >> (priv->spatial_id + 8)) & 1;
if (seq->operating_point_idc[i] == 0 ||
- in_temporal_layer || in_spatial_layer) {
+ (in_temporal_layer && in_spatial_layer)) {
fbs(seq->decoder_model_info.buffer_removal_time_length_minus_1 + 1,
buffer_removal_time[i], 1, i);
}
CHECK(FUNC(film_grain_params)(ctx, rw, current));
+ av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame %d: size %dx%d "
+ "upscaled %d render %dx%d subsample %dx%d "
+ "bitdepth %d tiles %dx%d.\n", priv->order_hint,
+ priv->frame_width, priv->frame_height, priv->upscaled_width,
+ priv->render_width, priv->render_height,
+ seq->color_config.subsampling_x + 1,
+ seq->color_config.subsampling_y + 1, priv->bit_depth,
+ priv->tile_rows, priv->tile_cols);
+
+update_refs:
for (i = 0; i < AV1_NUM_REF_FRAMES; i++) {
if (current->refresh_frame_flags & (1 << i)) {
priv->ref[i] = (AV1ReferenceFrameState) {
.subsampling_x = seq->color_config.subsampling_x,
.subsampling_y = seq->color_config.subsampling_y,
.bit_depth = priv->bit_depth,
- .order_hint = current->order_hint,
+ .order_hint = priv->order_hint,
};
}
}
- av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame %d: size %dx%d "
- "upscaled %d render %dx%d subsample %dx%d "
- "bitdepth %d tiles %dx%d.\n", current->order_hint,
- priv->frame_width, priv->frame_height, priv->upscaled_width,
- priv->render_width, priv->render_height,
- seq->color_config.subsampling_x + 1,
- seq->color_config.subsampling_y + 1, priv->bit_depth,
- priv->tile_rows, priv->tile_cols);
-
return 0;
}
else
HEADER("Frame Header");
- priv->seen_frame_header = 1;
-
#ifdef READ
start_pos = get_bits_count(rw);
#else