[FFmpeg-devel] [PATCH] lavc/vvcdec: show frames info with ffprobe and other tools.
Nuo Mi
nuomi2021 at gmail.com
Sat Jan 11 08:40:12 EET 2025
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
```
fixes https://trac.ffmpeg.org/ticket/11406
Co-authored-by: Ruben Gonzalez <rgonzalez at fluendo.com>
---
libavcodec/vvc/refs.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index bc3b3d0d13..79b692ac48 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -21,6 +21,7 @@
*/
#include <stdatomic.h>
+#include <stdbool.h>
#include "libavutil/mem.h"
#include "libavutil/thread.h"
@@ -168,6 +169,36 @@ fail:
return NULL;
}
+static void set_pict_type(AVFrame *frame, const VVCContext *s, const VVCFrameContext *fc)
+{
+ bool has_b = false, has_inter = false;
+
+ if (IS_IRAP(s)) {
+ frame->pict_type = AV_PICTURE_TYPE_I;
+ frame->flags |= AV_FRAME_FLAG_KEY;
+ return;
+ }
+
+ if (fc->ps.ph.r->ph_inter_slice_allowed_flag) {
+ // At this point, fc->slices is not fully initialized; we need to inspect the CBS directly.
+ const CodedBitstreamFragment *current = &s->current_frame;
+ for (int i = 0; i < current->nb_units && !has_b; i++) {
+ const CodedBitstreamUnit *unit = current->units + i;
+ if (unit->type <= VVC_RSV_IRAP_11) {
+ const H266RawSliceHeader *rsh = unit->content_ref;
+ has_inter |= !IS_I(rsh);
+ has_b |= IS_B(rsh);
+ }
+ }
+ }
+ if (!has_inter)
+ frame->pict_type = AV_PICTURE_TYPE_I;
+ else if (has_b)
+ frame->pict_type = AV_PICTURE_TYPE_B;
+ else
+ frame->pict_type = AV_PICTURE_TYPE_P;
+}
+
int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext *fc, AVFrame **frame)
{
const VVCPH *ph= &fc->ps.ph;
@@ -189,6 +220,7 @@ int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext *fc, AVFrame **frame)
if (!ref)
return AVERROR(ENOMEM);
+ set_pict_type(ref->frame, s, fc);
*frame = ref->frame;
fc->ref = ref;
--
2.34.1
More information about the ffmpeg-devel
mailing list