diff mbox series

[FFmpeg-devel,1/2] avcodec/proresenc: make transparency honored in mov/QT

Message ID 20231226222516.2513700-1-u@pkh.me
State Accepted
Commit 2142141a16158c691eeaac4824d1ceefc460ef9a
Headers show
Series [FFmpeg-devel,1/2] avcodec/proresenc: make transparency honored in mov/QT | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Clément Bœsch Dec. 26, 2023, 10:25 p.m. UTC
In the mov muxer (in mov_write_video_tag()), bits_per_coded_sample will
be written under certain conditions and is required to be 32 for the
transparency to be honored in QuickTime.

prores_kostya already has this setting but prores_anatoliy and
prores_videotoolbox didn't.
---
 libavcodec/proresenc_anatoliy.c | 3 +++
 libavcodec/videotoolboxenc.c    | 2 ++
 2 files changed, 5 insertions(+)

Comments

Stefano Sabatini Dec. 27, 2023, 11:54 a.m. UTC | #1
On date Tuesday 2023-12-26 23:25:15 +0100, Clément Bœsch wrote:
> In the mov muxer (in mov_write_video_tag()), bits_per_coded_sample will
> be written under certain conditions and is required to be 32 for the
> transparency to be honored in QuickTime.
> 
> prores_kostya already has this setting but prores_anatoliy and
> prores_videotoolbox didn't.
> ---
>  libavcodec/proresenc_anatoliy.c | 3 +++
>  libavcodec/videotoolboxenc.c    | 2 ++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index a1cb46aa59..16741afd68 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -930,6 +930,9 @@ static av_cold int prores_encode_init(AVCodecContext *avctx)
>          }
>      }
>  
> +    if (ctx->need_alpha)
> +        avctx->bits_per_coded_sample = 32;
> +
>      ff_fdctdsp_init(&ctx->fdsp, avctx);
>  
>      avctx->codec_tag = AV_RL32((const uint8_t*)profiles[avctx->profile].name);
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 15e0e1fe29..644fd60b00 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -521,6 +521,8 @@ static CMVideoCodecType get_cm_codec_type(AVCodecContext *avctx,
>          }
>          return kCMVideoCodecType_HEVC;
>      case AV_CODEC_ID_PRORES:
> +        if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA))
> +            avctx->bits_per_coded_sample = 32;
>          switch (profile) {
>          case AV_PROFILE_PRORES_PROXY:
>              return MKBETAG('a','p','c','o'); // kCMVideoCodecType_AppleProRes422Proxy

LGTM.
diff mbox series

Patch

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index a1cb46aa59..16741afd68 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -930,6 +930,9 @@  static av_cold int prores_encode_init(AVCodecContext *avctx)
         }
     }
 
+    if (ctx->need_alpha)
+        avctx->bits_per_coded_sample = 32;
+
     ff_fdctdsp_init(&ctx->fdsp, avctx);
 
     avctx->codec_tag = AV_RL32((const uint8_t*)profiles[avctx->profile].name);
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 15e0e1fe29..644fd60b00 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -521,6 +521,8 @@  static CMVideoCodecType get_cm_codec_type(AVCodecContext *avctx,
         }
         return kCMVideoCodecType_HEVC;
     case AV_CODEC_ID_PRORES:
+        if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA))
+            avctx->bits_per_coded_sample = 32;
         switch (profile) {
         case AV_PROFILE_PRORES_PROXY:
             return MKBETAG('a','p','c','o'); // kCMVideoCodecType_AppleProRes422Proxy