[FFmpeg-devel] [PATCH] ffv1: PIX_FMT_GRAY8 support

Paul B Mahol onemda at gmail.com
Tue Feb 14 06:39:03 CET 2012


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/ffv1.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index f483825..48b8ae1 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -32,6 +32,7 @@
 #include "rangecoder.h"
 #include "golomb.h"
 #include "mathops.h"
+#include "libavutil/pixdesc.h"
 #include "libavutil/avassert.h"
 
 #define MAX_PLANES 4
@@ -902,13 +903,14 @@ static av_cold int encode_init(AVCodecContext *avctx)
             return -1;
         }
         s->version= FFMAX(s->version, 1);
+    case PIX_FMT_GRAY8:
     case PIX_FMT_YUV444P:
     case PIX_FMT_YUV440P:
     case PIX_FMT_YUV422P:
     case PIX_FMT_YUV420P:
     case PIX_FMT_YUV411P:
     case PIX_FMT_YUV410P:
-        s->chroma_planes= avctx->pix_fmt == PIX_FMT_GRAY16 ? 0 : 1;
+        s->chroma_planes= av_pix_fmt_descriptors[avctx->pix_fmt].nb_components < 3 ? 0 : 1;
         s->colorspace= 0;
         break;
     case PIX_FMT_YUVA444P:
@@ -1593,8 +1595,11 @@ static int read_header(FFV1Context *f){
     }
 
     if(f->colorspace==0){
-        if(f->avctx->bits_per_raw_sample>8 && !f->transparency && !f->chroma_planes){
-            f->avctx->pix_fmt= PIX_FMT_GRAY16;
+        if(!f->transparency && !f->chroma_planes){
+            if (f->avctx->bits_per_raw_sample<=8)
+                f->avctx->pix_fmt= PIX_FMT_GRAY8;
+            else
+                f->avctx->pix_fmt= PIX_FMT_GRAY16;
         }else if(f->avctx->bits_per_raw_sample<=8 && !f->transparency){
             switch(16*f->chroma_h_shift + f->chroma_v_shift){
             case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P; break;
@@ -1837,7 +1842,7 @@ AVCodec ff_ffv1_encoder = {
     .encode         = encode_frame,
     .close          = common_end,
     .capabilities = CODEC_CAP_SLICE_THREADS,
-    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUVA420P, PIX_FMT_YUV444P, PIX_FMT_YUVA444P, PIX_FMT_YUV440P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_0RGB32, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_YUV420P9, PIX_FMT_YUV420P10, PIX_FMT_YUV422P10, PIX_FMT_GRAY16, PIX_FMT_NONE},
+    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUVA420P, PIX_FMT_YUV444P, PIX_FMT_YUVA444P, PIX_FMT_YUV440P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_0RGB32, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_YUV420P9, PIX_FMT_YUV420P10, PIX_FMT_YUV422P10, PIX_FMT_GRAY16, PIX_FMT_GRAY8, PIX_FMT_NONE},
     .long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"),
 };
 #endif
-- 
1.7.7



More information about the ffmpeg-devel mailing list