]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ffv1enc.c
lavc: Remove old vaapi decode infrastructure
[ffmpeg] / libavcodec / ffv1enc.c
index 9c2e463e6c5ca8e69018a3b54484d1541d461453..0eeccfffb4f0668b75d7b5c4a002739eb8d48a39 100644 (file)
@@ -31,9 +31,9 @@
 #include "libavutil/crc.h"
 #include "libavutil/opt.h"
 #include "libavutil/imgutils.h"
+
 #include "avcodec.h"
 #include "internal.h"
-#include "get_bits.h"
 #include "put_bits.h"
 #include "rangecoder.h"
 #include "golomb.h"
@@ -151,14 +151,7 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState *const state,
 
     assert(k <= 13);
 
-#if 0 // JPEG LS
-    if (k == 0 && 2 * state->drift <= -state->count)
-        code = v ^ (-1);
-    else
-        code = v;
-#else
     code = v ^ ((2 * state->drift + state->count) >> 31);
-#endif
 
     ff_dlog(NULL, "v:%d/%d bias:%d error:%d drift:%d count:%d k:%d\n", v, code,
             state->bias, state->error_sum, state->drift, state->count, k);
@@ -380,7 +373,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 +395,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 +416,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 +540,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 +745,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++)