*/
#include "avcodec.h"
-#include "common.h"
#include "dsputil.h"
#include "snow.h"
}Plane;
typedef struct SnowContext{
-// 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)
+// MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independent of MpegEncContext, so this will be removed then (FIXME/XXX)
AVCodecContext *avctx;
RangeCoder c;
int me_cache_generation;
slice_buffer sb;
- 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)
+ MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independent of MpegEncContext, so this will be removed then (FIXME/XXX)
}SnowContext;
typedef struct {
static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, slice_buffer * sb, int start_y, int h, int save_state[1]){
const int w= b->width;
int y;
- const int qlog= clip(s->qlog + b->qlog, 0, QROOT*16);
+ const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
int new_index = 0;
RangeCoder pc, ic;
uint8_t *pbbak= s->c.bytestream;
uint8_t *pbbak_start= s->c.bytestream_start;
- int score, score2, iscore, i_len, p_len, block_s, sum;
+ int score, score2, iscore, i_len, p_len, block_s, sum, base_bits;
const int w= s->b_width << s->block_max_depth;
const int h= s->b_height << s->block_max_depth;
const int rem_depth= s->block_max_depth - level;
my= ref_my;
}
}
- //FIXME if mb_cmp != SSE then intra cant be compared currently and mb_penalty vs. lambda2
+ //FIXME if mb_cmp != SSE then intra cannot be compared currently and mb_penalty vs. lambda2
// subpel search
+ base_bits= get_rac_count(&s->c) - 8*(s->c.bytestream - s->c.bytestream_start);
pc= s->c;
pc.bytestream_start=
pc.bytestream= p_buffer; //FIXME end/start? and at the other stoo
put_symbol(&pc, &p_state[128 + 32*(mx_context + 16*!!best_ref)], mx - pmx, 1);
put_symbol(&pc, &p_state[128 + 32*(my_context + 16*!!best_ref)], my - pmy, 1);
p_len= pc.bytestream - pc.bytestream_start;
- score += (s->lambda2*(p_len*8
- + (pc.outstanding_count - s->c.outstanding_count)*8
- + (-av_log2(pc.range) + av_log2(s->c.range))
- ))>>FF_LAMBDA_SHIFT;
+ score += (s->lambda2*(get_rac_count(&pc)-base_bits))>>FF_LAMBDA_SHIFT;
block_s= block_w*block_w;
sum = pix_sum(current_data[0], stride, block_w);
put_symbol(&ic, &i_state[64], cb-pcb, 1);
put_symbol(&ic, &i_state[96], cr-pcr, 1);
i_len= ic.bytestream - ic.bytestream_start;
- iscore += (s->lambda2*(i_len*8
- + (ic.outstanding_count - s->c.outstanding_count)*8
- + (-av_log2(ic.range) + av_log2(s->c.range))
- ))>>FF_LAMBDA_SHIFT;
+ iscore += (s->lambda2*(get_rac_count(&ic)-base_bits))>>FF_LAMBDA_SHIFT;
// assert(score==256*256*256*64-1);
assert(iscore < 255*255*256 + s->lambda2*10);
}
}
-void ff_snow_inner_add_yblock(uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
+void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){
int y, x;
DWTELEM * dst;
for(y=0; y<b_h; y++){
//FIXME ugly missue of obmc_stride
- uint8_t *obmc1= obmc + y*obmc_stride;
- uint8_t *obmc2= obmc1+ (obmc_stride>>1);
- uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
- uint8_t *obmc4= obmc3+ (obmc_stride>>1);
+ const uint8_t *obmc1= obmc + y*obmc_stride;
+ const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
+ const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
+ const uint8_t *obmc4= obmc3+ (obmc_stride>>1);
dst = slice_buffer_get_line(sb, src_y + y);
for(x=0; x<b_w; x++){
int v= obmc1[x] * block[3][x + y*src_stride]
}else
for(y=0; y<b_h; y++){
//FIXME ugly missue of obmc_stride
- uint8_t *obmc1= obmc + y*obmc_stride;
- uint8_t *obmc2= obmc1+ (obmc_stride>>1);
- uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
- uint8_t *obmc4= obmc3+ (obmc_stride>>1);
+ const uint8_t *obmc1= obmc + y*obmc_stride;
+ const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
+ const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
+ const uint8_t *obmc4= obmc3+ (obmc_stride>>1);
for(x=0; x<b_w; x++){
int v= obmc1[x] * block[3][x + y*src_stride]
+obmc2[x] * block[2][x + y*src_stride]
}
*b= backup;
- return clip(((ab<<LOG2_OBMC_MAX) + aa/2)/aa, 0, 255); //FIXME we shouldnt need cliping
+ return av_clip(((ab<<LOG2_OBMC_MAX) + aa/2)/aa, 0, 255); //FIXME we should not need clipping
}
static inline int get_block_bits(SnowContext *s, int x, int y, int w){
for(i=0; i<3; i++)
color[i]= get_dc(s, mb_x, mb_y, i);
- // get previous score (cant be cached due to OBMC)
+ // get previous score (cannot be cached due to OBMC)
if(pass > 0 && (block->type&BLOCK_INTRA)){
int color0[3]= {block->color[0], block->color[1], block->color[2]};
check_block(s, mb_x, mb_y, color0, 1, *obmc_edged, &best_rd);
const int level= b->level;
const int w= b->width;
const int h= b->height;
- const int qlog= clip(s->qlog + b->qlog, 0, QROOT*16);
+ const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
int x,y, thres1, thres2;
// START_TIMER
static void dequantize_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, DWTELEM *src, int stride, int start_y, int end_y){
const int w= b->width;
- const int qlog= clip(s->qlog + b->qlog, 0, QROOT*16);
+ const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
const int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
int x,y;
static void dequantize(SnowContext *s, SubBand *b, DWTELEM *src, int stride){
const int w= b->width;
const int h= b->height;
- const int qlog= clip(s->qlog + b->qlog, 0, QROOT*16);
+ const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
const int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
int x,y;
const int w= b->width;
const int h= b->height;
const int stride= b->stride;
- const int qlog= clip(2*QROOT + b->qlog, 0, QROOT*16);
+ const int qlog= av_clip(2*QROOT + b->qlog, 0, QROOT*16);
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
const int qdiv= (1<<16)/qmul;
int x, y;
// case PIX_FMT_YUV410P:
s->colorspace_type= 0;
break;
-/* case PIX_FMT_RGBA32:
+/* case PIX_FMT_RGB32:
s->colorspace= 1;
break;*/
default: