]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mv30.c
avcodec: Constify AVCodecs
[ffmpeg] / libavcodec / mv30.c
index 9f28199478f3242939ab0c04290dfff4e03d8245..21f52679c068d5819788249cb4946085c708dda5 100644 (file)
@@ -35,6 +35,8 @@
 #include "internal.h"
 #include "aandcttab.h"
 
+#define CBP_VLC_BITS  9
+
 typedef struct MV30Context {
     GetBitContext  gb;
 
@@ -102,7 +104,7 @@ static void get_qtable(int16_t *table, int quant, const uint8_t *quant_tab)
     }
 }
 
-static inline void idct_1d(int *blk, int step)
+static inline void idct_1d(unsigned *blk, int step)
 {
     const unsigned t0 = blk[0 * step] + blk[4 * step];
     const unsigned t1 = blk[0 * step] - blk[4 * step];
@@ -377,10 +379,7 @@ static int decode_coeffs(GetBitContext *gb, int16_t *coeffs, int nb_codes)
     memset(coeffs, 0, nb_codes * sizeof(*coeffs));
 
     for (int i = 0; i < nb_codes;) {
-        int value = get_vlc2(gb, cbp_tab.table, cbp_tab.bits, 1);
-
-        if (value < 0)
-            return AVERROR_INVALIDDATA;
+        int value = get_vlc2(gb, cbp_tab.table, CBP_VLC_BITS, 1);
 
         if (value > 0) {
             int x = get_bits(gb, value);
@@ -654,18 +653,14 @@ static int decode_frame(AVCodecContext *avctx, void *data,
     return avpkt->size;
 }
 
-static const uint16_t cbp_codes[] = {
-    0, 1, 4, 5, 6, 0xE, 0x1E, 0x3E, 0x7E, 0xFE, 0x1FE, 0x1FF,
-};
-
 static const uint8_t cbp_bits[] = {
     2, 2, 3, 3, 3, 4, 5, 6, 7, 8, 9, 9,
 };
 
 static av_cold void init_static_data(void)
 {
-    INIT_VLC_SPARSE_STATIC(&cbp_tab, 9, FF_ARRAY_ELEMS(cbp_bits),
-                           cbp_bits, 1, 1, cbp_codes, 2, 2, NULL, 0, 0, 512);
+    INIT_VLC_STATIC_FROM_LENGTHS(&cbp_tab, CBP_VLC_BITS, FF_ARRAY_ELEMS(cbp_bits),
+                                 cbp_bits, 1, NULL, 0, 0, 0, 0, 1 << CBP_VLC_BITS);
 }
 
 static av_cold int decode_init(AVCodecContext *avctx)
@@ -707,7 +702,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
     return 0;
 }
 
-AVCodec ff_mv30_decoder = {
+const AVCodec ff_mv30_decoder = {
     .name             = "mv30",
     .long_name        = NULL_IF_CONFIG_SMALL("MidiVid 3.0"),
     .type             = AVMEDIA_TYPE_VIDEO,