]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ffv1enc.c
vp8/armv6: mc: avoid boolean expression in calculation
[ffmpeg] / libavcodec / ffv1enc.c
index 7995376ca0da5688c011ce6d5c3e5f3cef37f82b..3bc22ed1e51a497c22eb18d3ebb4c4c8c7df6ba0 100644 (file)
@@ -380,7 +380,7 @@ static void write_quant_tables(RangeCoder *c,
 static void write_header(FFV1Context *f)
 {
     uint8_t state[CONTEXT_SIZE];
-    int i, j;
+    int i;
     RangeCoder *const c = &f->slice_context[0]->c;
 
     memset(state, 128, sizeof(state));
@@ -402,25 +402,6 @@ static void write_header(FFV1Context *f)
         put_rac(c, state, f->transparency);
 
         write_quant_tables(c, f->quant_table);
-    } else if (f->version < 3) {
-        put_symbol(c, state, f->slice_count, 0);
-        for (i = 0; i < f->slice_count; i++) {
-            FFV1Context *fs = f->slice_context[i];
-            put_symbol(c, state,
-                       (fs->slice_x      + 1) * f->num_h_slices / f->width, 0);
-            put_symbol(c, state,
-                       (fs->slice_y      + 1) * f->num_v_slices / f->height, 0);
-            put_symbol(c, state,
-                       (fs->slice_width  + 1) * f->num_h_slices / f->width - 1,
-                       0);
-            put_symbol(c, state,
-                       (fs->slice_height + 1) * f->num_v_slices / f->height - 1,
-                       0);
-            for (j = 0; j < f->plane_count; j++) {
-                put_symbol(c, state, f->plane[j].quant_table_index, 0);
-                av_assert0(f->plane[j].quant_table_index == f->context_model);
-            }
-        }
     }
 }
 
@@ -442,7 +423,7 @@ static int write_extradata(FFV1Context *f)
     ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
 
     put_symbol(c, state, f->version, 0);
-    if (f->version > 2) {
+    if (f->version > 1) {
         if (f->version == 3)
             f->minor_version = 2;
         put_symbol(c, state, f->minor_version, 0);
@@ -566,27 +547,44 @@ static av_cold int ffv1_encode_init(AVCodecContext *avctx)
 
     s->version = 0;
 
-    if ((avctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) ||
-        avctx->slices > 1)
-        s->version = FFMAX(s->version, 2);
-
-    if (avctx->level == 3) {
-        s->version = 3;
+    switch (avctx->level) {
+    case 3:
+        break;
+    case 2:
+        av_log(avctx, AV_LOG_ERROR,
+               "Version 2 had been deemed non-standard and deprecated "
+               "the support for it had been removed\n");
+        return AVERROR(ENOSYS);
+    case 1:
+    case 0:
+        if (avctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) {
+            av_log(avctx, AV_LOG_ERROR,
+                   "Multiple pass encoding requires version 3.\n");
+            return AVERROR(ENOSYS);
+        }
+        if (avctx->slices > 1) {
+            av_log(avctx, AV_LOG_ERROR,
+                   "Multiple slices support requires version 3.\n");
+            return AVERROR(ENOSYS);
+        }
+        break;
+    case FF_LEVEL_UNKNOWN:
+        if ((avctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) ||
+            avctx->slices > 1)
+            s->version = 3;
+        else
+            s->version = 0;
+        break;
+    default:
+        av_log(avctx, AV_LOG_ERROR, "Version %d not supported\n",
+               avctx->level);
+        return AVERROR(ENOSYS);
     }
 
     if (s->ec < 0) {
         s->ec = (s->version >= 3);
     }
 
-    if (s->version >= 2 &&
-        avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
-        av_log(avctx, AV_LOG_ERROR,
-               "Version %d requested, please set -strict experimental in "
-               "order to enable it\n",
-               s->version);
-        return AVERROR(ENOSYS);
-    }
-
 #if FF_API_CODER_TYPE
 FF_DISABLE_DEPRECATION_WARNINGS
     if (avctx->coder_type != -1)
@@ -754,7 +752,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
         int gob_count = 0;
         char *next;
 
-        av_assert0(s->version >= 2);
+        av_assert0(s->version > 2);
 
         for (;; ) {
             for (j = 0; j < 256; j++)