]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ffv1enc.c
checkasm: add vp9 MC tests.
[ffmpeg] / libavcodec / ffv1enc.c
index 35d88ca2449f390c3f5ff4645086e743b6204d09..338cc4e3c11524d7cdfd28c0e2f861ab72d41cf9 100644 (file)
@@ -683,8 +683,13 @@ static av_cold int encode_init(AVCodecContext *avctx)
     if (avctx->level <= 0 && s->version == 2) {
         s->version = 3;
     }
-    if (avctx->level >= 0 && avctx->level <= 4)
-        s->version = FFMAX(s->version, avctx->level);
+    if (avctx->level >= 0 && avctx->level <= 4) {
+        if (avctx->level < s->version) {
+            av_log(avctx, AV_LOG_ERROR, "Version %d needed for requested features but %d requested\n", s->version, avctx->level);
+            return AVERROR(EINVAL);
+        }
+        s->version = avctx->level;
+    }
 
     if (s->ec < 0) {
         s->ec = (s->version >= 3);
@@ -1123,7 +1128,7 @@ static int encode_slice(AVCodecContext *c, void *arg)
     int x            = fs->slice_x;
     int y            = fs->slice_y;
     const AVFrame *const p = f->picture.f;
-    const int ps     = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step_minus1 + 1;
+    const int ps     = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step;
     int ret;
     RangeCoder c_bak = fs->c;
     const uint8_t *planes[3] = {p->data[0] + ps*x + y*p->linesize[0],