From: Nuo Mi <nuomi2021@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Nuo Mi <nuomi2021@gmail.com>, Barry Warburton <blwarburton@gmail.com>
Subject: [FFmpeg-devel] [PATCH 2/2] lavc/vvcdec: export stream level VUI information
Date: Mon, 3 Feb 2025 17:17:51 +0800
Message-ID: <20250203091751.259888-2-nuomi2021@gmail.com> (raw)
In-Reply-To: <20250203091751.259888-1-nuomi2021@gmail.com>
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".
next prev parent reply other threads:[~2025-02-03 9:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
[not found] ` <823e6e37-adb6-4eb6-bf96-41cb94dfac39@gmail.com>
2025-02-22 3:43 ` [FFmpeg-devel] [PATCH 2/2] lavc/vvcdec: export stream level VUI information Nuo Mi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250203091751.259888-2-nuomi2021@gmail.com \
--to=nuomi2021@gmail.com \
--cc=blwarburton@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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