---
 libavcodec/dv.c    | 18 ------------------
 libavcodec/dvdec.c | 21 ++++++++++++++++++++-
 libavcodec/dvenc.c | 13 +++++++++++++
 3 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/libavcodec/dv.c b/libavcodec/dv.c
index 0941d51..c915480 100644
--- a/libavcodec/dv.c
+++ b/libavcodec/dv.c
@@ -239,7 +239,6 @@ int ff_dv_init_dynamic_tables(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;
 
@@ -296,23 +295,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;
 
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index ef9ba4c..b76c4b0 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -57,6 +57,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)
 {
@@ -370,7 +389,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,
 };
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 6338dee..0fc94e5 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -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"
@@ -35,6 +36,9 @@
 
 static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 {
+    DVVideoContext *s = avctx->priv_data;
+    DSPContext dsp;
+
     if (!avpriv_dv_codec_profile(avctx)) {
         av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. "
                "Valid DV profiles are:\n",
@@ -49,6 +53,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);
 }
 
-- 
1.8.3.2

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to