diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-04-17 03:15:19 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-04-17 04:04:49 +0200 |
commit | 8a28fa010a3af47e08f4562063b6cb4fe5d8d3e1 (patch) | |
tree | 18ffe1207c0538ad61b51b89a7de61eadc9cb422 /ffmpeg.c | |
parent | 4778783160fb8d7aa39dafdabc756f1691b830f7 (diff) | |
download | ffmpeg-8a28fa010a3af47e08f4562063b6cb4fe5d8d3e1.tar.gz |
ffmpeg: choose_pix_fmt: pass target fmt in
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r-- | ffmpeg.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -667,11 +667,11 @@ static void filter_release_buffer(AVFilterBuffer *fb) unref_buffer(buf->ist, buf); } -static void choose_pixel_fmt(AVStream *st, AVCodec *codec) +static enum PixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum PixelFormat target) { 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; + int has_alpha= av_pix_fmt_descriptors[target].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) { @@ -682,20 +682,21 @@ 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) + best= avcodec_find_best_pix_fmt2(best, *p, target, has_alpha, NULL); + if (*p == target) break; } if (*p == PIX_FMT_NONE) { - if (st->codec->pix_fmt != PIX_FMT_NONE) + if (target != PIX_FMT_NONE) av_log(NULL, AV_LOG_WARNING, "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n", - av_pix_fmt_descriptors[st->codec->pix_fmt].name, + av_pix_fmt_descriptors[target].name, codec->name, av_pix_fmt_descriptors[best].name); - st->codec->pix_fmt = best; + return best; } } + return target; } static const enum PixelFormat *choose_pixel_fmts(OutputStream *ost) @@ -4789,7 +4790,7 @@ static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const ch if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy) choose_sample_fmt(st, codec); else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy) - choose_pixel_fmt(st, codec); + choose_pixel_fmt(st, codec, st->codec->pix_fmt); } avformat_close_input(&ic); |