]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/eamad.c
lagarith: pad RGB buffer by 1 byte.
[ffmpeg] / libavcodec / eamad.c
index b738f9458c10309a4365410ca99f92f89c9c2dce..d7e65db927a590cde54f03a7d45c310ebfa374d3 100644 (file)
@@ -32,6 +32,7 @@
 #include "get_bits.h"
 #include "dsputil.h"
 #include "aandcttab.h"
+#include "eaidct.h"
 #include "mpeg12.h"
 #include "mpeg12data.h"
 #include "libavutil/imgutils.h"
@@ -56,21 +57,13 @@ typedef struct MadContext {
     int mb_y;
 } MadContext;
 
-static void bswap16_buf(uint16_t *dst, const uint16_t *src, int count)
-{
-    int i;
-    for (i=0; i<count; i++)
-        dst[i] = av_bswap16(src[i]);
-}
-
 static av_cold int decode_init(AVCodecContext *avctx)
 {
     MadContext *s = avctx->priv_data;
     s->avctx = avctx;
     avctx->pix_fmt = PIX_FMT_YUV420P;
-    if (avctx->idct_algo == FF_IDCT_AUTO)
-        avctx->idct_algo = FF_IDCT_EA;
     ff_dsputil_init(&s->dsp, avctx);
+    ff_init_scantable_permutation(s->dsp.idct_permutation, FF_NO_IDCT_PERM);
     ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
     ff_mpeg12_init_vlcs();
     return 0;
@@ -105,12 +98,12 @@ static inline void comp_block(MadContext *t, int mb_x, int mb_y,
 static inline void idct_put(MadContext *t, DCTELEM *block, int mb_x, int mb_y, int j)
 {
     if (j < 4) {
-        t->dsp.idct_put(
+        ff_ea_idct_put_c(
             t->frame.data[0] + (mb_y*16 + ((j&2)<<2))*t->frame.linesize[0] + mb_x*16 + ((j&1)<<3),
             t->frame.linesize[0], block);
     } else if (!(t->avctx->flags & CODEC_FLAG_GRAY)) {
         int index = j - 3;
-        t->dsp.idct_put(
+        ff_ea_idct_put_c(
             t->frame.data[index] + (mb_y*8)*t->frame.linesize[index] + mb_x*8,
             t->frame.linesize[index], block);
     }
@@ -219,15 +212,9 @@ static void calc_quant_matrix(MadContext *s, int qscale)
 {
     int i;
 
-    if (s->avctx->idct_algo == FF_IDCT_EA) {
-        s->quant_matrix[0] = (ff_inv_aanscales[0]*ff_mpeg1_default_intra_matrix[0]) >> 11;
-        for (i=1; i<64; i++)
-            s->quant_matrix[i] = (ff_inv_aanscales[i]*ff_mpeg1_default_intra_matrix[i]*qscale + 32) >> 10;
-    } else {
-        s->quant_matrix[0] = ff_mpeg1_default_intra_matrix[0];
-        for (i=1; i<64; i++)
-            s->quant_matrix[i] = (ff_mpeg1_default_intra_matrix[i]*qscale) << 1;
-    }
+    s->quant_matrix[0] = (ff_inv_aanscales[0]*ff_mpeg1_default_intra_matrix[0]) >> 11;
+    for (i=1; i<64; i++)
+        s->quant_matrix[i] = (ff_inv_aanscales[i]*ff_mpeg1_default_intra_matrix[i]*qscale + 32) >> 10;
 }
 
 static int decode_frame(AVCodecContext *avctx,
@@ -279,7 +266,7 @@ static int decode_frame(AVCodecContext *avctx,
     av_fast_malloc(&s->bitstream_buf, &s->bitstream_buf_size, (buf_end-buf) + FF_INPUT_BUFFER_PADDING_SIZE);
     if (!s->bitstream_buf)
         return AVERROR(ENOMEM);
-    bswap16_buf(s->bitstream_buf, (const uint16_t*)buf, (buf_end-buf)/2);
+    s->dsp.bswap16_buf(s->bitstream_buf, (const uint16_t*)buf, (buf_end-buf)/2);
     init_get_bits(&s->gb, s->bitstream_buf, 8*(buf_end-buf));
 
     for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)