diff mbox

[FFmpeg-devel] lavc/ffv1: Support YUV4xxP12 and GRAY12.

Message ID 201611171309.53170.cehoyos@ag.or.at
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Nov. 17, 2016, 12:09 p.m. UTC
Hi!

Attached patch adds support for 12bit formats to ffv1.

Please comment, Carl Eugen
From c7f3f21a1b6d96717a728c0f0c08de76092fdefb Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos@ag.or.at>
Date: Thu, 17 Nov 2016 13:08:27 +0100
Subject: [PATCH] lavc/ffv1: Support YUV4xxP12 and GRAY12.

---
 libavcodec/ffv1dec.c |    7 +++++++
 libavcodec/ffv1enc.c |   11 +++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer Nov. 19, 2016, 12:44 a.m. UTC | #1
On Thu, Nov 17, 2016 at 01:09:53PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch adds support for 12bit formats to ffv1.
> 
> Please comment, Carl Eugen

>  ffv1dec.c |    7 +++++++
>  ffv1enc.c |   11 +++++++++--
>  2 files changed, 16 insertions(+), 2 deletions(-)
> 6e49bf777dff4b3c5850ebe82fece36c2eed86fe  0001-lavc-ffv1-Support-YUV4xxP12-and-GRAY12.patch
> From c7f3f21a1b6d96717a728c0f0c08de76092fdefb Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <cehoyos@ag.or.at>
> Date: Thu, 17 Nov 2016 13:08:27 +0100
> Subject: [PATCH] lavc/ffv1: Support YUV4xxP12 and GRAY12.

LGTM

thx

[...]
Carl Eugen Hoyos Nov. 20, 2016, 9:27 p.m. UTC | #2
2016-11-19 1:44 GMT+01:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Thu, Nov 17, 2016 at 01:09:53PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch adds support for 12bit formats to ffv1.
>>
>> Please comment, Carl Eugen
>
>>  ffv1dec.c |    7 +++++++
>>  ffv1enc.c |   11 +++++++++--
>>  2 files changed, 16 insertions(+), 2 deletions(-)
>> 6e49bf777dff4b3c5850ebe82fece36c2eed86fe  0001-lavc-ffv1-Support-YUV4xxP12-and-GRAY12.patch
>> From c7f3f21a1b6d96717a728c0f0c08de76092fdefb Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <cehoyos@ag.or.at>
>> Date: Thu, 17 Nov 2016 13:08:27 +0100
>> Subject: [PATCH] lavc/ffv1: Support YUV4xxP12 and GRAY12.
>
> LGTM

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index 0719e28..a7ddb28 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -625,6 +625,13 @@  static int read_header(FFV1Context *f)
             case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUVA422P10; break;
             case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUVA420P10; break;
             }
+        } else if (f->avctx->bits_per_raw_sample == 12 && !f->transparency) {
+            f->packed_at_lsb = 1;
+            switch(16 * f->chroma_h_shift + f->chroma_v_shift) {
+            case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUV444P12; break;
+            case 0x10: f->avctx->pix_fmt = AV_PIX_FMT_YUV422P12; break;
+            case 0x11: f->avctx->pix_fmt = AV_PIX_FMT_YUV420P12; break;
+            }
         } else if (f->avctx->bits_per_raw_sample == 16 && !f->transparency){
             switch(16 * f->chroma_h_shift + f->chroma_v_shift) {
             case 0x00: f->avctx->pix_fmt = AV_PIX_FMT_YUV444P16; break;
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index c56623b..d2f0827 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -580,9 +580,15 @@  FF_ENABLE_DEPRECATION_WARNINGS
     case AV_PIX_FMT_YUVA444P10:
     case AV_PIX_FMT_YUVA422P10:
     case AV_PIX_FMT_YUVA420P10:
-        s->packed_at_lsb = 1;
         if (!avctx->bits_per_raw_sample && !s->bits_per_raw_sample)
             s->bits_per_raw_sample = 10;
+    case AV_PIX_FMT_GRAY12:
+    case AV_PIX_FMT_YUV444P12:
+    case AV_PIX_FMT_YUV420P12:
+    case AV_PIX_FMT_YUV422P12:
+        s->packed_at_lsb = 1;
+        if (!avctx->bits_per_raw_sample && !s->bits_per_raw_sample)
+            s->bits_per_raw_sample = 12;
     case AV_PIX_FMT_GRAY16:
     case AV_PIX_FMT_YUV444P16:
     case AV_PIX_FMT_YUV422P16:
@@ -1293,13 +1299,14 @@  AVCodec ff_ffv1_encoder = {
         AV_PIX_FMT_YUV410P,   AV_PIX_FMT_0RGB32,    AV_PIX_FMT_RGB32,     AV_PIX_FMT_YUV420P16,
         AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, AV_PIX_FMT_YUV444P9,  AV_PIX_FMT_YUV422P9,
         AV_PIX_FMT_YUV420P9,  AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
+        AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12,
         AV_PIX_FMT_YUVA444P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA420P16,
         AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA420P10,
         AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA420P9,
         AV_PIX_FMT_GRAY16,    AV_PIX_FMT_GRAY8,     AV_PIX_FMT_GBRP9,     AV_PIX_FMT_GBRP10,
         AV_PIX_FMT_GBRP12,    AV_PIX_FMT_GBRP14,
         AV_PIX_FMT_YA8,
-        AV_PIX_FMT_GRAY10,
+        AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12,
         AV_PIX_FMT_GBRP16, AV_PIX_FMT_RGB48,
         AV_PIX_FMT_NONE