38 int src_x,
int src_y,
int src_stride, slice_buffer * sb,
int add, uint8_t * dst8){
43 const uint8_t *obmc1= obmc + y*obmc_stride;
44 const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
45 const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
46 const uint8_t *
obmc4= obmc3+ (obmc_stride>>1);
49 int v= obmc1[x] *
block[3][x + y*src_stride]
50 +obmc2[x] *
block[2][x + y*src_stride]
51 +obmc3[x] *
block[1][x + y*src_stride]
61 if(v&(~255)) v= ~(v>>31);
62 dst8[x + y*src_stride] = v;
75 frame->width =
s->avctx->width ;
76 frame->height =
s->avctx->height;
93 frame->width =
s->avctx->width;
94 frame->height =
s->avctx->height;
101 int plane_index,
level, orientation;
103 for(plane_index=0; plane_index<3; plane_index++){
105 for(orientation=
level ? 1:0; orientation<4; orientation++){
106 memset(
s->plane[plane_index].band[
level][orientation].state,
MID_STATE,
sizeof(
s->plane[plane_index].band[
level][orientation].state));
110 memset(
s->header_state,
MID_STATE,
sizeof(
s->header_state));
111 memset(
s->block_state,
MID_STATE,
sizeof(
s->block_state));
122 s->block =
av_calloc(
w *
h,
sizeof(*
s->block) << (
s->block_max_depth*2));
130 static const uint8_t
weight[64]={
141 static const uint8_t brane[256]={
142 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x11,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
143 0x04,0x05,0xcc,0xcc,0xcc,0xcc,0xcc,0x41,0x15,0x16,0xcc,0xcc,0xcc,0xcc,0xcc,0x52,
144 0x04,0xcc,0x05,0xcc,0xcc,0xcc,0x41,0xcc,0x15,0xcc,0x16,0xcc,0xcc,0xcc,0x52,0xcc,
145 0x04,0xcc,0xcc,0x05,0xcc,0x41,0xcc,0xcc,0x15,0xcc,0xcc,0x16,0xcc,0x52,0xcc,0xcc,
146 0x04,0xcc,0xcc,0xcc,0x41,0xcc,0xcc,0xcc,0x15,0xcc,0xcc,0xcc,0x16,0xcc,0xcc,0xcc,
147 0x04,0xcc,0xcc,0x41,0xcc,0x05,0xcc,0xcc,0x15,0xcc,0xcc,0x52,0xcc,0x16,0xcc,0xcc,
148 0x04,0xcc,0x41,0xcc,0xcc,0xcc,0x05,0xcc,0x15,0xcc,0x52,0xcc,0xcc,0xcc,0x16,0xcc,
149 0x04,0x41,0xcc,0xcc,0xcc,0xcc,0xcc,0x05,0x15,0x52,0xcc,0xcc,0xcc,0xcc,0xcc,0x16,
150 0x44,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x55,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
151 0x48,0x49,0xcc,0xcc,0xcc,0xcc,0xcc,0x85,0x59,0x5A,0xcc,0xcc,0xcc,0xcc,0xcc,0x96,
152 0x48,0xcc,0x49,0xcc,0xcc,0xcc,0x85,0xcc,0x59,0xcc,0x5A,0xcc,0xcc,0xcc,0x96,0xcc,
153 0x48,0xcc,0xcc,0x49,0xcc,0x85,0xcc,0xcc,0x59,0xcc,0xcc,0x5A,0xcc,0x96,0xcc,0xcc,
154 0x48,0xcc,0xcc,0xcc,0x49,0xcc,0xcc,0xcc,0x59,0xcc,0xcc,0xcc,0x96,0xcc,0xcc,0xcc,
155 0x48,0xcc,0xcc,0x85,0xcc,0x49,0xcc,0xcc,0x59,0xcc,0xcc,0x96,0xcc,0x5A,0xcc,0xcc,
156 0x48,0xcc,0x85,0xcc,0xcc,0xcc,0x49,0xcc,0x59,0xcc,0x96,0xcc,0xcc,0xcc,0x5A,0xcc,
157 0x48,0x85,0xcc,0xcc,0xcc,0xcc,0xcc,0x49,0x59,0x96,0xcc,0xcc,0xcc,0xcc,0xcc,0x5A,
160 static const uint8_t needs[16]={
170 int16_t *tmpI= tmpIt;
171 uint8_t *tmp2= tmp2t[0];
172 const uint8_t *hpel[11];
174 r= brane[dx + 16*dy]&15;
175 l= brane[dx + 16*dy]>>4;
177 b= needs[l] | needs[
r];
183 for(x=0; x < b_w; x++){
203 if(am&(~255)) am= ~(am>>31);
216 for(y=0; y < b_h; y++){
217 for(x=0; x < b_w+1; x++){
232 if(am&(~255)) am= ~(am>>31);
244 for(y=0; y < b_h; y++){
245 for(x=0; x < b_w; x++){
259 if(am&(~255)) am= ~(am>>31);
273 hpel[ 6]= tmp2t[1] + 1;
276 hpel[ 9]= hpel[1] + 64;
277 hpel[10]= hpel[8] + 1;
279 #define MC_STRIDE(x) (needs[x] ? 64 : stride)
282 int dxy = dx / 8 + dy / 8 * 4;
283 const uint8_t *
src1 = hpel[dxy ];
284 const uint8_t *
src2 = hpel[dxy + 1];
285 const uint8_t *src3 = hpel[dxy + 4];
286 const uint8_t *src4 = hpel[dxy + 5];
293 for(y=0; y < b_h; y++){
294 for(x=0; x < b_w; x++){
295 dst[x]= ((8-dx)*(8-dy)*
src1[x] + dx*(8-dy)*
src2[x]+
296 (8-dx)* dy *src3[x] + dx* dy *src4[x]+32)>>6;
305 const uint8_t *
src1= hpel[l];
306 const uint8_t *
src2= hpel[
r];
309 int a=
weight[((dx&7) + (8*(dy&7)))];
311 for(y=0; y < b_h; y++){
312 for(x=0; x < b_w; x++){
322 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){
325 const unsigned color =
block->color[plane_index];
326 const unsigned color4 =
color*0x01010101;
328 for(y=0; y < b_h; y++){
329 *(uint32_t*)&dst[0 + y*
stride]= color4;
330 *(uint32_t*)&dst[4 + y*
stride]= color4;
331 *(uint32_t*)&dst[8 + y*
stride]= color4;
332 *(uint32_t*)&dst[12+ y*
stride]= color4;
333 *(uint32_t*)&dst[16+ y*
stride]= color4;
334 *(uint32_t*)&dst[20+ y*
stride]= color4;
335 *(uint32_t*)&dst[24+ y*
stride]= color4;
336 *(uint32_t*)&dst[28+ y*
stride]= color4;
339 for(y=0; y < b_h; y++){
340 *(uint32_t*)&dst[0 + y*
stride]= color4;
341 *(uint32_t*)&dst[4 + y*
stride]= color4;
342 *(uint32_t*)&dst[8 + y*
stride]= color4;
343 *(uint32_t*)&dst[12+ y*
stride]= color4;
346 for(y=0; y < b_h; y++){
347 *(uint32_t*)&dst[0 + y*
stride]= color4;
348 *(uint32_t*)&dst[4 + y*
stride]= color4;
351 for(y=0; y < b_h; y++){
352 *(uint32_t*)&dst[0 + y*
stride]= color4;
355 for(y=0; y < b_h; y++){
356 for(x=0; x < b_w; x++){
362 uint8_t *
src=
s->last_picture[
block->ref]->data[plane_index];
363 const int scale= plane_index ? (2*
s->mv_scale)>>
s->chroma_h_shift : 2*
s->mv_scale;
368 const int tab_index= 3 - (b_w>>2) + (b_w>>4);
383 av_assert2((tab_index>=0 && tab_index<4) || b_w==32);
385 || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h)
389 || !
s->plane[plane_index].fast_mc )
393 for(y=0; y<b_h; y+=16){
398 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst,
src + 3 + 3*
stride,
stride);
400 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst ,
src + 3 + 3*
stride,
stride);
401 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst+b_h,
src + 3 + b_h + 3*
stride,
stride);
404 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst ,
src + 3 + 3*
stride ,
stride);
410 #define mca(dx,dy,b_w)\
411 static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h){\
413 mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, stride, b_w, b_w, dx, dy);\
425 static
av_cold void snow_static_init(
void)
440 s->spatial_decomposition_count = 1;
449 s->qdsp.put_qpel_pixels_tab [0][dy+dx/4]=\
450 s->qdsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\
451 s->h264qpel.put_h264_qpel_pixels_tab[0][dy+dx/4];\
452 s->qdsp.put_qpel_pixels_tab [1][dy+dx/4]=\
453 s->qdsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\
454 s->h264qpel.put_h264_qpel_pixels_tab[1][dy+dx/4];
474 s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\
475 s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\
476 mc_block_hpel ## dx ## dy ## 16;\
477 s->hdsp.put_pixels_tab [1][dy/4+dx/8]=\
478 s->hdsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\
479 mc_block_hpel ## dx ## dy ## 8;
500 if (!
s->last_picture[
i])
506 if (!
s->mconly_picture || !
s->current_picture)
516 int plane_index,
level, orientation;
517 int ret, emu_buf_size;
533 s->mconly_picture->format != avctx->
pix_fmt) {
538 for(plane_index=0; plane_index <
s->nb_planes; plane_index++){
539 int w=
s->avctx->width;
540 int h=
s->avctx->height;
546 s->plane[plane_index].width =
w;
547 s->plane[plane_index].height=
h;
550 for(orientation=
level ? 1 : 0; orientation<4; orientation++){
553 b->buf=
s->spatial_dwt_buffer;
555 b->stride=
s->plane[plane_index].width << (
s->spatial_decomposition_count -
level);
556 b->width = (
w + !(orientation&1))>>1;
557 b->height= (
h + !(orientation>1))>>1;
559 b->stride_line = 1 << (
s->spatial_decomposition_count -
level);
565 b->buf_x_offset = (
w+1)>>1;
568 b->buf +=
b->stride>>1;
569 b->buf_y_offset =
b->stride_line >> 1;
571 b->ibuf=
s->spatial_idwt_buffer + (
b->buf -
s->spatial_dwt_buffer);
574 b->parent= &
s->plane[plane_index].band[
level-1][orientation];
578 sizeof(*
b->x_coeff));
590 #define USE_HALFPEL_PLANE 0
595 for(p=0; p <
s->nb_planes; p++){
597 int w= is_chroma ?
AV_CEIL_RSHIFT(
s->avctx->width,
s->chroma_h_shift) :
s->avctx->width;
598 int h= is_chroma ?
AV_CEIL_RSHIFT(
s->avctx->height,
s->chroma_v_shift) :
s->avctx->height;
599 int ls=
frame->linesize[p];
605 if (!halfpel[1][p] || !halfpel[2][p] || !halfpel[3][p]) {
649 if(
s->last_picture[
s->max_ref_frames-1]->data[0]){
652 if(
s->halfpel_plane[
s->max_ref_frames-1][1+
i/3][
i%3]) {
654 s->halfpel_plane[
s->max_ref_frames-1][1+
i/3][
i%3] =
NULL;
665 tmp=
s->last_picture[
s->max_ref_frames-1];
666 for(
i=
s->max_ref_frames-1;
i>0;
i--)
667 s->last_picture[
i] =
s->last_picture[
i-1];
668 memmove(
s->halfpel_plane+1,
s->halfpel_plane, (
s->max_ref_frames-1)*
sizeof(
void*)*4*4);
673 s->last_picture[0] =
s->current_picture;
674 s->current_picture =
tmp;
680 for(
i=0;
i<
s->max_ref_frames &&
s->last_picture[
i]->data[0];
i++)
681 if(
i &&
s->last_picture[
i-1]->key_frame)
684 if(
s->ref_frames==0){
692 s->current_picture->key_frame=
s->keyframe;
699 int plane_index,
level, orientation,
i;
720 if(
s->last_picture[
i] &&
s->last_picture[
i]->data[0]) {
721 av_assert0(
s->last_picture[
i]->data[0] !=
s->current_picture->data[0]);
726 for(plane_index=0; plane_index <
MAX_PLANES; plane_index++){
728 for(orientation=
level ? 1 : 0; orientation<4; orientation++){