32 #define pixeltmp int16_t
40 for (
int i = 0;
i <
h; ++
i) {
51 for (
int i = 0;
i <
w; ++
i) {
52 const int srcB =
src[-2*srcStride];
53 const int srcA =
src[-1*srcStride];
54 const int src0 =
src[0 *srcStride];
55 const int src1 =
src[1 *srcStride];
56 const int src2 =
src[2 *srcStride];
57 const int src3 =
src[3 *srcStride];
58 const int src4 =
src[4 *srcStride];
71 for (
int i = 0;
i <
h + 5; ++
i) {
77 tmp -= tmpStride*(
h+5-2);
78 for (
int i = 0;
i <
w; ++
i) {
79 const int tmpB =
tmp[-2*tmpStride];
80 const int tmpA =
tmp[-1*tmpStride];
81 const int tmp0 =
tmp[0 *tmpStride];
82 const int tmp1 =
tmp[1 *tmpStride];
83 const int tmp2 =
tmp[2 *tmpStride];
84 const int tmp3 =
tmp[3 *tmpStride];
85 const int tmp4 =
tmp[4 *tmpStride];
86 dst[0*dstStride] =
av_clip_uint8(((tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3) + 512) >> 10);
87 dst[1*dstStride] =
av_clip_uint8(((tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4) + 512) >> 10);
98 "put_h264_qpel_pixels_tab not at start of H264QpelContext");
100 s->put_snow_qpel_pixels_tab[3][0] = put_snow_qpel2_mc00_8_c;
101 s->put_snow_qpel_pixels_tab[3][1] = put_snow_qpel2_mc10_8_c;
102 s->put_snow_qpel_pixels_tab[3][2] = put_snow_qpel2_mc20_8_c;
103 s->put_snow_qpel_pixels_tab[3][3] = put_snow_qpel2_mc30_8_c;
104 s->put_snow_qpel_pixels_tab[3][4] = put_snow_qpel2_mc01_8_c;
105 s->put_snow_qpel_pixels_tab[3][5] = put_snow_qpel2_mc11_8_c;
106 s->put_snow_qpel_pixels_tab[3][6] = put_snow_qpel2_mc21_8_c;
107 s->put_snow_qpel_pixels_tab[3][7] = put_snow_qpel2_mc31_8_c;
108 s->put_snow_qpel_pixels_tab[3][8] = put_snow_qpel2_mc02_8_c;
109 s->put_snow_qpel_pixels_tab[3][9] = put_snow_qpel2_mc12_8_c;
110 s->put_snow_qpel_pixels_tab[3][10] = put_snow_qpel2_mc22_8_c;
111 s->put_snow_qpel_pixels_tab[3][11] = put_snow_qpel2_mc32_8_c;
112 s->put_snow_qpel_pixels_tab[3][12] = put_snow_qpel2_mc03_8_c;
113 s->put_snow_qpel_pixels_tab[3][13] = put_snow_qpel2_mc13_8_c;
114 s->put_snow_qpel_pixels_tab[3][14] = put_snow_qpel2_mc23_8_c;
115 s->put_snow_qpel_pixels_tab[3][15] = put_snow_qpel2_mc33_8_c;
119 int src_x,
int src_stride,
IDWTELEM *
const *lines,
int add, uint8_t *dst8)
125 for(y=0; y<b_h; y++){
127 const uint8_t *obmc1= obmc + y*obmc_stride;
128 const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
129 const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
130 const uint8_t *
obmc4= obmc3+ (obmc_stride>>1);
134 for(x=0; x<b_w; x++){
135 int v= obmc1[x] *
block[3][x + y*src_stride]
136 +obmc2[x] *
block[2][x + y*src_stride]
137 +obmc3[x] *
block[1][x + y*src_stride]
140 #if FRAC_BITS > LOG2_OBMC_MAX
142 #elif FRAC_BITS < LOG2_OBMC_MAX
148 if(v&(~255)) v= ~(v>>31);
149 dst8[x + y*src_stride] = v;
158 int plane_index,
level, orientation;
160 for(plane_index=0; plane_index<3; plane_index++){
162 for(orientation=
level ? 1:0; orientation<4; orientation++){
163 memset(
s->plane[plane_index].band[
level][orientation].state,
MID_STATE,
sizeof(
s->plane[plane_index].band[
level][orientation].state));
167 memset(
s->header_state,
MID_STATE,
sizeof(
s->header_state));
168 memset(
s->block_state,
MID_STATE,
sizeof(
s->block_state));
179 s->block =
av_calloc(
w *
h,
sizeof(*
s->block) << (
s->block_max_depth*2));
187 static const uint8_t
weight[64]={
198 static const uint8_t brane[256]={
199 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x11,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
200 0x04,0x05,0xcc,0xcc,0xcc,0xcc,0xcc,0x41,0x15,0x16,0xcc,0xcc,0xcc,0xcc,0xcc,0x52,
201 0x04,0xcc,0x05,0xcc,0xcc,0xcc,0x41,0xcc,0x15,0xcc,0x16,0xcc,0xcc,0xcc,0x52,0xcc,
202 0x04,0xcc,0xcc,0x05,0xcc,0x41,0xcc,0xcc,0x15,0xcc,0xcc,0x16,0xcc,0x52,0xcc,0xcc,
203 0x04,0xcc,0xcc,0xcc,0x41,0xcc,0xcc,0xcc,0x15,0xcc,0xcc,0xcc,0x16,0xcc,0xcc,0xcc,
204 0x04,0xcc,0xcc,0x41,0xcc,0x05,0xcc,0xcc,0x15,0xcc,0xcc,0x52,0xcc,0x16,0xcc,0xcc,
205 0x04,0xcc,0x41,0xcc,0xcc,0xcc,0x05,0xcc,0x15,0xcc,0x52,0xcc,0xcc,0xcc,0x16,0xcc,
206 0x04,0x41,0xcc,0xcc,0xcc,0xcc,0xcc,0x05,0x15,0x52,0xcc,0xcc,0xcc,0xcc,0xcc,0x16,
207 0x44,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x55,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
208 0x48,0x49,0xcc,0xcc,0xcc,0xcc,0xcc,0x85,0x59,0x5A,0xcc,0xcc,0xcc,0xcc,0xcc,0x96,
209 0x48,0xcc,0x49,0xcc,0xcc,0xcc,0x85,0xcc,0x59,0xcc,0x5A,0xcc,0xcc,0xcc,0x96,0xcc,
210 0x48,0xcc,0xcc,0x49,0xcc,0x85,0xcc,0xcc,0x59,0xcc,0xcc,0x5A,0xcc,0x96,0xcc,0xcc,
211 0x48,0xcc,0xcc,0xcc,0x49,0xcc,0xcc,0xcc,0x59,0xcc,0xcc,0xcc,0x96,0xcc,0xcc,0xcc,
212 0x48,0xcc,0xcc,0x85,0xcc,0x49,0xcc,0xcc,0x59,0xcc,0xcc,0x96,0xcc,0x5A,0xcc,0xcc,
213 0x48,0xcc,0x85,0xcc,0xcc,0xcc,0x49,0xcc,0x59,0xcc,0x96,0xcc,0xcc,0xcc,0x5A,0xcc,
214 0x48,0x85,0xcc,0xcc,0xcc,0xcc,0xcc,0x49,0x59,0x96,0xcc,0xcc,0xcc,0xcc,0xcc,0x5A,
217 static const uint8_t needs[16]={
227 int16_t *tmpI= tmpIt;
228 uint8_t *tmp2= tmp2t[0];
229 const uint8_t *hpel[11];
231 r= brane[dx + 16*dy]&15;
232 l= brane[dx + 16*dy]>>4;
234 b= needs[l] | needs[
r];
240 for(x=0; x < b_w; x++){
250 if(!
p ||
p->fast_mc){
251 am= 20*(
a2+
a3) - 5*(
a1+a4) + (
a0+a5);
255 am=
p->hcoeff[0]*(
a2+
a3) +
p->hcoeff[1]*(
a1+a4) +
p->hcoeff[2]*(
a0+a5) +
p->hcoeff[3]*(a_1+a6);
260 if(am&(~255)) am= ~(am>>31);
273 for(y=0; y < b_h; y++){
274 for(x=0; x < b_w+1; x++){
285 am= (20*(
a2+
a3) - 5*(
a1+a4) + (
a0+a5) + 16)>>5;
287 am= (
p->hcoeff[0]*(
a2+
a3) +
p->hcoeff[1]*(
a1+a4) +
p->hcoeff[2]*(
a0+a5) +
p->hcoeff[3]*(a_1+a6) + 32)>>6;
289 if(am&(~255)) am= ~(am>>31);
301 for(y=0; y < b_h; y++){
302 for(x=0; x < b_w; x++){
313 am= (20*(
a2+
a3) - 5*(
a1+a4) + (
a0+a5) + 512)>>10;
315 am= (
p->hcoeff[0]*(
a2+
a3) +
p->hcoeff[1]*(
a1+a4) +
p->hcoeff[2]*(
a0+a5) +
p->hcoeff[3]*(a_1+a6) + 2048)>>12;
316 if(am&(~255)) am= ~(am>>31);
330 hpel[ 6]= tmp2t[1] + 1;
333 hpel[ 9]= hpel[1] + 64;
334 hpel[10]= hpel[8] + 1;
336 #define MC_STRIDE(x) (needs[x] ? 64 : stride)
339 int dxy = dx / 8 + dy / 8 * 4;
340 const uint8_t *
src1 = hpel[dxy ];
341 const uint8_t *
src2 = hpel[dxy + 1];
342 const uint8_t *src3 = hpel[dxy + 4];
343 const uint8_t *src4 = hpel[dxy + 5];
350 for(y=0; y < b_h; y++){
351 for(x=0; x < b_w; x++){
352 dst[x]= ((8-dx)*(8-dy)*
src1[x] + dx*(8-dy)*
src2[x]+
353 (8-dx)* dy *src3[x] + dx* dy *src4[x]+32)>>6;
362 const uint8_t *
src1= hpel[l];
363 const uint8_t *
src2= hpel[
r];
366 int a=
weight[((dx&7) + (8*(dy&7)))];
368 for(y=0; y < b_h; y++){
369 for(x=0; x < b_w; x++){
379 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){
382 const unsigned color =
block->color[plane_index];
383 const unsigned color4 =
color*0x01010101;
385 for(y=0; y < b_h; y++){
396 for(y=0; y < b_h; y++){
403 for(y=0; y < b_h; y++){
408 for(y=0; y < b_h; y++){
412 for(y=0; y < b_h; y++){
413 for(x=0; x < b_w; x++){
419 const uint8_t *
src =
s->last_picture[
block->ref]->data[plane_index];
420 const int scale= plane_index ? (2*
s->mv_scale)>>
s->chroma_h_shift : 2*
s->mv_scale;
425 const int tab_index= 3 - (b_w>>2) + (b_w>>4);
440 av_assert2((tab_index>=0 && tab_index<4) || b_w==32);
442 || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h)
446 || !
s->plane[plane_index].fast_mc )
450 for(y=0; y<b_h; y+=16){
458 s->put_snow_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](
dst+b_h,
src + 3 + b_h + 3*
stride,
stride);
467 #define mca(dx,dy,b_w)\
468 static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h){\
470 mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, stride, b_w, b_w, dx, dy);\
482 static
av_cold void snow_static_init(
void)
497 s->spatial_decomposition_count = 1;
505 s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\
506 s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\
507 mc_block_hpel ## dx ## dy ## 16;\
508 s->hdsp.put_pixels_tab [1][dy/4+dx/8]=\
509 s->hdsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\
510 mc_block_hpel ## dx ## dy ## 8;
531 if (!
s->last_picture[
i])
537 if (!
s->mconly_picture || !
s->current_picture)
547 int plane_index,
level, orientation;
554 for(plane_index=0; plane_index <
s->nb_planes; plane_index++){
555 int w=
s->avctx->width;
556 int h=
s->avctx->height;
562 s->plane[plane_index].width =
w;
563 s->plane[plane_index].height=
h;
566 for(orientation=
level ? 1 : 0; orientation<4; orientation++){
569 b->buf=
s->spatial_dwt_buffer;
571 b->stride=
s->plane[plane_index].width << (
s->spatial_decomposition_count -
level);
572 b->width = (
w + !(orientation&1))>>1;
573 b->height= (
h + !(orientation>1))>>1;
575 b->stride_line = 1 << (
s->spatial_decomposition_count -
level);
581 b->buf_x_offset = (
w+1)>>1;
584 b->buf +=
b->stride>>1;
585 b->buf_y_offset =
b->stride_line >> 1;
587 b->ibuf=
s->spatial_idwt_buffer + (
b->buf -
s->spatial_dwt_buffer);
590 b->parent= &
s->plane[plane_index].band[
level-1][orientation];
594 sizeof(*
b->x_coeff));
610 tmp=
s->last_picture[
s->max_ref_frames-1];
611 for (
int i =
s->max_ref_frames - 1;
i > 0;
i--)
612 s->last_picture[
i] =
s->last_picture[
i-1];
613 s->last_picture[0] =
s->current_picture;
614 s->current_picture =
tmp;
623 for(
i=0;
i<
s->max_ref_frames &&
s->last_picture[
i]->data[0];
i++)
627 if(
s->ref_frames==0){
639 int plane_index,
level, orientation,
i;
654 for(plane_index=0; plane_index <
MAX_PLANES; plane_index++){
656 for(orientation=
level ? 1 : 0; orientation<4; orientation++){