buf->line = av_mallocz (sizeof(IDWTELEM *) * line_count);
buf->data_stack = av_malloc (sizeof(IDWTELEM *) * max_allocated_lines);
- for (i = 0; i < max_allocated_lines; i++)
- {
+ for(i = 0; i < max_allocated_lines; i++){
buf->data_stack[i] = av_malloc (sizeof(IDWTELEM) * line_width);
}
static void slice_buffer_flush(slice_buffer * buf)
{
int i;
- for (i = 0; i < buf->line_count; i++)
- {
+ for(i = 0; i < buf->line_count; i++){
if (buf->line[i])
slice_buffer_release(buf, i);
}
int i;
slice_buffer_flush(buf);
- for (i = buf->data_count - 1; i >= 0; i--)
- {
+ for(i = buf->data_count - 1; i >= 0; i--){
av_freep(&buf->data_stack[i]);
}
av_freep(&buf->data_stack);
memset(line, 0, b->width*sizeof(IDWTELEM));
v = b->x_coeff[new_index].coeff;
x = b->x_coeff[new_index++].x;
- while(x < w)
- {
+ while(x < w){
register int t= ( (v>>1)*qmul + qadd)>>QEXPSHIFT;
register int u= -(v&1);
line[x] = (t^u) - u;
#else
if(sliced){
s->dsp.inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
- }else
- for(y=0; y<b_h; y++){
- //FIXME ugly misuse of obmc_stride
- 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]
- +obmc3[x] * block[1][x + y*src_stride]
- +obmc4[x] * block[0][x + y*src_stride];
-
- v <<= 8 - LOG2_OBMC_MAX;
- if(FRAC_BITS != 8){
- v >>= 8 - FRAC_BITS;
- }
- if(add){
- v += dst[x + y*dst_stride];
- v = (v + (1<<(FRAC_BITS-1))) >> FRAC_BITS;
- if(v&(~255)) v= ~(v>>31);
- dst8[x + y*src_stride] = v;
- }else{
- dst[x + y*dst_stride] -= v;
+ }else{
+ for(y=0; y<b_h; y++){
+ //FIXME ugly misuse of obmc_stride
+ 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]
+ +obmc3[x] * block[1][x + y*src_stride]
+ +obmc4[x] * block[0][x + y*src_stride];
+
+ v <<= 8 - LOG2_OBMC_MAX;
+ if(FRAC_BITS != 8){
+ v >>= 8 - FRAC_BITS;
+ }
+ if(add){
+ v += dst[x + y*dst_stride];
+ v = (v + (1<<(FRAC_BITS-1))) >> FRAC_BITS;
+ if(v&(~255)) v= ~(v>>31);
+ dst8[x + y*src_stride] = v;
+ }else{
+ dst[x + y*dst_stride] -= v;
+ }
}
}
}
return;
if(add){
- for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++)
- {
+ for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){
// DWTELEM * line = slice_buffer_get_line(sb, y);
IDWTELEM * line = sb->line[y];
- for(x=0; x<w; x++)
- {
+ for(x=0; x<w; x++){
// int v= buf[x + y*w] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
int v= line[x] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
v >>= FRAC_BITS;
}
}
}else{
- for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++)
- {
+ for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){
// DWTELEM * line = slice_buffer_get_line(sb, y);
IDWTELEM * line = sb->line[y];
- for(x=0; x<w; x++)
- {
+ for(x=0; x<w; x++){
line[x] -= 128 << FRAC_BITS;
// buf[x + y*w]-= 128<<FRAC_BITS;
}
return;
}
- for(mb_x=0; mb_x<=mb_w; mb_x++){
- add_yblock(s, 1, sb, old_buffer, dst8, obmc,
- block_w*mb_x - block_w/2,
- block_w*mb_y - block_w/2,
- block_w, block_w,
- w, h,
- w, ref_stride, obmc_stride,
- mb_x - 1, mb_y - 1,
- add, 0, plane_index);
- }
+ for(mb_x=0; mb_x<=mb_w; mb_x++){
+ add_yblock(s, 1, sb, old_buffer, dst8, obmc,
+ block_w*mb_x - block_w/2,
+ block_w*mb_y - block_w/2,
+ block_w, block_w,
+ w, h,
+ w, ref_stride, obmc_stride,
+ mb_x - 1, mb_y - 1,
+ add, 0, plane_index);
+ }
}
static av_always_inline void predict_slice(SnowContext *s, IDWTELEM *buf, int plane_index, int add, int mb_y){
}
//skip stuff outside the picture
- if(mb_x==0 || mb_y==0 || mb_x==b_width-1 || mb_y==b_height-1)
- {
+ if(mb_x==0 || mb_y==0 || mb_x==b_width-1 || mb_y==b_height-1){
uint8_t *src= s-> input_picture.data[0];
uint8_t *dst= s->current_picture.data[0];
const int stride= s->current_picture.linesize[0];
}
}
-static int common_init(AVCodecContext *avctx){
+static av_cold int common_init(AVCodecContext *avctx){
SnowContext *s = avctx->priv_data;
int width, height;
int i, j;
coef_sum = (uint64_t)coef_sum * coef_sum >> 16;
assert(coef_sum < INT_MAX);
- if(pict->pict_type == I_TYPE){
+ if(pict->pict_type == FF_I_TYPE){
s->m.current_picture.mb_var_sum= coef_sum;
s->m.current_picture.mc_mb_var_sum= 0;
}else{
#endif /* QUANTIZE2==1 */
-static int encode_init(AVCodecContext *avctx)
+static av_cold int encode_init(AVCodecContext *avctx)
{
SnowContext *s = avctx->priv_data;
int plane_index;
frame_start(s);
s->m.current_picture_ptr= &s->m.current_picture;
- if(pict->pict_type == P_TYPE){
+ if(pict->pict_type == FF_P_TYPE){
int block_width = (width +15)>>4;
int block_height= (height+15)>>4;
int stride= s->current_picture.linesize[0];
redo_frame:
- if(pict->pict_type == I_TYPE)
+ if(pict->pict_type == FF_I_TYPE)
s->spatial_decomposition_count= 5;
else
s->spatial_decomposition_count= 5;
s->m.pict_type = pict->pict_type;
- s->qbias= pict->pict_type == P_TYPE ? 2 : 0;
+ s->qbias= pict->pict_type == FF_P_TYPE ? 2 : 0;
common_init_after_header(avctx);
predict_plane(s, s->spatial_idwt_buffer, plane_index, 0);
if( plane_index==0
- && pict->pict_type == P_TYPE
+ && pict->pict_type == FF_P_TYPE
&& !(avctx->flags&CODEC_FLAG_PASS2)
&& s->m.me.scene_change_score > s->avctx->scenechange_threshold){
ff_init_range_encoder(c, buf, buf_size);
if(!QUANTIZE2)
quantize(s, b, b->ibuf, b->buf, b->stride, s->qbias);
if(orientation==0)
- decorrelate(s, b, b->ibuf, b->stride, pict->pict_type == P_TYPE, 0);
+ decorrelate(s, b, b->ibuf, b->stride, pict->pict_type == FF_P_TYPE, 0);
encode_subband(s, b, b->ibuf, b->parent ? b->parent->ibuf : NULL, b->stride, orientation);
assert(b->parent==NULL || b->parent->stride == b->stride*2);
if(orientation==0)
predict_plane(s, s->spatial_idwt_buffer, plane_index, 1);
}else{
//ME/MC only
- if(pict->pict_type == I_TYPE){
+ if(pict->pict_type == FF_I_TYPE){
for(y=0; y<h; y++){
for(x=0; x<w; x++){
s->current_picture.data[plane_index][y*s->current_picture.linesize[plane_index] + x]=
return ff_rac_terminate(c);
}
-static void common_end(SnowContext *s){
+static av_cold void common_end(SnowContext *s){
int plane_index, level, orientation, i;
av_freep(&s->spatial_dwt_buffer);
}
}
-static int encode_end(AVCodecContext *avctx)
+static av_cold int encode_end(AVCodecContext *avctx)
{
SnowContext *s = avctx->priv_data;
return 0;
}
-static int decode_init(AVCodecContext *avctx)
+static av_cold int decode_init(AVCodecContext *avctx)
{
avctx->pix_fmt= PIX_FMT_YUV420P;
return bytes_read;
}
-static int decode_end(AVCodecContext *avctx)
+static av_cold int decode_end(AVCodecContext *avctx)
{
SnowContext *s = avctx->priv_data;
decode_end,
decode_frame,
0 /*CODEC_CAP_DR1*/ /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
- NULL
+ NULL,
+ .long_name = NULL_IF_CONFIG_SMALL("Snow"),
};
#ifdef CONFIG_SNOW_ENCODER
encode_init,
encode_frame,
encode_end,
+ .long_name = NULL_IF_CONFIG_SMALL("Snow"),
};
#endif