[FFmpeg-devel] [PATCH] vc2enc: add non-experimental support for all video formats from spec
Rostislav Pehlivanov
atomnuker at gmail.com
Mon Mar 21 18:40:54 CET 2016
Simplified the detection loop, the score thing was just to warn the user
about what exactly's wrong but since soon the need to add -strict -1
might be removed this makes it pointless to verbosely warn.
Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
---
libavcodec/vc2enc.c | 41 +++++++++++++++++------------------------
1 file changed, 17 insertions(+), 24 deletions(-)
diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index 71437d5..29a1d0a 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -1070,7 +1070,7 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx)
{
Plane *p;
SubBand *b;
- int i, j, level, o, shift, top_score = 0, top_fmt = 0;
+ int i, j, level, o, shift;
const AVPixFmtDescriptor *fmt = av_pix_fmt_desc_get(avctx->pix_fmt);
const int depth = fmt->comp[0].depth;
VC2EncContext *s = avctx->priv_data;
@@ -1097,29 +1097,22 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx)
(avctx->field_order == AV_FIELD_PROGRESSIVE));
for (i = 0; i < base_video_fmts_len; i++) {
- int score = 0;
const VC2BaseVideoFormat *fmt = &base_video_fmts[i];
- if (avctx->pix_fmt == fmt->pix_fmt)
- score++;
- if (avctx->time_base.num == fmt->time_base.num)
- score++;
- if (avctx->time_base.den == fmt->time_base.den)
- score++;
- if (avctx->width == fmt->width)
- score++;
- if (avctx->height == fmt->height)
- score++;
- if (s->interlaced == fmt->interlaced)
- score++;
- if (score > top_score) {
- top_score = score;
- top_fmt = i;
- }
- }
-
- if (top_score == FORMAT_MAX_SCORE) {
- s->base_vf = base_video_fmts[top_fmt].base_vf;
- s->level = base_video_fmts[top_fmt].level;
+ if (avctx->pix_fmt != fmt->pix_fmt)
+ continue;
+ if (avctx->time_base.num != fmt->time_base.num)
+ continue;
+ if (avctx->time_base.den != fmt->time_base.den)
+ continue;
+ if (avctx->width != fmt->width)
+ continue;
+ if (avctx->height != fmt->height)
+ continue;
+ if (s->interlaced != fmt->interlaced)
+ continue;
+ s->base_vf = base_video_fmts[i].base_vf;
+ s->level = base_video_fmts[i].level;
+ break;
}
if (s->interlaced)
@@ -1148,7 +1141,7 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx)
}
} else {
av_log(avctx, AV_LOG_INFO, "Selected base video format = %i (%s)\n",
- s->base_vf, base_video_fmts[top_fmt].name);
+ s->base_vf, base_video_fmts[s->base_vf - 1].name);
}
/* Chroma subsampling */
--
2.8.0.rc3
More information about the ffmpeg-devel
mailing list