]> git.sesse.net Git - ffmpeg/commitdiff
dv: Properly split decoder and encoder initialization
authorDiego Biurrun <diego@biurrun.de>
Fri, 7 Feb 2014 10:04:24 +0000 (11:04 +0100)
committerDiego Biurrun <diego@biurrun.de>
Fri, 27 Jun 2014 12:03:06 +0000 (05:03 -0700)
libavcodec/dv.c
libavcodec/dvdec.c
libavcodec/dvenc.c

index e840f4858ef2b425ad4f73c1d93ef363fa4a3ee3..bb1a26970f5a8285e6aa79aca94c8958b47e9a14 100644 (file)
@@ -235,7 +235,6 @@ int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const DVprofile *d)
 av_cold int ff_dvvideo_init(AVCodecContext *avctx)
 {
     DVVideoContext *s = avctx->priv_data;
-    DSPContext dsp;
     static int done = 0;
     int i, j;
 
@@ -292,23 +291,6 @@ av_cold int ff_dvvideo_init(AVCodecContext *avctx)
         ff_free_vlc(&dv_vlc);
     }
 
-    /* Generic DSP setup */
-    ff_dsputil_init(&dsp, avctx);
-    ff_set_cmp(&dsp, dsp.ildct_cmp, avctx->ildct_cmp);
-    s->get_pixels = dsp.get_pixels;
-    s->ildct_cmp = dsp.ildct_cmp[5];
-
-    /* 88DCT setup */
-    s->fdct[0]     = dsp.fdct;
-    s->idct_put[0] = dsp.idct_put;
-    for (i = 0; i < 64; i++)
-       s->dv_zigzag[0][i] = dsp.idct_permutation[ff_zigzag_direct[i]];
-
-    /* 248DCT setup */
-    s->fdct[1]     = dsp.fdct248;
-    s->idct_put[1] = ff_simple_idct248_put;  // FIXME: need to add it to DSP
-    memcpy(s->dv_zigzag[1], ff_dv_zigzag248_direct, sizeof(s->dv_zigzag[1]));
-
     s->avctx = avctx;
     avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
 
index 89f5821b0027a434f046df65d9535181da9d3635..9a559dbd45a8815c72e57b709a3746469cb22e33 100644 (file)
@@ -58,6 +58,25 @@ typedef struct BlockInfo {
 
 static const int dv_iweight_bits = 14;
 
+static av_cold int dvvideo_decode_init(AVCodecContext *avctx)
+{
+    DVVideoContext *s = avctx->priv_data;
+    DSPContext dsp;
+    int i;
+
+    ff_dsputil_init(&dsp, avctx);
+
+    for (i = 0; i < 64; i++)
+       s->dv_zigzag[0][i] = dsp.idct_permutation[ff_zigzag_direct[i]];
+
+    memcpy(s->dv_zigzag[1], ff_dv_zigzag248_direct, sizeof(s->dv_zigzag[1]));
+
+    s->idct_put[0] = dsp.idct_put;
+    s->idct_put[1] = ff_simple_idct248_put;
+
+    return ff_dvvideo_init(avctx);
+}
+
 /* decode AC coefficients */
 static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, int16_t *block)
 {
@@ -381,7 +400,7 @@ AVCodec ff_dvvideo_decoder = {
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_DVVIDEO,
     .priv_data_size = sizeof(DVVideoContext),
-    .init           = ff_dvvideo_init,
+    .init           = dvvideo_decode_init,
     .decode         = dvvideo_decode_frame,
     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
 };
index 94fb7eaf6fbd123f1de76878d8dceec2a5494882..5b013adf51fc61acf139b05b2d2cf87e4687fe23 100644 (file)
@@ -28,6 +28,7 @@
 #include "libavutil/pixdesc.h"
 #include "config.h"
 #include "avcodec.h"
+#include "dsputil.h"
 #include "internal.h"
 #include "put_bits.h"
 #include "dv.h"
@@ -36,6 +37,7 @@
 static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 {
     DVVideoContext *s = avctx->priv_data;
+    DSPContext dsp;
     int ret;
 
     s->sys = avpriv_dv_codec_profile(avctx);
@@ -58,6 +60,15 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 
     dv_vlc_map_tableinit();
 
+    ff_dsputil_init(&dsp, avctx);
+    ff_set_cmp(&dsp, dsp.ildct_cmp, avctx->ildct_cmp);
+
+    s->get_pixels = dsp.get_pixels;
+    s->ildct_cmp  = dsp.ildct_cmp[5];
+
+    s->fdct[0]    = dsp.fdct;
+    s->fdct[1]    = dsp.fdct248;
+
     return ff_dvvideo_init(avctx);
 }