*
*/
+#include "libavutil/common.h"
+#include "h264chroma.h"
#include "vc1dsp.h"
}
}
-static void vc1_v_s_overlap_c(DCTELEM *top, DCTELEM *bottom)
+static void vc1_v_s_overlap_c(int16_t *top, int16_t *bottom)
{
int i;
int a, b, c, d;
}
}
-static void vc1_h_s_overlap_c(DCTELEM *left, DCTELEM *right)
+static void vc1_h_s_overlap_c(int16_t *left, int16_t *right)
{
int i;
int a, b, c, d;
* @see 8.6
*/
static av_always_inline int vc1_filter_line(uint8_t* src, int stride, int pq){
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-
int a0 = (2*(src[-2*stride] - src[ 1*stride]) - 5*(src[-1*stride] - src[ 0*stride]) + 4) >> 3;
int a0_sign = a0 >> 31; /* Store sign */
a0 = (a0 ^ a0_sign) - a0_sign; /* a0 = FFABS(a0); */
else{
d = FFMIN(d, clip);
d = (d ^ d_sign) - d_sign; /* Restore sign */
- src[-1*stride] = cm[src[-1*stride] - d];
- src[ 0*stride] = cm[src[ 0*stride] + d];
+ src[-1*stride] = av_clip_uint8(src[-1*stride] - d);
+ src[ 0*stride] = av_clip_uint8(src[ 0*stride] + d);
}
return 1;
}
/** Do inverse transform on 8x8 block
*/
-static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
+static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
int dc = block[0];
- const uint8_t *cm;
dc = (3 * dc + 1) >> 1;
dc = (3 * dc + 16) >> 5;
- cm = ff_cropTbl + MAX_NEG_CROP + dc;
for(i = 0; i < 8; i++){
- dest[0] = cm[dest[0]];
- dest[1] = cm[dest[1]];
- dest[2] = cm[dest[2]];
- dest[3] = cm[dest[3]];
- dest[4] = cm[dest[4]];
- dest[5] = cm[dest[5]];
- dest[6] = cm[dest[6]];
- dest[7] = cm[dest[7]];
+ dest[0] = av_clip_uint8(dest[0] + dc);
+ dest[1] = av_clip_uint8(dest[1] + dc);
+ dest[2] = av_clip_uint8(dest[2] + dc);
+ dest[3] = av_clip_uint8(dest[3] + dc);
+ dest[4] = av_clip_uint8(dest[4] + dc);
+ dest[5] = av_clip_uint8(dest[5] + dc);
+ dest[6] = av_clip_uint8(dest[6] + dc);
+ dest[7] = av_clip_uint8(dest[7] + dc);
dest += linesize;
}
}
-static void vc1_inv_trans_8x8_c(DCTELEM block[64])
+static void vc1_inv_trans_8x8_c(int16_t block[64])
{
int i;
register int t1,t2,t3,t4,t5,t6,t7,t8;
- DCTELEM *src, *dst, temp[64];
+ int16_t *src, *dst, temp[64];
src = block;
dst = temp;
/** Do inverse transform on 8x4 part of block
*/
-static void vc1_inv_trans_8x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
+static void vc1_inv_trans_8x4_dc_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
int dc = block[0];
- const uint8_t *cm;
dc = ( 3 * dc + 1) >> 1;
dc = (17 * dc + 64) >> 7;
- cm = ff_cropTbl + MAX_NEG_CROP + dc;
for(i = 0; i < 4; i++){
- dest[0] = cm[dest[0]];
- dest[1] = cm[dest[1]];
- dest[2] = cm[dest[2]];
- dest[3] = cm[dest[3]];
- dest[4] = cm[dest[4]];
- dest[5] = cm[dest[5]];
- dest[6] = cm[dest[6]];
- dest[7] = cm[dest[7]];
+ dest[0] = av_clip_uint8(dest[0] + dc);
+ dest[1] = av_clip_uint8(dest[1] + dc);
+ dest[2] = av_clip_uint8(dest[2] + dc);
+ dest[3] = av_clip_uint8(dest[3] + dc);
+ dest[4] = av_clip_uint8(dest[4] + dc);
+ dest[5] = av_clip_uint8(dest[5] + dc);
+ dest[6] = av_clip_uint8(dest[6] + dc);
+ dest[7] = av_clip_uint8(dest[7] + dc);
dest += linesize;
}
}
-static void vc1_inv_trans_8x4_c(uint8_t *dest, int linesize, DCTELEM *block)
+static void vc1_inv_trans_8x4_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
register int t1,t2,t3,t4,t5,t6,t7,t8;
- DCTELEM *src, *dst;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ int16_t *src, *dst;
src = block;
dst = block;
t3 = 22 * src[ 8] + 10 * src[24];
t4 = 22 * src[24] - 10 * src[ 8];
- dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
- dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
- dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
- dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
+ dest[0*linesize] = av_clip_uint8(dest[0*linesize] + ((t1 + t3) >> 7));
+ dest[1*linesize] = av_clip_uint8(dest[1*linesize] + ((t2 - t4) >> 7));
+ dest[2*linesize] = av_clip_uint8(dest[2*linesize] + ((t2 + t4) >> 7));
+ dest[3*linesize] = av_clip_uint8(dest[3*linesize] + ((t1 - t3) >> 7));
src ++;
dest++;
/** Do inverse transform on 4x8 parts of block
*/
-static void vc1_inv_trans_4x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
+static void vc1_inv_trans_4x8_dc_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
int dc = block[0];
- const uint8_t *cm;
dc = (17 * dc + 4) >> 3;
dc = (12 * dc + 64) >> 7;
- cm = ff_cropTbl + MAX_NEG_CROP + dc;
for(i = 0; i < 8; i++){
- dest[0] = cm[dest[0]];
- dest[1] = cm[dest[1]];
- dest[2] = cm[dest[2]];
- dest[3] = cm[dest[3]];
+ dest[0] = av_clip_uint8(dest[0] + dc);
+ dest[1] = av_clip_uint8(dest[1] + dc);
+ dest[2] = av_clip_uint8(dest[2] + dc);
+ dest[3] = av_clip_uint8(dest[3] + dc);
dest += linesize;
}
}
-static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, DCTELEM *block)
+static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
register int t1,t2,t3,t4,t5,t6,t7,t8;
- DCTELEM *src, *dst;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ int16_t *src, *dst;
src = block;
dst = block;
t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
- dest[0*linesize] = cm[dest[0*linesize] + ((t5 + t1) >> 7)];
- dest[1*linesize] = cm[dest[1*linesize] + ((t6 + t2) >> 7)];
- dest[2*linesize] = cm[dest[2*linesize] + ((t7 + t3) >> 7)];
- dest[3*linesize] = cm[dest[3*linesize] + ((t8 + t4) >> 7)];
- dest[4*linesize] = cm[dest[4*linesize] + ((t8 - t4 + 1) >> 7)];
- dest[5*linesize] = cm[dest[5*linesize] + ((t7 - t3 + 1) >> 7)];
- dest[6*linesize] = cm[dest[6*linesize] + ((t6 - t2 + 1) >> 7)];
- dest[7*linesize] = cm[dest[7*linesize] + ((t5 - t1 + 1) >> 7)];
+ dest[0*linesize] = av_clip_uint8(dest[0*linesize] + ((t5 + t1) >> 7));
+ dest[1*linesize] = av_clip_uint8(dest[1*linesize] + ((t6 + t2) >> 7));
+ dest[2*linesize] = av_clip_uint8(dest[2*linesize] + ((t7 + t3) >> 7));
+ dest[3*linesize] = av_clip_uint8(dest[3*linesize] + ((t8 + t4) >> 7));
+ dest[4*linesize] = av_clip_uint8(dest[4*linesize] + ((t8 - t4 + 1) >> 7));
+ dest[5*linesize] = av_clip_uint8(dest[5*linesize] + ((t7 - t3 + 1) >> 7));
+ dest[6*linesize] = av_clip_uint8(dest[6*linesize] + ((t6 - t2 + 1) >> 7));
+ dest[7*linesize] = av_clip_uint8(dest[7*linesize] + ((t5 - t1 + 1) >> 7));
src ++;
dest++;
/** Do inverse transform on 4x4 part of block
*/
-static void vc1_inv_trans_4x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
+static void vc1_inv_trans_4x4_dc_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
int dc = block[0];
- const uint8_t *cm;
dc = (17 * dc + 4) >> 3;
dc = (17 * dc + 64) >> 7;
- cm = ff_cropTbl + MAX_NEG_CROP + dc;
for(i = 0; i < 4; i++){
- dest[0] = cm[dest[0]];
- dest[1] = cm[dest[1]];
- dest[2] = cm[dest[2]];
- dest[3] = cm[dest[3]];
+ dest[0] = av_clip_uint8(dest[0] + dc);
+ dest[1] = av_clip_uint8(dest[1] + dc);
+ dest[2] = av_clip_uint8(dest[2] + dc);
+ dest[3] = av_clip_uint8(dest[3] + dc);
dest += linesize;
}
}
-static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block)
+static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, int16_t *block)
{
int i;
register int t1,t2,t3,t4;
- DCTELEM *src, *dst;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ int16_t *src, *dst;
src = block;
dst = block;
t3 = 22 * src[ 8] + 10 * src[24];
t4 = 22 * src[24] - 10 * src[ 8];
- dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
- dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
- dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
- dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
+ dest[0*linesize] = av_clip_uint8(dest[0*linesize] + ((t1 + t3) >> 7));
+ dest[1*linesize] = av_clip_uint8(dest[1*linesize] + ((t2 - t4) >> 7));
+ dest[2*linesize] = av_clip_uint8(dest[2*linesize] + ((t2 + t4) >> 7));
+ dest[3*linesize] = av_clip_uint8(dest[3*linesize] + ((t1 - t3) >> 7));
src ++;
dest++;
return 0; /* should not occur */ \
}
-VC1_MSPEL_FILTER_16B(ver, uint8_t);
-VC1_MSPEL_FILTER_16B(hor, int16_t);
+VC1_MSPEL_FILTER_16B(ver, uint8_t)
+VC1_MSPEL_FILTER_16B(hor, int16_t)
/** Filter used to interpolate fractional pel values
/** Function used to do motion compensation with bicubic interpolation
*/
#define VC1_MSPEL_MC(OP, OPNAME)\
-static void OPNAME ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int hmode, int vmode, int rnd)\
+static av_always_inline void OPNAME ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int hmode, int vmode, int rnd)\
{\
int i, j;\
\
/* pixel functions - really are entry points to vc1_mspel_mc */
#define PUT_VC1_MSPEL(a, b)\
-static void put_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
- put_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
-}\
-static void avg_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
- avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
+static void put_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, \
+ const uint8_t *src, \
+ ptrdiff_t stride, int rnd) \
+{ \
+ put_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
+} \
+static void avg_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, \
+ const uint8_t *src, \
+ ptrdiff_t stride, int rnd) \
+{ \
+ avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
}
PUT_VC1_MSPEL(1, 0)
}
}
+static void put_no_rnd_vc1_chroma_mc4_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y){
+ const int A=(8-x)*(8-y);
+ const int B=( x)*(8-y);
+ const int C=(8-x)*( y);
+ const int D=( x)*( y);
+ int i;
+
+ assert(x<8 && y<8 && x>=0 && y>=0);
+
+ for(i=0; i<h; i++)
+ {
+ dst[0] = (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6;
+ dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6;
+ dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6;
+ dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6;
+ dst+= stride;
+ src+= stride;
+ }
+}
+
#define avg2(a,b) ((a+b+1)>>1)
static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){
const int A=(8-x)*(8-y);
dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c;
dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c;
+ dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = put_no_rnd_vc1_chroma_mc4_c;
#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
dsp->sprite_h = sprite_h_c;
dsp->sprite_v_double_twoscale = sprite_v_double_twoscale_c;
#endif
- if (HAVE_ALTIVEC)
- ff_vc1dsp_init_altivec(dsp);
- if (HAVE_MMX)
- ff_vc1dsp_init_mmx(dsp);
+ if (ARCH_X86)
+ ff_vc1dsp_init_x86(dsp);
+ if (ARCH_PPC)
+ ff_vc1dsp_init_ppc(dsp);
}