@@ -1247,6 +1247,18 @@ static void cbs_av1_close(CodedBitstreamContext *ctx)
av_buffer_unref(&priv->frame_header_ref);
}
+int ff_cbs_av1_get_frame_width(const AV1RawFrameHeader *frame)
+{
+ int denom, frame_width = frame->frame_width_minus_1 + 1;
+
+ if (!frame->use_superres)
+ return frame_width;
+
+ denom = frame->coded_denom + AV1_SUPERRES_DENOM_MIN;
+
+ return (frame_width * AV1_SUPERRES_NUM + denom / 2) / denom;
+}
+
const CodedBitstreamType ff_cbs_type_av1 = {
.codec_id = AV_CODEC_ID_AV1,
@@ -445,4 +445,9 @@ typedef struct CodedBitstreamAV1Context {
} CodedBitstreamAV1Context;
+/**
+ * Return the frame's width with superres upscaling applied, if any.
+ */
+int ff_cbs_av1_get_frame_width(const AV1RawFrameHeader *frame);
+
#endif /* AVCODEC_CBS_AV1_H */
Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/cbs_av1.c | 12 ++++++++++++ libavcodec/cbs_av1.h | 5 +++++ 2 files changed, 17 insertions(+)