31 int src_x,
int src_y,
int src_stride, slice_buffer * sb,
int add, uint8_t * dst8){
36 const uint8_t *obmc1= obmc + y*obmc_stride;
37 const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
38 const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
39 const uint8_t *
obmc4= obmc3+ (obmc_stride>>1);
42 int v= obmc1[x] *
block[3][x + y*src_stride]
43 +obmc2[x] *
block[2][x + y*src_stride]
44 +obmc3[x] *
block[1][x + y*src_stride]
54 if(v&(~255)) v= ~(v>>31);
55 dst8[x + y*src_stride] = v;
64 int plane_index,
level, orientation;
66 for(plane_index=0; plane_index<3; plane_index++){
68 for(orientation=
level ? 1:0; orientation<4; orientation++){
69 memset(
s->plane[plane_index].band[
level][orientation].state,
MID_STATE,
sizeof(
s->plane[plane_index].band[
level][orientation].state));
73 memset(
s->header_state,
MID_STATE,
sizeof(
s->header_state));
74 memset(
s->block_state,
MID_STATE,
sizeof(
s->block_state));
85 s->block =
av_calloc(
w *
h,
sizeof(*
s->block) << (
s->block_max_depth*2));
93 static const uint8_t
weight[64]={
104 static const uint8_t brane[256]={
105 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x11,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
106 0x04,0x05,0xcc,0xcc,0xcc,0xcc,0xcc,0x41,0x15,0x16,0xcc,0xcc,0xcc,0xcc,0xcc,0x52,
107 0x04,0xcc,0x05,0xcc,0xcc,0xcc,0x41,0xcc,0x15,0xcc,0x16,0xcc,0xcc,0xcc,0x52,0xcc,
108 0x04,0xcc,0xcc,0x05,0xcc,0x41,0xcc,0xcc,0x15,0xcc,0xcc,0x16,0xcc,0x52,0xcc,0xcc,
109 0x04,0xcc,0xcc,0xcc,0x41,0xcc,0xcc,0xcc,0x15,0xcc,0xcc,0xcc,0x16,0xcc,0xcc,0xcc,
110 0x04,0xcc,0xcc,0x41,0xcc,0x05,0xcc,0xcc,0x15,0xcc,0xcc,0x52,0xcc,0x16,0xcc,0xcc,
111 0x04,0xcc,0x41,0xcc,0xcc,0xcc,0x05,0xcc,0x15,0xcc,0x52,0xcc,0xcc,0xcc,0x16,0xcc,
112 0x04,0x41,0xcc,0xcc,0xcc,0xcc,0xcc,0x05,0x15,0x52,0xcc,0xcc,0xcc,0xcc,0xcc,0x16,
113 0x44,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x55,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
114 0x48,0x49,0xcc,0xcc,0xcc,0xcc,0xcc,0x85,0x59,0x5A,0xcc,0xcc,0xcc,0xcc,0xcc,0x96,
115 0x48,0xcc,0x49,0xcc,0xcc,0xcc,0x85,0xcc,0x59,0xcc,0x5A,0xcc,0xcc,0xcc,0x96,0xcc,
116 0x48,0xcc,0xcc,0x49,0xcc,0x85,0xcc,0xcc,0x59,0xcc,0xcc,0x5A,0xcc,0x96,0xcc,0xcc,
117 0x48,0xcc,0xcc,0xcc,0x49,0xcc,0xcc,0xcc,0x59,0xcc,0xcc,0xcc,0x96,0xcc,0xcc,0xcc,
118 0x48,0xcc,0xcc,0x85,0xcc,0x49,0xcc,0xcc,0x59,0xcc,0xcc,0x96,0xcc,0x5A,0xcc,0xcc,
119 0x48,0xcc,0x85,0xcc,0xcc,0xcc,0x49,0xcc,0x59,0xcc,0x96,0xcc,0xcc,0xcc,0x5A,0xcc,
120 0x48,0x85,0xcc,0xcc,0xcc,0xcc,0xcc,0x49,0x59,0x96,0xcc,0xcc,0xcc,0xcc,0xcc,0x5A,
123 static const uint8_t needs[16]={
133 int16_t *tmpI= tmpIt;
134 uint8_t *tmp2= tmp2t[0];
135 const uint8_t *hpel[11];
137 r= brane[dx + 16*dy]&15;
138 l= brane[dx + 16*dy]>>4;
140 b= needs[l] | needs[
r];
146 for(x=0; x < b_w; x++){
157 am= 20*(
a2+
a3) - 5*(
a1+a4) + (
a0+a5);
166 if(am&(~255)) am= ~(am>>31);
179 for(y=0; y < b_h; y++){
180 for(x=0; x < b_w+1; x++){
191 am= (20*(
a2+
a3) - 5*(
a1+a4) + (
a0+a5) + 16)>>5;
195 if(am&(~255)) am= ~(am>>31);
207 for(y=0; y < b_h; y++){
208 for(x=0; x < b_w; x++){
219 am= (20*(
a2+
a3) - 5*(
a1+a4) + (
a0+a5) + 512)>>10;
222 if(am&(~255)) am= ~(am>>31);
236 hpel[ 6]= tmp2t[1] + 1;
239 hpel[ 9]= hpel[1] + 64;
240 hpel[10]= hpel[8] + 1;
242 #define MC_STRIDE(x) (needs[x] ? 64 : stride)
245 int dxy = dx / 8 + dy / 8 * 4;
246 const uint8_t *
src1 = hpel[dxy ];
247 const uint8_t *
src2 = hpel[dxy + 1];
248 const uint8_t *src3 = hpel[dxy + 4];
249 const uint8_t *src4 = hpel[dxy + 5];
256 for(y=0; y < b_h; y++){
257 for(x=0; x < b_w; x++){
258 dst[x]= ((8-dx)*(8-dy)*
src1[x] + dx*(8-dy)*
src2[x]+
259 (8-dx)* dy *src3[x] + dx* dy *src4[x]+32)>>6;
268 const uint8_t *
src1= hpel[l];
269 const uint8_t *
src2= hpel[
r];
272 int a=
weight[((dx&7) + (8*(dy&7)))];
274 for(y=0; y < b_h; y++){
275 for(x=0; x < b_w; x++){
285 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){
288 const unsigned color =
block->color[plane_index];
289 const unsigned color4 =
color*0x01010101;
291 for(y=0; y < b_h; y++){
302 for(y=0; y < b_h; y++){
309 for(y=0; y < b_h; y++){
314 for(y=0; y < b_h; y++){
318 for(y=0; y < b_h; y++){
319 for(x=0; x < b_w; x++){
325 const uint8_t *
src =
s->last_picture[
block->ref]->data[plane_index];
326 const int scale= plane_index ? (2*
s->mv_scale)>>
s->chroma_h_shift : 2*
s->mv_scale;
331 const int tab_index= 3 - (b_w>>2) + (b_w>>4);
346 av_assert2((tab_index>=0 && tab_index<4) || b_w==32);
348 || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h)
352 || !
s->plane[plane_index].fast_mc )
356 for(y=0; y<b_h; y+=16){
361 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](
dst,
src + 3 + 3*
stride,
stride);
363 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](
dst ,
src + 3 + 3*
stride,
stride);
364 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](
dst+b_h,
src + 3 + b_h + 3*
stride,
stride);
367 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](
dst ,
src + 3 + 3*
stride ,
stride);
373 #define mca(dx,dy,b_w)\
374 static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h){\
376 mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, stride, b_w, b_w, dx, dy);\
388 static
av_cold void snow_static_init(
void)
403 s->spatial_decomposition_count = 1;
410 s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\
411 s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\
412 mc_block_hpel ## dx ## dy ## 16;\
413 s->hdsp.put_pixels_tab [1][dy/4+dx/8]=\
414 s->hdsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\
415 mc_block_hpel ## dx ## dy ## 8;
436 if (!
s->last_picture[
i])
442 if (!
s->mconly_picture || !
s->current_picture)
452 int plane_index,
level, orientation;
462 for(plane_index=0; plane_index <
s->nb_planes; plane_index++){
463 int w=
s->avctx->width;
464 int h=
s->avctx->height;
470 s->plane[plane_index].width =
w;
471 s->plane[plane_index].height=
h;
474 for(orientation=
level ? 1 : 0; orientation<4; orientation++){
477 b->buf=
s->spatial_dwt_buffer;
479 b->stride=
s->plane[plane_index].width << (
s->spatial_decomposition_count -
level);
480 b->width = (
w + !(orientation&1))>>1;
481 b->height= (
h + !(orientation>1))>>1;
483 b->stride_line = 1 << (
s->spatial_decomposition_count -
level);
489 b->buf_x_offset = (
w+1)>>1;
492 b->buf +=
b->stride>>1;
493 b->buf_y_offset =
b->stride_line >> 1;
495 b->ibuf=
s->spatial_idwt_buffer + (
b->buf -
s->spatial_dwt_buffer);
498 b->parent= &
s->plane[plane_index].band[
level-1][orientation];
502 sizeof(*
b->x_coeff));
518 if(
s->last_picture[
s->max_ref_frames-1]->data[0]){
529 tmp=
s->last_picture[
s->max_ref_frames-1];
530 for (
int i =
s->max_ref_frames - 1;
i > 0;
i--)
531 s->last_picture[
i] =
s->last_picture[
i-1];
532 s->last_picture[0] =
s->current_picture;
533 s->current_picture =
tmp;
540 for(
i=0;
i<
s->max_ref_frames &&
s->last_picture[
i]->data[0];
i++)
544 if(
s->ref_frames==0){
556 int plane_index,
level, orientation,
i;
569 if(
s->last_picture[
i] &&
s->last_picture[
i]->data[0]) {
570 av_assert0(
s->last_picture[
i]->data[0] !=
s->current_picture->data[0]);
575 for(plane_index=0; plane_index <
MAX_PLANES; plane_index++){
577 for(orientation=
level ? 1 : 0; orientation<4; orientation++){