[SCM] libav/experimental: automatic pixel format selection

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 15:40:23 UTC 2013


The following commit has been merged in the experimental branch:
commit fcee01646748763cf63528c97b99e976d6c76da8
Author: Michael Niedermayer <michaelni at gmx.at>
Date:   Wed May 12 16:00:44 2004 +0000

    automatic pixel format selection
    
    Originally committed as revision 3131 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/ffmpeg.c b/ffmpeg.c
index b6fa3e7..6297587 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2744,6 +2744,7 @@ static void opt_output_file(const char *filename)
             } else {
                 char *p;
                 int i;
+                AVCodec *codec;
             
                 codec_id = file_oformat->video_codec;
                 if (video_codec_id != CODEC_ID_NONE)
@@ -2759,7 +2760,18 @@ static void opt_output_file(const char *filename)
                 video_enc->width = frame_width + frame_padright + frame_padleft;
                 video_enc->height = frame_height + frame_padtop + frame_padbottom;
 		video_enc->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255);
-		video_enc->pix_fmt = frame_pix_fmt;
+                video_enc->pix_fmt = frame_pix_fmt;
+
+                codec = avcodec_find_encoder(codec_id);
+                if(codec && codec->pix_fmts){
+                    const enum PixelFormat *p= codec->pix_fmts;
+                    for(; *p!=-1; p++){
+                        if(*p == video_enc->pix_fmt)
+                            break;
+                    }
+                    if(*p == -1)
+                        video_enc->pix_fmt = codec->pix_fmts[0];
+                }
 
                 if (!intra_only)
                     video_enc->gop_size = gop_size;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index d7781dc..fe4aeb2 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1658,6 +1658,7 @@ typedef struct AVCodec {
     struct AVCodec *next;
     void (*flush)(AVCodecContext *);
     const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
+    const enum PixelFormat *pix_fmts;       ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
 } AVCodec;
 
 /**
diff --git a/libavcodec/svq1.c b/libavcodec/svq1.c
index 97b6db7..7c5c59d 100644
--- a/libavcodec/svq1.c
+++ b/libavcodec/svq1.c
@@ -1933,6 +1933,7 @@ AVCodec svq1_decoder = {
     svq1_decode_frame,
     CODEC_CAP_DR1,
     .flush= ff_mpeg_flush,
+    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV410P, -1},
 };
 
 #ifdef CONFIG_ENCODERS
@@ -1945,6 +1946,7 @@ AVCodec svq1_encoder = {
     svq1_encode_init,
     svq1_encode_frame,
     svq1_encode_end,
+    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV410P, -1},
 };
 
 #endif //CONFIG_ENCODERS

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list