/*
* Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at>
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
int i;
if(v){
- const int a= ABS(v);
+ const int a= FFABS(v);
const int e= av_log2(a);
#if 1
const int el= FFMIN(e, 10);
p= parent[px + py*2*stride];
}
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);
}else{
}
}
if(v){
- int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p));
- int l2= 2*ABS(l) + (l<0);
- int t2= 2*ABS(t) + (t<0);
+ int context= av_log2(/*FFABS(ll) + */3*FFABS(l) + FFABS(lt) + 2*FFABS(t) + FFABS(rt) + FFABS(p));
+ int l2= 2*FFABS(l) + (l<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);
}
}
}
}
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]);
if(v){
static int pix_norm1(uint8_t * pix, int line_size, int w)
{
int s, i, j;
- uint32_t *sq = squareTbl + 256;
+ uint32_t *sq = ff_squareTbl + 256;
s = 0;
for (i = 0; i < w; i++) {
const int shift= 1+qpel;
MotionEstContext *c= &s->m.me;
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 my_context= av_log2(2*ABS(left->my - top->my));
+ int mx_context= av_log2(2*FFABS(left->mx - top->mx));
+ 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 ref, best_ref, ref_score, ref_mx, ref_my;
int pcr= left->color[2];
int pmx, pmy;
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 my_context= av_log2(2*ABS(left->my - top->my)) + 16*!!b->ref;
+ int mx_context= av_log2(2*FFABS(left->mx - top->mx)) + 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;
if(s->keyframe){
int my= mid_pred(left->my, top->my, tr->my);
int ref = 0;
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 my_context= av_log2(2*ABS(left->my - top->my)) + 0*av_log2(2*ABS(tr->my - top->my));
+ 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*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;
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;
int dmx, dmy;
-// int mx_context= av_log2(2*ABS(left->mx - top->mx));
-// int my_context= av_log2(2*ABS(left->my - top->my));
+// int mx_context= av_log2(2*FFABS(left->mx - top->mx));
+// int my_context= av_log2(2*FFABS(left->my - top->my));
if(x<0 || x>=b_stride || y>=b_height)
return 0;
//FIXME try accurate rate
//FIXME intra and inter predictors if surrounding blocks arent the same type
if(b->type & BLOCK_INTRA){
- return 3+2*( av_log2(2*ABS(left->color[0] - b->color[0]))
- + av_log2(2*ABS(left->color[1] - b->color[1]))
- + av_log2(2*ABS(left->color[2] - b->color[2])));
+ return 3+2*( av_log2(2*FFABS(left->color[0] - b->color[0]))
+ + av_log2(2*FFABS(left->color[1] - b->color[1]))
+ + av_log2(2*FFABS(left->color[2] - b->color[2])));
}else{
pred_mv(s, &dmx, &dmy, b->ref, left, top, tr);
dmx-= b->mx;
dmy-= b->my;
- return 2*(1 + av_log2(2*ABS(dmx)) //FIXME kill the 2* can be merged in lambda
- + av_log2(2*ABS(dmy))
+ return 2*(1 + av_log2(2*FFABS(dmx)) //FIXME kill the 2* can be merged in lambda
+ + av_log2(2*FFABS(dmy))
+ av_log2(2*b->ref));
}
}
pict->quality= ff_rate_estimate_qscale(&s->m, 1);
if (pict->quality < 0)
- return -1;
+ return INT_MIN;
s->lambda= pict->quality * 3/2;
delta_qlog= qscale2qlog(pict->quality) - s->qlog;
s->qlog+= delta_qlog;
if(s->pass1_rc && plane_index==0){
int delta_qlog = ratecontrol_1pass(s, pict);
- if (delta_qlog < 0)
+ if (delta_qlog <= INT_MIN)
return -1;
if(delta_qlog){
//reordering qlog in the bitstream would eliminate this reset
if(avctx->flags&CODEC_FLAG_PASS1)
ff_write_pass1_stats(&s->m);
s->m.last_pict_type = s->m.pict_type;
+ avctx->frame_bits = s->m.frame_bits;
+ avctx->mv_bits = s->m.mv_bits;
+ avctx->misc_bits = s->m.misc_bits;
+ avctx->p_tex_bits = s->m.p_tex_bits;
emms_c();
ff_spatial_idwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
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
printf("testing AC coder\n");
for(i=-256; i<256; i++){
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")
}
ff_rac_terminate(&s.c);
START_TIMER
j= get_symbol(&s.c, s.header_state, 1);
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
{
for(x=0; x<width; x++){
int64_t d= buffer[0][x + y*width];
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("%8"PRId64" ", 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);
errors[level][orientation]= error;
for(level=0; level<s.spatial_decomposition_count; level++){
printf(" {");
for(orientation=0; orientation<4; orientation++){
- printf("%8lld,", errors[level][orientation]/g);
+ printf("%8"PRId64",", errors[level][orientation]/g);
}
printf("},\n");
}
for(x=0; x<width; x++){
int64_t d= buffer[0][x + y*width];
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("%8"PRId64" ", d);
}
- if(ABS(height/2-y)<9) printf("\n");
+ if(FFABS(height/2-y)<9) printf("\n");
}
}