[FFmpeg-cvslog] avcodec/av1_vaapi: fixed a decoding corruption issue

Ruijing Dong git at videolan.org
Fri Nov 4 04:05:48 EET 2022


ffmpeg | branch: master | Ruijing Dong <ruijing.dong at amd.com> | Wed Nov  2 15:35:53 2022 -0400| [89e3814569dc061cd4008351ed3d87366645960e] | committer: Haihao Xiang

avcodec/av1_vaapi: fixed a decoding corruption issue

In av1_spec.pdf page 38/669, there is a sentence below:

if ( frame_type == KEY_FRAME && show_frame ) {
   for ( i = 0; i < NUM_REF_FRAMES; i++) {
      RefValid[ i ] = 0
      ......
   }
   ......
}

This shows that the condition of invalidating current
DPB frames should be the coming frame_type is KEY_FRAME plus
show_frame is equal to 1. Otherwise, some of the frames
in sequence after KEY_FRAME still refer to the reference frames
before KEY_FRAME, and if these before KEY_FRAME reference
frames were invalidated, these frames could not find their
reference frames, and it could cause image corruption.

Mesa fix is in https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19386

Reviewed-by: Fei Wang <fei.w.wang at intel.com>
Signed-off-by: Ruijing Dong <ruijing.dong at amd.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=89e3814569dc061cd4008351ed3d87366645960e
---

 libavcodec/vaapi_av1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c
index 63374c31c9..d0339b2705 100644
--- a/libavcodec/vaapi_av1.c
+++ b/libavcodec/vaapi_av1.c
@@ -274,7 +274,7 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx,
     };
 
     for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) {
-        if (pic_param.pic_info_fields.bits.frame_type == AV1_FRAME_KEY)
+        if (pic_param.pic_info_fields.bits.frame_type == AV1_FRAME_KEY && frame_header->show_frame)
             pic_param.ref_frame_map[i] = VA_INVALID_ID;
         else
             pic_param.ref_frame_map[i] = ctx->ref_tab[i].valid ?



More information about the ffmpeg-cvslog mailing list