summaryrefslogtreecommitdiff
path: root/ffmpeg/libavcodec/dsputil.c
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/dsputil.c
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/dsputil.c')
-rw-r--r--ffmpeg/libavcodec/dsputil.c205
1 files changed, 49 insertions, 156 deletions
diff --git a/ffmpeg/libavcodec/dsputil.c b/ffmpeg/libavcodec/dsputil.c
index b56af0e..0e9e347 100644
--- a/ffmpeg/libavcodec/dsputil.c
+++ b/ffmpeg/libavcodec/dsputil.c
@@ -27,6 +27,7 @@
* DSP utils
*/
+#include "libavutil/attributes.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "avcodec.h"
@@ -68,9 +69,6 @@ const uint8_t ff_zigzag248_direct[64] = {
53, 61, 54, 62, 39, 47, 55, 63,
};
-/* not permutated inverse zigzag_direct + 1 for MMX quantizer */
-DECLARE_ALIGNED(16, uint16_t, ff_inv_zigzag_direct16)[64];
-
const uint8_t ff_alternate_horizontal_scan[64] = {
0, 1, 2, 3, 8, 9, 16, 17,
10, 11, 4, 5, 6, 7, 15, 14,
@@ -107,7 +105,9 @@ static const uint8_t simple_mmx_permutation[64]={
static const uint8_t idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7};
-void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){
+av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
+ const uint8_t *src_scantable)
+{
int i;
int end;
@@ -128,8 +128,8 @@ void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_s
}
}
-void ff_init_scantable_permutation(uint8_t *idct_permutation,
- int idct_permutation_type)
+av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
+ int idct_permutation_type)
{
int i;
@@ -797,7 +797,7 @@ static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int
#define QPEL_MC(r, OPNAME, RND, OP) \
static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
int i;\
for(i=0; i<h; i++)\
{\
@@ -816,7 +816,7 @@ static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstS
\
static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
const int w=8;\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
int i;\
for(i=0; i<w; i++)\
{\
@@ -843,7 +843,7 @@ static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstS
}\
\
static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
int i;\
\
for(i=0; i<h; i++)\
@@ -870,7 +870,7 @@ static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dst
}\
\
static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+ const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
int i;\
const int w=16;\
for(i=0; i<w; i++)\
@@ -1329,19 +1329,19 @@ QPEL_MC(0, avg_ , _ , op_avg)
void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
- put_pixels8_8_c(dst, src, stride, 8);
+ put_pixels8_8_c(dst, src, stride, 8);
}
void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
- avg_pixels8_8_c(dst, src, stride, 8);
+ avg_pixels8_8_c(dst, src, stride, 8);
}
void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
- put_pixels16_8_c(dst, src, stride, 16);
+ put_pixels16_8_c(dst, src, stride, 16);
}
void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
{
- avg_pixels16_8_c(dst, src, stride, 16);
+ avg_pixels16_8_c(dst, src, stride, 16);
}
#define put_qpel8_mc00_c ff_put_pixels8x8_c
@@ -1352,7 +1352,7 @@ void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
#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){
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i;
for(i=0; i<h; i++){
@@ -1434,7 +1434,7 @@ DIRAC_MC(avg)
#endif
static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i;
for(i=0; i<w; i++){
@@ -1513,107 +1513,6 @@ static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8);
}
-static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
- if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- int x;
- const int strength= ff_h263_loop_filter_strength[qscale];
-
- for(x=0; x<8; x++){
- int d1, d2, ad1;
- int p0= src[x-2*stride];
- int p1= src[x-1*stride];
- int p2= src[x+0*stride];
- int p3= src[x+1*stride];
- int d = (p0 - p3 + 4*(p2 - p1)) / 8;
-
- if (d<-2*strength) d1= 0;
- else if(d<- strength) d1=-2*strength - d;
- else if(d< strength) d1= d;
- else if(d< 2*strength) d1= 2*strength - d;
- else d1= 0;
-
- p1 += d1;
- p2 -= d1;
- if(p1&256) p1= ~(p1>>31);
- if(p2&256) p2= ~(p2>>31);
-
- src[x-1*stride] = p1;
- src[x+0*stride] = p2;
-
- ad1= FFABS(d1)>>1;
-
- d2= av_clip((p0-p3)/4, -ad1, ad1);
-
- src[x-2*stride] = p0 - d2;
- src[x+ stride] = p3 + d2;
- }
- }
-}
-
-static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
- if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- int y;
- const int strength= ff_h263_loop_filter_strength[qscale];
-
- for(y=0; y<8; y++){
- int d1, d2, ad1;
- int p0= src[y*stride-2];
- int p1= src[y*stride-1];
- int p2= src[y*stride+0];
- int p3= src[y*stride+1];
- int d = (p0 - p3 + 4*(p2 - p1)) / 8;
-
- if (d<-2*strength) d1= 0;
- else if(d<- strength) d1=-2*strength - d;
- else if(d< strength) d1= d;
- else if(d< 2*strength) d1= 2*strength - d;
- else d1= 0;
-
- p1 += d1;
- p2 -= d1;
- if(p1&256) p1= ~(p1>>31);
- if(p2&256) p2= ~(p2>>31);
-
- src[y*stride-1] = p1;
- src[y*stride+0] = p2;
-
- ad1= FFABS(d1)>>1;
-
- d2= av_clip((p0-p3)/4, -ad1, ad1);
-
- src[y*stride-2] = p0 - d2;
- src[y*stride+1] = p3 + d2;
- }
- }
-}
-
-static void h261_loop_filter_c(uint8_t *src, int stride){
- int x,y,xy,yz;
- int temp[64];
-
- for(x=0; x<8; x++){
- temp[x ] = 4*src[x ];
- temp[x + 7*8] = 4*src[x + 7*stride];
- }
- for(y=1; y<7; y++){
- for(x=0; x<8; x++){
- xy = y * stride + x;
- yz = y * 8 + x;
- temp[yz] = src[xy - stride] + 2*src[xy] + src[xy + stride];
- }
- }
-
- for(y=0; y<8; y++){
- src[ y*stride] = (temp[ y*8] + 2)>>2;
- src[7+y*stride] = (temp[7+y*8] + 2)>>2;
- for(x=1; x<7; x++){
- xy = y * stride + x;
- yz = y * 8 + x;
- src[xy] = (temp[yz-1] + 2*temp[yz] + temp[yz+1] + 8)>>4;
- }
- }
-}
-
static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
int s, i;
@@ -1955,7 +1854,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
long i;
- for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
+ for (i = 0; i <= w - (int)sizeof(long); i += sizeof(long)) {
long a = *(long*)(src+i);
long b = *(long*)(dst+i);
*(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
@@ -1980,7 +1879,7 @@ static void diff_bytes_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
}
}else
#endif
- for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
+ for (i = 0; i <= w - (int)sizeof(long); i += sizeof(long)) {
long a = *(long*)(src1+i);
long b = *(long*)(src2+i);
*(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
@@ -2596,19 +2495,6 @@ static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2, co
return res;
}
-static void apply_window_int16_c(int16_t *output, const int16_t *input,
- const int16_t *window, unsigned int len)
-{
- int i;
- int len2 = len >> 1;
-
- for (i = 0; i < len2; i++) {
- int16_t w = window[i];
- output[i] = (MUL16(input[i], w) + (1 << 14)) >> 15;
- output[len-i-1] = (MUL16(input[len-i-1], w) + (1 << 14)) >> 15;
- }
-}
-
static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min,
int32_t max, unsigned int len)
{
@@ -2625,12 +2511,12 @@ static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min,
} while (len > 0);
}
-static void ff_jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
+static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
{
ff_j_rev_dct (block);
put_pixels_clamped_c(block, dest, line_size);
}
-static void ff_jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
+static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
{
ff_j_rev_dct (block);
add_pixels_clamped_c(block, dest, line_size);
@@ -2675,8 +2561,6 @@ av_cold void ff_dsputil_static_init(void)
for(i=0;i<512;i++) {
ff_squareTbl[i] = (i - 256) * (i - 256);
}
-
- for(i=0; i<64; i++) ff_inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1;
}
int ff_check_alignment(void){
@@ -2744,10 +2628,15 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->idct_add = ff_simple_idct_add_10;
c->idct = ff_simple_idct_10;
c->idct_permutation_type = FF_NO_IDCT_PERM;
+ } else if (avctx->bits_per_raw_sample == 12) {
+ c->idct_put = ff_simple_idct_put_12;
+ c->idct_add = ff_simple_idct_add_12;
+ c->idct = ff_simple_idct_12;
+ c->idct_permutation_type = FF_NO_IDCT_PERM;
} else {
if(avctx->idct_algo==FF_IDCT_INT){
- c->idct_put= ff_jref_idct_put;
- c->idct_add= ff_jref_idct_add;
+ c->idct_put= jref_idct_put;
+ c->idct_add= jref_idct_add;
c->idct = ff_j_rev_dct;
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
}else if(avctx->idct_algo==FF_IDCT_FAAN){
@@ -2891,20 +2780,12 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->bswap_buf= bswap_buf;
c->bswap16_buf = bswap16_buf;
- if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- c->h263_h_loop_filter= h263_h_loop_filter_c;
- c->h263_v_loop_filter= h263_v_loop_filter_c;
- }
-
- c->h261_loop_filter= h261_loop_filter_c;
-
c->try_8x8basis= try_8x8basis_c;
c->add_8x8basis= add_8x8basis_c;
c->vector_clipf = vector_clipf_c;
c->scalarproduct_int16 = scalarproduct_int16_c;
c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
- c->apply_window_int16 = apply_window_int16_c;
c->vector_clip_int32 = vector_clip_int32_c;
c->shrink[0]= av_image_copy_plane;
@@ -2919,13 +2800,13 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
#define FUNC(f, depth) f ## _ ## depth
#define FUNCC(f, depth) f ## _ ## depth ## _c
-#define BIT_DEPTH_FUNCS(depth) \
- c->get_pixels = FUNCC(get_pixels, depth);
-
c->draw_edges = FUNCC(draw_edges, 8);
c->clear_block = FUNCC(clear_block, 8);
c->clear_blocks = FUNCC(clear_blocks, 8);
+#define BIT_DEPTH_FUNCS(depth) \
+ c->get_pixels = FUNCC(get_pixels, depth);
+
switch (avctx->bits_per_raw_sample) {
case 9:
case 10:
@@ -2941,13 +2822,20 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
}
- if (HAVE_MMX) ff_dsputil_init_mmx (c, avctx);
- if (ARCH_ARM) ff_dsputil_init_arm (c, avctx);
- if (HAVE_VIS) ff_dsputil_init_vis (c, avctx);
- if (ARCH_ALPHA) ff_dsputil_init_alpha (c, avctx);
- if (ARCH_PPC) ff_dsputil_init_ppc (c, avctx);
- if (ARCH_SH4) ff_dsputil_init_sh4 (c, avctx);
- if (ARCH_BFIN) ff_dsputil_init_bfin (c, avctx);
+ if (ARCH_ALPHA)
+ ff_dsputil_init_alpha(c, avctx);
+ if (ARCH_ARM)
+ ff_dsputil_init_arm(c, avctx);
+ if (ARCH_BFIN)
+ ff_dsputil_init_bfin(c, avctx);
+ if (ARCH_PPC)
+ ff_dsputil_init_ppc(c, avctx);
+ if (ARCH_SH4)
+ ff_dsputil_init_sh4(c, avctx);
+ if (HAVE_VIS)
+ ff_dsputil_init_vis(c, avctx);
+ if (ARCH_X86)
+ ff_dsputil_init_x86(c, avctx);
ff_init_scantable_permutation(c->idct_permutation,
c->idct_permutation_type);
@@ -2957,3 +2845,8 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
{
ff_dsputil_init(c, avctx);
}
+
+av_cold void avpriv_dsputil_init(DSPContext *c, AVCodecContext *avctx)
+{
+ ff_dsputil_init(c, avctx);
+}