From acf0283925151bdfa135e934cf6e3c351b2adf75 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 10 Jul 2012 14:29:10 +0200 Subject: [PATCH] Set default ffv1 coder to -1. Autoselect coder 1 instead of default coder if bits_per_raw_sample > 8. Fixes ticket #1519. --- libavcodec/ffv1.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index a0322dfa3f..6d60117d2e 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -916,7 +916,7 @@ static av_cold int encode_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } - s->ac= avctx->coder_type ? 2:0; + s->ac= avctx->coder_type > 0 ? 2 : 0; s->plane_count=3; switch(avctx->pix_fmt){ @@ -944,6 +944,10 @@ static av_cold int encode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample invalid\n"); return AVERROR_INVALIDDATA; } + if(!s->ac && avctx->coder_type == -1) { + av_log(avctx, AV_LOG_INFO, "bits_per_raw_sample > 8, forcing coder 1\n"); + s->ac = 2; + } if(!s->ac){ av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample of more than 8 needs -coder 1 currently\n"); return AVERROR_INVALIDDATA; @@ -2058,6 +2062,11 @@ static const AVClass class = { .version = LIBAVUTIL_VERSION_INT, }; +static const AVCodecDefault ffv1_defaults[] = { + { "coder", "-1" }, + { NULL }, +}; + AVCodec ff_ffv1_encoder = { .name = "ffv1", .type = AVMEDIA_TYPE_VIDEO, @@ -2067,6 +2076,7 @@ AVCodec ff_ffv1_encoder = { .encode2 = encode_frame, .close = common_end, .capabilities = CODEC_CAP_SLICE_THREADS, + .defaults = ffv1_defaults, .pix_fmts = (const enum PixelFormat[]){ PIX_FMT_YUV420P, PIX_FMT_YUVA420P, PIX_FMT_YUVA422P, PIX_FMT_YUV444P, PIX_FMT_YUVA444P, PIX_FMT_YUV440P, PIX_FMT_YUV422P, PIX_FMT_YUV411P,