Rename ABS macro to FFABS.

Originally committed as revision 6666 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Diego Biurrun 18 years ago
parent 02305ff38f
commit c26abfa541
  1. 2
      ffmpeg.c
  2. 2
      libavcodec/cabac.h
  3. 2
      libavcodec/dct-test.c
  4. 60
      libavcodec/dsputil.c
  5. 2
      libavcodec/dv.c
  6. 16
      libavcodec/error_resilience.c
  7. 4
      libavcodec/ffv1.c
  8. 8
      libavcodec/flacenc.c
  9. 4
      libavcodec/h263.c
  10. 80
      libavcodec/h264.c
  11. 12
      libavcodec/i386/dsputil_mmx.c
  12. 18
      libavcodec/jpeg_ls.c
  13. 16
      libavcodec/motion_est.c
  14. 10
      libavcodec/motion_est_template.c
  15. 8
      libavcodec/mpeg12.c
  16. 30
      libavcodec/mpegvideo.c
  17. 2
      libavcodec/msmpeg4.c
  18. 10
      libavcodec/ratecontrol.c
  19. 2
      libavcodec/resample2.c
  20. 54
      libavcodec/snow.c
  21. 24
      libavcodec/vc1.c
  22. 6
      libavcodec/vorbis.c
  23. 8
      libavcodec/vp3.c
  24. 4
      libavcodec/vp6.c
  25. 2
      libavcodec/wmv2.c
  26. 2
      libavformat/gxf.c
  27. 4
      libavformat/ogg2.c
  28. 8
      libavformat/utils.c
  29. 2
      libavutil/common.h
  30. 6
      libavutil/rational.c
  31. 22
      libpostproc/postprocess.c
  32. 32
      libpostproc/postprocess_template.c

@ -1924,7 +1924,7 @@ static int av_encode(AVFormatContext **output_files,
// fprintf(stderr, "next:%lld dts:%lld off:%lld %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type); // fprintf(stderr, "next:%lld dts:%lld off:%lld %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type);
if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE) { if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE) {
int64_t delta= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q) - ist->next_pts; int64_t delta= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q) - ist->next_pts;
if(ABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE && !copy_ts){ if(FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE && !copy_ts){
input_files_ts_offset[ist->file_index]-= delta; input_files_ts_offset[ist->file_index]-= delta;
if (verbose > 2) if (verbose > 2)
fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]); fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]);

@ -219,7 +219,7 @@ static void put_cabac_ueg(CABACContext *c, uint8_t * state, int v, int max, int
else{ else{
const int sign= v < 0; const int sign= v < 0;
if(is_signed) v= ABS(v); if(is_signed) v= FFABS(v);
if(v<max){ if(v<max){
for(i=0; i<v; i++){ for(i=0; i<v; i++){

@ -224,7 +224,7 @@ void dct_error(const char *name, int is_idct,
} }
#endif #endif
} }
for(i=0; i<64; i++) sysErrMax= MAX(sysErrMax, ABS(sysErr[i])); for(i=0; i<64; i++) sysErrMax= MAX(sysErrMax, FFABS(sysErr[i]));
#if 1 // dump systematic errors #if 1 // dump systematic errors
for(i=0; i<64; i++){ for(i=0; i<64; i++){

@ -358,7 +358,7 @@ static inline int w_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, in
for(i=0; i<size; i++){ for(i=0; i<size; i++){
for(j=0; j<size; j++){ for(j=0; j<size; j++){
int v= tmp[sx + sy + i*stride + j] * scale[type][dec_count-3][level][ori]; int v= tmp[sx + sy + i*stride + j] * scale[type][dec_count-3][level][ori];
s += ABS(v); s += FFABS(v);
} }
} }
} }
@ -2729,7 +2729,7 @@ static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
src[x-1*stride] = p1; src[x-1*stride] = p1;
src[x+0*stride] = p2; src[x+0*stride] = p2;
ad1= ABS(d1)>>1; ad1= FFABS(d1)>>1;
d2= clip((p0-p3)/4, -ad1, ad1); d2= clip((p0-p3)/4, -ad1, ad1);
@ -2764,7 +2764,7 @@ static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
src[y*stride-1] = p1; src[y*stride-1] = p1;
src[y*stride+0] = p2; src[y*stride+0] = p2;
ad1= ABS(d1)>>1; ad1= FFABS(d1)>>1;
d2= clip((p0-p3)/4, -ad1, ad1); d2= clip((p0-p3)/4, -ad1, ad1);
@ -2816,18 +2816,18 @@ static inline void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystrid
const int q1 = pix[1*xstride]; const int q1 = pix[1*xstride];
const int q2 = pix[2*xstride]; const int q2 = pix[2*xstride];
if( ABS( p0 - q0 ) < alpha && if( FFABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta && FFABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) { FFABS( q1 - q0 ) < beta ) {
int tc = tc0[i]; int tc = tc0[i];
int i_delta; int i_delta;
if( ABS( p2 - p0 ) < beta ) { if( FFABS( p2 - p0 ) < beta ) {
pix[-2*xstride] = p1 + clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc0[i], tc0[i] ); pix[-2*xstride] = p1 + clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc0[i], tc0[i] );
tc++; tc++;
} }
if( ABS( q2 - q0 ) < beta ) { if( FFABS( q2 - q0 ) < beta ) {
pix[ xstride] = q1 + clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc0[i], tc0[i] ); pix[ xstride] = q1 + clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc0[i], tc0[i] );
tc++; tc++;
} }
@ -2864,9 +2864,9 @@ static inline void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystr
const int q0 = pix[0]; const int q0 = pix[0];
const int q1 = pix[1*xstride]; const int q1 = pix[1*xstride];
if( ABS( p0 - q0 ) < alpha && if( FFABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta && FFABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) { FFABS( q1 - q0 ) < beta ) {
int delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); int delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
@ -2895,9 +2895,9 @@ static inline void h264_loop_filter_chroma_intra_c(uint8_t *pix, int xstride, in
const int q0 = pix[0]; const int q0 = pix[0];
const int q1 = pix[1*xstride]; const int q1 = pix[1*xstride];
if( ABS( p0 - q0 ) < alpha && if( FFABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta && FFABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) { FFABS( q1 - q0 ) < beta ) {
pix[-xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */ pix[-xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */
pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */ pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */
@ -3126,9 +3126,9 @@ static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
} }
if(y+1<h){ if(y+1<h){
for(x=0; x<15; x++){ for(x=0; x<15; x++){
score2+= ABS( s1[x ] - s1[x +stride] score2+= FFABS( s1[x ] - s1[x +stride]
- s1[x+1] + s1[x+1+stride]) - s1[x+1] + s1[x+1+stride])
-ABS( s2[x ] - s2[x +stride] -FFABS( s2[x ] - s2[x +stride]
- s2[x+1] + s2[x+1+stride]); - s2[x+1] + s2[x+1+stride]);
} }
} }
@ -3136,8 +3136,8 @@ static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
s2+= stride; s2+= stride;
} }
if(c) return score1 + ABS(score2)*c->avctx->nsse_weight; if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
else return score1 + ABS(score2)*8; else return score1 + FFABS(score2)*8;
} }
static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){ static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
@ -3152,9 +3152,9 @@ static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
} }
if(y+1<h){ if(y+1<h){
for(x=0; x<7; x++){ for(x=0; x<7; x++){
score2+= ABS( s1[x ] - s1[x +stride] score2+= FFABS( s1[x ] - s1[x +stride]
- s1[x+1] + s1[x+1+stride]) - s1[x+1] + s1[x+1+stride])
-ABS( s2[x ] - s2[x +stride] -FFABS( s2[x ] - s2[x +stride]
- s2[x+1] + s2[x+1+stride]); - s2[x+1] + s2[x+1+stride]);
} }
} }
@ -3162,8 +3162,8 @@ static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
s2+= stride; s2+= stride;
} }
if(c) return score1 + ABS(score2)*c->avctx->nsse_weight; if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
else return score1 + ABS(score2)*8; else return score1 + FFABS(score2)*8;
} }
static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){ static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){
@ -3353,7 +3353,7 @@ o2= (i1)-(i2);
y= a-b;\ y= a-b;\
} }
#define BUTTERFLYA(x,y) (ABS((x)+(y)) + ABS((x)-(y))) #define BUTTERFLYA(x,y) (FFABS((x)+(y)) + FFABS((x)-(y)))
static int hadamard8_diff8x8_c(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){ static int hadamard8_diff8x8_c(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
int i; int i;
@ -3450,7 +3450,7 @@ static int hadamard8_intra8x8_c(/*MpegEncContext*/ void *s, uint8_t *src, uint8_
+BUTTERFLYA(temp[8*3+i], temp[8*7+i]); +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
} }
sum -= ABS(temp[8*0] + temp[8*4]); // -mean sum -= FFABS(temp[8*0] + temp[8*4]); // -mean
return sum; return sum;
} }
@ -3467,7 +3467,7 @@ static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2
s->dsp.fdct(temp); s->dsp.fdct(temp);
for(i=0; i<64; i++) for(i=0; i<64; i++)
sum+= ABS(temp[i]); sum+= FFABS(temp[i]);
return sum; return sum;
} }
@ -3516,7 +3516,7 @@ static int dct264_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *s
#undef DST #undef DST
#define SRC(x) dct[x][i] #define SRC(x) dct[x][i]
#define DST(x,v) sum += ABS(v) #define DST(x,v) sum += FFABS(v)
for( i = 0; i < 8; i++ ) for( i = 0; i < 8; i++ )
DCT8_1D DCT8_1D
#undef SRC #undef SRC
@ -3537,7 +3537,7 @@ static int dct_max8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2
s->dsp.fdct(temp); s->dsp.fdct(temp);
for(i=0; i<64; i++) for(i=0; i<64; i++)
sum= FFMAX(sum, ABS(temp[i])); sum= FFMAX(sum, FFABS(temp[i]));
return sum; return sum;
} }
@ -3711,8 +3711,8 @@ static int vsad_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy
for(y=1; y<h; y++){ for(y=1; y<h; y++){
for(x=0; x<16; x+=4){ for(x=0; x<16; x+=4){
score+= ABS(s[x ] - s[x +stride]) + ABS(s[x+1] - s[x+1+stride]) score+= FFABS(s[x ] - s[x +stride]) + FFABS(s[x+1] - s[x+1+stride])
+ABS(s[x+2] - s[x+2+stride]) + ABS(s[x+3] - s[x+3+stride]); +FFABS(s[x+2] - s[x+2+stride]) + FFABS(s[x+3] - s[x+3+stride]);
} }
s+= stride; s+= stride;
} }
@ -3726,7 +3726,7 @@ static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int st
for(y=1; y<h; y++){ for(y=1; y<h; y++){
for(x=0; x<16; x++){ for(x=0; x<16; x++){
score+= ABS(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]); score+= FFABS(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]);
} }
s1+= stride; s1+= stride;
s2+= stride; s2+= stride;

@ -705,7 +705,7 @@ static always_inline void dv_set_class_number(DCTELEM* blk, EncBlockInfo* bi,
/* weigh it and and shift down into range, adding for rounding */ /* weigh it and and shift down into range, adding for rounding */
/* the extra division by a factor of 2^4 reverses the 8x expansion of the DCT /* the extra division by a factor of 2^4 reverses the 8x expansion of the DCT
AND the 2x doubling of the weights */ AND the 2x doubling of the weights */
level = (ABS(level) * weight[i] + (1<<(dv_weight_bits+3))) >> (dv_weight_bits+4); level = (FFABS(level) * weight[i] + (1<<(dv_weight_bits+3))) >> (dv_weight_bits+4);
bi->mb[i] = level; bi->mb[i] = level;
if(level>max) max= level; if(level>max) max= level;
bi->bit_size[area] += dv_rl2vlc_size(i - prev - 1, level); bi->bit_size[area] += dv_rl2vlc_size(i - prev - 1, level);

@ -217,7 +217,7 @@ static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int st
if(!(left_damage||right_damage)) continue; // both undamaged if(!(left_damage||right_damage)) continue; // both undamaged
if( (!left_intra) && (!right_intra) if( (!left_intra) && (!right_intra)
&& ABS(left_mv[0]-right_mv[0]) + ABS(left_mv[1]+right_mv[1]) < 2) continue; && FFABS(left_mv[0]-right_mv[0]) + FFABS(left_mv[1]+right_mv[1]) < 2) continue;
for(y=0; y<8; y++){ for(y=0; y<8; y++){
int a,b,c,d; int a,b,c,d;
@ -226,7 +226,7 @@ static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int st
b= dst[offset + 8 + y*stride] - dst[offset + 7 + y*stride]; b= dst[offset + 8 + y*stride] - dst[offset + 7 + y*stride];
c= dst[offset + 9 + y*stride] - dst[offset + 8 + y*stride]; c= dst[offset + 9 + y*stride] - dst[offset + 8 + y*stride];
d= ABS(b) - ((ABS(a) + ABS(c) + 1)>>1); d= FFABS(b) - ((FFABS(a) + FFABS(c) + 1)>>1);
d= FFMAX(d, 0); d= FFMAX(d, 0);
if(b<0) d= -d; if(b<0) d= -d;
@ -277,7 +277,7 @@ static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int st
if(!(top_damage||bottom_damage)) continue; // both undamaged if(!(top_damage||bottom_damage)) continue; // both undamaged
if( (!top_intra) && (!bottom_intra) if( (!top_intra) && (!bottom_intra)
&& ABS(top_mv[0]-bottom_mv[0]) + ABS(top_mv[1]+bottom_mv[1]) < 2) continue; && FFABS(top_mv[0]-bottom_mv[0]) + FFABS(top_mv[1]+bottom_mv[1]) < 2) continue;
for(x=0; x<8; x++){ for(x=0; x<8; x++){
int a,b,c,d; int a,b,c,d;
@ -286,7 +286,7 @@ static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int st
b= dst[offset + x + 8*stride] - dst[offset + x + 7*stride]; b= dst[offset + x + 8*stride] - dst[offset + x + 7*stride];
c= dst[offset + x + 9*stride] - dst[offset + x + 8*stride]; c= dst[offset + x + 9*stride] - dst[offset + x + 8*stride];
d= ABS(b) - ((ABS(a) + ABS(c)+1)>>1); d= FFABS(b) - ((FFABS(a) + FFABS(c)+1)>>1);
d= FFMAX(d, 0); d= FFMAX(d, 0);
if(b<0) d= -d; if(b<0) d= -d;
@ -495,22 +495,22 @@ int score_sum=0;
if(mb_x>0 && fixed[mb_xy-1]){ if(mb_x>0 && fixed[mb_xy-1]){
int k; int k;
for(k=0; k<16; k++) for(k=0; k<16; k++)
score += ABS(src[k*s->linesize-1 ]-src[k*s->linesize ]); score += FFABS(src[k*s->linesize-1 ]-src[k*s->linesize ]);
} }
if(mb_x+1<mb_width && fixed[mb_xy+1]){ if(mb_x+1<mb_width && fixed[mb_xy+1]){
int k; int k;
for(k=0; k<16; k++) for(k=0; k<16; k++)
score += ABS(src[k*s->linesize+15]-src[k*s->linesize+16]); score += FFABS(src[k*s->linesize+15]-src[k*s->linesize+16]);
} }
if(mb_y>0 && fixed[mb_xy-mb_stride]){ if(mb_y>0 && fixed[mb_xy-mb_stride]){
int k; int k;
for(k=0; k<16; k++) for(k=0; k<16; k++)
score += ABS(src[k-s->linesize ]-src[k ]); score += FFABS(src[k-s->linesize ]-src[k ]);
} }
if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){ if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){
int k; int k;
for(k=0; k<16; k++) for(k=0; k<16; k++)
score += ABS(src[k+s->linesize*15]-src[k+s->linesize*16]); score += FFABS(src[k+s->linesize*15]-src[k+s->linesize*16]);
} }
if(score <= best_score){ // <= will favor the last MV if(score <= best_score){ // <= will favor the last MV

@ -225,7 +225,7 @@ static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signe
int i; int i;
if(v){ if(v){
const int a= ABS(v); const int a= FFABS(v);
const int e= av_log2(a); const int e= av_log2(a);
put_rac(c, state+0, 0); put_rac(c, state+0, 0);
@ -273,7 +273,7 @@ static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){
static inline void update_vlc_state(VlcState * const state, const int v){ static inline void update_vlc_state(VlcState * const state, const int v){
int drift= state->drift; int drift= state->drift;
int count= state->count; int count= state->count;
state->error_sum += ABS(v); state->error_sum += FFABS(v);
drift += v; drift += v;
if(count == 128){ //FIXME variable if(count == 128){ //FIXME variable

@ -1032,10 +1032,10 @@ static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n)
for(i=2; i<n; i++) { for(i=2; i<n; i++) {
lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2]; lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2];
rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2]; rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2];
sum[2] += ABS((lt + rt) >> 1); sum[2] += FFABS((lt + rt) >> 1);
sum[3] += ABS(lt - rt); sum[3] += FFABS(lt - rt);
sum[0] += ABS(lt); sum[0] += FFABS(lt);
sum[1] += ABS(rt); sum[1] += FFABS(rt);
} }
/* estimate bit counts */ /* estimate bit counts */
for(i=0; i<4; i++) { for(i=0; i<4; i++) {

@ -212,7 +212,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
int div, error; int div, error;
div= (s->avctx->time_base.num*1800000LL + 500LL*s->avctx->time_base.den) / ((1000LL+i)*s->avctx->time_base.den); div= (s->avctx->time_base.num*1800000LL + 500LL*s->avctx->time_base.den) / ((1000LL+i)*s->avctx->time_base.den);
div= clip(1, div, 127); div= clip(1, div, 127);
error= ABS(s->avctx->time_base.num*1800000LL - (1000LL+i)*s->avctx->time_base.den*div); error= FFABS(s->avctx->time_base.num*1800000LL - (1000LL+i)*s->avctx->time_base.den*div);
if(error < best_error){ if(error < best_error){
best_error= error; best_error= error;
best_divisor= div; best_divisor= div;
@ -4933,7 +4933,7 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
#if 0 #if 0
if(s->error_resilience >= FF_ER_COMPLIANT){ if(s->error_resilience >= FF_ER_COMPLIANT){
const int abs_level= ABS(level); const int abs_level= FFABS(level);
if(abs_level<=MAX_LEVEL && run<=MAX_RUN){ if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
const int run1= run - rl->max_run[last][abs_level] - 1; const int run1= run - rl->max_run[last][abs_level] - 1;
if(abs_level <= rl->max_level[last][run]){ if(abs_level <= rl->max_level[last][run]){

@ -1343,7 +1343,7 @@ static inline void direct_dist_scale_factor(H264Context * const h){
h->dist_scale_factor[i] = 256; h->dist_scale_factor[i] = 256;
}else{ }else{
int tb = clip(poc - poc0, -128, 127); int tb = clip(poc - poc0, -128, 127);
int tx = (16384 + (ABS(td) >> 1)) / td; int tx = (16384 + (FFABS(td) >> 1)) / td;
h->dist_scale_factor[i] = clip((tb*tx + 32) >> 6, -1024, 1023); h->dist_scale_factor[i] = clip((tb*tx + 32) >> 6, -1024, 1023);
} }
} }
@ -1474,8 +1474,8 @@ static inline void pred_direct_motion(H264Context * const h, int *mb_type){
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1); fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
if(!IS_INTRA(mb_type_col) if(!IS_INTRA(mb_type_col)
&& ( (l1ref0[0] == 0 && ABS(l1mv0[0][0]) <= 1 && ABS(l1mv0[0][1]) <= 1) && ( (l1ref0[0] == 0 && FFABS(l1mv0[0][0]) <= 1 && FFABS(l1mv0[0][1]) <= 1)
|| (l1ref0[0] < 0 && l1ref1[0] == 0 && ABS(l1mv1[0][0]) <= 1 && ABS(l1mv1[0][1]) <= 1 || (l1ref0[0] < 0 && l1ref1[0] == 0 && FFABS(l1mv1[0][0]) <= 1 && FFABS(l1mv1[0][1]) <= 1
&& (h->x264_build>33 || !h->x264_build)))){ && (h->x264_build>33 || !h->x264_build)))){
if(ref[0] > 0) if(ref[0] > 0)
fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mv[0][0],mv[0][1]), 4); fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mv[0][0],mv[0][1]), 4);
@ -1510,7 +1510,7 @@ static inline void pred_direct_motion(H264Context * const h, int *mb_type){
const int16_t (*l1mv)[2]= l1ref0[x8 + y8*h->b8_stride] == 0 ? l1mv0 : l1mv1; const int16_t (*l1mv)[2]= l1ref0[x8 + y8*h->b8_stride] == 0 ? l1mv0 : l1mv1;
if(IS_SUB_8X8(sub_mb_type)){ if(IS_SUB_8X8(sub_mb_type)){
const int16_t *mv_col = l1mv[x8*3 + y8*3*h->b_stride]; const int16_t *mv_col = l1mv[x8*3 + y8*3*h->b_stride];
if(ABS(mv_col[0]) <= 1 && ABS(mv_col[1]) <= 1){ if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){
if(ref[0] == 0) if(ref[0] == 0)
fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4); fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
if(ref[1] == 0) if(ref[1] == 0)
@ -1519,7 +1519,7 @@ static inline void pred_direct_motion(H264Context * const h, int *mb_type){
}else }else
for(i4=0; i4<4; i4++){ for(i4=0; i4<4; i4++){
const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*h->b_stride]; const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*h->b_stride];
if(ABS(mv_col[0]) <= 1 && ABS(mv_col[1]) <= 1){ if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){
if(ref[0] == 0) if(ref[0] == 0)
*(uint32_t*)h->mv_cache[0][scan8[i8*4+i4]] = 0; *(uint32_t*)h->mv_cache[0][scan8[i8*4+i4]] = 0;
if(ref[1] == 0) if(ref[1] == 0)
@ -4213,7 +4213,7 @@ static void implicit_weight_table(H264Context *h){
int td = clip(poc1 - poc0, -128, 127); int td = clip(poc1 - poc0, -128, 127);
if(td){ if(td){
int tb = clip(cur_poc - poc0, -128, 127); int tb = clip(cur_poc - poc0, -128, 127);
int tx = (16384 + (ABS(td) >> 1)) / td; int tx = (16384 + (FFABS(td) >> 1)) / td;
int dist_scale_factor = clip((tb*tx + 32) >> 6, -1024, 1023) >> 2; int dist_scale_factor = clip((tb*tx + 32) >> 6, -1024, 1023) >> 2;
if(dist_scale_factor < -64 || dist_scale_factor > 128) if(dist_scale_factor < -64 || dist_scale_factor > 128)
h->implicit_weight[ref0][ref1] = 32; h->implicit_weight[ref0][ref1] = 32;
@ -6733,12 +6733,12 @@ static void filter_mb_edgev( H264Context *h, uint8_t *pix, int stride, int16_t b
const int q1 = pix[1]; const int q1 = pix[1];
const int q2 = pix[2]; const int q2 = pix[2];
if( ABS( p0 - q0 ) < alpha && if( FFABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta && FFABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) { FFABS( q1 - q0 ) < beta ) {
if(ABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){ if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
if( ABS( p2 - p0 ) < beta) if( FFABS( p2 - p0 ) < beta)
{ {
const int p3 = pix[-4]; const int p3 = pix[-4];
/* p0', p1', p2' */ /* p0', p1', p2' */
@ -6749,7 +6749,7 @@ static void filter_mb_edgev( H264Context *h, uint8_t *pix, int stride, int16_t b
/* p0' */ /* p0' */
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
} }
if( ABS( q2 - q0 ) < beta) if( FFABS( q2 - q0 ) < beta)
{ {
const int q3 = pix[3]; const int q3 = pix[3];
/* q0', q1', q2' */ /* q0', q1', q2' */
@ -6819,17 +6819,17 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int
const int q1 = pix[1]; const int q1 = pix[1];
const int q2 = pix[2]; const int q2 = pix[2];
if( ABS( p0 - q0 ) < alpha && if( FFABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta && FFABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) { FFABS( q1 - q0 ) < beta ) {
int tc = tc0; int tc = tc0;
int i_delta; int i_delta;
if( ABS( p2 - p0 ) < beta ) { if( FFABS( p2 - p0 ) < beta ) {
pix[-2] = p1 + clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0, tc0 ); pix[-2] = p1 + clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0, tc0 );
tc++; tc++;
} }
if( ABS( q2 - q0 ) < beta ) { if( FFABS( q2 - q0 ) < beta ) {
pix[1] = q1 + clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0, tc0 ); pix[1] = q1 + clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0, tc0 );
tc++; tc++;
} }
@ -6848,12 +6848,12 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int
const int q1 = pix[1]; const int q1 = pix[1];
const int q2 = pix[2]; const int q2 = pix[2];
if( ABS( p0 - q0 ) < alpha && if( FFABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta && FFABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) { FFABS( q1 - q0 ) < beta ) {
if(ABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){ if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
if( ABS( p2 - p0 ) < beta) if( FFABS( p2 - p0 ) < beta)
{ {
const int p3 = pix[-4]; const int p3 = pix[-4];
/* p0', p1', p2' */ /* p0', p1', p2' */
@ -6864,7 +6864,7 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int
/* p0' */ /* p0' */
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
} }
if( ABS( q2 - q0 ) < beta) if( FFABS( q2 - q0 ) < beta)
{ {
const int q3 = pix[3]; const int q3 = pix[3];
/* q0', q1', q2' */ /* q0', q1', q2' */
@ -6911,9 +6911,9 @@ static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, in
const int q0 = pix[0]; const int q0 = pix[0];
const int q1 = pix[1]; const int q1 = pix[1];
if( ABS( p0 - q0 ) < alpha && if( FFABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta && FFABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) { FFABS( q1 - q0 ) < beta ) {
const int i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); const int i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
pix[-1] = clip_uint8( p0 + i_delta ); /* p0' */ pix[-1] = clip_uint8( p0 + i_delta ); /* p0' */
@ -6926,9 +6926,9 @@ static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, in
const int q0 = pix[0]; const int q0 = pix[0];
const int q1 = pix[1]; const int q1 = pix[1];
if( ABS( p0 - q0 ) < alpha && if( FFABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta && FFABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) { FFABS( q1 - q0 ) < beta ) {
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */ pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */
pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */ pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */
@ -6960,15 +6960,15 @@ static void filter_mb_edgeh( H264Context *h, uint8_t *pix, int stride, int16_t b
const int q1 = pix[1*pix_next]; const int q1 = pix[1*pix_next];
const int q2 = pix[2*pix_next]; const int q2 = pix[2*pix_next];
if( ABS( p0 - q0 ) < alpha && if( FFABS( p0 - q0 ) < alpha &&
ABS( p1 - p0 ) < beta && FFABS( p1 - p0 ) < beta &&
ABS( q1 - q0 ) < beta ) { FFABS( q1 - q0 ) < beta ) {
const int p3 = pix[-4*pix_next]; const int p3 = pix[-4*pix_next];
const int q3 = pix[ 3*pix_next]; const int q3 = pix[ 3*pix_next];
if(ABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){ if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
if( ABS( p2 - p0 ) < beta) { if( FFABS( p2 - p0 ) < beta) {
/* p0', p1', p2' */ /* p0', p1', p2' */
pix[-1*pix_next] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3; pix[-1*pix_next] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3;
pix[-2*pix_next] = ( p2 + p1 + p0 + q0 + 2 ) >> 2; pix[-2*pix_next] = ( p2 + p1 + p0 + q0 + 2 ) >> 2;
@ -6977,7 +6977,7 @@ static void filter_mb_edgeh( H264Context *h, uint8_t *pix, int stride, int16_t b
/* p0' */ /* p0' */
pix[-1*pix_next] = ( 2*p1 + p0 + q1 + 2 ) >> 2; pix[-1*pix_next] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
} }
if( ABS( q2 - q0 ) < beta) { if( FFABS( q2 - q0 ) < beta) {
/* q0', q1', q2' */ /* q0', q1', q2' */
pix[0*pix_next] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3; pix[0*pix_next] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3;
pix[1*pix_next] = ( p0 + q0 + q1 + q2 + 2 ) >> 2; pix[1*pix_next] = ( p0 + q0 + q1 + q2 + 2 ) >> 2;
@ -7313,8 +7313,8 @@ static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8
int v = 0; int v = 0;
for( l = 0; !v && l < 1 + (h->slice_type == B_TYPE); l++ ) { for( l = 0; !v && l < 1 + (h->slice_type == B_TYPE); l++ ) {
v |= ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] || v |= ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] ||
ABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 ||
ABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit; FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit;
} }
bS[0] = bS[1] = bS[2] = bS[3] = v; bS[0] = bS[1] = bS[2] = bS[3] = v;
mv_done = 1; mv_done = 1;
@ -7337,8 +7337,8 @@ static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8
bS[i] = 0; bS[i] = 0;
for( l = 0; l < 1 + (h->slice_type == B_TYPE); l++ ) { for( l = 0; l < 1 + (h->slice_type == B_TYPE); l++ ) {
if( ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] || if( ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] ||
ABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 ||
ABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit ) { FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit ) {
bS[i] = 1; bS[i] = 1;
break; break;
} }
@ -8505,7 +8505,7 @@ int main(){
printf("\n");*/ printf("\n");*/
for(j=0; j<16; j++){ for(j=0; j<16; j++){
int diff= ABS(src[j] - ref[j]); int diff= FFABS(src[j] - ref[j]);
error+= diff*diff; error+= diff*diff;
max_error= FFMAX(max_error, diff); max_error= FFMAX(max_error, diff);

@ -1184,8 +1184,8 @@ static int nsse16_mmx(void *p, uint8_t * pix1, uint8_t * pix2, int line_size, in
else score1 = sse16_mmx(c, pix1, pix2, line_size, h); else score1 = sse16_mmx(c, pix1, pix2, line_size, h);
score2= hf_noise16_mmx(pix1, line_size, h) - hf_noise16_mmx(pix2, line_size, h); score2= hf_noise16_mmx(pix1, line_size, h) - hf_noise16_mmx(pix2, line_size, h);
if(c) return score1 + ABS(score2)*c->avctx->nsse_weight; if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
else return score1 + ABS(score2)*8; else return score1 + FFABS(score2)*8;
} }
static int nsse8_mmx(void *p, uint8_t * pix1, uint8_t * pix2, int line_size, int h) { static int nsse8_mmx(void *p, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
@ -1193,8 +1193,8 @@ static int nsse8_mmx(void *p, uint8_t * pix1, uint8_t * pix2, int line_size, int
int score1= sse8_mmx(c, pix1, pix2, line_size, h); int score1= sse8_mmx(c, pix1, pix2, line_size, h);
int score2= hf_noise8_mmx(pix1, line_size, h) - hf_noise8_mmx(pix2, line_size, h); int score2= hf_noise8_mmx(pix1, line_size, h) - hf_noise8_mmx(pix2, line_size, h);
if(c) return score1 + ABS(score2)*c->avctx->nsse_weight; if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
else return score1 + ABS(score2)*8; else return score1 + FFABS(score2)*8;
} }
static int vsad_intra16_mmx(void *v, uint8_t * pix, uint8_t * dummy, int line_size, int h) { static int vsad_intra16_mmx(void *v, uint8_t * pix, uint8_t * dummy, int line_size, int h) {
@ -2580,7 +2580,7 @@ static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int o
static int try_8x8basis_mmx(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){ static int try_8x8basis_mmx(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){
long i=0; long i=0;
assert(ABS(scale) < 256); assert(FFABS(scale) < 256);
scale<<= 16 + 1 - BASIS_SHIFT + RECON_SHIFT; scale<<= 16 + 1 - BASIS_SHIFT + RECON_SHIFT;
asm volatile( asm volatile(
@ -2628,7 +2628,7 @@ static int try_8x8basis_mmx(int16_t rem[64], int16_t weight[64], int16_t basis[6
static void add_8x8basis_mmx(int16_t rem[64], int16_t basis[64], int scale){ static void add_8x8basis_mmx(int16_t rem[64], int16_t basis[64], int scale){
long i=0; long i=0;
if(ABS(scale) < 256){ if(FFABS(scale) < 256){
scale<<= 16 + 1 - BASIS_SHIFT + RECON_SHIFT; scale<<= 16 + 1 - BASIS_SHIFT + RECON_SHIFT;
asm volatile( asm volatile(
"pcmpeqw %%mm6, %%mm6 \n\t" // -1w "pcmpeqw %%mm6, %%mm6 \n\t" // -1w

@ -213,7 +213,7 @@ static inline int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q)
if(!state->near && !k && (2 * state->B[Q] <= -state->N[Q])) if(!state->near && !k && (2 * state->B[Q] <= -state->N[Q]))
ret = -(ret + 1); ret = -(ret + 1);
state->A[Q] += ABS(ret); state->A[Q] += FFABS(ret);
ret *= state->twonear; ret *= state->twonear;
state->B[Q] += ret; state->B[Q] += ret;
@ -274,7 +274,7 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RI
} }
/* update state */ /* update state */
state->A[Q] += ABS(ret) - RItype; state->A[Q] += FFABS(ret) - RItype;
ret *= state->twonear; ret *= state->twonear;
if(state->N[Q] == state->reset){ if(state->N[Q] == state->reset){
state->A[Q] >>=1; state->A[Q] >>=1;
@ -306,7 +306,7 @@ static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s, uint8_
D1 = Rb - Rc; D1 = Rb - Rc;
D2 = Rc - Ra; D2 = Rc - Ra;
/* run mode */ /* run mode */
if((ABS(D0) <= state->near) && (ABS(D1) <= state->near) && (ABS(D2) <= state->near)) { if((FFABS(D0) <= state->near) && (FFABS(D1) <= state->near) && (FFABS(D2) <= state->near)) {
int r; int r;
int RItype; int RItype;
@ -340,7 +340,7 @@ static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s, uint8_
/* decode run termination value */ /* decode run termination value */
Rb = last[x]; Rb = last[x];
RItype = (ABS(Ra - Rb) <= state->near) ? 1 : 0; RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
err = ls_get_code_runterm(&s->gb, state, RItype, log2_run[state->run_index[comp]]); err = ls_get_code_runterm(&s->gb, state, RItype, log2_run[state->run_index[comp]]);
if(state->run_index[comp]) if(state->run_index[comp])
state->run_index[comp]--; state->run_index[comp]--;
@ -491,13 +491,13 @@ static inline void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q,
err += state->range; err += state->range;
if(err >= ((state->range + 1) >> 1)) { if(err >= ((state->range + 1) >> 1)) {
err -= state->range; err -= state->range;
val = 2 * ABS(err) - 1 - map; val = 2 * FFABS(err) - 1 - map;
} else } else
val = 2 * err + map; val = 2 * err + map;
set_ur_golomb_jpegls(pb, val, k, state->limit, state->qbpp); set_ur_golomb_jpegls(pb, val, k, state->limit, state->qbpp);
state->A[Q] += ABS(err); state->A[Q] += FFABS(err);
state->B[Q] += err * state->twonear; state->B[Q] += err * state->twonear;
if(state->N[Q] == state->reset) { if(state->N[Q] == state->reset) {
@ -598,12 +598,12 @@ static inline void ls_encode_line(JLSState *state, PutBitContext *pb, uint8_t *l
D2 = Rc - Ra; D2 = Rc - Ra;
/* run mode */ /* run mode */
if((ABS(D0) <= state->near) && (ABS(D1) <= state->near) && (ABS(D2) <= state->near)) { if((FFABS(D0) <= state->near) && (FFABS(D1) <= state->near) && (FFABS(D2) <= state->near)) {
int RUNval, RItype, run; int RUNval, RItype, run;
run = 0; run = 0;
RUNval = Ra; RUNval = Ra;
while(x < w && (ABS(cur[x] - RUNval) <= state->near)){ while(x < w && (FFABS(cur[x] - RUNval) <= state->near)){
run++; run++;
cur[x] = Ra; cur[x] = Ra;
x += stride; x += stride;
@ -612,7 +612,7 @@ static inline void ls_encode_line(JLSState *state, PutBitContext *pb, uint8_t *l
if(x >= w) if(x >= w)
return; return;
Rb = last[x]; Rb = last[x];
RItype = (ABS(Ra - Rb) <= state->near); RItype = (FFABS(Ra - Rb) <= state->near);
pred = RItype ? Ra : Rb; pred = RItype ? Ra : Rb;
err = cur[x] - pred; err = cur[x] - pred;

@ -296,14 +296,14 @@ static int pix_dev(uint8_t * pix, int line_size, int mean)
s = 0; s = 0;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j += 8) { for (j = 0; j < 16; j += 8) {
s += ABS(pix[0]-mean); s += FFABS(pix[0]-mean);
s += ABS(pix[1]-mean); s += FFABS(pix[1]-mean);
s += ABS(pix[2]-mean); s += FFABS(pix[2]-mean);
s += ABS(pix[3]-mean); s += FFABS(pix[3]-mean);
s += ABS(pix[4]-mean); s += FFABS(pix[4]-mean);
s += ABS(pix[5]-mean); s += FFABS(pix[5]-mean);
s += ABS(pix[6]-mean); s += FFABS(pix[6]-mean);
s += ABS(pix[7]-mean); s += FFABS(pix[7]-mean);
pix += 8; pix += 8;
} }
pix += line_size - 16; pix += line_size - 16;

@ -639,8 +639,8 @@ static int funny_diamond_search(MpegEncContext * s, int *best, int dmin,
{ {
int dx, dy, i; int dx, dy, i;
static int stats[8*8]; static int stats[8*8];
dx= ABS(x-best[0]); dx= FFABS(x-best[0]);
dy= ABS(y-best[1]); dy= FFABS(y-best[1]);
if(dy>dx){ if(dy>dx){
dx^=dy; dy^=dx; dx^=dy; dx^=dy; dy^=dx; dx^=dy;
} }
@ -695,7 +695,7 @@ static int sab_diamond_search(MpegEncContext * s, int *best, int dmin,
MotionEstContext * const c= &s->me; MotionEstContext * const c= &s->me;
me_cmp_func cmpf, chroma_cmpf; me_cmp_func cmpf, chroma_cmpf;
Minima minima[MAX_SAB_SIZE]; Minima minima[MAX_SAB_SIZE];
const int minima_count= ABS(c->dia_size); const int minima_count= FFABS(c->dia_size);
int i, j; int i, j;
LOAD_COMMON LOAD_COMMON
LOAD_COMMON2 LOAD_COMMON2
@ -829,8 +829,8 @@ static int var_diamond_search(MpegEncContext * s, int *best, int dmin,
{ {
int dx, dy, i; int dx, dy, i;
static int stats[8*8]; static int stats[8*8];
dx= ABS(x-best[0]); dx= FFABS(x-best[0]);
dy= ABS(y-best[1]); dy= FFABS(y-best[1]);
stats[dy*8 + dx] ++; stats[dy*8 + dx] ++;
if(256*256*256*64 % (stats[0]+1)==0){ if(256*256*256*64 % (stats[0]+1)==0){
for(i=0; i<64; i++){ for(i=0; i<64; i++){

@ -159,7 +159,7 @@ static void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len){
for(run=0; run<64; run++){ for(run=0; run<64; run++){
int len, bits, code; int len, bits, code;
int alevel= ABS(level); int alevel= FFABS(level);
int sign= (level>>31)&1; int sign= (level>>31)&1;
if (alevel > rl->max_level[0][run]) if (alevel > rl->max_level[0][run])
@ -206,7 +206,7 @@ static int find_frame_rate_index(MpegEncContext *s){
int64_t n1= 1001LL*s->avctx->time_base.den; int64_t n1= 1001LL*s->avctx->time_base.den;
if(s->avctx->strict_std_compliance > FF_COMPLIANCE_INOFFICIAL && i>=9) break; if(s->avctx->strict_std_compliance > FF_COMPLIANCE_INOFFICIAL && i>=9) break;
d = ABS(n0 - n1); d = FFABS(n0 - n1);
if(d < dmin){ if(d < dmin){
dmin=d; dmin=d;
s->frame_rate_index= i; s->frame_rate_index= i;
@ -279,7 +279,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
else else
error-= av_q2d(mpeg2_aspect[i])*s->height/s->width; error-= av_q2d(mpeg2_aspect[i])*s->height/s->width;
error= ABS(error); error= FFABS(error);
if(error < best_aspect_error){ if(error < best_aspect_error){
best_aspect_error= error; best_aspect_error= error;
@ -806,7 +806,7 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
int bits, code; int bits, code;
int diff=i; int diff=i;
adiff = ABS(diff); adiff = FFABS(diff);
if(diff<0) diff--; if(diff<0) diff--;
index = av_log2(2*adiff); index = av_log2(2*adiff);

@ -1703,7 +1703,7 @@ static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h
buf[sy*stride + sx]+= color; buf[sy*stride + sx]+= color;
if(ABS(ex - sx) > ABS(ey - sy)){ if(FFABS(ex - sx) > FFABS(ey - sy)){
if(sx > ex){ if(sx > ex){
SWAP(int, sx, ex); SWAP(int, sx, ex);
SWAP(int, sy, ey); SWAP(int, sy, ey);
@ -2037,7 +2037,7 @@ static int get_sae(uint8_t *src, int ref, int stride){
for(y=0; y<16; y++){ for(y=0; y<16; y++){
for(x=0; x<16; x++){ for(x=0; x<16; x++){
acc+= ABS(src[x+y*stride] - ref); acc+= FFABS(src[x+y*stride] - ref);
} }
} }
@ -2186,9 +2186,9 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref){
switch(s->avctx->frame_skip_exp){ switch(s->avctx->frame_skip_exp){
case 0: score= FFMAX(score, v); break; case 0: score= FFMAX(score, v); break;
case 1: score+= ABS(v);break; case 1: score+= FFABS(v);break;
case 2: score+= v*v;break; case 2: score+= v*v;break;
case 3: score64+= ABS(v*v*(int64_t)v);break; case 3: score64+= FFABS(v*v*(int64_t)v);break;
case 4: score64+= v*v*(int64_t)(v*v);break; case 4: score64+= v*v*(int64_t)(v*v);break;
} }
} }
@ -2219,7 +2219,7 @@ static int estimate_best_b_count(MpegEncContext *s){
// emms_c(); // emms_c();
p_lambda= s->last_lambda_for[P_TYPE]; //s->next_picture_ptr->quality; p_lambda= s->last_lambda_for[P_TYPE]; //s->next_picture_ptr->quality;
b_lambda= s->last_lambda_for[B_TYPE]; //p_lambda *ABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset; b_lambda= s->last_lambda_for[B_TYPE]; //p_lambda *FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
if(!b_lambda) b_lambda= p_lambda; //FIXME we should do this somewhere else if(!b_lambda) b_lambda= p_lambda; //FIXME we should do this somewhere else
lambda2= (b_lambda*b_lambda + (1<<FF_LAMBDA_SHIFT)/2 ) >> FF_LAMBDA_SHIFT; lambda2= (b_lambda*b_lambda + (1<<FF_LAMBDA_SHIFT)/2 ) >> FF_LAMBDA_SHIFT;
@ -4146,7 +4146,7 @@ static inline void dct_single_coeff_elimination(MpegEncContext *s, int n, int th
for(i=0; i<=last_index; i++){ for(i=0; i<=last_index; i++){
const int j = s->intra_scantable.permutated[i]; const int j = s->intra_scantable.permutated[i];
const int level = ABS(block[j]); const int level = FFABS(block[j]);
if(level==1){ if(level==1){
if(skip_dc && i==0) continue; if(skip_dc && i==0) continue;
score+= tab[run]; score+= tab[run];
@ -5887,13 +5887,13 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
for(i=start_i; i<=last_non_zero; i++){ for(i=start_i; i<=last_non_zero; i++){
int level_index, j; int level_index, j;
const int dct_coeff= ABS(block[ scantable[i] ]); const int dct_coeff= FFABS(block[ scantable[i] ]);
const int zero_distoration= dct_coeff*dct_coeff; const int zero_distoration= dct_coeff*dct_coeff;
int best_score=256*256*256*120; int best_score=256*256*256*120;
for(level_index=0; level_index < coeff_count[i]; level_index++){ for(level_index=0; level_index < coeff_count[i]; level_index++){
int distoration; int distoration;
int level= coeff[level_index][i]; int level= coeff[level_index][i];
const int alevel= ABS(level); const int alevel= FFABS(level);
int unquant_coeff; int unquant_coeff;
assert(level); assert(level);
@ -6003,7 +6003,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
s->coded_score[n] = last_score; s->coded_score[n] = last_score;
dc= ABS(block[0]); dc= FFABS(block[0]);
last_non_zero= last_i - 1; last_non_zero= last_i - 1;
memset(block + start_i, 0, (64-start_i)*sizeof(DCTELEM)); memset(block + start_i, 0, (64-start_i)*sizeof(DCTELEM));
@ -6016,7 +6016,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
for(i=0; i<coeff_count[0]; i++){ for(i=0; i<coeff_count[0]; i++){
int level= coeff[i][0]; int level= coeff[i][0];
int alevel= ABS(level); int alevel= FFABS(level);
int unquant_coeff, score, distortion; int unquant_coeff, score, distortion;
if(s->out_format == FMT_H263){ if(s->out_format == FMT_H263){
@ -6158,7 +6158,7 @@ STOP_TIMER("memset rem[]")}
int qns=4; int qns=4;
int w; int w;
w= ABS(weight[i]) + qns*one; w= FFABS(weight[i]) + qns*one;
w= 15 + (48*qns*one + w/2)/w; // 16 .. 63 w= 15 + (48*qns*one + w/2)/w; // 16 .. 63
weight[i] = w; weight[i] = w;
@ -6282,7 +6282,7 @@ STOP_TIMER("dct")}
int score, new_coeff, unquant_change; int score, new_coeff, unquant_change;
score=0; score=0;
if(s->avctx->quantizer_noise_shaping < 2 && ABS(new_level) > ABS(level)) if(s->avctx->quantizer_noise_shaping < 2 && FFABS(new_level) > FFABS(level))
continue; continue;
if(new_level){ if(new_level){
@ -6302,7 +6302,7 @@ STOP_TIMER("dct")}
- last_length[UNI_AC_ENC_INDEX(run, level+64)]; - last_length[UNI_AC_ENC_INDEX(run, level+64)];
} }
}else{ }else{
assert(ABS(new_level)==1); assert(FFABS(new_level)==1);
if(analyze_gradient){ if(analyze_gradient){
int g= d1[ scantable[i] ]; int g= d1[ scantable[i] ];
@ -6335,7 +6335,7 @@ STOP_TIMER("dct")}
} }
}else{ }else{
new_coeff=0; new_coeff=0;
assert(ABS(level)==1); assert(FFABS(level)==1);
if(i < last_non_zero){ if(i < last_non_zero){
int next_i= i + run2 + 1; int next_i= i + run2 + 1;
@ -6403,7 +6403,7 @@ after_last++;
#ifdef REFINE_STATS #ifdef REFINE_STATS
if(block[j]){ if(block[j]){
if(block[j] - best_change){ if(block[j] - best_change){
if(ABS(block[j]) > ABS(block[j] - best_change)){ if(FFABS(block[j]) > FFABS(block[j] - best_change)){
raise++; raise++;
}else{ }else{
lower++; lower++;

@ -1716,7 +1716,7 @@ static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
//printf("level: %d, run: %d at %d %d\n", level, run, s->mb_x, s->mb_y); //printf("level: %d, run: %d at %d %d\n", level, run, s->mb_x, s->mb_y);
#if 0 // waste of time / this will detect very few errors #if 0 // waste of time / this will detect very few errors
{ {
const int abs_level= ABS(level); const int abs_level= FFABS(level);
const int run1= run - rl->max_run[last][abs_level] - run_diff; const int run1= run - rl->max_run[last][abs_level] - run_diff;
if(abs_level<=MAX_LEVEL && run<=MAX_RUN){ if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
if(abs_level <= rl->max_level[last][run]){ if(abs_level <= rl->max_level[last][run]){

@ -372,7 +372,7 @@ static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, doubl
const double last_non_b_q= rcc->last_qscale_for[rcc->last_non_b_pict_type]; const double last_non_b_q= rcc->last_qscale_for[rcc->last_non_b_pict_type];
if (pict_type==I_TYPE && (a->i_quant_factor>0.0 || rcc->last_non_b_pict_type==P_TYPE)) if (pict_type==I_TYPE && (a->i_quant_factor>0.0 || rcc->last_non_b_pict_type==P_TYPE))
q= last_p_q *ABS(a->i_quant_factor) + a->i_quant_offset; q= last_p_q *FFABS(a->i_quant_factor) + a->i_quant_offset;
else if(pict_type==B_TYPE && a->b_quant_factor>0.0) else if(pict_type==B_TYPE && a->b_quant_factor>0.0)
q= last_non_b_q* a->b_quant_factor + a->b_quant_offset; q= last_non_b_q* a->b_quant_factor + a->b_quant_offset;
@ -403,11 +403,11 @@ static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pic
assert(qmin <= qmax); assert(qmin <= qmax);
if(pict_type==B_TYPE){ if(pict_type==B_TYPE){
qmin= (int)(qmin*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5); qmin= (int)(qmin*FFABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5);
qmax= (int)(qmax*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5); qmax= (int)(qmax*FFABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5);
}else if(pict_type==I_TYPE){ }else if(pict_type==I_TYPE){
qmin= (int)(qmin*ABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5); qmin= (int)(qmin*FFABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5);
qmax= (int)(qmax*ABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5); qmax= (int)(qmax*FFABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5);
} }
qmin= clip(qmin, 1, FF_LAMBDA_MAX); qmin= clip(qmin, 1, FF_LAMBDA_MAX);

@ -215,7 +215,7 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
if(sample_index < 0){ if(sample_index < 0){
for(i=0; i<c->filter_length; i++) for(i=0; i<c->filter_length; i++)
val += src[ABS(sample_index + i) % src_size] * filter[i]; val += src[FFABS(sample_index + i) % src_size] * filter[i];
}else if(sample_index + c->filter_length > src_size){ }else if(sample_index + c->filter_length > src_size){
break; break;
}else if(c->linear){ }else if(c->linear){

@ -590,7 +590,7 @@ static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signe
int i; int i;
if(v){ if(v){
const int a= ABS(v); const int a= FFABS(v);
const int e= av_log2(a); const int e= av_log2(a);
#if 1 #if 1
const int el= FFMIN(e, 10); const int el= FFMIN(e, 10);
@ -1666,7 +1666,7 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELE
p= parent[px + py*2*stride]; p= parent[px + py*2*stride];
} }
if(/*ll|*/l|lt|t|rt|p){ if(/*ll|*/l|lt|t|rt|p){
int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); int context= av_log2(/*FFABS(ll) + */3*FFABS(l) + FFABS(lt) + 2*FFABS(t) + FFABS(rt) + FFABS(p));
put_rac(&s->c, &b->state[0][context], !!v); put_rac(&s->c, &b->state[0][context], !!v);
}else{ }else{
@ -1682,11 +1682,11 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELE
} }
} }
if(v){ if(v){
int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); int context= av_log2(/*FFABS(ll) + */3*FFABS(l) + FFABS(lt) + 2*FFABS(t) + FFABS(rt) + FFABS(p));
int l2= 2*ABS(l) + (l<0); int l2= 2*FFABS(l) + (l<0);
int t2= 2*ABS(t) + (t<0); int t2= 2*FFABS(t) + (t<0);
put_symbol2(&s->c, b->state[context + 2], ABS(v)-1, context-4); put_symbol2(&s->c, b->state[context + 2], FFABS(v)-1, context-4);
put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l2&0xFF] + 3*quant3bA[t2&0xFF]], v<0); put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l2&0xFF] + 3*quant3bA[t2&0xFF]], v<0);
} }
} }
@ -1749,7 +1749,7 @@ static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, i
} }
} }
if(/*ll|*/l|lt|t|rt|p){ if(/*ll|*/l|lt|t|rt|p){
int context= av_log2(/*ABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1)); int context= av_log2(/*FFABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1));
v=get_rac(&s->c, &b->state[0][context]); v=get_rac(&s->c, &b->state[0][context]);
if(v){ if(v){
@ -2016,8 +2016,8 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
const int shift= 1+qpel; const int shift= 1+qpel;
MotionEstContext *c= &s->m.me; MotionEstContext *c= &s->m.me;
int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref); int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref);
int mx_context= av_log2(2*ABS(left->mx - top->mx)); int mx_context= av_log2(2*FFABS(left->mx - top->mx));
int my_context= av_log2(2*ABS(left->my - top->my)); int my_context= av_log2(2*FFABS(left->my - top->my));
int s_context= 2*left->level + 2*top->level + tl->level + tr->level; int s_context= 2*left->level + 2*top->level + tl->level + tr->level;
int ref, best_ref, ref_score, ref_mx, ref_my; int ref, best_ref, ref_score, ref_mx, ref_my;
@ -2229,8 +2229,8 @@ static void encode_q_branch2(SnowContext *s, int level, int x, int y){
int pcr= left->color[2]; int pcr= left->color[2];
int pmx, pmy; int pmx, pmy;
int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref); int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref);
int mx_context= av_log2(2*ABS(left->mx - top->mx)) + 16*!!b->ref; int mx_context= av_log2(2*FFABS(left->mx - top->mx)) + 16*!!b->ref;
int my_context= av_log2(2*ABS(left->my - top->my)) + 16*!!b->ref; int my_context= av_log2(2*FFABS(left->my - top->my)) + 16*!!b->ref;
int s_context= 2*left->level + 2*top->level + tl->level + tr->level; int s_context= 2*left->level + 2*top->level + tl->level + tr->level;
if(s->keyframe){ if(s->keyframe){
@ -2293,8 +2293,8 @@ static void decode_q_branch(SnowContext *s, int level, int x, int y){
int my= mid_pred(left->my, top->my, tr->my); int my= mid_pred(left->my, top->my, tr->my);
int ref = 0; int ref = 0;
int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref); int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref);
int mx_context= av_log2(2*ABS(left->mx - top->mx)) + 0*av_log2(2*ABS(tr->mx - top->mx)); int mx_context= av_log2(2*FFABS(left->mx - top->mx)) + 0*av_log2(2*FFABS(tr->mx - top->mx));
int my_context= av_log2(2*ABS(left->my - top->my)) + 0*av_log2(2*ABS(tr->my - top->my)); int my_context= av_log2(2*FFABS(left->my - top->my)) + 0*av_log2(2*FFABS(tr->my - top->my));
type= get_rac(&s->c, &s->block_state[1 + left->type + top->type]) ? BLOCK_INTRA : 0; type= get_rac(&s->c, &s->block_state[1 + left->type + top->type]) ? BLOCK_INTRA : 0;
@ -2908,8 +2908,8 @@ static inline int get_block_bits(SnowContext *s, int x, int y, int w){
BlockNode *tl = y && x ? &s->block[index-b_stride-1] : left; BlockNode *tl = y && x ? &s->block[index-b_stride-1] : left;
BlockNode *tr = y && x+w<b_stride ? &s->block[index-b_stride+w] : tl; BlockNode *tr = y && x+w<b_stride ? &s->block[index-b_stride+w] : tl;
int dmx, dmy; int dmx, dmy;
// int mx_context= av_log2(2*ABS(left->mx - top->mx)); // int mx_context= av_log2(2*FFABS(left->mx - top->mx));
// int my_context= av_log2(2*ABS(left->my - top->my)); // int my_context= av_log2(2*FFABS(left->my - top->my));
if(x<0 || x>=b_stride || y>=b_height) if(x<0 || x>=b_stride || y>=b_height)
return 0; return 0;
@ -2923,15 +2923,15 @@ static inline int get_block_bits(SnowContext *s, int x, int y, int w){
//FIXME try accurate rate //FIXME try accurate rate
//FIXME intra and inter predictors if surrounding blocks arent the same type //FIXME intra and inter predictors if surrounding blocks arent the same type
if(b->type & BLOCK_INTRA){ if(b->type & BLOCK_INTRA){
return 3+2*( av_log2(2*ABS(left->color[0] - b->color[0])) return 3+2*( av_log2(2*FFABS(left->color[0] - b->color[0]))
+ av_log2(2*ABS(left->color[1] - b->color[1])) + av_log2(2*FFABS(left->color[1] - b->color[1]))
+ av_log2(2*ABS(left->color[2] - b->color[2]))); + av_log2(2*FFABS(left->color[2] - b->color[2])));
}else{ }else{
pred_mv(s, &dmx, &dmy, b->ref, left, top, tr); pred_mv(s, &dmx, &dmy, b->ref, left, top, tr);
dmx-= b->mx; dmx-= b->mx;
dmy-= b->my; dmy-= b->my;
return 2*(1 + av_log2(2*ABS(dmx)) //FIXME kill the 2* can be merged in lambda return 2*(1 + av_log2(2*FFABS(dmx)) //FIXME kill the 2* can be merged in lambda
+ av_log2(2*ABS(dmy)) + av_log2(2*FFABS(dmy))
+ av_log2(2*b->ref)); + av_log2(2*b->ref));
} }
} }
@ -4563,7 +4563,7 @@ int main(){
ff_spatial_idwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count); ff_spatial_idwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
for(i=0; i<width*height; i++) for(i=0; i<width*height; i++)
if(ABS(buffer[0][i] - buffer[1][i])>20) printf("fsck: %d %d %d\n",i, buffer[0][i], buffer[1][i]); if(FFABS(buffer[0][i] - buffer[1][i])>20) printf("fsck: %d %d %d\n",i, buffer[0][i], buffer[1][i]);
#if 0 #if 0
printf("testing AC coder\n"); printf("testing AC coder\n");
@ -4573,7 +4573,7 @@ int main(){
for(i=-256; i<256; i++){ for(i=-256; i<256; i++){
START_TIMER START_TIMER
put_symbol(&s.c, s.header_state, i*i*i/3*ABS(i), 1); put_symbol(&s.c, s.header_state, i*i*i/3*FFABS(i), 1);
STOP_TIMER("put_symbol") STOP_TIMER("put_symbol")
} }
ff_rac_terminate(&s.c); ff_rac_terminate(&s.c);
@ -4587,7 +4587,7 @@ STOP_TIMER("put_symbol")
START_TIMER START_TIMER
j= get_symbol(&s.c, s.header_state, 1); j= get_symbol(&s.c, s.header_state, 1);
STOP_TIMER("get_symbol") STOP_TIMER("get_symbol")
if(j!=i*i*i/3*ABS(i)) printf("fsck: %d != %d\n", i, j); if(j!=i*i*i/3*FFABS(i)) printf("fsck: %d != %d\n", i, j);
} }
#endif #endif
{ {
@ -4616,9 +4616,9 @@ int64_t g=0;
for(x=0; x<width; x++){ for(x=0; x<width; x++){
int64_t d= buffer[0][x + y*width]; int64_t d= buffer[0][x + y*width];
error += d*d; error += d*d;
if(ABS(width/2-x)<9 && ABS(height/2-y)<9 && level==2) printf("%8lld ", d); if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9 && level==2) printf("%8lld ", d);
} }
if(ABS(height/2-y)<9 && level==2) printf("\n"); if(FFABS(height/2-y)<9 && level==2) printf("\n");
} }
error= (int)(sqrt(error)+0.5); error= (int)(sqrt(error)+0.5);
errors[level][orientation]= error; errors[level][orientation]= error;
@ -4669,9 +4669,9 @@ int64_t g=0;
for(x=0; x<width; x++){ for(x=0; x<width; x++){
int64_t d= buffer[0][x + y*width]; int64_t d= buffer[0][x + y*width];
error += d*d; error += d*d;
if(ABS(width/2-x)<9 && ABS(height/2-y)<9) printf("%8lld ", d); if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9) printf("%8lld ", d);
} }
if(ABS(height/2-y)<9) printf("\n"); if(FFABS(height/2-y)<9) printf("\n");
} }
} }

@ -1950,9 +1950,9 @@ static inline void vc1_pred_mv(MpegEncContext *s, int n, int dmv_x, int dmv_y, i
/* Calculate hybrid prediction as specified in 8.3.5.3.5 */ /* Calculate hybrid prediction as specified in 8.3.5.3.5 */
if((!s->first_slice_line || (n==2 || n==3)) && (s->mb_x || (n==1 || n==3))) { if((!s->first_slice_line || (n==2 || n==3)) && (s->mb_x || (n==1 || n==3))) {
if(is_intra[xy - wrap]) if(is_intra[xy - wrap])
sum = ABS(px) + ABS(py); sum = FFABS(px) + FFABS(py);
else else
sum = ABS(px - A[0]) + ABS(py - A[1]); sum = FFABS(px - A[0]) + FFABS(py - A[1]);
if(sum > 32) { if(sum > 32) {
if(get_bits1(&s->gb)) { if(get_bits1(&s->gb)) {
px = A[0]; px = A[0];
@ -1963,9 +1963,9 @@ static inline void vc1_pred_mv(MpegEncContext *s, int n, int dmv_x, int dmv_y, i
} }
} else { } else {
if(is_intra[xy - 1]) if(is_intra[xy - 1])
sum = ABS(px) + ABS(py); sum = FFABS(px) + FFABS(py);
else else
sum = ABS(px - C[0]) + ABS(py - C[1]); sum = FFABS(px - C[0]) + FFABS(py - C[1]);
if(sum > 32) { if(sum > 32) {
if(get_bits1(&s->gb)) { if(get_bits1(&s->gb)) {
px = A[0]; px = A[0];
@ -2218,9 +2218,9 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int
/* Calculate hybrid prediction as specified in 8.3.5.3.5 */ /* Calculate hybrid prediction as specified in 8.3.5.3.5 */
if(0 && !s->first_slice_line && s->mb_x) { if(0 && !s->first_slice_line && s->mb_x) {
if(is_intra[xy - wrap]) if(is_intra[xy - wrap])
sum = ABS(px) + ABS(py); sum = FFABS(px) + FFABS(py);
else else
sum = ABS(px - A[0]) + ABS(py - A[1]); sum = FFABS(px - A[0]) + FFABS(py - A[1]);
if(sum > 32) { if(sum > 32) {
if(get_bits1(&s->gb)) { if(get_bits1(&s->gb)) {
px = A[0]; px = A[0];
@ -2231,9 +2231,9 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int
} }
} else { } else {
if(is_intra[xy - 2]) if(is_intra[xy - 2])
sum = ABS(px) + ABS(py); sum = FFABS(px) + FFABS(py);
else else
sum = ABS(px - C[0]) + ABS(py - C[1]); sum = FFABS(px - C[0]) + FFABS(py - C[1]);
if(sum > 32) { if(sum > 32) {
if(get_bits1(&s->gb)) { if(get_bits1(&s->gb)) {
px = A[0]; px = A[0];
@ -2295,9 +2295,9 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int
/* Calculate hybrid prediction as specified in 8.3.5.3.5 */ /* Calculate hybrid prediction as specified in 8.3.5.3.5 */
if(0 && !s->first_slice_line && s->mb_x) { if(0 && !s->first_slice_line && s->mb_x) {
if(is_intra[xy - wrap]) if(is_intra[xy - wrap])
sum = ABS(px) + ABS(py); sum = FFABS(px) + FFABS(py);
else else
sum = ABS(px - A[0]) + ABS(py - A[1]); sum = FFABS(px - A[0]) + FFABS(py - A[1]);
if(sum > 32) { if(sum > 32) {
if(get_bits1(&s->gb)) { if(get_bits1(&s->gb)) {
px = A[0]; px = A[0];
@ -2308,9 +2308,9 @@ static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int
} }
} else { } else {
if(is_intra[xy - 2]) if(is_intra[xy - 2])
sum = ABS(px) + ABS(py); sum = FFABS(px) + FFABS(py);
else else
sum = ABS(px - C[0]) + ABS(py - C[1]); sum = FFABS(px - C[0]) + FFABS(py - C[1]);
if(sum > 32) { if(sum > 32) {
if(get_bits1(&s->gb)) { if(get_bits1(&s->gb)) {
px = A[0]; px = A[0];

@ -1236,7 +1236,7 @@ static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
static void render_line(int x0, int y0, int x1, int y1, float * buf, int n) { static void render_line(int x0, int y0, int x1, int y1, float * buf, int n) {
int dy = y1 - y0; int dy = y1 - y0;
int adx = x1 - x0; int adx = x1 - x0;
int ady = ABS(dy); int ady = FFABS(dy);
int base = dy / adx; int base = dy / adx;
int x = x0; int x = x0;
int y = y0; int y = y0;
@ -1244,7 +1244,7 @@ static void render_line(int x0, int y0, int x1, int y1, float * buf, int n) {
int sy; int sy;
if (dy < 0) sy = base - 1; if (dy < 0) sy = base - 1;
else sy = base + 1; else sy = base + 1;
ady = ady - ABS(base) * adx; ady = ady - FFABS(base) * adx;
if (x >= n) return; if (x >= n) return;
buf[x] = ff_vorbis_floor1_inverse_db_table[y]; buf[x] = ff_vorbis_floor1_inverse_db_table[y];
for (x = x0 + 1; x < x1; x++) { for (x = x0 + 1; x < x1; x++) {
@ -1354,7 +1354,7 @@ static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *
high_neigh_offs=vf->list[i].high; high_neigh_offs=vf->list[i].high;
dy=floor1_Y_final[high_neigh_offs]-floor1_Y_final[low_neigh_offs]; // render_point begin dy=floor1_Y_final[high_neigh_offs]-floor1_Y_final[low_neigh_offs]; // render_point begin
adx=vf->list[high_neigh_offs].x-vf->list[low_neigh_offs].x; adx=vf->list[high_neigh_offs].x-vf->list[low_neigh_offs].x;
ady= ABS(dy); ady= FFABS(dy);
err=ady*(vf->list[i].x-vf->list[low_neigh_offs].x); err=ady*(vf->list[i].x-vf->list[low_neigh_offs].x);
off=(int16_t)err/(int16_t)adx; off=(int16_t)err/(int16_t)adx;
if (dy<0) { if (dy<0) {

@ -1455,11 +1455,11 @@ static void reverse_dc_prediction(Vp3DecodeContext *s,
/* check for outranging on the [ul u l] and /* check for outranging on the [ul u l] and
* [ul u ur l] predictors */ * [ul u ur l] predictors */
if ((transform == 13) || (transform == 15)) { if ((transform == 13) || (transform == 15)) {
if (ABS(predicted_dc - vu) > 128) if (FFABS(predicted_dc - vu) > 128)
predicted_dc = vu; predicted_dc = vu;
else if (ABS(predicted_dc - vl) > 128) else if (FFABS(predicted_dc - vl) > 128)
predicted_dc = vl; predicted_dc = vl;
else if (ABS(predicted_dc - vul) > 128) else if (FFABS(predicted_dc - vul) > 128)
predicted_dc = vul; predicted_dc = vul;
} }
@ -1527,7 +1527,7 @@ static void render_slice(Vp3DecodeContext *s, int slice)
if (!s->flipped_image) stride = -stride; if (!s->flipped_image) stride = -stride;
if(ABS(stride) > 2048) if(FFABS(stride) > 2048)
return; //various tables are fixed size return; //various tables are fixed size
/* for each fragment row in the slice (both of them)... */ /* for each fragment row in the slice (both of them)... */

@ -428,8 +428,8 @@ static void vp6_filter(vp56_context_t *s, uint8_t *dst, uint8_t *src,
filter4 = s->filter_mode; filter4 = s->filter_mode;
if (filter4 == 2) { if (filter4 == 2) {
if (s->max_vector_length && if (s->max_vector_length &&
(ABS(mv.x) > s->max_vector_length || (FFABS(mv.x) > s->max_vector_length ||
ABS(mv.y) > s->max_vector_length)) { FFABS(mv.y) > s->max_vector_length)) {
filter4 = 0; filter4 = 0;
} else if (!s->sample_variance_threshold } else if (!s->sample_variance_threshold
|| (vp6_block_variance(src+offset1, stride) || (vp6_block_variance(src+offset1, stride)

@ -513,7 +513,7 @@ static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py){
C = s->current_picture.motion_val[0][xy + 2 - wrap]; C = s->current_picture.motion_val[0][xy + 2 - wrap];
if(s->mb_x && !s->first_slice_line && !s->mspel && w->top_left_mv_flag) if(s->mb_x && !s->first_slice_line && !s->mspel && w->top_left_mv_flag)
diff= FFMAX(ABS(A[0] - B[0]), ABS(A[1] - B[1])); diff= FFMAX(FFABS(A[0] - B[0]), FFABS(A[1] - B[1]));
else else
diff=0; diff=0;

@ -488,7 +488,7 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int
maxlen = FFMAX(maxlen, 200 * 1024); maxlen = FFMAX(maxlen, 200 * 1024);
url_fseek(&s->pb, pos, SEEK_SET); url_fseek(&s->pb, pos, SEEK_SET);
found = gxf_resync_media(s, maxlen, -1, timestamp); found = gxf_resync_media(s, maxlen, -1, timestamp);
if (ABS(found - timestamp) > 4) if (FFABS(found - timestamp) > 4)
return -1; return -1;
return 0; return 0;
} }

@ -605,7 +605,7 @@ ogg_read_seek (AVFormatContext * s, int stream_index, int64_t target_ts,
pts = ogg_gptopts (s, i, ogg->streams[i].granule); pts = ogg_gptopts (s, i, ogg->streams[i].granule);
p = url_ftell (bc); p = url_ftell (bc);
if (ABS (pts - target_ts) * st->time_base.num < st->time_base.den) if (FFABS (pts - target_ts) * st->time_base.num < st->time_base.den)
break; break;
if (pts > target_ts){ if (pts > target_ts){
@ -633,7 +633,7 @@ ogg_read_seek (AVFormatContext * s, int stream_index, int64_t target_ts,
} }
} }
if (ABS (pts - target_ts) * st->time_base.num < st->time_base.den){ if (FFABS (pts - target_ts) * st->time_base.num < st->time_base.den){
ogg_restore (s, 1); ogg_restore (s, 1);
ogg_reset (ogg); ogg_reset (ogg);
}else{ }else{

@ -711,8 +711,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
by knowing the futur */ by knowing the futur */
} else if(pkt->pts != AV_NOPTS_VALUE || pkt->dts != AV_NOPTS_VALUE || pkt->duration){ } else if(pkt->pts != AV_NOPTS_VALUE || pkt->dts != AV_NOPTS_VALUE || pkt->duration){
if(pkt->pts != AV_NOPTS_VALUE && pkt->duration){ if(pkt->pts != AV_NOPTS_VALUE && pkt->duration){
int64_t old_diff= ABS(st->cur_dts - pkt->duration - pkt->pts); int64_t old_diff= FFABS(st->cur_dts - pkt->duration - pkt->pts);
int64_t new_diff= ABS(st->cur_dts - pkt->pts); int64_t new_diff= FFABS(st->cur_dts - pkt->pts);
if(old_diff < new_diff && old_diff < (pkt->duration>>3)){ if(old_diff < new_diff && old_diff < (pkt->duration>>3)){
pkt->pts += pkt->duration; pkt->pts += pkt->duration;
// av_log(NULL, AV_LOG_DEBUG, "id:%d old:%Ld new:%Ld dur:%d cur:%Ld size:%d\n", pkt->stream_index, old_diff, new_diff, pkt->duration, st->cur_dts, pkt->size); // av_log(NULL, AV_LOG_DEBUG, "id:%d old:%Ld new:%Ld dur:%d cur:%Ld size:%d\n", pkt->stream_index, old_diff, new_diff, pkt->duration, st->cur_dts, pkt->size);
@ -1947,7 +1947,7 @@ int av_find_stream_info(AVFormatContext *ic)
best_error= INT64_MAX; best_error= INT64_MAX;
for(j=1; j<60*12; j++){ for(j=1; j<60*12; j++){
error= ABS(1001*12*num - 1001*j*den); error= FFABS(1001*12*num - 1001*j*den);
if(error < best_error){ if(error < best_error){
best_error= error; best_error= error;
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, j, 12, INT_MAX); av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, j, 12, INT_MAX);
@ -1955,7 +1955,7 @@ int av_find_stream_info(AVFormatContext *ic)
} }
for(j=0; j<3; j++){ for(j=0; j<3; j++){
static const int ticks[]= {24,30,60}; static const int ticks[]= {24,30,60};
error= ABS(1001*12*num - 1000*12*den * ticks[j]); error= FFABS(1001*12*num - 1000*12*den * ticks[j]);
if(error < best_error){ if(error < best_error){
best_error= error; best_error= error;
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, ticks[j]*1000, 1001, INT_MAX); av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, ticks[j]*1000, 1001, INT_MAX);

@ -192,7 +192,7 @@ typedef uint64_t uint_fast64_t;
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
/* assume b>0 */ /* assume b>0 */
#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
#define ABS(a) ((a) >= 0 ? (a) : (-(a))) #define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
#define FFSIGN(a) ((a) > 0 ? 1 : -1) #define FFSIGN(a) ((a) > 0 ? 1 : -1)
#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) #define FFMAX(a,b) ((a) > (b) ? (a) : (b))

@ -36,10 +36,10 @@
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){ int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
AVRational a0={0,1}, a1={1,0}; AVRational a0={0,1}, a1={1,0};
int sign= (nom<0) ^ (den<0); int sign= (nom<0) ^ (den<0);
int64_t gcd= ff_gcd(ABS(nom), ABS(den)); int64_t gcd= ff_gcd(FFABS(nom), FFABS(den));
nom = ABS(nom)/gcd; nom = FFABS(nom)/gcd;
den = ABS(den)/gcd; den = FFABS(den)/gcd;
if(nom<=max && den<=max){ if(nom<=max && den<=max){
a1= (AVRational){nom, den}; a1= (AVRational){nom, den};
den=0; den=0;

@ -330,13 +330,13 @@ static inline void doHorizDefFilter_C(uint8_t dst[], int stride, PPContext *c)
{ {
const int middleEnergy= 5*(dst[4] - dst[3]) + 2*(dst[2] - dst[5]); const int middleEnergy= 5*(dst[4] - dst[3]) + 2*(dst[2] - dst[5]);
if(ABS(middleEnergy) < 8*c->QP) if(FFABS(middleEnergy) < 8*c->QP)
{ {
const int q=(dst[3] - dst[4])/2; const int q=(dst[3] - dst[4])/2;
const int leftEnergy= 5*(dst[2] - dst[1]) + 2*(dst[0] - dst[3]); const int leftEnergy= 5*(dst[2] - dst[1]) + 2*(dst[0] - dst[3]);
const int rightEnergy= 5*(dst[6] - dst[5]) + 2*(dst[4] - dst[7]); const int rightEnergy= 5*(dst[6] - dst[5]) + 2*(dst[4] - dst[7]);
int d= ABS(middleEnergy) - FFMIN( ABS(leftEnergy), ABS(rightEnergy) ); int d= FFABS(middleEnergy) - FFMIN( FFABS(leftEnergy), FFABS(rightEnergy) );
d= FFMAX(d, 0); d= FFMAX(d, 0);
d= (5*d + 32) >> 6; d= (5*d + 32) >> 6;
@ -369,8 +369,8 @@ static inline void doHorizLowPass_C(uint8_t dst[], int stride, PPContext *c)
int y; int y;
for(y=0; y<BLOCK_SIZE; y++) for(y=0; y<BLOCK_SIZE; y++)
{ {
const int first= ABS(dst[-1] - dst[0]) < c->QP ? dst[-1] : dst[0]; const int first= FFABS(dst[-1] - dst[0]) < c->QP ? dst[-1] : dst[0];
const int last= ABS(dst[8] - dst[7]) < c->QP ? dst[8] : dst[7]; const int last= FFABS(dst[8] - dst[7]) < c->QP ? dst[8] : dst[7];
int sums[10]; int sums[10];
sums[0] = 4*first + dst[0] + dst[1] + dst[2] + 4; sums[0] = 4*first + dst[0] + dst[1] + dst[2] + 4;
@ -445,7 +445,7 @@ static inline void horizX1Filter(uint8_t *src, int stride, int QP)
int b= src[3] - src[4]; int b= src[3] - src[4];
int c= src[5] - src[6]; int c= src[5] - src[6];
int d= FFMAX(ABS(b) - (ABS(a) + ABS(c))/2, 0); int d= FFMAX(FFABS(b) - (FFABS(a) + FFABS(c))/2, 0);
if(d < QP) if(d < QP)
{ {
@ -505,8 +505,8 @@ static always_inline void do_a_deblock_C(uint8_t *src, int step, int stride, PPC
} }
} }
if(max-min < 2*QP){ if(max-min < 2*QP){
const int first= ABS(src[-1*step] - src[0]) < QP ? src[-1*step] : src[0]; const int first= FFABS(src[-1*step] - src[0]) < QP ? src[-1*step] : src[0];
const int last= ABS(src[8*step] - src[7*step]) < QP ? src[8*step] : src[7*step]; const int last= FFABS(src[8*step] - src[7*step]) < QP ? src[8*step] : src[7*step];
int sums[10]; int sums[10];
sums[0] = 4*first + src[0*step] + src[1*step] + src[2*step] + 4; sums[0] = 4*first + src[0*step] + src[1*step] + src[2*step] + 4;
@ -532,13 +532,13 @@ static always_inline void do_a_deblock_C(uint8_t *src, int step, int stride, PPC
}else{ }else{
const int middleEnergy= 5*(src[4*step] - src[3*step]) + 2*(src[2*step] - src[5*step]); const int middleEnergy= 5*(src[4*step] - src[3*step]) + 2*(src[2*step] - src[5*step]);
if(ABS(middleEnergy) < 8*QP) if(FFABS(middleEnergy) < 8*QP)
{ {
const int q=(src[3*step] - src[4*step])/2; const int q=(src[3*step] - src[4*step])/2;
const int leftEnergy= 5*(src[2*step] - src[1*step]) + 2*(src[0*step] - src[3*step]); const int leftEnergy= 5*(src[2*step] - src[1*step]) + 2*(src[0*step] - src[3*step]);
const int rightEnergy= 5*(src[6*step] - src[5*step]) + 2*(src[4*step] - src[7*step]); const int rightEnergy= 5*(src[6*step] - src[5*step]) + 2*(src[4*step] - src[7*step]);
int d= ABS(middleEnergy) - FFMIN( ABS(leftEnergy), ABS(rightEnergy) ); int d= FFABS(middleEnergy) - FFMIN( FFABS(leftEnergy), FFABS(rightEnergy) );
d= FFMAX(d, 0); d= FFMAX(d, 0);
d= (5*d + 32) >> 6; d= (5*d + 32) >> 6;
@ -1045,8 +1045,8 @@ void pp_postprocess(uint8_t * src[3], int srcStride[3],
int mbHeight= (height+15)>>4; int mbHeight= (height+15)>>4;
PPMode *mode = (PPMode*)vm; PPMode *mode = (PPMode*)vm;
PPContext *c = (PPContext*)vc; PPContext *c = (PPContext*)vc;
int minStride= FFMAX(ABS(srcStride[0]), ABS(dstStride[0])); int minStride= FFMAX(FFABS(srcStride[0]), FFABS(dstStride[0]));
int absQPStride = ABS(QPStride); int absQPStride = FFABS(QPStride);
// c->stride and c->QPStride are always positive // c->stride and c->QPStride are always positive
if(c->stride < minStride || c->qpStride < absQPStride) if(c->stride < minStride || c->qpStride < absQPStride)

@ -338,8 +338,8 @@ static inline void RENAME(doVertLowPass)(uint8_t *src, int stride, PPContext *c)
src+= stride*3; src+= stride*3;
for(x=0; x<BLOCK_SIZE; x++) for(x=0; x<BLOCK_SIZE; x++)
{ {
const int first= ABS(src[0] - src[l1]) < c->QP ? src[0] : src[l1]; const int first= FFABS(src[0] - src[l1]) < c->QP ? src[0] : src[l1];
const int last= ABS(src[l8] - src[l9]) < c->QP ? src[l9] : src[l8]; const int last= FFABS(src[l8] - src[l9]) < c->QP ? src[l9] : src[l8];
int sums[10]; int sums[10];
sums[0] = 4*first + src[l1] + src[l2] + src[l3] + 4; sums[0] = 4*first + src[l1] + src[l2] + src[l3] + 4;
@ -460,7 +460,7 @@ static inline void RENAME(vertRK1Filter)(uint8_t *src, int stride, int QP)
for(x=0; x<BLOCK_SIZE; x++) for(x=0; x<BLOCK_SIZE; x++)
{ {
const int v = (src[x+l5] - src[x+l4]); const int v = (src[x+l5] - src[x+l4]);
if(ABS(v) < QP15) if(FFABS(v) < QP15)
{ {
src[x+l3] +=v>>3; src[x+l3] +=v>>3;
src[x+l4] +=v>>1; src[x+l4] +=v>>1;
@ -589,7 +589,7 @@ static inline void RENAME(vertX1Filter)(uint8_t *src, int stride, PPContext *co)
int b= src[l4] - src[l5]; int b= src[l4] - src[l5];
int c= src[l5] - src[l6]; int c= src[l5] - src[l6];
int d= ABS(b) - ((ABS(a) + ABS(c))>>1); int d= FFABS(b) - ((FFABS(a) + FFABS(c))>>1);
d= FFMAX(d, 0); d= FFMAX(d, 0);
if(d < co->QP*2) if(d < co->QP*2)
@ -845,13 +845,13 @@ static inline void RENAME(doVertDefFilter)(uint8_t src[], int stride, PPContext
for(x=0; x<BLOCK_SIZE; x++) for(x=0; x<BLOCK_SIZE; x++)
{ {
const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]); const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]);
if(ABS(middleEnergy)< 8*QP) if(FFABS(middleEnergy)< 8*QP)
{ {
const int q=(src[l4] - src[l5])/2; const int q=(src[l4] - src[l5])/2;
const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]); const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]);
const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]); const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]);
int d= ABS(middleEnergy) - FFMIN( ABS(leftEnergy), ABS(rightEnergy) ); int d= FFABS(middleEnergy) - FFMIN( FFABS(leftEnergy), FFABS(rightEnergy) );
d= FFMAX(d, 0); d= FFMAX(d, 0);
d= (5*d + 32) >> 6; d= (5*d + 32) >> 6;
@ -880,7 +880,7 @@ src-=8;
for(y=4; y<6; y++) for(y=4; y<6; y++)
{ {
int d= src[x+y*stride] - tmp[x+(y-4)*8]; int d= src[x+y*stride] - tmp[x+(y-4)*8];
int ad= ABS(d); int ad= FFABS(d);
static int max=0; static int max=0;
static int sum=0; static int sum=0;
static int num=0; static int num=0;
@ -1149,13 +1149,13 @@ src-=8;
for(x=0; x<BLOCK_SIZE; x++) for(x=0; x<BLOCK_SIZE; x++)
{ {
const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]); const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]);
if(ABS(middleEnergy) < 8*c->QP) if(FFABS(middleEnergy) < 8*c->QP)
{ {
const int q=(src[l4] - src[l5])/2; const int q=(src[l4] - src[l5])/2;
const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]); const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]);
const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]); const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]);
int d= ABS(middleEnergy) - FFMIN( ABS(leftEnergy), ABS(rightEnergy) ); int d= FFABS(middleEnergy) - FFMIN( FFABS(leftEnergy), FFABS(rightEnergy) );
d= FFMAX(d, 0); d= FFMAX(d, 0);
d= (5*d + 32) >> 6; d= (5*d + 32) >> 6;
@ -1491,7 +1491,7 @@ DERING_CORE((%0, %1, 8) ,(%%REGd, %1, 4),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,
static int worstRange=0; static int worstRange=0;
static int worstDiff=0; static int worstDiff=0;
int diff= (f - *p); int diff= (f - *p);
int absDiff= ABS(diff); int absDiff= FFABS(diff);
int error= diff*diff; int error= diff*diff;
if(x==1 || x==8 || y==1 || y==8) continue; if(x==1 || x==8 || y==1 || y==8) continue;
@ -2552,7 +2552,7 @@ L2_DIFF_CORE((%0, %%REGc) , (%1, %%REGc))
int d1=ref - cur; int d1=ref - cur;
// if(x==0 || x==7) d1+= d1>>1; // if(x==0 || x==7) d1+= d1>>1;
// if(y==0 || y==7) d1+= d1>>1; // if(y==0 || y==7) d1+= d1>>1;
// d+= ABS(d1); // d+= FFABS(d1);
d+= d1*d1; d+= d1*d1;
// sysd+= d1; // sysd+= d1;
} }
@ -3529,7 +3529,7 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
dstBlock+=8; dstBlock+=8;
srcBlock+=8; srcBlock+=8;
} }
if(width==ABS(dstStride)) if(width==FFABS(dstStride))
linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride); linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride);
else else
{ {
@ -3551,7 +3551,7 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
uint8_t *tempBlock2= c.tempBlocks + 8; uint8_t *tempBlock2= c.tempBlocks + 8;
#endif #endif
int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride]; int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride];
int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*ABS(QPStride)]; int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*FFABS(QPStride)];
int QP=0; int QP=0;
/* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards /* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards
if not than use a temporary buffer */ if not than use a temporary buffer */
@ -3565,14 +3565,14 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
/* duplicate last line of src to fill the void upto line (copyAhead+7) */ /* duplicate last line of src to fill the void upto line (copyAhead+7) */
for(i=FFMAX(height-y, 8); i<copyAhead+8; i++) for(i=FFMAX(height-y, 8); i<copyAhead+8; i++)
memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), ABS(srcStride)); memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), FFABS(srcStride));
/* copy up to (copyAhead+1) lines of dst (line -1 to (copyAhead-1))*/ /* copy up to (copyAhead+1) lines of dst (line -1 to (copyAhead-1))*/
linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride); linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride);
/* duplicate last line of dst to fill the void upto line (copyAhead) */ /* duplicate last line of dst to fill the void upto line (copyAhead) */
for(i=height-y+1; i<=copyAhead; i++) for(i=height-y+1; i<=copyAhead; i++)
memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), ABS(dstStride)); memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), FFABS(dstStride));
dstBlock= tempDst + dstStride; dstBlock= tempDst + dstStride;
srcBlock= tempSrc; srcBlock= tempSrc;
@ -3783,7 +3783,7 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
if(y+15 >= height) if(y+15 >= height)
{ {
uint8_t *dstBlock= &(dst[y*dstStride]); uint8_t *dstBlock= &(dst[y*dstStride]);
if(width==ABS(dstStride)) if(width==FFABS(dstStride))
linecpy(dstBlock, tempDst + dstStride, height-y, dstStride); linecpy(dstBlock, tempDst + dstStride, height-y, dstStride);
else else
{ {

Loading…
Cancel
Save