diff mbox

[FFmpeg-devel] avcodec/cbs_av1: fix parsing frame_size_with_refs

Message ID 20181027003827.7080-1-jamrial@gmail.com
State Accepted
Commit 99ef8b8afd993fec3160c633f5fe87cceb7fe392
Headers show

Commit Message

James Almer Oct. 27, 2018, 12:38 a.m. UTC
found_ref is not a single value in the bitstream. Fixes parsing files with
frame size changes.

Based on code from cbs_vp9.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/cbs_av1.h                 | 2 +-
 libavcodec/cbs_av1_syntax_template.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

James Almer Oct. 27, 2018, 12:41 a.m. UTC | #1
On 10/26/2018 9:38 PM, James Almer wrote:
> found_ref is not a single value in the bitstream. Fixes parsing files with
> frame size changes.

See https://0x0.st/s64M.ivf, since AOM doesn't seem to offer a
conformance suite with a relevant sample, like Google did for VP9.
Mark Thompson Oct. 27, 2018, 6:54 p.m. UTC | #2
On 27/10/18 01:38, James Almer wrote:
> found_ref is not a single value in the bitstream. Fixes parsing files with
> frame size changes.
> 
> Based on code from cbs_vp9.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavcodec/cbs_av1.h                 | 2 +-
>  libavcodec/cbs_av1_syntax_template.c | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)

Urgh, yes (I hate the surprise mutable variables in these specs).

LGTM.

Thanks!

- Mark

> diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
> index 0d7fd761f1..b66a09c389 100644
> --- a/libavcodec/cbs_av1.h
> +++ b/libavcodec/cbs_av1.h
> @@ -161,7 +161,7 @@ typedef struct AV1RawFrameHeader {
>      uint8_t  render_width_minus_1;
>      uint8_t  render_height_minus_1;
>  
> -    uint8_t found_ref;
> +    uint8_t found_ref[AV1_REFS_PER_FRAME];
>  
>      uint8_t refresh_frame_flags;
>      uint8_t allow_intrabc;
> diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
> index 84ab2973ab..e146bbf8bb 100644
> --- a/libavcodec/cbs_av1_syntax_template.c
> +++ b/libavcodec/cbs_av1_syntax_template.c
> @@ -417,8 +417,8 @@ static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext *rw,
>      int i, err;
>  
>      for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
> -        flag(found_ref);
> -        if (current->found_ref) {
> +        flags(found_ref[i], 1, i);
> +        if (current->found_ref[i]) {
>              AV1ReferenceFrameState *ref =
>                  &priv->ref[current->ref_frame_idx[i]];
>  
> @@ -439,7 +439,7 @@ static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext *rw,
>          }
>      }
>  
> -    if (current->found_ref == 0) {
> +    if (i >= AV1_REFS_PER_FRAME) {
>          CHECK(FUNC(frame_size)(ctx, rw, current));
>          CHECK(FUNC(render_size)(ctx, rw, current));
>      } else {
>
James Almer Oct. 27, 2018, 7:12 p.m. UTC | #3
On 10/27/2018 3:54 PM, Mark Thompson wrote:
> On 27/10/18 01:38, James Almer wrote:
>> found_ref is not a single value in the bitstream. Fixes parsing files with
>> frame size changes.
>>
>> Based on code from cbs_vp9.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>  libavcodec/cbs_av1.h                 | 2 +-
>>  libavcodec/cbs_av1_syntax_template.c | 6 +++---
>>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> Urgh, yes (I hate the surprise mutable variables in these specs).
> 
> LGTM.
> 
> Thanks!
> 
> - Mark

Pushed.
diff mbox

Patch

diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 0d7fd761f1..b66a09c389 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -161,7 +161,7 @@  typedef struct AV1RawFrameHeader {
     uint8_t  render_width_minus_1;
     uint8_t  render_height_minus_1;
 
-    uint8_t found_ref;
+    uint8_t found_ref[AV1_REFS_PER_FRAME];
 
     uint8_t refresh_frame_flags;
     uint8_t allow_intrabc;
diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 84ab2973ab..e146bbf8bb 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -417,8 +417,8 @@  static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext *rw,
     int i, err;
 
     for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
-        flag(found_ref);
-        if (current->found_ref) {
+        flags(found_ref[i], 1, i);
+        if (current->found_ref[i]) {
             AV1ReferenceFrameState *ref =
                 &priv->ref[current->ref_frame_idx[i]];
 
@@ -439,7 +439,7 @@  static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext *rw,
         }
     }
 
-    if (current->found_ref == 0) {
+    if (i >= AV1_REFS_PER_FRAME) {
         CHECK(FUNC(frame_size)(ctx, rw, current));
         CHECK(FUNC(render_size)(ctx, rw, current));
     } else {