aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-04 15:26:52 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-04 15:26:52 +0100
commit594090c6c20a796ddfb04d54e2df98dca3fc653a (patch)
tree76bc5daa59079643a1bf8400568f64aedd771508 /ffmpeg.c
parentf88d5df383d77f54b7c6d8f0482a5a0bffb7bd33 (diff)
downloadffmpeg-594090c6c20a796ddfb04d54e2df98dca3fc653a.tar.gz
ffmpeg: select best pixel format for the encoder if no exact match.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index f0135315b9..90f05ce12f 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -764,6 +764,8 @@ static void choose_pixel_fmt(AVStream *st, AVCodec *codec)
{
if(codec && codec->pix_fmts){
const enum PixelFormat *p= codec->pix_fmts;
+ int has_alpha= av_pix_fmt_descriptors[st->codec->pix_fmt].nb_components % 2 == 0;
+ enum PixelFormat best= PIX_FMT_NONE;
if(st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL){
if(st->codec->codec_id==CODEC_ID_MJPEG){
p= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE};
@@ -772,6 +774,7 @@ static void choose_pixel_fmt(AVStream *st, AVCodec *codec)
}
}
for (; *p != PIX_FMT_NONE; p++) {
+ best= avcodec_find_best_pix_fmt2(best, *p, st->codec->pix_fmt, has_alpha, NULL);
if(*p == st->codec->pix_fmt)
break;
}
@@ -781,8 +784,8 @@ static void choose_pixel_fmt(AVStream *st, AVCodec *codec)
"Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",
av_pix_fmt_descriptors[st->codec->pix_fmt].name,
codec->name,
- av_pix_fmt_descriptors[codec->pix_fmts[0]].name);
- st->codec->pix_fmt = codec->pix_fmts[0];
+ av_pix_fmt_descriptors[best].name);
+ st->codec->pix_fmt = best;
}
}
}