30 int src_x,
int src_y,
int src_stride, slice_buffer * sb,
int add, uint8_t * dst8){
35 const uint8_t *obmc1= obmc + y*obmc_stride;
36 const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
37 const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
38 const uint8_t *
obmc4= obmc3+ (obmc_stride>>1);
41 int v= obmc1[x] *
block[3][x + y*src_stride]
42 +obmc2[x] *
block[2][x + y*src_stride]
43 +obmc3[x] *
block[1][x + y*src_stride]
53 if(v&(~255)) v= ~(v>>31);
54 dst8[x + y*src_stride] = v;
63 int plane_index,
level, orientation;
65 for(plane_index=0; plane_index<3; plane_index++){
67 for(orientation=
level ? 1:0; orientation<4; orientation++){
68 memset(
s->plane[plane_index].band[
level][orientation].state,
MID_STATE,
sizeof(
s->plane[plane_index].band[
level][orientation].state));
72 memset(
s->header_state,
MID_STATE,
sizeof(
s->header_state));
73 memset(
s->block_state,
MID_STATE,
sizeof(
s->block_state));
84 s->block =
av_calloc(
w *
h,
sizeof(*
s->block) << (
s->block_max_depth*2));
92 static const uint8_t
weight[64]={
103 static const uint8_t brane[256]={
104 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x11,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
105 0x04,0x05,0xcc,0xcc,0xcc,0xcc,0xcc,0x41,0x15,0x16,0xcc,0xcc,0xcc,0xcc,0xcc,0x52,
106 0x04,0xcc,0x05,0xcc,0xcc,0xcc,0x41,0xcc,0x15,0xcc,0x16,0xcc,0xcc,0xcc,0x52,0xcc,
107 0x04,0xcc,0xcc,0x05,0xcc,0x41,0xcc,0xcc,0x15,0xcc,0xcc,0x16,0xcc,0x52,0xcc,0xcc,
108 0x04,0xcc,0xcc,0xcc,0x41,0xcc,0xcc,0xcc,0x15,0xcc,0xcc,0xcc,0x16,0xcc,0xcc,0xcc,
109 0x04,0xcc,0xcc,0x41,0xcc,0x05,0xcc,0xcc,0x15,0xcc,0xcc,0x52,0xcc,0x16,0xcc,0xcc,
110 0x04,0xcc,0x41,0xcc,0xcc,0xcc,0x05,0xcc,0x15,0xcc,0x52,0xcc,0xcc,0xcc,0x16,0xcc,
111 0x04,0x41,0xcc,0xcc,0xcc,0xcc,0xcc,0x05,0x15,0x52,0xcc,0xcc,0xcc,0xcc,0xcc,0x16,
112 0x44,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x55,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
113 0x48,0x49,0xcc,0xcc,0xcc,0xcc,0xcc,0x85,0x59,0x5A,0xcc,0xcc,0xcc,0xcc,0xcc,0x96,
114 0x48,0xcc,0x49,0xcc,0xcc,0xcc,0x85,0xcc,0x59,0xcc,0x5A,0xcc,0xcc,0xcc,0x96,0xcc,
115 0x48,0xcc,0xcc,0x49,0xcc,0x85,0xcc,0xcc,0x59,0xcc,0xcc,0x5A,0xcc,0x96,0xcc,0xcc,
116 0x48,0xcc,0xcc,0xcc,0x49,0xcc,0xcc,0xcc,0x59,0xcc,0xcc,0xcc,0x96,0xcc,0xcc,0xcc,
117 0x48,0xcc,0xcc,0x85,0xcc,0x49,0xcc,0xcc,0x59,0xcc,0xcc,0x96,0xcc,0x5A,0xcc,0xcc,
118 0x48,0xcc,0x85,0xcc,0xcc,0xcc,0x49,0xcc,0x59,0xcc,0x96,0xcc,0xcc,0xcc,0x5A,0xcc,
119 0x48,0x85,0xcc,0xcc,0xcc,0xcc,0xcc,0x49,0x59,0x96,0xcc,0xcc,0xcc,0xcc,0xcc,0x5A,
122 static const uint8_t needs[16]={
132 int16_t *tmpI= tmpIt;
133 uint8_t *tmp2= tmp2t[0];
134 const uint8_t *hpel[11];
136 r= brane[dx + 16*dy]&15;
137 l= brane[dx + 16*dy]>>4;
139 b= needs[l] | needs[
r];
145 for(x=0; x < b_w; x++){
165 if(am&(~255)) am= ~(am>>31);
178 for(y=0; y < b_h; y++){
179 for(x=0; x < b_w+1; x++){
194 if(am&(~255)) am= ~(am>>31);
206 for(y=0; y < b_h; y++){
207 for(x=0; x < b_w; x++){
221 if(am&(~255)) am= ~(am>>31);
235 hpel[ 6]= tmp2t[1] + 1;
238 hpel[ 9]= hpel[1] + 64;
239 hpel[10]= hpel[8] + 1;
241 #define MC_STRIDE(x) (needs[x] ? 64 : stride)
244 int dxy = dx / 8 + dy / 8 * 4;
245 const uint8_t *
src1 = hpel[dxy ];
246 const uint8_t *
src2 = hpel[dxy + 1];
247 const uint8_t *src3 = hpel[dxy + 4];
248 const uint8_t *src4 = hpel[dxy + 5];
255 for(y=0; y < b_h; y++){
256 for(x=0; x < b_w; x++){
257 dst[x]= ((8-dx)*(8-dy)*
src1[x] + dx*(8-dy)*
src2[x]+
258 (8-dx)* dy *src3[x] + dx* dy *src4[x]+32)>>6;
267 const uint8_t *
src1= hpel[l];
268 const uint8_t *
src2= hpel[
r];
271 int a=
weight[((dx&7) + (8*(dy&7)))];
273 for(y=0; y < b_h; y++){
274 for(x=0; x < b_w; x++){
284 void ff_snow_pred_block(
SnowContext *
s, uint8_t *dst, uint8_t *
tmp, ptrdiff_t
stride,
int sx,
int sy,
int b_w,
int b_h,
const BlockNode *
block,
int plane_index,
int w,
int h){
287 const unsigned color =
block->color[plane_index];
288 const unsigned color4 =
color*0x01010101;
290 for(y=0; y < b_h; y++){
291 *(uint32_t*)&dst[0 + y*
stride]= color4;
292 *(uint32_t*)&dst[4 + y*
stride]= color4;
293 *(uint32_t*)&dst[8 + y*
stride]= color4;
294 *(uint32_t*)&dst[12+ y*
stride]= color4;
295 *(uint32_t*)&dst[16+ y*
stride]= color4;
296 *(uint32_t*)&dst[20+ y*
stride]= color4;
297 *(uint32_t*)&dst[24+ y*
stride]= color4;
298 *(uint32_t*)&dst[28+ y*
stride]= color4;
301 for(y=0; y < b_h; y++){
302 *(uint32_t*)&dst[0 + y*
stride]= color4;
303 *(uint32_t*)&dst[4 + y*
stride]= color4;
304 *(uint32_t*)&dst[8 + y*
stride]= color4;
305 *(uint32_t*)&dst[12+ y*
stride]= color4;
308 for(y=0; y < b_h; y++){
309 *(uint32_t*)&dst[0 + y*
stride]= color4;
310 *(uint32_t*)&dst[4 + y*
stride]= color4;
313 for(y=0; y < b_h; y++){
314 *(uint32_t*)&dst[0 + y*
stride]= color4;
317 for(y=0; y < b_h; y++){
318 for(x=0; x < b_w; x++){
324 const uint8_t *
src =
s->last_picture[
block->ref]->data[plane_index];
325 const int scale= plane_index ? (2*
s->mv_scale)>>
s->chroma_h_shift : 2*
s->mv_scale;
330 const int tab_index= 3 - (b_w>>2) + (b_w>>4);
345 av_assert2((tab_index>=0 && tab_index<4) || b_w==32);
347 || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h)
351 || !
s->plane[plane_index].fast_mc )
355 for(y=0; y<b_h; y+=16){
360 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst,
src + 3 + 3*
stride,
stride);
362 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst ,
src + 3 + 3*
stride,
stride);
363 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst+b_h,
src + 3 + b_h + 3*
stride,
stride);
366 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst ,
src + 3 + 3*
stride ,
stride);
372 #define mca(dx,dy,b_w)\
373 static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h){\
375 mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, stride, b_w, b_w, dx, dy);\
387 static
av_cold void snow_static_init(
void)
402 s->spatial_decomposition_count = 1;
409 s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\
410 s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\
411 mc_block_hpel ## dx ## dy ## 16;\
412 s->hdsp.put_pixels_tab [1][dy/4+dx/8]=\
413 s->hdsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\
414 mc_block_hpel ## dx ## dy ## 8;
435 if (!
s->last_picture[
i])
441 if (!
s->mconly_picture || !
s->current_picture)
451 int plane_index,
level, orientation;
461 for(plane_index=0; plane_index <
s->nb_planes; plane_index++){
462 int w=
s->avctx->width;
463 int h=
s->avctx->height;
469 s->plane[plane_index].width =
w;
470 s->plane[plane_index].height=
h;
473 for(orientation=
level ? 1 : 0; orientation<4; orientation++){
476 b->buf=
s->spatial_dwt_buffer;
478 b->stride=
s->plane[plane_index].width << (
s->spatial_decomposition_count -
level);
479 b->width = (
w + !(orientation&1))>>1;
480 b->height= (
h + !(orientation>1))>>1;
482 b->stride_line = 1 << (
s->spatial_decomposition_count -
level);
488 b->buf_x_offset = (
w+1)>>1;
491 b->buf +=
b->stride>>1;
492 b->buf_y_offset =
b->stride_line >> 1;
494 b->ibuf=
s->spatial_idwt_buffer + (
b->buf -
s->spatial_dwt_buffer);
497 b->parent= &
s->plane[plane_index].band[
level-1][orientation];
501 sizeof(*
b->x_coeff));
517 if(
s->last_picture[
s->max_ref_frames-1]->data[0]){
528 tmp=
s->last_picture[
s->max_ref_frames-1];
529 for (
int i =
s->max_ref_frames - 1;
i > 0;
i--)
530 s->last_picture[
i] =
s->last_picture[
i-1];
531 s->last_picture[0] =
s->current_picture;
532 s->current_picture =
tmp;
539 for(
i=0;
i<
s->max_ref_frames &&
s->last_picture[
i]->data[0];
i++)
543 if(
s->ref_frames==0){
555 int plane_index,
level, orientation,
i;
568 if(
s->last_picture[
i] &&
s->last_picture[
i]->data[0]) {
569 av_assert0(
s->last_picture[
i]->data[0] !=
s->current_picture->data[0]);
574 for(plane_index=0; plane_index <
MAX_PLANES; plane_index++){
576 for(orientation=
level ? 1 : 0; orientation<4; orientation++){