diff mbox series

[FFmpeg-devel] avformat/yuv4mpegenc: add support for yuva444p

Message ID 20210724160837.27313-1-onemda@gmail.com
State Accepted
Commit a1f7d25ceff2fd52c56148fe1b4fa21e6ef2acd6
Headers show
Series [FFmpeg-devel] avformat/yuv4mpegenc: add support for yuva444p | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Paul B Mahol July 24, 2021, 4:08 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/yuv4mpegenc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Michael Niedermayer July 25, 2021, 11:30 a.m. UTC | #1
On Sat, Jul 24, 2021 at 06:08:37PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/yuv4mpegenc.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

LGTM

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
index aff066f1c5..efa05133d5 100644
--- a/libavformat/yuv4mpegenc.c
+++ b/libavformat/yuv4mpegenc.c
@@ -113,6 +113,9 @@  static int yuv4_write_header(AVFormatContext *s)
     case AV_PIX_FMT_YUV444P:
         colorspace = " C444 XYSCSS=444";
         break;
+    case AV_PIX_FMT_YUVA444P:
+        colorspace = " C444alpha XYSCSS=444";
+        break;
     case AV_PIX_FMT_YUV420P9:
         colorspace = " C420p9 XYSCSS=420P9";
         break;
@@ -197,6 +200,7 @@  static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
     case AV_PIX_FMT_YUV420P:
     case AV_PIX_FMT_YUV422P:
     case AV_PIX_FMT_YUV444P:
+    case AV_PIX_FMT_YUVA444P:
     // TODO: remove YUVJ pixel formats when they are completely removed from the codebase.
     case AV_PIX_FMT_YUVJ420P:
     case AV_PIX_FMT_YUVJ422P:
@@ -254,6 +258,13 @@  static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
             avio_write(pb, ptr2, width);
             ptr2 += frame->linesize[2];
         }
+        if (st->codecpar->format == AV_PIX_FMT_YUVA444P) {
+            ptr = frame->data[3];
+            for (i = 0; i < height; i++) {     /* A */
+                avio_write(pb, ptr, width);
+                ptr += frame->linesize[3];
+            }
+        }
     }
 
     return 0;
@@ -302,6 +313,7 @@  static int yuv4_init(AVFormatContext *s)
     case AV_PIX_FMT_YUV420P16:
     case AV_PIX_FMT_YUV422P16:
     case AV_PIX_FMT_YUV444P16:
+    case AV_PIX_FMT_YUVA444P:
         if (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
             av_log(s, AV_LOG_ERROR, "'%s' is not an official yuv4mpegpipe pixel format. "
                    "Use '-strict -1' to encode to this pixel format.\n",
@@ -319,6 +331,7 @@  static int yuv4_init(AVFormatContext *s)
                "yuv444p12, yuv422p12, yuv420p12, "
                "yuv444p14, yuv422p14, yuv420p14, "
                "yuv444p16, yuv422p16, yuv420p16, "
+               "yuva444p, "
                "gray9, gray10, gray12 "
                "and gray16 pixel formats. "
                "Use -pix_fmt to select one.\n");