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;
90 frame->width =
s->avctx->width;
91 frame->height =
s->avctx->height;
98 int plane_index,
level, orientation;
100 for(plane_index=0; plane_index<3; plane_index++){
102 for(orientation=
level ? 1:0; orientation<4; orientation++){
103 memset(
s->plane[plane_index].band[
level][orientation].state,
MID_STATE,
sizeof(
s->plane[plane_index].band[
level][orientation].state));
107 memset(
s->header_state,
MID_STATE,
sizeof(
s->header_state));
108 memset(
s->block_state,
MID_STATE,
sizeof(
s->block_state));
119 s->block =
av_calloc(
w *
h,
sizeof(*
s->block) << (
s->block_max_depth*2));
127 static const uint8_t
weight[64]={
138 static const uint8_t brane[256]={
139 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x11,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
140 0x04,0x05,0xcc,0xcc,0xcc,0xcc,0xcc,0x41,0x15,0x16,0xcc,0xcc,0xcc,0xcc,0xcc,0x52,
141 0x04,0xcc,0x05,0xcc,0xcc,0xcc,0x41,0xcc,0x15,0xcc,0x16,0xcc,0xcc,0xcc,0x52,0xcc,
142 0x04,0xcc,0xcc,0x05,0xcc,0x41,0xcc,0xcc,0x15,0xcc,0xcc,0x16,0xcc,0x52,0xcc,0xcc,
143 0x04,0xcc,0xcc,0xcc,0x41,0xcc,0xcc,0xcc,0x15,0xcc,0xcc,0xcc,0x16,0xcc,0xcc,0xcc,
144 0x04,0xcc,0xcc,0x41,0xcc,0x05,0xcc,0xcc,0x15,0xcc,0xcc,0x52,0xcc,0x16,0xcc,0xcc,
145 0x04,0xcc,0x41,0xcc,0xcc,0xcc,0x05,0xcc,0x15,0xcc,0x52,0xcc,0xcc,0xcc,0x16,0xcc,
146 0x04,0x41,0xcc,0xcc,0xcc,0xcc,0xcc,0x05,0x15,0x52,0xcc,0xcc,0xcc,0xcc,0xcc,0x16,
147 0x44,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x55,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
148 0x48,0x49,0xcc,0xcc,0xcc,0xcc,0xcc,0x85,0x59,0x5A,0xcc,0xcc,0xcc,0xcc,0xcc,0x96,
149 0x48,0xcc,0x49,0xcc,0xcc,0xcc,0x85,0xcc,0x59,0xcc,0x5A,0xcc,0xcc,0xcc,0x96,0xcc,
150 0x48,0xcc,0xcc,0x49,0xcc,0x85,0xcc,0xcc,0x59,0xcc,0xcc,0x5A,0xcc,0x96,0xcc,0xcc,
151 0x48,0xcc,0xcc,0xcc,0x49,0xcc,0xcc,0xcc,0x59,0xcc,0xcc,0xcc,0x96,0xcc,0xcc,0xcc,
152 0x48,0xcc,0xcc,0x85,0xcc,0x49,0xcc,0xcc,0x59,0xcc,0xcc,0x96,0xcc,0x5A,0xcc,0xcc,
153 0x48,0xcc,0x85,0xcc,0xcc,0xcc,0x49,0xcc,0x59,0xcc,0x96,0xcc,0xcc,0xcc,0x5A,0xcc,
154 0x48,0x85,0xcc,0xcc,0xcc,0xcc,0xcc,0x49,0x59,0x96,0xcc,0xcc,0xcc,0xcc,0xcc,0x5A,
157 static const uint8_t needs[16]={
167 int16_t *tmpI= tmpIt;
168 uint8_t *tmp2= tmp2t[0];
169 const uint8_t *hpel[11];
171 r= brane[dx + 16*dy]&15;
172 l= brane[dx + 16*dy]>>4;
174 b= needs[l] | needs[
r];
180 for(x=0; x < b_w; x++){
200 if(am&(~255)) am= ~(am>>31);
213 for(y=0; y < b_h; y++){
214 for(x=0; x < b_w+1; x++){
229 if(am&(~255)) am= ~(am>>31);
241 for(y=0; y < b_h; y++){
242 for(x=0; x < b_w; x++){
256 if(am&(~255)) am= ~(am>>31);
270 hpel[ 6]= tmp2t[1] + 1;
273 hpel[ 9]= hpel[1] + 64;
274 hpel[10]= hpel[8] + 1;
276 #define MC_STRIDE(x) (needs[x] ? 64 : stride)
279 int dxy = dx / 8 + dy / 8 * 4;
280 const uint8_t *
src1 = hpel[dxy ];
281 const uint8_t *src2 = hpel[dxy + 1];
282 const uint8_t *src3 = hpel[dxy + 4];
283 const uint8_t *src4 = hpel[dxy + 5];
290 for(y=0; y < b_h; y++){
291 for(x=0; x < b_w; x++){
292 dst[x]= ((8-dx)*(8-dy)*
src1[x] + dx*(8-dy)*src2[x]+
293 (8-dx)* dy *src3[x] + dx* dy *src4[x]+32)>>6;
302 const uint8_t *
src1= hpel[l];
303 const uint8_t *src2= hpel[
r];
306 int a=
weight[((dx&7) + (8*(dy&7)))];
308 for(y=0; y < b_h; y++){
309 for(x=0; x < b_w; x++){
310 dst[x]= (
a*
src1[x] +
b*src2[x] + 4)>>3;
319 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){
322 const unsigned color =
block->color[plane_index];
323 const unsigned color4 =
color*0x01010101;
325 for(y=0; y < b_h; y++){
326 *(uint32_t*)&dst[0 + y*
stride]= color4;
327 *(uint32_t*)&dst[4 + y*
stride]= color4;
328 *(uint32_t*)&dst[8 + y*
stride]= color4;
329 *(uint32_t*)&dst[12+ y*
stride]= color4;
330 *(uint32_t*)&dst[16+ y*
stride]= color4;
331 *(uint32_t*)&dst[20+ y*
stride]= color4;
332 *(uint32_t*)&dst[24+ y*
stride]= color4;
333 *(uint32_t*)&dst[28+ y*
stride]= color4;
336 for(y=0; y < b_h; y++){
337 *(uint32_t*)&dst[0 + y*
stride]= color4;
338 *(uint32_t*)&dst[4 + y*
stride]= color4;
339 *(uint32_t*)&dst[8 + y*
stride]= color4;
340 *(uint32_t*)&dst[12+ y*
stride]= color4;
343 for(y=0; y < b_h; y++){
344 *(uint32_t*)&dst[0 + y*
stride]= color4;
345 *(uint32_t*)&dst[4 + y*
stride]= color4;
348 for(y=0; y < b_h; y++){
349 *(uint32_t*)&dst[0 + y*
stride]= color4;
352 for(y=0; y < b_h; y++){
353 for(x=0; x < b_w; x++){
359 uint8_t *
src=
s->last_picture[
block->ref]->data[plane_index];
360 const int scale= plane_index ? (2*
s->mv_scale)>>
s->chroma_h_shift : 2*
s->mv_scale;
365 const int tab_index= 3 - (b_w>>2) + (b_w>>4);
380 av_assert2((tab_index>=0 && tab_index<4) || b_w==32);
382 || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h)
386 || !
s->plane[plane_index].fast_mc )
390 for(y=0; y<b_h; y+=16){
395 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst,
src + 3 + 3*
stride,
stride);
397 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst ,
src + 3 + 3*
stride,
stride);
398 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst+b_h,
src + 3 + b_h + 3*
stride,
stride);
401 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst ,
src + 3 + 3*
stride ,
stride);
407 #define mca(dx,dy,b_w)\
408 static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h){\
410 mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, stride, b_w, b_w, dx, dy);\
422 static
av_cold void snow_static_init(
void)
437 s->spatial_decomposition_count = 1;
446 s->qdsp.put_qpel_pixels_tab [0][dy+dx/4]=\
447 s->qdsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\
448 s->h264qpel.put_h264_qpel_pixels_tab[0][dy+dx/4];\
449 s->qdsp.put_qpel_pixels_tab [1][dy+dx/4]=\
450 s->qdsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\
451 s->h264qpel.put_h264_qpel_pixels_tab[1][dy+dx/4];
471 s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\
472 s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\
473 mc_block_hpel ## dx ## dy ## 16;\
474 s->hdsp.put_pixels_tab [1][dy/4+dx/8]=\
475 s->hdsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\
476 mc_block_hpel ## dx ## dy ## 8;
497 if (!
s->last_picture[
i])
503 if (!
s->mconly_picture || !
s->current_picture)
513 int plane_index,
level, orientation;
514 int ret, emu_buf_size;
526 if(
s->mconly_picture->format != avctx->
pix_fmt) {
531 for(plane_index=0; plane_index <
s->nb_planes; plane_index++){
532 int w=
s->avctx->width;
533 int h=
s->avctx->height;
539 s->plane[plane_index].width =
w;
540 s->plane[plane_index].height=
h;
543 for(orientation=
level ? 1 : 0; orientation<4; orientation++){
546 b->buf=
s->spatial_dwt_buffer;
548 b->stride=
s->plane[plane_index].width << (
s->spatial_decomposition_count -
level);
549 b->width = (
w + !(orientation&1))>>1;
550 b->height= (
h + !(orientation>1))>>1;
552 b->stride_line = 1 << (
s->spatial_decomposition_count -
level);
558 b->buf_x_offset = (
w+1)>>1;
561 b->buf +=
b->stride>>1;
562 b->buf_y_offset =
b->stride_line >> 1;
564 b->ibuf=
s->spatial_idwt_buffer + (
b->buf -
s->spatial_dwt_buffer);
567 b->parent= &
s->plane[plane_index].band[
level-1][orientation];
571 sizeof(*
b->x_coeff));
583 #define USE_HALFPEL_PLANE 0
588 for(p=0; p <
s->nb_planes; p++){
590 int w= is_chroma ?
AV_CEIL_RSHIFT(
s->avctx->width,
s->chroma_h_shift) :
s->avctx->width;
591 int h= is_chroma ?
AV_CEIL_RSHIFT(
s->avctx->height,
s->chroma_v_shift) :
s->avctx->height;
592 int ls=
frame->linesize[p];
598 if (!halfpel[1][p] || !halfpel[2][p] || !halfpel[3][p]) {
642 if(
s->last_picture[
s->max_ref_frames-1]->data[0]){
645 if(
s->halfpel_plane[
s->max_ref_frames-1][1+
i/3][
i%3]) {
647 s->halfpel_plane[
s->max_ref_frames-1][1+
i/3][
i%3] =
NULL;
658 tmp=
s->last_picture[
s->max_ref_frames-1];
659 for(
i=
s->max_ref_frames-1;
i>0;
i--)
660 s->last_picture[
i] =
s->last_picture[
i-1];
661 memmove(
s->halfpel_plane+1,
s->halfpel_plane, (
s->max_ref_frames-1)*
sizeof(
void*)*4*4);
666 s->last_picture[0] =
s->current_picture;
667 s->current_picture =
tmp;
673 for(
i=0;
i<
s->max_ref_frames &&
s->last_picture[
i]->data[0];
i++)
674 if(
i &&
s->last_picture[
i-1]->key_frame)
677 if(
s->ref_frames==0){
685 s->current_picture->key_frame=
s->keyframe;
692 int plane_index,
level, orientation,
i;
713 if(
s->last_picture[
i] &&
s->last_picture[
i]->data[0]) {
714 av_assert0(
s->last_picture[
i]->data[0] !=
s->current_picture->data[0]);
719 for(plane_index=0; plane_index <
MAX_PLANES; plane_index++){
721 for(orientation=
level ? 1 : 0; orientation<4; orientation++){