[FFmpeg-devel] [PATCH] avcodec/vvcdec: set pict_type and AV_FRAME_FLAG_KEY

Ruben Gonzalez rgonzalez at fluendo.com
Thu Jan 2 18:19:23 EET 2025


Update VVC decoder to show frames info with ffprobe and other tools.

Tested with:
```
wget  https://www.itu.int/wftp3/av-arch/jvet-site/bitstream_exchange/VVC/draft_conformance/draft6/CodingToolsSets_E_Tencent_1.zip
unzip CodingToolsSets_E_Tencent_1.zip CodingToolsSets_E_Tencent_1.bit
ffprobe -hide_banner CodingToolsSets_E_Tencent_1.bit -select_streams v -show_frames -show_entries frame=pict_type,key_frame -of csv
```

From
```
frame,0,?
frame,0,?
frame,0,?
frame,0,?
frame,0,?
frame,0,?
frame,0,?
frame,0,?
frame,0,?
```

To:
```
frame,1,I
frame,0,B
frame,0,B
frame,0,B
frame,0,B
frame,0,B
frame,0,B
frame,0,P
frame,0,B
```

Signed-off-by: Ruben Gonzalez <rgonzalez at fluendo.com>
---
 libavcodec/vvc/dec.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 1cb168de7e..71408caf7b 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -712,7 +712,18 @@ static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
     if ((ret = ff_vvc_set_new_ref(s, fc, &fc->frame)) < 0)
         goto fail;
 
-    if (!IS_IDR(s))
+    if (sc->sh.r->sh_slice_type == VVC_SLICE_TYPE_B)
+        fc->frame->pict_type = AV_PICTURE_TYPE_B;
+
+    if (sc->sh.r->sh_slice_type == VVC_SLICE_TYPE_P)
+        fc->frame->pict_type = AV_PICTURE_TYPE_P;
+
+    if (sc->sh.r->sh_slice_type == VVC_SLICE_TYPE_I)
+        fc->frame->pict_type = AV_PICTURE_TYPE_I;
+
+    if (IS_IDR(s))
+        fc->frame->flags |= AV_FRAME_FLAG_KEY;
+    else
         ff_vvc_bump_frame(s, fc);
 
     av_frame_unref(fc->output_frame);
-- 
2.47.1



More information about the ffmpeg-devel mailing list