Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] Correctly set low_delay_hrd_flag when rewriting fixed_frame_rate_flag in h264_metadata bitstream filter
@ 2022-02-04 23:00 Keshav Varma
  2022-02-04 23:23 ` Keshav Varma
  0 siblings, 1 reply; 2+ messages in thread
From: Keshav Varma @ 2022-02-04 23:00 UTC (permalink / raw)
  To: ffmpeg-devel

After changes like ef13faf, the h264_metadata bitstream filter stopped
working when using the fixed_frame_rate_flag option on an input stream
that doesn't contain VUI because the default inferred value of
low_hrd_delay_flag seems to be 1. ffmpeg used to raise a warning, but
proceeded anyway but now aborts after the other fixes since the output
is rightfully invalid.

I believe this change makes the bitstream filter conform to page 403
of the ITU spec: "When fixed_frame_rate_flag is equal to 1,
low_delay_hrd_flag shall be equal to 0. When low_delay_hrd_flag is not
present, its value shall be inferred to be equal to 1 −
fixed_frame_rate_flag."

Signed-off-by: Keshav Varma <keshavdv@gmail.com>
---
 libavcodec/h264_metadata_bsf.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 9df99cbae3..59a7eba546 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -228,7 +228,13 @@ static int h264_metadata_update_sps(AVBSFContext *bsf,
         sps->vui.timing_info_present_flag = 1;
         need_vui = 1;
     }
-    SET_VUI_FIELD(fixed_frame_rate_flag);
+
+    // Set fixed frame rate flag and update low_delay_hrd_flag to match
+    if (ctx->fixed_frame_rate_flag >= 0) {
+        sps->vui.fixed_frame_rate_flag = ctx->fixed_frame_rate_flag;
+        sps->vui.low_delay_hrd_flag = 1 - sps->vui.fixed_frame_rate_flag;
+    }
+
     if (ctx->zero_new_constraint_set_flags) {
         sps->constraint_set4_flag = 0;
         sps->constraint_set5_flag = 0;
--
2.31.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:[~2022-02-04 23:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 23:00 [FFmpeg-devel] [PATCH] Correctly set low_delay_hrd_flag when rewriting fixed_frame_rate_flag in h264_metadata bitstream filter Keshav Varma
2022-02-04 23:23 ` Keshav Varma

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