* [FFmpeg-devel] [PATCH 1/2] lavc/vvcdec: refact, set AVCodecContext->has_b_frames in sps_export_stream_params
@ 2025-02-03 9:17 Nuo Mi
2025-02-03 9:17 ` [FFmpeg-devel] [PATCH 2/2] lavc/vvcdec: export stream level VUI information Nuo Mi
0 siblings, 1 reply; 2+ messages in thread
From: Nuo Mi @ 2025-02-03 9:17 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Nuo Mi
---
libavcodec/vvc/dec.c | 1 -
libavcodec/vvc/ps.c | 29 +++++++++++++++++++----------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 51dd60ae92..68fb26352e 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -812,7 +812,6 @@ static int export_frame_params(VVCContext *s, const VVCFrameContext *fc)
c->width = pps->width - ((pps->r->pps_conf_win_left_offset + pps->r->pps_conf_win_right_offset) << sps->hshift[CHROMA]);
c->height = pps->height - ((pps->r->pps_conf_win_top_offset + pps->r->pps_conf_win_bottom_offset) << sps->vshift[CHROMA]);
- c->has_b_frames = sps->r->sps_dpb_params.dpb_max_num_reorder_pics[sps->r->sps_max_sublayers_minus1];
return 0;
}
diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c
index 01b4615eda..664e2c6376 100644
--- a/libavcodec/vvc/ps.c
+++ b/libavcodec/vvc/ps.c
@@ -23,6 +23,7 @@
#include <stdbool.h>
#include "libavcodec/cbs_h266.h"
+#include "libavcodec/decode.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/refstruct.h"
@@ -180,12 +181,19 @@ static void sps_ladf(VVCSPS* sps)
}
}
-static int sps_derive(VVCSPS *sps, void *log_ctx)
+static void sps_export_stream_params(AVCodecContext *c, const VVCSPS *sps)
+{
+ const H266RawSPS *r = sps->r;
+
+ c->has_b_frames = !!r->sps_dpb_params.dpb_max_num_reorder_pics[r->sps_max_sublayers_minus1];
+}
+
+static int sps_derive(VVCSPS *sps, AVCodecContext *c)
{
int ret;
const H266RawSPS *r = sps->r;
- ret = sps_bit_depth(sps, log_ctx);
+ ret = sps_bit_depth(sps, c);
if (ret < 0)
return ret;
sps_poc(sps);
@@ -197,6 +205,7 @@ static int sps_derive(VVCSPS *sps, void *log_ctx)
if (ret < 0)
return ret;
}
+ sps_export_stream_params(c, sps);
return 0;
}
@@ -207,7 +216,7 @@ static void sps_free(AVRefStructOpaque opaque, void *obj)
av_refstruct_unref(&sps->r);
}
-static const VVCSPS *sps_alloc(const H266RawSPS *rsps, void *log_ctx)
+static const VVCSPS *sps_alloc(const H266RawSPS *rsps, AVCodecContext *c)
{
int ret;
VVCSPS *sps = av_refstruct_alloc_ext(sizeof(*sps), 0, NULL, sps_free);
@@ -217,7 +226,7 @@ static const VVCSPS *sps_alloc(const H266RawSPS *rsps, void *log_ctx)
av_refstruct_replace(&sps->r, rsps);
- ret = sps_derive(sps, log_ctx);
+ ret = sps_derive(sps, c);
if (ret < 0)
goto fail;
@@ -228,7 +237,7 @@ fail:
return NULL;
}
-static int decode_sps(VVCParamSets *ps, const H266RawSPS *rsps, void *log_ctx, int is_clvss)
+static int decode_sps(VVCParamSets *ps, AVCodecContext *c, const H266RawSPS *rsps, int is_clvss)
{
const int sps_id = rsps->sps_seq_parameter_set_id;
const VVCSPS *old_sps = ps->sps_list[sps_id];
@@ -245,7 +254,7 @@ static int decode_sps(VVCParamSets *ps, const H266RawSPS *rsps, void *log_ctx, i
return AVERROR_INVALIDDATA;
}
- sps = sps_alloc(rsps, log_ctx);
+ sps = sps_alloc(rsps, c);
if (!sps)
return AVERROR(ENOMEM);
@@ -647,7 +656,7 @@ static int decode_pps(VVCParamSets *ps, const H266RawPPS *rpps)
return ret;
}
-static int decode_ps(VVCParamSets *ps, const CodedBitstreamH266Context *h266, void *log_ctx, int is_clvss)
+static int decode_ps(VVCParamSets *ps, AVCodecContext *c, const CodedBitstreamH266Context *h266, int is_clvss)
{
const H266RawPictureHeader *ph = h266->ph;
const H266RawPPS *rpps;
@@ -665,13 +674,13 @@ static int decode_ps(VVCParamSets *ps, const CodedBitstreamH266Context *h266, vo
if (!rsps)
return AVERROR_INVALIDDATA;
- ret = decode_sps(ps, rsps, log_ctx, is_clvss);
+ ret = decode_sps(ps, c, rsps, is_clvss);
if (ret < 0)
return ret;
if (rsps->sps_log2_ctu_size_minus5 > 2) {
// CTU > 128 are reserved in vvc spec v3
- av_log(log_ctx, AV_LOG_ERROR, "CTU size > 128. \n");
+ av_log(c, AV_LOG_ERROR, "CTU size > 128. \n");
return AVERROR_PATCHWELCOME;
}
@@ -960,7 +969,7 @@ int ff_vvc_decode_frame_ps(VVCFrameParamSets *fps, struct VVCContext *s)
decode_recovery_flag(s);
is_clvss = IS_CLVSS(s);
- ret = decode_ps(ps, h266, s->avctx, is_clvss);
+ ret = decode_ps(ps, s->avctx, h266, is_clvss);
if (ret < 0)
return ret;
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] lavc/vvcdec: export stream level VUI information
2025-02-03 9:17 [FFmpeg-devel] [PATCH 1/2] lavc/vvcdec: refact, set AVCodecContext->has_b_frames in sps_export_stream_params Nuo Mi
@ 2025-02-03 9:17 ` Nuo Mi
0 siblings, 0 replies; 2+ messages in thread
From: Nuo Mi @ 2025-02-03 9:17 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Nuo Mi, Barry Warburton
Previously, VUI information was not exposed.
If the container lacks HDR metadata, HDR videos appear washed out
Command: mp4box -add hdr.mp4#video:colr=nclc,1,1,1 -new new.mp4 && ffprobe new.mp4
Before: Stream #0:0[0x1](und): Video: vvc (vvc1 / 0x31637676), yuv420p10le(bt709), 1920x1080, 12164 kb/s, 50 fps, 50 tbr, 90k tbn (default)
After: Stream #0:0[0x1](und): Video: vvc (vvc1 / 0x31637676), yuv420p10le(tv, bt2020nc/bt2020/arib-std-b67), 1920x1080 [SAR 1:1 DAR 16:9], 12164 kb/s, 50 fps, 50 tbr, 90k tbn (default)
Reported-by: Barry Warburton <blwarburton@gmail.com>
---
libavcodec/vvc/ps.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c
index 664e2c6376..d026e797b3 100644
--- a/libavcodec/vvc/ps.c
+++ b/libavcodec/vvc/ps.c
@@ -24,6 +24,7 @@
#include "libavcodec/cbs_h266.h"
#include "libavcodec/decode.h"
+#include "libavcodec/h2645data.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/refstruct.h"
@@ -181,11 +182,50 @@ static void sps_ladf(VVCSPS* sps)
}
}
+#define EXTENDED_SAR 255
+static void sps_vui(AVCodecContext *c, const H266RawVUI *vui)
+{
+ AVRational sar = (AVRational){ 0, 1 };
+ if (vui->vui_aspect_ratio_info_present_flag) {
+ if (vui->vui_aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect))
+ sar = ff_h2645_pixel_aspect[vui->vui_aspect_ratio_idc];
+ else if (vui->vui_aspect_ratio_idc == EXTENDED_SAR) {
+ sar = (AVRational){ vui->vui_sar_width, vui->vui_sar_height };
+ } else {
+ av_log(c, AV_LOG_WARNING, "Unknown SAR index: %u.\n", vui->vui_aspect_ratio_idc);
+ }
+ }
+ ff_set_sar(c, sar);
+
+ if (vui->vui_colour_description_present_flag) {
+ c->color_primaries = vui->vui_colour_primaries;
+ c->color_trc = vui->vui_transfer_characteristics;
+ c->colorspace = vui->vui_matrix_coeffs;
+ c->color_range = vui->vui_full_range_flag ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
+
+ // Set invalid values to "unspecified"
+ if (!av_color_primaries_name(c->color_primaries))
+ c->color_primaries = AVCOL_PRI_UNSPECIFIED;
+ if (!av_color_transfer_name(c->color_trc))
+ c->color_trc = AVCOL_TRC_UNSPECIFIED;
+ if (!av_color_space_name(c->colorspace))
+ c->colorspace = AVCOL_SPC_UNSPECIFIED;
+ } else {
+ c->color_primaries = AVCOL_PRI_UNSPECIFIED;
+ c->color_trc = AVCOL_TRC_UNSPECIFIED;
+ c->colorspace = AVCOL_SPC_UNSPECIFIED;
+ c->color_range = AVCOL_RANGE_MPEG;
+ }
+}
+
+
static void sps_export_stream_params(AVCodecContext *c, const VVCSPS *sps)
{
const H266RawSPS *r = sps->r;
c->has_b_frames = !!r->sps_dpb_params.dpb_max_num_reorder_pics[r->sps_max_sublayers_minus1];
+ if (r->sps_vui_parameters_present_flag)
+ sps_vui(c, &r->vui);
}
static int sps_derive(VVCSPS *sps, AVCodecContext *c)
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-03 9:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-03 9:17 [FFmpeg-devel] [PATCH 1/2] lavc/vvcdec: refact, set AVCodecContext->has_b_frames in sps_export_stream_params Nuo Mi
2025-02-03 9:17 ` [FFmpeg-devel] [PATCH 2/2] lavc/vvcdec: export stream level VUI information Nuo Mi
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git