diff mbox

[FFmpeg-devel] lavc/dpx: Support gray12

Message ID 201611102308.23921.cehoyos@ag.or.at
State Accepted
Commit b1367f7e5e6717cbd0ac658f74479b927c1945e3
Headers show

Commit Message

Carl Eugen Hoyos Nov. 10, 2016, 10:08 p.m. UTC
Hi!

Not sure how useful this is but we also support gprp12.

Please comment, Carl Eugen
From 525d19c0486bae49d2ee304d1afc8960d4f58bbc Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos@ag.or.at>
Date: Thu, 10 Nov 2016 23:04:46 +0100
Subject: [PATCH] lavc/dpx: Support GRAY12 colourspace.

---
 libavcodec/dpx.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer Nov. 11, 2016, 1:31 p.m. UTC | #1
On Thu, Nov 10, 2016 at 11:08:23PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Not sure how useful this is but we also support gprp12.
> 
> Please comment, Carl Eugen

>  dpx.c |   12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> ce5928daf60172d4d2d16a39ad12ef1b2a2e7a0a  0001-lavc-dpx-Support-GRAY12-colourspace.patch
> From 525d19c0486bae49d2ee304d1afc8960d4f58bbc Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <cehoyos@ag.or.at>
> Date: Thu, 10 Nov 2016 23:04:46 +0100
> Subject: [PATCH] lavc/dpx: Support GRAY12 colourspace.

should be ok

thx

[...]
Kieran O Leary Nov. 11, 2016, 1:56 p.m. UTC | #2
Hi Carl,


On Fri, Nov 11, 2016 at 1:31 PM, Michael Niedermayer <michael@niedermayer.cc
> wrote:

> On Thu, Nov 10, 2016 at 11:08:23PM +0100, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > Not sure how useful this is but we also support gprp12.
> >
> > Please comment, Carl Eugen
>

I'm sure that this could be useful for film archives. I have never seen
12-bit GRAY DPX files in the wild. Would it be possible to share any test
files that you used to test this decoder?

Thanks,

Kieran.
Carl Eugen Hoyos Nov. 13, 2016, 11:34 p.m. UTC | #3
2016-11-11 14:31 GMT+01:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Thu, Nov 10, 2016 at 11:08:23PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Not sure how useful this is but we also support gprp12.
>>
>> Please comment, Carl Eugen
>
>>  dpx.c |   12 ++++++++----
>>  1 file changed, 8 insertions(+), 4 deletions(-)
>> ce5928daf60172d4d2d16a39ad12ef1b2a2e7a0a  0001-lavc-dpx-Support-GRAY12-colourspace.patch
>> From 525d19c0486bae49d2ee304d1afc8960d4f58bbc Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <cehoyos@ag.or.at>
>> Date: Thu, 10 Nov 2016 23:04:46 +0100
>> Subject: [PATCH] lavc/dpx: Support GRAY12 colourspace.
>
> should be ok

Patch applied.

Thank you, Carl Eugen
Carl Eugen Hoyos Nov. 13, 2016, 11:38 p.m. UTC | #4
2016-11-11 14:56 GMT+01:00 Kieran O Leary <kieran.o.leary@gmail.com>:
> Hi Carl,
>
>
> On Fri, Nov 11, 2016 at 1:31 PM, Michael Niedermayer <michael@niedermayer.cc
>> wrote:
>
>> On Thu, Nov 10, 2016 at 11:08:23PM +0100, Carl Eugen Hoyos wrote:
>> > Hi!
>> >
>> > Not sure how useful this is but we also support gprp12.
>> >
>> > Please comment, Carl Eugen
>>
>
> I'm sure that this could be useful for film archives.

Only if such files exist in the wild...

> I have never seen 12-bit GRAY DPX files in the wild.

> Would it be possible to share any test
> files that you used to test this decoder?

ImageMagick and GraphicsMagick can produce broken (!)
samples. It should be possible to patch FFmpeg's dpx
encoder to write it though.

Carl Eugen
diff mbox

Patch

diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index e4dd1b0..1aa2cbd 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -243,6 +243,10 @@  static int decode_frame(AVCodecContext *avctx,
     case 6080:
         avctx->pix_fmt = AV_PIX_FMT_GRAY8;
         break;
+    case 6121:
+    case 6120:
+        avctx->pix_fmt = AV_PIX_FMT_GRAY12;
+        break;
     case 50081:
     case 50080:
         avctx->pix_fmt = AV_PIX_FMT_RGB24;
@@ -345,12 +349,12 @@  static int decode_frame(AVCodecContext *avctx,
                                 (uint16_t*)ptr[2],
                                 (uint16_t*)ptr[3]};
             for (y = 0; y < avctx->width; y++) {
-                *dst[2] = read16(&buf, endian) >> 4;
-                dst[2]++;
+                if (elements >= 3)
+                    *dst[2]++ = read16(&buf, endian) >> 4;
                 *dst[0] = read16(&buf, endian) >> 4;
                 dst[0]++;
-                *dst[1] = read16(&buf, endian) >> 4;
-                dst[1]++;
+                if (elements >= 2)
+                    *dst[1]++ = read16(&buf, endian) >> 4;
                 if (elements == 4)
                     *dst[3]++ = read16(&buf, endian) >> 4;
             }