]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mimic.c
alsdec: check sample pointer range in revert_channel_correlation
[ffmpeg] / libavcodec / mimic.c
index 0fe83137bbeebead22b0751cf055b29f732e12a5..7f97366de4db75d860a2ed41aaf57edd2f9b50d3 100644 (file)
 #include <stdint.h>
 
 #include "avcodec.h"
+#include "blockdsp.h"
 #include "internal.h"
 #include "get_bits.h"
 #include "bytestream.h"
-#include "dsputil.h"
+#include "bswapdsp.h"
+#include "hpeldsp.h"
+#include "idctdsp.h"
 #include "thread.h"
 
 #define MIMIC_HEADER_SIZE   20
 
-typedef struct {
+typedef struct MimicContext {
     AVCodecContext *avctx;
 
     int             num_vblocks[3];
@@ -51,7 +54,10 @@ typedef struct {
 
     GetBitContext   gb;
     ScanTable       scantable;
-    DSPContext      dsp;
+    BlockDSPContext bdsp;
+    BswapDSPContext bbdsp;
+    HpelDSPContext  hdsp;
+    IDCTDSPContext  idsp;
     VLC             vlc;
 
     /* Kept in the context so multithreading can have a constant to read from */
@@ -143,8 +149,11 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx)
         av_log(avctx, AV_LOG_ERROR, "error initializing vlc table\n");
         return ret;
     }
-    ff_dsputil_init(&ctx->dsp, avctx);
-    ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, col_zag);
+    ff_blockdsp_init(&ctx->bdsp, avctx);
+    ff_bswapdsp_init(&ctx->bbdsp);
+    ff_hpeldsp_init(&ctx->hdsp, avctx->flags);
+    ff_idctdsp_init(&ctx->idsp, avctx);
+    ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable, col_zag);
 
     for (i = 0; i < FF_ARRAY_ELEMS(ctx->frames); i++) {
         ctx->frames[i].f = av_frame_alloc();
@@ -224,7 +233,7 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
     int16_t *block = ctx->dct_block;
     unsigned int pos;
 
-    ctx->dsp.clear_block(block);
+    ctx->bdsp.clear_block(block);
 
     block[0] = get_bits(&ctx->gb, 8) << 3;
 
@@ -293,7 +302,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
                                    "block.\n");
                             return ret;
                         }
-                        ctx->dsp.idct_put(dst, stride, ctx->dct_block);
+                        ctx->idsp.idct_put(dst, stride, ctx->dct_block);
                     } else {
                         unsigned int backref = get_bits(&ctx->gb, 4);
                         int index            = (ctx->cur_index + backref) & 15;
@@ -304,7 +313,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
                                                      cur_row, 0);
                             p += src -
                                  ctx->flipped_ptrs[ctx->prev_index].data[plane];
-                            ctx->dsp.put_pixels_tab[1][0](dst, p, stride, 8);
+                            ctx->hdsp.put_pixels_tab[1][0](dst, p, stride, 8);
                         } else {
                             av_log(ctx->avctx, AV_LOG_ERROR,
                                      "No such backreference! Buggy sample.\n");
@@ -313,7 +322,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
                 } else {
                     ff_thread_await_progress(&ctx->frames[ctx->prev_index],
                                              cur_row, 0);
-                    ctx->dsp.put_pixels_tab[1][0](dst, src, stride, 8);
+                    ctx->hdsp.put_pixels_tab[1][0](dst, src, stride, 8);
                 }
                 src += 8;
                 dst += 8;
@@ -419,9 +428,9 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
     if (!ctx->swap_buf)
         return AVERROR(ENOMEM);
 
-    ctx->dsp.bswap_buf(ctx->swap_buf,
-                       (const uint32_t*) (buf + MIMIC_HEADER_SIZE),
-                       swap_buf_size >> 2);
+    ctx->bbdsp.bswap_buf(ctx->swap_buf,
+                         (const uint32_t *) (buf + MIMIC_HEADER_SIZE),
+                         swap_buf_size >> 2);
     init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3);
 
     res = decode(ctx, quality, num_coeffs, !is_pframe);
@@ -464,6 +473,7 @@ static av_cold int mimic_init_thread_copy(AVCodecContext *avctx)
 
 AVCodec ff_mimic_decoder = {
     .name                  = "mimic",
+    .long_name             = NULL_IF_CONFIG_SMALL("Mimic"),
     .type                  = AVMEDIA_TYPE_VIDEO,
     .id                    = AV_CODEC_ID_MIMIC,
     .priv_data_size        = sizeof(MimicContext),
@@ -471,7 +481,6 @@ AVCodec ff_mimic_decoder = {
     .close                 = mimic_decode_end,
     .decode                = mimic_decode_frame,
     .capabilities          = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
-    .long_name             = NULL_IF_CONFIG_SMALL("Mimic"),
     .update_thread_context = ONLY_IF_THREADS_ENABLED(mimic_decode_update_thread_context),
     .init_thread_copy      = ONLY_IF_THREADS_ENABLED(mimic_init_thread_copy),
 };