#define DWTELEM int
#define QROOT 8
#define LOSSLESS_QLOG -128
+#define FRAC_BITS 8
static const int8_t quant3[256]={
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independant of MpegEncContext, so this will be removed then (FIXME/XXX)
}SnowContext;
-#define QEXPSHIFT 7 //FIXME try to change this to 0
+#define QEXPSHIFT (7-FRAC_BITS+8) //FIXME try to change this to 0
static const uint8_t qexp[8]={
128, 140, 152, 166, 181, 197, 215, 235
// 64, 70, 76, 83, 91, 99, 108, 117
+obmc2[x] * block[2][x + y*src_stride]
+obmc3[x] * block[1][x + y*src_stride]
+obmc4[x] * block[0][x + y*src_stride];
- if(add) dst[x + y*dst_stride] += v * (256/OBMC_MAX);
- else dst[x + y*dst_stride] -= v * (256/OBMC_MAX);
+
+ v *= 256/OBMC_MAX;
+ if(FRAC_BITS != 8){
+ v += 1<<(7 - FRAC_BITS);
+ v >>= 8 - FRAC_BITS;
+ }
+ if(add) dst[x + y*dst_stride] += v;
+ else dst[x + y*dst_stride] -= v;
}
}
#endif
if(s->keyframe || (s->avctx->debug&512)){
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- if(add) buf[x + y*w]+= 128*256;
- else buf[x + y*w]-= 128*256;
+ if(add) buf[x + y*w]+= 128<<FRAC_BITS;
+ else buf[x + y*w]-= 128<<FRAC_BITS;
}
}
if(pict->data[plane_index]) //FIXME gray hack
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- s->spatial_dwt_buffer[y*w + x]= pict->data[plane_index][y*pict->linesize[plane_index] + x]<<8;
+ s->spatial_dwt_buffer[y*w + x]= pict->data[plane_index][y*pict->linesize[plane_index] + x]<<FRAC_BITS;
}
}
predict_plane(s, s->spatial_dwt_buffer, plane_index, 0);
if(s->qlog == LOSSLESS_QLOG){
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- s->spatial_dwt_buffer[y*w + x]= (s->spatial_dwt_buffer[y*w + x] + 127)>>8;
+ s->spatial_dwt_buffer[y*w + x]= (s->spatial_dwt_buffer[y*w + x] + (1<<(FRAC_BITS-1)))>>FRAC_BITS;
}
}
}
if(s->qlog == LOSSLESS_QLOG){
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- s->spatial_dwt_buffer[y*w + x]<<=8;
+ s->spatial_dwt_buffer[y*w + x]<<=FRAC_BITS;
}
}
}
//FIXME optimize
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- int v= (s->spatial_dwt_buffer[y*w + x]+128)>>8;
+ int v= (s->spatial_dwt_buffer[y*w + x]+(1<<(FRAC_BITS-1)))>>FRAC_BITS;
if(v&(~255)) v= ~(v>>31);
s->current_picture.data[plane_index][y*s->current_picture.linesize[plane_index] + x]= v;
}
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- int v= (s->spatial_dwt_buffer[y*w + x]+128)>>8;
+ int v= (s->spatial_dwt_buffer[y*w + x]+(1<<(FRAC_BITS-1)))>>FRAC_BITS;
if(v&(~255)) v= ~(v>>31);
s->mconly_picture.data[plane_index][y*s->mconly_picture.linesize[plane_index] + x]= v;
}
if(s->qlog == LOSSLESS_QLOG){
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- s->spatial_dwt_buffer[y*w + x]<<=8;
+ s->spatial_dwt_buffer[y*w + x]<<=FRAC_BITS;
}
}
}
//FIXME optimize
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- int v= (s->spatial_dwt_buffer[y*w + x]+128)>>8;
+ int v= (s->spatial_dwt_buffer[y*w + x]+(1<<(FRAC_BITS-1)))>>FRAC_BITS;
if(v&(~255)) v= ~(v>>31);
s->current_picture.data[plane_index][y*s->current_picture.linesize[plane_index] + x]= v;
}