[FFmpeg-devel] [PATCH 3/3] avcodec/cbs_av1: remove frame dimensions from CodedBitstreamAV1Context
James Almer
jamrial at gmail.com
Sun Aug 23 05:02:18 EEST 2020
The values contained in these fields are only valid for the last frame parsed
by CBS. Unlike tile_rows and tile_cols, these are not used in functions within
cbs_av1_syntax_template.c that don't have access to the relevant
AV1RawFrameHeader, and since each frame now has their relevant derived values,
there's no need to keep these here anymore.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavcodec/cbs_av1.h | 5 ---
libavcodec/cbs_av1_syntax_template.c | 55 ++++++++++++++--------------
2 files changed, 27 insertions(+), 33 deletions(-)
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 4482498eb3..0eb78bef83 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -437,11 +437,6 @@ typedef struct CodedBitstreamAV1Context {
int operating_point_idc;
int bit_depth;
- int frame_width;
- int frame_height;
- int upscaled_width;
- int render_width;
- int render_height;
int num_planes;
int coded_lossless;
diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 27d04375fc..96dc864bd2 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -468,9 +468,9 @@ static int FUNC(superres_params)(CodedBitstreamContext *ctx, RWContext *rw,
denom = AV1_SUPERRES_NUM;
}
- priv->upscaled_width = current->upscaled_width = priv->frame_width;
- priv->frame_width = current->frame_width = (priv->upscaled_width * AV1_SUPERRES_NUM +
- denom / 2) / denom;
+ current->upscaled_width = current->frame_width;
+ current->frame_width = (current->upscaled_width * AV1_SUPERRES_NUM +
+ denom / 2) / denom;
return 0;
}
@@ -486,11 +486,11 @@ static int FUNC(frame_size)(CodedBitstreamContext *ctx, RWContext *rw,
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 = current->frame_width_minus_1 + 1;
- priv->frame_height = current->frame_height = current->frame_height_minus_1 + 1;
+ current->frame_width = current->frame_width_minus_1 + 1;
+ current->frame_height = current->frame_height_minus_1 + 1;
} else {
- priv->frame_width = current->frame_width = seq->max_frame_width_minus_1 + 1;
- priv->frame_height = current->frame_height = seq->max_frame_height_minus_1 + 1;
+ current->frame_width = seq->max_frame_width_minus_1 + 1;
+ current->frame_height = seq->max_frame_height_minus_1 + 1;
}
CHECK(FUNC(superres_params)(ctx, rw, current));
@@ -501,7 +501,6 @@ static int FUNC(frame_size)(CodedBitstreamContext *ctx, RWContext *rw,
static int FUNC(render_size)(CodedBitstreamContext *ctx, RWContext *rw,
AV1RawFrameHeader *current)
{
- CodedBitstreamAV1Context *priv = ctx->priv_data;
int err;
flag(render_and_frame_size_different);
@@ -510,11 +509,11 @@ static int FUNC(render_size)(CodedBitstreamContext *ctx, RWContext *rw,
fb(16, render_width_minus_1);
fb(16, render_height_minus_1);
- priv->render_width = current->render_width = current->render_width_minus_1 + 1;
- priv->render_height = current->render_height = current->render_height_minus_1 + 1;
+ current->render_width = current->render_width_minus_1 + 1;
+ current->render_height = current->render_height_minus_1 + 1;
} else {
- priv->render_width = current->render_width = current->upscaled_width;
- priv->render_height = current->render_height = current->frame_height;
+ current->render_width = current->upscaled_width;
+ current->render_height = current->frame_height;
}
return 0;
@@ -540,11 +539,11 @@ static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext *rw,
return AVERROR_INVALIDDATA;
}
- priv->upscaled_width = current->upscaled_width = ref->upscaled_width;
- priv->frame_width = current->frame_width = ref->frame_width;
- priv->frame_height = current->frame_height = ref->frame_height;
- priv->render_width = current->render_width = ref->render_width;
- priv->render_height = current->render_height = ref->render_height;
+ current->upscaled_width = ref->upscaled_width;
+ current->frame_width = ref->frame_width;
+ current->frame_height = ref->frame_height;
+ current->render_width = ref->render_width;
+ current->render_height = ref->render_height;
break;
}
}
@@ -585,8 +584,8 @@ static int FUNC(tile_info)(CodedBitstreamContext *ctx, RWContext *rw,
int min_log2_tiles, min_log2_tile_rows;
int i, err;
- mi_cols = 2 * ((priv->frame_width + 7) >> 3);
- mi_rows = 2 * ((priv->frame_height + 7) >> 3);
+ mi_cols = 2 * ((current->frame_width + 7) >> 3);
+ mi_rows = 2 * ((current->frame_height + 7) >> 3);
sb_cols = seq->use_128x128_superblock ? ((mi_cols + 31) >> 5)
: ((mi_cols + 15) >> 4);
@@ -1412,7 +1411,7 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
CHECK(FUNC(render_size)(ctx, rw, current));
if (current->allow_screen_content_tools &&
- priv->upscaled_width == priv->frame_width)
+ current->upscaled_width == current->frame_width)
flag(allow_intrabc);
else
infer(allow_intrabc, 0);
@@ -1515,7 +1514,7 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
}
}
priv->all_lossless = priv->coded_lossless &&
- priv->frame_width == priv->upscaled_width;
+ current->frame_width == current->upscaled_width;
CHECK(FUNC(loop_filter_params)(ctx, rw, current));
@@ -1546,11 +1545,11 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
priv->ref[i] = (AV1ReferenceFrameState) {
.valid = 1,
.frame_id = current->current_frame_id,
- .upscaled_width = priv->upscaled_width,
- .frame_width = priv->frame_width,
- .frame_height = priv->frame_height,
- .render_width = priv->render_width,
- .render_height = priv->render_height,
+ .upscaled_width = current->upscaled_width,
+ .frame_width = current->frame_width,
+ .frame_height = current->frame_height,
+ .render_width = current->render_width,
+ .render_height = current->render_height,
.frame_type = current->frame_type,
.subsampling_x = seq->color_config.subsampling_x,
.subsampling_y = seq->color_config.subsampling_y,
@@ -1563,8 +1562,8 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
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,
+ current->frame_width, current->frame_height, current->upscaled_width,
+ current->render_width, current->render_height,
seq->color_config.subsampling_x + 1,
seq->color_config.subsampling_y + 1, priv->bit_depth,
priv->tile_rows, priv->tile_cols);
--
2.27.0
More information about the ffmpeg-devel
mailing list