Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Keshav Varma <keshavdv@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] Correctly set low_delay_hrd_flag when rewriting fixed_frame_rate_flag in h264_metadata bitstream filter
Date: Fri, 4 Feb 2022 15:23:03 -0800
Message-ID: <CAMrYdZegajjoaZeCnJZOZqBwxVGJ6v-ohLOKJiLtkXDO9Or5vQ@mail.gmail.com> (raw)
In-Reply-To: <CAMrYdZcAtvLjS8=H5=ypH6kJAC3hzDmq-Wcfi2cFcUUb9+HiaQ@mail.gmail.com>

Rereading the spec, I think it only makes sense to update the
low_delay_hrd_flag parameter when the bitstream filter option for
fixed_frame_rate_flag is 1 to avoid clobbering the existing value in
other cases. I tried to work through all the scenarios below:

<fixed_frame_rate_flag>/<low_delay_hrd_flag> (BSF options) -> Resulting flags:

0/0 (tick_rate=10) -> 0/0
0/1 (tick_rate=10) -> 0/1
1/0 (tick_rate=10) -> 1/0
1/1 (tick_rate=10) -> 1/1
0/0 (fixed_frame_rate_flag=0) -> 0/1
0/1 (fixed_frame_rate_flag=0) -> 0/1
1/0 (fixed_frame_rate_flag=0) -> 0/0
1/1 (fixed_frame_rate_flag=0) -> 0/1
0/0 (fixed_frame_rate_flag=1) -> 1/0
0/1 (fixed_frame_rate_flag=1) -> 1/0
1/0 (fixed_frame_rate_flag=1) -> 1/0
1/1 (fixed_frame_rate_flag=1) -> 1/0


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

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 9df99cbae3..3e558a5166 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 fixed frame rate flag and update low_delay_hrd_flag to match
     SET_VUI_FIELD(fixed_frame_rate_flag);
+    if (ctx->fixed_frame_rate_flag) {
+        sps->vui.low_delay_hrd_flag = 0;
+    }
+
     if (ctx->zero_new_constraint_set_flags) {
         sps->constraint_set4_flag = 0;
         sps->constraint_set5_flag = 0;
--
2.31.1


On Fri, Feb 4, 2022 at 3:00 PM Keshav Varma <keshavdv@gmail.com> wrote:
>
> 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".

      reply	other threads:[~2022-02-04 23:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-04 23:00 Keshav Varma
2022-02-04 23:23 ` Keshav Varma [this message]

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=CAMrYdZegajjoaZeCnJZOZqBwxVGJ6v-ohLOKJiLtkXDO9Or5vQ@mail.gmail.com \
    --to=keshavdv@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