avcodec/ffv1enc: Add RGB48 support
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 16 Aug 2016 21:06:02 +0000 (23:06 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 16 Aug 2016 21:06:02 +0000 (23:06 +0200)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/ffv1enc.c
libavcodec/ffv1enc_template.c

index dc9c499..dae68ae 100644 (file)
@@ -624,6 +624,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
         s->chroma_planes = 1;
         s->bits_per_raw_sample = 8;
         break;
+    case AV_PIX_FMT_RGB48:
+        s->colorspace = 1;
+        s->chroma_planes = 1;
+        s->bits_per_raw_sample = 16;
+        s->use32bit = 1;
+        if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
+            av_log(avctx, AV_LOG_ERROR, "16bit RGB is experimental and under development, only use it for experiments\n");
+            return AVERROR_INVALIDDATA;
+        }
+        break;
     case AV_PIX_FMT_0RGB32:
         s->colorspace = 1;
         s->chroma_planes = 1;
@@ -1287,7 +1297,7 @@ AVCodec ff_ffv1_encoder = {
         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_GBRP16,
+        AV_PIX_FMT_GBRP16, AV_PIX_FMT_RGB48,
         AV_PIX_FMT_NONE
 
     },
index 01aee49..b7eea0d 100644 (file)
@@ -129,6 +129,7 @@ static int RENAME(encode_rgb_frame)(FFV1Context *s, const uint8_t *src[3],
     const int ring_size = s->context_model ? 3 : 2;
     TYPE *sample[4][3];
     int lbd    = s->bits_per_raw_sample <= 8;
+    int packed = !src[1];
     int bits   = s->bits_per_raw_sample > 0 ? s->bits_per_raw_sample : 8;
     int offset = 1 << bits;
 
@@ -150,6 +151,11 @@ static int RENAME(encode_rgb_frame)(FFV1Context *s, const uint8_t *src[3],
                 g = (v >>  8) & 0xFF;
                 r = (v >> 16) & 0xFF;
                 a =  v >> 24;
+            } else if (packed) {
+                const uint16_t *p = ((const uint16_t*)(src[0] + x*6 + stride[0]*y));
+                r = p[0];
+                g = p[1];
+                b = p[2];
             } else if (sizeof(TYPE) == 4) {
                 g = *((const uint16_t *)(src[0] + x*2 + stride[0]*y));
                 b = *((const uint16_t *)(src[1] + x*2 + stride[1]*y));