55 |
****************************************************************************/ |
****************************************************************************/ |
56 |
|
|
57 |
#include "../portab.h" |
#include "../portab.h" |
58 |
|
#include "../global.h" |
59 |
#include "reduced.h" |
#include "reduced.h" |
60 |
|
|
61 |
// function pointers |
/* function pointers */ |
62 |
COPY_UPSAMPLED_8X8_16TO8 * copy_upsampled_8x8_16to8; |
COPY_UPSAMPLED_8X8_16TO8 * copy_upsampled_8x8_16to8; |
63 |
ADD_UPSAMPLED_8X8_16TO8 * add_upsampled_8x8_16to8; |
ADD_UPSAMPLED_8X8_16TO8 * add_upsampled_8x8_16to8; |
64 |
VFILTER_31 * vfilter_31; |
VFILTER_31 * vfilter_31; |
66 |
FILTER_18X18_TO_8X8 * filter_18x18_to_8x8; |
FILTER_18X18_TO_8X8 * filter_18x18_to_8x8; |
67 |
FILTER_DIFF_18X18_TO_8X8 * filter_diff_18x18_to_8x8; |
FILTER_DIFF_18X18_TO_8X8 * filter_diff_18x18_to_8x8; |
68 |
|
|
69 |
////////////////////////////////////////////////////////// |
/*---------------------------------------------------------------------------- |
70 |
// Upsampling (1/3/3/1) filter |
* Upsampling (1/3/3/1) filter |
71 |
|
*--------------------------------------------------------------------------*/ |
72 |
|
|
73 |
#define CLIP(x) ((x)<0 ? 0 : (x)>255 ? 255 : (x)) |
#define ADD(dst,src) (dst) = CLIP((dst)+(src), 0, 255) |
|
#define ADD(dst,src) (dst) = CLIP((dst)+(src)) |
|
74 |
|
|
75 |
static __inline void Filter_31(uint8_t *Dst1, uint8_t *Dst2, |
static __inline void Filter_31(uint8_t *Dst1, uint8_t *Dst2, |
76 |
const int16_t *Src1, const int16_t *Src2) |
const int16_t *Src1, const int16_t *Src2) |
78 |
/* Src[] is assumed to be >=0. So we can use ">>2" instead of "/2" */ |
/* Src[] is assumed to be >=0. So we can use ">>2" instead of "/2" */ |
79 |
int16_t a = (3*Src1[0]+ Src2[0]+2) >> 2; |
int16_t a = (3*Src1[0]+ Src2[0]+2) >> 2; |
80 |
int16_t b = ( Src1[0]+3*Src2[0]+2) >> 2; |
int16_t b = ( Src1[0]+3*Src2[0]+2) >> 2; |
81 |
Dst1[0] = CLIP(a); |
Dst1[0] = CLIP(a, 0, 255); |
82 |
Dst2[0] = CLIP(b); |
Dst2[0] = CLIP(b, 0, 255); |
83 |
} |
} |
84 |
|
|
85 |
static __inline void Filter_9331(uint8_t *Dst1, uint8_t *Dst2, |
static __inline void Filter_9331(uint8_t *Dst1, uint8_t *Dst2, |
90 |
int16_t b = (3*Src1[0]+ 9*Src1[1]+ 1*Src2[0] + 3*Src2[1] + 8) >> 4; |
int16_t b = (3*Src1[0]+ 9*Src1[1]+ 1*Src2[0] + 3*Src2[1] + 8) >> 4; |
91 |
int16_t c = (3*Src1[0]+ 1*Src1[1]+ 9*Src2[0] + 3*Src2[1] + 8) >> 4; |
int16_t c = (3*Src1[0]+ 1*Src1[1]+ 9*Src2[0] + 3*Src2[1] + 8) >> 4; |
92 |
int16_t d = (1*Src1[0]+ 3*Src1[1]+ 3*Src2[0] + 9*Src2[1] + 8) >> 4; |
int16_t d = (1*Src1[0]+ 3*Src1[1]+ 3*Src2[0] + 9*Src2[1] + 8) >> 4; |
93 |
Dst1[0] = CLIP(a); |
Dst1[0] = CLIP(a, 0, 255); |
94 |
Dst1[1] = CLIP(b); |
Dst1[1] = CLIP(b, 0, 255); |
95 |
Dst2[0] = CLIP(c); |
Dst2[0] = CLIP(c, 0, 255); |
96 |
Dst2[1] = CLIP(d); |
Dst2[1] = CLIP(d, 0, 255); |
97 |
} |
} |
98 |
|
|
99 |
void xvid_Copy_Upsampled_8x8_16To8_C(uint8_t *Dst, const int16_t *Src, const int BpS) |
void xvid_Copy_Upsampled_8x8_16To8_C(uint8_t *Dst, const int16_t *Src, const int BpS) |
100 |
{ |
{ |
101 |
int x, y; |
int x, y; |
102 |
|
|
103 |
Dst[0] = CLIP(Src[0]); |
Dst[0] = CLIP(Src[0], 0, 255); |
104 |
for(x=0; x<7; ++x) Filter_31(Dst+2*x+1, Dst+2*x+2, Src+x, Src+x+1); |
for(x=0; x<7; ++x) Filter_31(Dst+2*x+1, Dst+2*x+2, Src+x, Src+x+1); |
105 |
Dst[15] = CLIP(Src[7]); |
Dst[15] = CLIP(Src[7], 0, 255); |
106 |
Dst += BpS; |
Dst += BpS; |
107 |
for(y=0; y<7; ++y) { |
for(y=0; y<7; ++y) { |
108 |
uint8_t *const Dst2 = Dst + BpS; |
uint8_t *const Dst2 = Dst + BpS; |
113 |
Src += 8; |
Src += 8; |
114 |
Dst += 2*BpS; |
Dst += 2*BpS; |
115 |
} |
} |
116 |
Dst[0] = CLIP(Src[0]); |
Dst[0] = CLIP(Src[0], 0, 255); |
117 |
for(x=0; x<7; ++x) Filter_31(Dst+2*x+1, Dst+2*x+2, Src+x, Src+x+1); |
for(x=0; x<7; ++x) Filter_31(Dst+2*x+1, Dst+2*x+2, Src+x, Src+x+1); |
118 |
Dst[15] = CLIP(Src[7]); |
Dst[15] = CLIP(Src[7], 0, 255); |
119 |
} |
} |
120 |
|
|
121 |
static __inline void Filter_Add_31(uint8_t *Dst1, uint8_t *Dst2, |
static __inline void Filter_Add_31(uint8_t *Dst1, uint8_t *Dst2, |
162 |
for(x=0; x<7; ++x) Filter_Add_31(Dst+2*x+1, Dst+2*x+2, Src+x, Src+x+1); |
for(x=0; x<7; ++x) Filter_Add_31(Dst+2*x+1, Dst+2*x+2, Src+x, Src+x+1); |
163 |
ADD(Dst[15], Src[7]); |
ADD(Dst[15], Src[7]); |
164 |
} |
} |
|
#undef CLIP |
|
165 |
#undef ADD |
#undef ADD |
166 |
|
|
167 |
////////////////////////////////////////////////////////// |
/*---------------------------------------------------------------------------- |
168 |
// horizontal and vertical deblocking |
* horizontal and vertical deblocking |
169 |
|
*--------------------------------------------------------------------------*/ |
170 |
|
|
171 |
void xvid_HFilter_31_C(uint8_t *Src1, uint8_t *Src2, int Nb_Blks) |
void xvid_HFilter_31_C(uint8_t *Src1, uint8_t *Src2, int Nb_Blks) |
172 |
{ |
{ |
192 |
} |
} |
193 |
} |
} |
194 |
|
|
195 |
////////////////////////////////////////////////////////// |
/*---------------------------------------------------------------------------- |
196 |
// 16x16 -> 8x8 (1/3/3/1) downsampling |
* 16x16 -> 8x8 (1/3/3/1) downsampling |
197 |
// |
* |
198 |
// Warning! These read 1 pixel outside of the input 16x16 block! |
* Warning! These read 1 pixel outside of the input 16x16 block! |
199 |
// |
*--------------------------------------------------------------------------*/ |
|
////////////////////////////////////////////////////////// |
|
200 |
|
|
201 |
void xvid_Filter_18x18_To_8x8_C(int16_t *Dst, const uint8_t *Src, const int BpS) |
void xvid_Filter_18x18_To_8x8_C(int16_t *Dst, const uint8_t *Src, const int BpS) |
202 |
{ |
{ |
241 |
T += 16; |
T += 16; |
242 |
} |
} |
243 |
} |
} |
|
|
|
|
////////////////////////////////////////////////////////// |
|