diff mbox series

[FFmpeg-devel,1/3] avcodec/cbs_av1: infer frame sizes when not coded in the bitstream

Message ID 20200823192358.12087-1-jamrial@gmail.com
State Accepted
Commit f1e92ee36b5e6bda6bf748e802fcda64aa5bab20
Headers show
Series [FFmpeg-devel,1/3] avcodec/cbs_av1: infer frame sizes when not coded in the bitstream | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

James Almer Aug. 23, 2020, 7:23 p.m. UTC
This makes them available for all frames within a Temporal Unit.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/cbs_av1_syntax_template.c | 43 +++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 10 deletions(-)

Comments

Mark Thompson Aug. 23, 2020, 10:59 p.m. UTC | #1
On 23/08/2020 20:23, James Almer wrote:
> This makes them available for all frames within a Temporal Unit.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   libavcodec/cbs_av1_syntax_template.c | 43 +++++++++++++++++++++-------
>   1 file changed, 33 insertions(+), 10 deletions(-)

Set LGTM.

Thanks,

- Mark
James Almer Aug. 23, 2020, 11:58 p.m. UTC | #2
On 8/23/2020 7:59 PM, Mark Thompson wrote:
> On 23/08/2020 20:23, James Almer wrote:
>> This makes them available for all frames within a Temporal Unit.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavcodec/cbs_av1_syntax_template.c | 43 +++++++++++++++++++++-------
>>   1 file changed, 33 insertions(+), 10 deletions(-)
> 
> Set LGTM.
> 
> Thanks,
> 
> - Mark

Applied, thanks.
diff mbox series

Patch

diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 3a832c3ca0..dedd549572 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -492,14 +492,14 @@  static int FUNC(frame_size)(CodedBitstreamContext *ctx, RWContext *rw,
     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;
@@ -516,14 +516,14 @@  static int FUNC(render_size)(CodedBitstreamContext *ctx, RWContext *rw,
     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;
 }
 
@@ -547,6 +547,11 @@  static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext *rw,
                 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_height   = ref->frame_height;
@@ -1273,6 +1278,13 @@  static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
             fb(3, frame_to_show_map_idx);
             frame = &priv->ref[current->frame_to_show_map_idx];
 
+            if (!frame->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) {
                 fb(seq->decoder_model_info.frame_presentation_time_length_minus_1 + 1,
@@ -1287,6 +1299,17 @@  static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
             else
                 infer(refresh_frame_flags, 0);
 
+            infer(frame_width_minus_1,   frame->upscaled_width - 1);
+            infer(frame_height_minus_1,  frame->frame_height - 1);
+            infer(render_width_minus_1,  frame->render_width - 1);
+            infer(render_height_minus_1, frame->render_height - 1);
+
+            priv->upscaled_width = frame->upscaled_width;
+            priv->frame_width    = frame->frame_width;
+            priv->frame_height   = frame->frame_height;
+            priv->render_width   = frame->render_width;
+            priv->render_height  = frame->render_height;
+
             return 0;
         }