32 int src_x,
int src_y,
int src_stride, slice_buffer * sb,
int add, uint8_t * dst8){
37 const uint8_t *obmc1= obmc + y*obmc_stride;
38 const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
39 const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
40 const uint8_t *
obmc4= obmc3+ (obmc_stride>>1);
43 int v= obmc1[x] *
block[3][x + y*src_stride]
44 +obmc2[x] *
block[2][x + y*src_stride]
45 +obmc3[x] *
block[1][x + y*src_stride]
55 if(v&(~255)) v= ~(v>>31);
56 dst8[x + y*src_stride] = v;
69 frame->width =
s->avctx->width ;
70 frame->height =
s->avctx->height;
87 frame->width =
s->avctx->width;
88 frame->height =
s->avctx->height;
95 int plane_index,
level, orientation;
97 for(plane_index=0; plane_index<3; plane_index++){
99 for(orientation=
level ? 1:0; orientation<4; orientation++){
100 memset(
s->plane[plane_index].band[
level][orientation].state,
MID_STATE,
sizeof(
s->plane[plane_index].band[
level][orientation].state));
104 memset(
s->header_state,
MID_STATE,
sizeof(
s->header_state));
105 memset(
s->block_state,
MID_STATE,
sizeof(
s->block_state));
116 s->block =
av_calloc(
w *
h,
sizeof(*
s->block) << (
s->block_max_depth*2));
124 static const uint8_t
weight[64]={
135 static const uint8_t brane[256]={
136 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x11,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
137 0x04,0x05,0xcc,0xcc,0xcc,0xcc,0xcc,0x41,0x15,0x16,0xcc,0xcc,0xcc,0xcc,0xcc,0x52,
138 0x04,0xcc,0x05,0xcc,0xcc,0xcc,0x41,0xcc,0x15,0xcc,0x16,0xcc,0xcc,0xcc,0x52,0xcc,
139 0x04,0xcc,0xcc,0x05,0xcc,0x41,0xcc,0xcc,0x15,0xcc,0xcc,0x16,0xcc,0x52,0xcc,0xcc,
140 0x04,0xcc,0xcc,0xcc,0x41,0xcc,0xcc,0xcc,0x15,0xcc,0xcc,0xcc,0x16,0xcc,0xcc,0xcc,
141 0x04,0xcc,0xcc,0x41,0xcc,0x05,0xcc,0xcc,0x15,0xcc,0xcc,0x52,0xcc,0x16,0xcc,0xcc,
142 0x04,0xcc,0x41,0xcc,0xcc,0xcc,0x05,0xcc,0x15,0xcc,0x52,0xcc,0xcc,0xcc,0x16,0xcc,
143 0x04,0x41,0xcc,0xcc,0xcc,0xcc,0xcc,0x05,0x15,0x52,0xcc,0xcc,0xcc,0xcc,0xcc,0x16,
144 0x44,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x55,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
145 0x48,0x49,0xcc,0xcc,0xcc,0xcc,0xcc,0x85,0x59,0x5A,0xcc,0xcc,0xcc,0xcc,0xcc,0x96,
146 0x48,0xcc,0x49,0xcc,0xcc,0xcc,0x85,0xcc,0x59,0xcc,0x5A,0xcc,0xcc,0xcc,0x96,0xcc,
147 0x48,0xcc,0xcc,0x49,0xcc,0x85,0xcc,0xcc,0x59,0xcc,0xcc,0x5A,0xcc,0x96,0xcc,0xcc,
148 0x48,0xcc,0xcc,0xcc,0x49,0xcc,0xcc,0xcc,0x59,0xcc,0xcc,0xcc,0x96,0xcc,0xcc,0xcc,
149 0x48,0xcc,0xcc,0x85,0xcc,0x49,0xcc,0xcc,0x59,0xcc,0xcc,0x96,0xcc,0x5A,0xcc,0xcc,
150 0x48,0xcc,0x85,0xcc,0xcc,0xcc,0x49,0xcc,0x59,0xcc,0x96,0xcc,0xcc,0xcc,0x5A,0xcc,
151 0x48,0x85,0xcc,0xcc,0xcc,0xcc,0xcc,0x49,0x59,0x96,0xcc,0xcc,0xcc,0xcc,0xcc,0x5A,
154 static const uint8_t needs[16]={
164 int16_t *tmpI= tmpIt;
165 uint8_t *tmp2= tmp2t[0];
166 const uint8_t *hpel[11];
168 r= brane[dx + 16*dy]&15;
169 l= brane[dx + 16*dy]>>4;
171 b= needs[l] | needs[
r];
177 for(x=0; x < b_w; x++){
197 if(am&(~255)) am= ~(am>>31);
210 for(y=0; y < b_h; y++){
211 for(x=0; x < b_w+1; x++){
226 if(am&(~255)) am= ~(am>>31);
238 for(y=0; y < b_h; y++){
239 for(x=0; x < b_w; x++){
253 if(am&(~255)) am= ~(am>>31);
267 hpel[ 6]= tmp2t[1] + 1;
270 hpel[ 9]= hpel[1] + 64;
271 hpel[10]= hpel[8] + 1;
273 #define MC_STRIDE(x) (needs[x] ? 64 : stride)
276 int dxy = dx / 8 + dy / 8 * 4;
277 const uint8_t *
src1 = hpel[dxy ];
278 const uint8_t *
src2 = hpel[dxy + 1];
279 const uint8_t *src3 = hpel[dxy + 4];
280 const uint8_t *src4 = hpel[dxy + 5];
287 for(y=0; y < b_h; y++){
288 for(x=0; x < b_w; x++){
289 dst[x]= ((8-dx)*(8-dy)*
src1[x] + dx*(8-dy)*
src2[x]+
290 (8-dx)* dy *src3[x] + dx* dy *src4[x]+32)>>6;
299 const uint8_t *
src1= hpel[l];
300 const uint8_t *
src2= hpel[
r];
303 int a=
weight[((dx&7) + (8*(dy&7)))];
305 for(y=0; y < b_h; y++){
306 for(x=0; x < b_w; x++){
316 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){
319 const unsigned color =
block->color[plane_index];
320 const unsigned color4 =
color*0x01010101;
322 for(y=0; y < b_h; y++){
323 *(uint32_t*)&dst[0 + y*
stride]= color4;
324 *(uint32_t*)&dst[4 + y*
stride]= color4;
325 *(uint32_t*)&dst[8 + y*
stride]= color4;
326 *(uint32_t*)&dst[12+ y*
stride]= color4;
327 *(uint32_t*)&dst[16+ y*
stride]= color4;
328 *(uint32_t*)&dst[20+ y*
stride]= color4;
329 *(uint32_t*)&dst[24+ y*
stride]= color4;
330 *(uint32_t*)&dst[28+ y*
stride]= color4;
333 for(y=0; y < b_h; y++){
334 *(uint32_t*)&dst[0 + y*
stride]= color4;
335 *(uint32_t*)&dst[4 + y*
stride]= color4;
336 *(uint32_t*)&dst[8 + y*
stride]= color4;
337 *(uint32_t*)&dst[12+ y*
stride]= color4;
340 for(y=0; y < b_h; y++){
341 *(uint32_t*)&dst[0 + y*
stride]= color4;
342 *(uint32_t*)&dst[4 + y*
stride]= color4;
345 for(y=0; y < b_h; y++){
346 *(uint32_t*)&dst[0 + y*
stride]= color4;
349 for(y=0; y < b_h; y++){
350 for(x=0; x < b_w; x++){
356 const uint8_t *
src =
s->last_picture[
block->ref]->data[plane_index];
357 const int scale= plane_index ? (2*
s->mv_scale)>>
s->chroma_h_shift : 2*
s->mv_scale;
362 const int tab_index= 3 - (b_w>>2) + (b_w>>4);
377 av_assert2((tab_index>=0 && tab_index<4) || b_w==32);
379 || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h)
383 || !
s->plane[plane_index].fast_mc )
387 for(y=0; y<b_h; y+=16){
392 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst,
src + 3 + 3*
stride,
stride);
394 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst ,
src + 3 + 3*
stride,
stride);
395 s->h264qpel.put_h264_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst+b_h,
src + 3 + b_h + 3*
stride,
stride);
398 s->h264qpel.put_h264_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst ,
src + 3 + 3*
stride ,
stride);
404 #define mca(dx,dy,b_w)\
405 static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h){\
407 mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, stride, b_w, b_w, dx, dy);\
419 static
av_cold void snow_static_init(
void)
434 s->spatial_decomposition_count = 1;
442 s->qdsp.put_qpel_pixels_tab [0][dy+dx/4]=\
443 s->qdsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\
444 s->h264qpel.put_h264_qpel_pixels_tab[0][dy+dx/4];\
445 s->qdsp.put_qpel_pixels_tab [1][dy+dx/4]=\
446 s->qdsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\
447 s->h264qpel.put_h264_qpel_pixels_tab[1][dy+dx/4];
467 s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\
468 s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\
469 mc_block_hpel ## dx ## dy ## 16;\
470 s->hdsp.put_pixels_tab [1][dy/4+dx/8]=\
471 s->hdsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\
472 mc_block_hpel ## dx ## dy ## 8;
493 if (!
s->last_picture[
i])
499 if (!
s->mconly_picture || !
s->current_picture)
509 int plane_index,
level, orientation;
510 int ret, emu_buf_size;
526 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));
587 if(
s->last_picture[
s->max_ref_frames-1]->data[0]){
598 tmp=
s->last_picture[
s->max_ref_frames-1];
599 for(
i=
s->max_ref_frames-1;
i>0;
i--)
600 s->last_picture[
i] =
s->last_picture[
i-1];
601 s->last_picture[0] =
s->current_picture;
602 s->current_picture =
tmp;
608 for(
i=0;
i<
s->max_ref_frames &&
s->last_picture[
i]->data[0];
i++)
609 if(
i &&
s->last_picture[
i-1]->key_frame)
612 if(
s->ref_frames==0){
620 s->current_picture->key_frame=
s->keyframe;
627 int plane_index,
level, orientation,
i;
647 if(
s->last_picture[
i] &&
s->last_picture[
i]->data[0]) {
648 av_assert0(
s->last_picture[
i]->data[0] !=
s->current_picture->data[0]);
653 for(plane_index=0; plane_index <
MAX_PLANES; plane_index++){
655 for(orientation=
level ? 1 : 0; orientation<4; orientation++){