diff mbox series

[FFmpeg-devel] avcodec/videotoolboxenc: Fixes non-B-Frame encoding

Message ID 20210926124752.14573-1-ffmpeg-devel@fluthaus.com
State Accepted
Commit b786bc7433dfe082441a57c1ba9ae9ea47904b78
Headers show
Series [FFmpeg-devel] avcodec/videotoolboxenc: Fixes non-B-Frame encoding | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

NoHalfBits Sept. 26, 2021, 12:47 p.m. UTC
Sets vtctx->has_b_frames to 0 if the VideoToolbox compression
session will not emit B-frames (and, in consequence, no valid
DTSs). Required for the handling of invalid DTSs in
'vtenc_cm_to_avpacket' (line 2018ff) to work correctly and not
abort encoding with "DTS is invalid." when no B-frames are
generated.

Signed-off-by: NoHalfBits <ffmpeg-devel@fluthaus.com>
---
 libavcodec/videotoolboxenc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Rick Kern Sept. 27, 2021, 11:12 a.m. UTC | #1
On Sun, Sep 26, 2021 at 8:48 AM NoHalfBits <ffmpeg-devel@fluthaus.com>
wrote:

> Sets vtctx->has_b_frames to 0 if the VideoToolbox compression
> session will not emit B-frames (and, in consequence, no valid
> DTSs). Required for the handling of invalid DTSs in
> 'vtenc_cm_to_avpacket' (line 2018ff) to work correctly and not
> abort encoding with "DTS is invalid." when no B-frames are
> generated.
>
> Signed-off-by: NoHalfBits <ffmpeg-devel@fluthaus.com>
> ---
>  libavcodec/videotoolboxenc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 8dfd6e3d0c..93c3898fb5 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -1516,7 +1516,10 @@ static av_cold int vtenc_init(AVCodecContext *avctx)
>      if (!status && has_b_frames_cfbool) {
>          //Some devices don't output B-frames for main profile, even if
> requested.
>          // HEVC has b-pyramid
> -        vtctx->has_b_frames = (CFBooleanGetValue(has_b_frames_cfbool) &&
> avctx->codec_id == AV_CODEC_ID_HEVC) ? 2 : 1;
> +        if (CFBooleanGetValue(has_b_frames_cfbool))
> +            vtctx->has_b_frames = avctx->codec_id == AV_CODEC_ID_HEVC ? 2
> : 1;
> +        else
> +            vtctx->has_b_frames = 0;
>
Pushed, thanks.

         CFRelease(has_b_frames_cfbool);
>      }
>      avctx->has_b_frames = vtctx->has_b_frames;
> --
> 2.30.1 (Apple Git-130)
>
> _______________________________________________
> 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".
>
diff mbox series

Patch

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 8dfd6e3d0c..93c3898fb5 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1516,7 +1516,10 @@  static av_cold int vtenc_init(AVCodecContext *avctx)
     if (!status && has_b_frames_cfbool) {
         //Some devices don't output B-frames for main profile, even if requested.
         // HEVC has b-pyramid
-        vtctx->has_b_frames = (CFBooleanGetValue(has_b_frames_cfbool) && avctx->codec_id == AV_CODEC_ID_HEVC) ? 2 : 1;
+        if (CFBooleanGetValue(has_b_frames_cfbool))
+            vtctx->has_b_frames = avctx->codec_id == AV_CODEC_ID_HEVC ? 2 : 1;
+        else
+            vtctx->has_b_frames = 0;
         CFRelease(has_b_frames_cfbool);
     }
     avctx->has_b_frames = vtctx->has_b_frames;