aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2013-12-27 10:29:14 +0100
committerDiego Biurrun <diego@biurrun.de>2014-05-29 06:41:15 -0700
commit256da0770e495176d1b2699ec6e9c7993c2a6d7b (patch)
treedb3fb26e041fbfc2fc18fa390a9fe4008b10230b
parent3832a6590156e6abc575bed51cbffa78617ee5fd (diff)
downloadffmpeg-256da0770e495176d1b2699ec6e9c7993c2a6d7b.tar.gz
dsputil: Move mspel_pixels_tab to the only place it is used
-rw-r--r--libavcodec/dsputil.c118
-rw-r--r--libavcodec/dsputil.h5
-rw-r--r--libavcodec/wmv2.c8
-rw-r--r--libavcodec/wmv2dsp.c119
-rw-r--r--libavcodec/wmv2dsp.h4
5 files changed, 135 insertions, 119 deletions
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index ddd9d734b9..11447c01e8 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -1191,113 +1191,12 @@ void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
#define put_no_rnd_qpel8_mc00_c ff_put_pixels8x8_c
#define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_c
-static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src,
- int dstStride, int srcStride, int h)
+void ff_put_pixels8_l2_8(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
+ int dst_stride, int src_stride1, int src_stride2,
+ int h)
{
- const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
- int i;
-
- for (i = 0; i < h; i++) {
- dst[0] = cm[(9 * (src[0] + src[1]) - (src[-1] + src[2]) + 8) >> 4];
- dst[1] = cm[(9 * (src[1] + src[2]) - (src[0] + src[3]) + 8) >> 4];
- dst[2] = cm[(9 * (src[2] + src[3]) - (src[1] + src[4]) + 8) >> 4];
- dst[3] = cm[(9 * (src[3] + src[4]) - (src[2] + src[5]) + 8) >> 4];
- dst[4] = cm[(9 * (src[4] + src[5]) - (src[3] + src[6]) + 8) >> 4];
- dst[5] = cm[(9 * (src[5] + src[6]) - (src[4] + src[7]) + 8) >> 4];
- dst[6] = cm[(9 * (src[6] + src[7]) - (src[5] + src[8]) + 8) >> 4];
- dst[7] = cm[(9 * (src[7] + src[8]) - (src[6] + src[9]) + 8) >> 4];
- dst += dstStride;
- src += srcStride;
- }
-}
-
-static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src,
- int dstStride, int srcStride, int w)
-{
- const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
- int i;
-
- for (i = 0; i < w; i++) {
- const int src_1 = src[-srcStride];
- const int src0 = src[0];
- const int src1 = src[srcStride];
- const int src2 = src[2 * srcStride];
- const int src3 = src[3 * srcStride];
- const int src4 = src[4 * srcStride];
- const int src5 = src[5 * srcStride];
- const int src6 = src[6 * srcStride];
- const int src7 = src[7 * srcStride];
- const int src8 = src[8 * srcStride];
- const int src9 = src[9 * srcStride];
- dst[0 * dstStride] = cm[(9 * (src0 + src1) - (src_1 + src2) + 8) >> 4];
- dst[1 * dstStride] = cm[(9 * (src1 + src2) - (src0 + src3) + 8) >> 4];
- dst[2 * dstStride] = cm[(9 * (src2 + src3) - (src1 + src4) + 8) >> 4];
- dst[3 * dstStride] = cm[(9 * (src3 + src4) - (src2 + src5) + 8) >> 4];
- dst[4 * dstStride] = cm[(9 * (src4 + src5) - (src3 + src6) + 8) >> 4];
- dst[5 * dstStride] = cm[(9 * (src5 + src6) - (src4 + src7) + 8) >> 4];
- dst[6 * dstStride] = cm[(9 * (src6 + src7) - (src5 + src8) + 8) >> 4];
- dst[7 * dstStride] = cm[(9 * (src7 + src8) - (src6 + src9) + 8) >> 4];
- src++;
- dst++;
- }
-}
-
-static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- uint8_t half[64];
-
- wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
- put_pixels8_l2_8(dst, src, half, stride, stride, 8, 8);
-}
-
-static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8);
-}
+ put_pixels8_l2_8(dst, src1, src2, dst_stride, src_stride1, src_stride2, h);
-static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- uint8_t half[64];
-
- wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
- put_pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8);
-}
-
-static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8);
-}
-
-static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- uint8_t halfH[88];
- uint8_t halfV[64];
- uint8_t halfHV[64];
-
- wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
- wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8);
- wmv2_mspel8_v_lowpass(halfHV, halfH + 8, 8, 8, 8);
- put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
-}
-
-static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- uint8_t halfH[88];
- uint8_t halfV[64];
- uint8_t halfHV[64];
-
- wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
- wmv2_mspel8_v_lowpass(halfV, src + 1, 8, stride, 8);
- wmv2_mspel8_v_lowpass(halfHV, halfH + 8, 8, 8, 8);
- put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
-}
-
-static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
-{
- uint8_t halfH[88];
-
- wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
- wmv2_mspel8_v_lowpass(dst, halfH + 8, stride, 8, 8);
}
static inline int pix_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
@@ -2360,15 +2259,6 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
#undef dspfunc
- c->put_mspel_pixels_tab[0] = ff_put_pixels8x8_c;
- c->put_mspel_pixels_tab[1] = put_mspel8_mc10_c;
- c->put_mspel_pixels_tab[2] = put_mspel8_mc20_c;
- c->put_mspel_pixels_tab[3] = put_mspel8_mc30_c;
- c->put_mspel_pixels_tab[4] = put_mspel8_mc02_c;
- c->put_mspel_pixels_tab[5] = put_mspel8_mc12_c;
- c->put_mspel_pixels_tab[6] = put_mspel8_mc22_c;
- c->put_mspel_pixels_tab[7] = put_mspel8_mc32_c;
-
#define SET_CMP_FUNC(name) \
c->name[0] = name ## 16_c; \
c->name[1] = name ## 8x8_c;
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index de5a460752..d261f7e702 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -39,6 +39,10 @@ void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
+void ff_put_pixels8_l2_8(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
+ int dst_stride, int src_stride1, int src_stride2,
+ int h);
+
void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
int dxx, int dxy, int dyx, int dyy, int shift, int r,
int width, int height);
@@ -174,7 +178,6 @@ typedef struct DSPContext {
qpel_mc_func put_qpel_pixels_tab[2][16];
qpel_mc_func avg_qpel_pixels_tab[2][16];
qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
- qpel_mc_func put_mspel_pixels_tab[8];
me_cmp_func pix_abs[2][4];
diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c
index 9ba9451147..003f0220c1 100644
--- a/libavcodec/wmv2.c
+++ b/libavcodec/wmv2.c
@@ -129,10 +129,10 @@ void ff_mspel_motion(MpegEncContext *s,
emu=1;
}
- s->dsp.put_mspel_pixels_tab[dxy](dest_y , ptr , linesize);
- s->dsp.put_mspel_pixels_tab[dxy](dest_y+8 , ptr+8 , linesize);
- s->dsp.put_mspel_pixels_tab[dxy](dest_y +8*linesize, ptr +8*linesize, linesize);
- s->dsp.put_mspel_pixels_tab[dxy](dest_y+8+8*linesize, ptr+8+8*linesize, linesize);
+ w->wdsp.put_mspel_pixels_tab[dxy](dest_y, ptr, linesize);
+ w->wdsp.put_mspel_pixels_tab[dxy](dest_y + 8, ptr + 8, linesize);
+ w->wdsp.put_mspel_pixels_tab[dxy](dest_y + 8 * linesize, ptr + 8 * linesize, linesize);
+ w->wdsp.put_mspel_pixels_tab[dxy](dest_y + 8 + 8 * linesize, ptr + 8 + 8 * linesize, linesize);
if(s->flags&CODEC_FLAG_GRAY) return;
diff --git a/libavcodec/wmv2dsp.c b/libavcodec/wmv2dsp.c
index 72dfe78b53..dff49f47a4 100644
--- a/libavcodec/wmv2dsp.c
+++ b/libavcodec/wmv2dsp.c
@@ -20,6 +20,7 @@
#include "libavutil/common.h"
#include "avcodec.h"
#include "dsputil.h"
+#include "mathops.h"
#include "wmv2dsp.h"
#define W0 2048
@@ -138,9 +139,127 @@ static void wmv2_idct_put_c(uint8_t *dest, int line_size, int16_t *block)
}
}
+static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src,
+ int dstStride, int srcStride, int h)
+{
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
+ int i;
+
+ for (i = 0; i < h; i++) {
+ dst[0] = cm[(9 * (src[0] + src[1]) - (src[-1] + src[2]) + 8) >> 4];
+ dst[1] = cm[(9 * (src[1] + src[2]) - (src[0] + src[3]) + 8) >> 4];
+ dst[2] = cm[(9 * (src[2] + src[3]) - (src[1] + src[4]) + 8) >> 4];
+ dst[3] = cm[(9 * (src[3] + src[4]) - (src[2] + src[5]) + 8) >> 4];
+ dst[4] = cm[(9 * (src[4] + src[5]) - (src[3] + src[6]) + 8) >> 4];
+ dst[5] = cm[(9 * (src[5] + src[6]) - (src[4] + src[7]) + 8) >> 4];
+ dst[6] = cm[(9 * (src[6] + src[7]) - (src[5] + src[8]) + 8) >> 4];
+ dst[7] = cm[(9 * (src[7] + src[8]) - (src[6] + src[9]) + 8) >> 4];
+ dst += dstStride;
+ src += srcStride;
+ }
+}
+
+static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src,
+ int dstStride, int srcStride, int w)
+{
+ const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
+ int i;
+
+ for (i = 0; i < w; i++) {
+ const int src_1 = src[-srcStride];
+ const int src0 = src[0];
+ const int src1 = src[srcStride];
+ const int src2 = src[2 * srcStride];
+ const int src3 = src[3 * srcStride];
+ const int src4 = src[4 * srcStride];
+ const int src5 = src[5 * srcStride];
+ const int src6 = src[6 * srcStride];
+ const int src7 = src[7 * srcStride];
+ const int src8 = src[8 * srcStride];
+ const int src9 = src[9 * srcStride];
+ dst[0 * dstStride] = cm[(9 * (src0 + src1) - (src_1 + src2) + 8) >> 4];
+ dst[1 * dstStride] = cm[(9 * (src1 + src2) - (src0 + src3) + 8) >> 4];
+ dst[2 * dstStride] = cm[(9 * (src2 + src3) - (src1 + src4) + 8) >> 4];
+ dst[3 * dstStride] = cm[(9 * (src3 + src4) - (src2 + src5) + 8) >> 4];
+ dst[4 * dstStride] = cm[(9 * (src4 + src5) - (src3 + src6) + 8) >> 4];
+ dst[5 * dstStride] = cm[(9 * (src5 + src6) - (src4 + src7) + 8) >> 4];
+ dst[6 * dstStride] = cm[(9 * (src6 + src7) - (src5 + src8) + 8) >> 4];
+ dst[7 * dstStride] = cm[(9 * (src7 + src8) - (src6 + src9) + 8) >> 4];
+ src++;
+ dst++;
+ }
+}
+
+static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ uint8_t half[64];
+
+ wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
+ ff_put_pixels8_l2_8(dst, src, half, stride, stride, 8, 8);
+}
+
+static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8);
+}
+
+static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ uint8_t half[64];
+
+ wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
+ ff_put_pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8);
+}
+
+static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8);
+}
+
+static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ uint8_t halfH[88];
+ uint8_t halfV[64];
+ uint8_t halfHV[64];
+
+ wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
+ wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8);
+ wmv2_mspel8_v_lowpass(halfHV, halfH + 8, 8, 8, 8);
+ ff_put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
+}
+
+static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ uint8_t halfH[88];
+ uint8_t halfV[64];
+ uint8_t halfHV[64];
+
+ wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
+ wmv2_mspel8_v_lowpass(halfV, src + 1, 8, stride, 8);
+ wmv2_mspel8_v_lowpass(halfHV, halfH + 8, 8, 8, 8);
+ ff_put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
+}
+
+static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
+{
+ uint8_t halfH[88];
+
+ wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
+ wmv2_mspel8_v_lowpass(dst, halfH + 8, stride, 8, 8);
+}
+
av_cold void ff_wmv2dsp_init(WMV2DSPContext *c)
{
c->idct_add = wmv2_idct_add_c;
c->idct_put = wmv2_idct_put_c;
c->idct_perm = FF_NO_IDCT_PERM;
+
+ c->put_mspel_pixels_tab[0] = ff_put_pixels8x8_c;
+ c->put_mspel_pixels_tab[1] = put_mspel8_mc10_c;
+ c->put_mspel_pixels_tab[2] = put_mspel8_mc20_c;
+ c->put_mspel_pixels_tab[3] = put_mspel8_mc30_c;
+ c->put_mspel_pixels_tab[4] = put_mspel8_mc02_c;
+ c->put_mspel_pixels_tab[5] = put_mspel8_mc12_c;
+ c->put_mspel_pixels_tab[6] = put_mspel8_mc22_c;
+ c->put_mspel_pixels_tab[7] = put_mspel8_mc32_c;
}
diff --git a/libavcodec/wmv2dsp.h b/libavcodec/wmv2dsp.h
index 3368b3a971..935620da6d 100644
--- a/libavcodec/wmv2dsp.h
+++ b/libavcodec/wmv2dsp.h
@@ -21,10 +21,14 @@
#include <stdint.h>
+#include "dsputil.h"
+
typedef struct WMV2DSPContext {
void (*idct_add)(uint8_t *dest, int line_size, int16_t *block);
void (*idct_put)(uint8_t *dest, int line_size, int16_t *block);
+ qpel_mc_func put_mspel_pixels_tab[8];
+
int idct_perm;
} WMV2DSPContext;