59 memset(score, 0,
sizeof(*score)*score_stride*((p->
height + Q2_STEP-1)/Q2_STEP));
60 for(y=0; y<p->
height; y++){
61 for(x=0; x<p->
width; x++){
62 int sx= (x-xo + step/2) / step / Q2_STEP;
63 int sy= (y-yo + step/2) / step / Q2_STEP;
65 assert(sx>=0 && sy>=0 && sx < score_stride);
67 score[sx + sy*score_stride] += v*
v;
68 assert(score[sx + sy*score_stride] >= 0);
74 int level, orientation;
77 for(orientation=level ? 1 : 0; orientation<4; orientation++){
90 const int score_stride= (width + 10)/Q2_STEP;
91 int best_score[(width + 10)/Q2_STEP * (height + 10)/Q2_STEP];
92 int score[(width + 10)/Q2_STEP * (height + 10)/Q2_STEP];
101 for(orientation=level ? 1 : 0; orientation<4; orientation++){
105 assert(src == b->
buf);
110 for(pass=0; pass<1; pass++){
114 for(orientation=level ? 1 : 0; orientation<4; orientation++){
119 for(ys= 0; ys<Q2_STEP; ys++){
120 for(xs= 0; xs<Q2_STEP; xs++){
121 memcpy(idwt2_buffer, best_dequant, height * stride *
sizeof(
IDWTELEM));
122 dequantize_all(s, p, idwt2_buffer, width, height);
124 find_sse(s, p, best_score, score_stride, idwt2_buffer, s->
spatial_idwt_buffer, level, orientation);
125 memcpy(idwt2_buffer, best_dequant, height * stride *
sizeof(
IDWTELEM));
126 for(y=ys; y<b->
height; y+= Q2_STEP){
127 for(x=xs; x<b->
width; x+= Q2_STEP){
133 dequantize_all(s, p, idwt2_buffer, width, height);
135 find_sse(s, p, score, score_stride, idwt2_buffer, s->
spatial_idwt_buffer, level, orientation);
136 for(y=ys; y<b->
height; y+= Q2_STEP){
137 for(x=xs; x<b->
width; x+= Q2_STEP){
138 int score_idx= x/Q2_STEP + (y/Q2_STEP)*score_stride;
139 if(score[score_idx] <= best_score[score_idx] + threshold){
140 best_score[score_idx]= score[score_idx];
141 if(best_dst[x + y*b->
stride]<0) best_dst[x + y*b->
stride]++;
142 if(best_dst[x + y*b->
stride]>0) best_dst[x + y*b->
stride]--;
160 int plane_index, ret;
163 av_log(avctx,
AV_LOG_ERROR,
"This codec is under development, files encoded with it may not be decodable with future versions!!!\n"
164 "Use vstrict=-2 / -strict -2 to use it anyway.\n");
180 for(plane_index=0; plane_index<3; plane_index++){
263 for (i = 0; i < h; i++) {
264 for (j = 0; j < w; j++) {
268 pix += line_size - w;
280 for (i = 0; i < w; i++) {
281 for (j = 0; j < w; j ++) {
285 pix += line_size - w;
296 return (3*lambda)>>(FF_LAMBDA_SHIFT+1);
317 #define P_TOPRIGHT P[3]
318 #define P_MEDIAN P[4]
320 #define FLAG_QPEL 1 //must be 1
330 int score, score2, iscore, i_len, p_len, block_s, sum, base_bits;
334 const int index= (x + y*w) << rem_depth;
336 int trx= (x+1)<<rem_depth;
337 int try= (y+1)<<rem_depth;
343 const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->
block[index-w+(1<<rem_depth)] : tl;
344 int pl = left->
color[0];
345 int pcb= left->
color[1];
346 int pcr= left->
color[2];
356 int16_t last_mv[3][2];
358 const int shift= 1+qpel;
364 int ref, best_ref, ref_score, ref_mx, ref_my;
368 set_blocks(s, level, x, y, pl, pcb, pcr, 0, 0, 0,
BLOCK_INTRA);
383 last_mv[1][0]= right->
mx;
384 last_mv[1][1]= right->
my;
385 last_mv[2][0]= bottom->
mx;
386 last_mv[2][1]= bottom->
my;
393 assert(c-> stride == stride);
401 c->
xmin = - x*block_w - 16+3;
402 c->
ymin = - y*block_w - 16+3;
433 assert(ref_mx >= c->
xmin);
434 assert(ref_mx <= c->xmax);
435 assert(ref_my >= c->
ymin);
436 assert(ref_my <= c->ymax);
446 if(score > ref_score){
459 pc.bytestream= p_buffer;
463 put_rac(&pc, &p_state[4 + s_context], 1);
466 put_symbol(&pc, &p_state[128 + 1024 + 32*ref_context], best_ref, 0);
467 pred_mv(s, &pmx, &pmy, best_ref, left, top, tr);
468 put_symbol(&pc, &p_state[128 + 32*(mx_context + 16*!!best_ref)], mx - pmx, 1);
469 put_symbol(&pc, &p_state[128 + 32*(my_context + 16*!!best_ref)], my - pmy, 1);
470 p_len= pc.bytestream - pc.bytestream_start;
473 block_s= block_w*block_w;
474 sum =
pix_sum(current_data[0], stride, block_w, block_w);
475 l= (sum + block_s/2)/block_s;
476 iscore =
pix_norm1(current_data[0], stride, block_w) - 2*l*sum + l*l*block_s;
480 cb= (sum + block_s/2)/block_s;
483 cr= (sum + block_s/2)/block_s;
488 ic.bytestream= i_buffer;
491 put_rac(&ic, &i_state[4 + s_context], 1);
496 i_len= ic.bytestream - ic.bytestream_start;
500 assert(iscore < 255*255*256 + s->lambda2*10);
502 assert(l>=0 && l<=255);
503 assert(pl>=0 && pl<=255);
506 int varc= iscore >> 8;
507 int vard= score >> 8;
508 if (vard <= 64 || vard < varc)
522 if(score2 < score && score2 < iscore)
527 pred_mv(s, &pmx, &pmy, 0, left, top, tr);
528 memcpy(pbbak, i_buffer, i_len);
532 set_blocks(s, level, x, y, l, cb, cr, pmx, pmy, 0,
BLOCK_INTRA);
536 memcpy(pbbak, p_buffer, p_len);
540 set_blocks(s, level, x, y, pl, pcb, pcr, mx, my, best_ref, 0);
549 const int index= (x + y*w) << rem_depth;
550 int trx= (x+1)<<rem_depth;
555 const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->
block[index-w+(1<<rem_depth)] : tl;
556 int pl = left->
color[0];
557 int pcb= left->
color[1];
558 int pcr= left->
color[2];
566 set_blocks(s, level, x, y, pl, pcb, pcr, 0, 0, 0,
BLOCK_INTRA);
583 pred_mv(s, &pmx, &pmy, 0, left, top, tr);
588 set_blocks(s, level, x, y, b->
color[0], b->
color[1], b->
color[2], pmx, pmy, 0,
BLOCK_INTRA);
590 pred_mv(s, &pmx, &pmy, b->
ref, left, top, tr);
596 set_blocks(s, level, x, y, pl, pcb, pcr, b->
mx, b->
my, b->
ref, 0);
604 const int block_w = plane_index ? block_size>>s->
chroma_h_shift : block_size;
605 const int block_h = plane_index ? block_size>>s->
chroma_v_shift : block_size;
607 const int obmc_stride= plane_index ? (2*block_size)>>s->
chroma_h_shift : 2*block_size;
609 uint8_t *src= s-> input_picture.data[plane_index];
612 const int w= p->
width;
614 int index= mb_x + mb_y*b_stride;
623 b->
color[plane_index]= 0;
624 memset(dst, 0, obmc_stride*obmc_stride*
sizeof(
IDWTELEM));
627 int mb_x2= mb_x + (i &1) - 1;
628 int mb_y2= mb_y + (i>>1) - 1;
629 int x= block_w*mb_x2 + block_w/2;
630 int y= block_h*mb_y2 + block_h/2;
633 x, y, block_w, block_h, w, h, obmc_stride, ref_stride, obmc_stride, mb_x2, mb_y2, 0, 0, plane_index);
635 for(y2=
FFMAX(y, 0); y2<
FFMIN(h, y+block_h); y2++){
636 for(x2=
FFMAX(x, 0); x2<
FFMIN(w, x+block_w); x2++){
637 int index= x2-(block_w*mb_x - block_w/2) + (y2-(block_h*mb_y - block_h/2))*obmc_stride;
638 int obmc_v= obmc[
index];
640 if(y<0) obmc_v += obmc[index + block_h*obmc_stride];
641 if(x<0) obmc_v += obmc[index + block_w];
642 if(y+block_h>h) obmc_v += obmc[index - block_h*obmc_stride];
643 if(x+block_w>w) obmc_v += obmc[index - block_w];
648 ab += (src[x2 + y2*ref_stride] - (d>>
FRAC_BITS)) * obmc_v;
649 aa += obmc_v * obmc_v;
661 int index= x + y*b_stride;
665 const BlockNode *tl = y && x ? &s->
block[index-b_stride-1] : left;
666 const BlockNode *tr = y && x+w<b_stride ? &s->
block[index-b_stride+w] : tl;
671 if(x<0 || x>=b_stride || y>=b_height)
687 pred_mv(s, &dmx, &dmy, b->
ref, left, top, tr);
699 const int block_w = plane_index ? block_size>>s->
chroma_h_shift : block_size;
700 const int block_h = plane_index ? block_size>>s->
chroma_v_shift : block_size;
701 const int obmc_stride= plane_index ? (2*block_size)>>s->
chroma_h_shift : 2*block_size;
704 uint8_t *src= s-> input_picture.data[plane_index];
710 const int w= p->
width;
715 int sx= block_w*mb_x - block_w/2;
716 int sy= block_h*mb_y - block_h/2;
717 int x0=
FFMAX(0,-sx);
718 int y0=
FFMAX(0,-sy);
719 int x1=
FFMIN(block_w*2, w-sx);
720 int y1=
FFMIN(block_h*2, h-sy);
725 ff_snow_pred_block(s, cur, tmp, ref_stride, sx, sy, block_w*2, block_h*2, &s->
block[mb_x + mb_y*b_stride], plane_index, w, h);
727 for(y=y0; y<y1; y++){
728 const uint8_t *obmc1= obmc_edged[
y];
730 uint8_t *cur1 = cur + y*ref_stride;
731 uint8_t *dst1 = dst + sx + (sy+
y)*ref_stride;
732 for(x=x0; x<x1; x++){
733 #if FRAC_BITS >= LOG2_OBMC_MAX
739 if(v&(~255)) v= ~(v>>31);
746 && (mb_x == 0 || mb_x == b_stride-1)
747 && (mb_y == 0 || mb_y == b_height-1)){
757 memcpy(dst + sx+x0 + (sy+y)*ref_stride, cur + x0 + y*ref_stride, x1-x0);
768 distortion =
ff_w97_32_c(&s->
m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, 32);
770 distortion =
ff_w53_32_c(&s->
m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, 32);
774 int off = sx+16*(i&1) + (sy+16*(i>>1))*ref_stride;
775 distortion += s->
dsp.
me_cmp[0](&s->
m, src +
off, dst +
off, ref_stride, 16);
780 distortion = s->
dsp.
me_cmp[0](&s->
m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, block_w*2);
789 rate +=
get_block_bits(s, mb_x + (i&1) - (i>>1), mb_y + (i>>1), 1);
791 if(mb_x == b_stride-2)
794 return distortion + rate*penalty_factor;
801 const int block_w = plane_index ? block_size>>s->
chroma_h_shift : block_size;
802 const int block_h = plane_index ? block_size>>s->
chroma_v_shift : block_size;
804 const int obmc_stride= plane_index ? (2*block_size)>>s->
chroma_h_shift : 2*block_size;
807 uint8_t *src= s-> input_picture.data[plane_index];
812 const int w= p->
width;
821 int mb_x2= mb_x + (i%3) - 1;
822 int mb_y2= mb_y + (i/3) - 1;
823 int x= block_w*mb_x2 + block_w/2;
824 int y= block_h*mb_y2 + block_h/2;
827 x, y, block_w, block_h, w, h, 0, ref_stride, obmc_stride, mb_x2, mb_y2, 1, 1, plane_index);
830 for(y2= y; y2<0; y2++)
831 memcpy(dst + x + y2*ref_stride, src + x + y2*ref_stride, block_w);
832 for(y2= h; y2<y+block_h; y2++)
833 memcpy(dst + x + y2*ref_stride, src + x + y2*ref_stride, block_w);
835 for(y2= y; y2<y+block_h; y2++)
836 memcpy(dst + x + y2*ref_stride, src + x + y2*ref_stride, -x);
839 for(y2= y; y2<y+block_h; y2++)
840 memcpy(dst + w + y2*ref_stride, src + w + y2*ref_stride, x+block_w - w);
843 assert(block_w== 8 || block_w==16);
844 distortion += s->
dsp.
me_cmp[block_w==8](&s->
m, src + x + y*ref_stride, dst + x + y*ref_stride, ref_stride, block_h);
858 for(i=merged?4:0; i<9; i++){
859 static const int dxy[9][2] = {{0,0},{1,0},{0,1},{1,1},{2,0},{2,1},{-1,2},{0,2},{1,2}};
863 return distortion + rate*penalty_factor;
867 const int w= b->
width;
880 int l=0, lt=0,
t=0, rt=0;
884 t= src[x + (y-1)*stride];
886 lt= src[x - 1 + (y-1)*stride];
889 rt= src[x + 1 + (y-1)*stride];
902 if(px<b->parent->width && py<b->parent->height)
903 p= parent[px + py*2*
stride];
907 runs[run_index++]=
run;
915 max_index= run_index;
916 runs[run_index++]=
run;
918 run= runs[run_index++];
921 if(run_index <= max_index)
931 int l=0, lt=0,
t=0, rt=0;
935 t= src[x + (y-1)*stride];
937 lt= src[x - 1 + (y-1)*stride];
940 rt= src[x + 1 + (y-1)*stride];
953 if(px<b->parent->width && py<b->parent->height)
954 p= parent[px + py*2*
stride];
962 run= runs[run_index++];
964 if(run_index <= max_index)
974 int l2= 2*
FFABS(l) + (l<0);
1000 assert(mb_x>=0 && mb_y>=0);
1001 assert(mb_x<b_stride);
1004 block->
color[0] = p[0];
1005 block->
color[1] = p[1];
1006 block->
color[2] = p[2];
1035 int p[2] = {p0, p1};
1036 return check_block(s, mb_x, mb_y, p, 0, obmc_edged, best_rd);
1049 backup[0] = block[0];
1050 backup[1] = block[1];
1051 backup[2] = block[b_stride];
1052 backup[3] = block[b_stride + 1];
1054 assert(mb_x>=0 && mb_y>=0);
1055 assert(mb_x<b_stride);
1056 assert(((mb_x|mb_y)&1) == 0);
1068 block[1]= block[b_stride]= block[b_stride+1]= *
block;
1077 block[0]= backup[0];
1078 block[1]= backup[1];
1079 block[b_stride]= backup[2];
1080 block[b_stride+1]= backup[3];
1086 int pass, mb_x, mb_y;
1089 const int b_stride= b_width;
1096 for(mb_y= 0; mb_y<s->
b_height; mb_y++)
1097 for(mb_x= 0; mb_x<s->
b_width; mb_x++)
1103 for(pass=0; pass<25; pass++){
1106 for(mb_y= 0; mb_y<b_height; mb_y++){
1107 for(mb_x= 0; mb_x<b_width; mb_x++){
1108 int dia_change, i, j, ref;
1109 int best_rd= INT_MAX, ref_rd;
1111 const int index= mb_x + mb_y * b_stride;
1120 BlockNode *brb= mb_x+1<b_width && mb_y+1<b_height ? &s->
block[index+b_stride+1] :
NULL;
1137 for (y = 0; y < b_w * 2; y++)
1140 for(y=0; y<b_w*2; y++)
1141 memset(obmc_edged[y], obmc_edged[y][0] + obmc_edged[y][b_w-1], b_w);
1142 if(mb_x==b_stride-1)
1143 for(y=0; y<b_w*2; y++)
1144 memset(obmc_edged[y]+b_w, obmc_edged[y][b_w] + obmc_edged[y][b_w*2-1], b_w);
1146 for(x=0; x<b_w*2; x++)
1147 obmc_edged[0][x] += obmc_edged[b_w-1][x];
1148 for(y=1; y<b_w; y++)
1149 memcpy(obmc_edged[y], obmc_edged[0], b_w*2);
1151 if(mb_y==b_height-1){
1152 for(x=0; x<b_w*2; x++)
1153 obmc_edged[b_w*2-1][x] += obmc_edged[b_w][x];
1154 for(y=b_w; y<b_w*2-1; y++)
1155 memcpy(obmc_edged[y], obmc_edged[b_w*2-1], b_w*2);
1160 if(mb_x==0 || mb_y==0 || mb_x==b_width-1 || mb_y==b_height-1){
1161 uint8_t *src= s-> input_picture.data[0];
1166 const int sx= block_w*mb_x - block_w/2;
1167 const int sy= block_h*mb_y - block_h/2;
1173 memcpy(dst + sx + y*stride, src + sx + y*stride, block_w*2);
1174 for(y=h; y<sy+block_h*2; y++)
1175 memcpy(dst + sx + y*stride, src + sx + y*stride, block_w*2);
1177 for(y=sy; y<sy+block_h*2; y++)
1178 memcpy(dst + sx + y*stride, src + sx + y*stride, -sx);
1180 if(sx+block_w*2 > w){
1181 for(y=sy; y<sy+block_h*2; y++)
1182 memcpy(dst + w + y*stride, src + w + y*stride, sx+block_w*2 - w);
1188 color[i]=
get_dc(s, mb_x, mb_y, i);
1193 check_block(s, mb_x, mb_y, color0, 1, obmc_edged, &best_rd);
1209 check_block_inter(s, mb_x, mb_y, mvr[-b_stride][0], mvr[-b_stride][1], obmc_edged, &best_rd);
1215 check_block_inter(s, mb_x, mb_y, mvr[b_stride][0], mvr[b_stride][1], obmc_edged, &best_rd);
1223 dia_change |=
check_block_inter(s, mb_x, mb_y, block->
mx+4*(i-j), block->
my+(4*j), obmc_edged, &best_rd);
1224 dia_change |=
check_block_inter(s, mb_x, mb_y, block->
mx-4*(i-j), block->
my-(4*j), obmc_edged, &best_rd);
1225 dia_change |=
check_block_inter(s, mb_x, mb_y, block->
mx+4*(i-j), block->
my-(4*j), obmc_edged, &best_rd);
1226 dia_change |=
check_block_inter(s, mb_x, mb_y, block->
mx-4*(i-j), block->
my+(4*j), obmc_edged, &best_rd);
1232 static const int square[8][2]= {{+1, 0},{-1, 0},{ 0,+1},{ 0,-1},{+1,+1},{-1,-1},{+1,-1},{-1,+1},};
1235 dia_change |=
check_block_inter(s, mb_x, mb_y, block->
mx+square[i][0], block->
my+square[i][1], obmc_edged, &best_rd);
1239 mvr[0][0]= block->
mx;
1240 mvr[0][1]= block->
my;
1241 if(ref_rd > best_rd){
1248 check_block(s, mb_x, mb_y, color, 1, obmc_edged, &best_rd);
1270 for(mb_y= 0; mb_y<b_height; mb_y+=2){
1271 for(mb_x= 0; mb_x<b_width; mb_x+=2){
1273 int best_rd, init_rd;
1274 const int index= mb_x + mb_y * b_stride;
1279 b[2]= b[0]+b_stride;
1294 (b[0]->mx + b[1]->mx + b[2]->mx + b[3]->mx + 2) >> 2,
1295 (b[0]->my + b[1]->my + b[2]->my + b[3]->my + 2) >> 2, 0, &best_rd);
1301 if(init_rd != best_rd)
1332 const int w= b->
width;
1341 dst[x + y*stride]= src[x + y*stride];
1345 bias= bias ? 0 : (3*qmul)>>3;
1352 int i= src[x + y*
stride];
1354 if((
unsigned)(i+thres1) > thres2){
1372 int i= src[x + y*
stride];
1374 if((
unsigned)(i+thres1) > thres2){
1377 i= (i + bias) / qmul;
1382 i= (i + bias) / qmul;
1393 const int w= b->
width;
1404 int i= src[x + y*
stride];
1415 const int w= b->
width;
1419 for(y=h-1; y>=0; y--){
1420 for(x=w-1; x>=0; x--){
1425 if(y && x+1<w) src[i] -=
mid_pred(src[i - 1], src[i - stride], src[i - stride + 1]);
1426 else src[i] -= src[i - 1];
1428 if(y) src[i] -=
mid_pred(src[i - 1], src[i - stride], src[i - 1] + src[i - stride] - src[i - 1 - stride]);
1429 else src[i] -= src[i - 1];
1432 if(y) src[i] -= src[i -
stride];
1439 const int w= b->
width;
1449 if(y && x+1<w) src[i] +=
mid_pred(src[i - 1], src[i - stride], src[i - stride + 1]);
1450 else src[i] += src[i - 1];
1452 if(y) src[i] +=
mid_pred(src[i - 1], src[i - stride], src[i - 1] + src[i - stride] - src[i - 1 - stride]);
1453 else src[i] += src[i - 1];
1456 if(y) src[i] += src[i -
stride];
1463 int plane_index,
level, orientation;
1465 for(plane_index=0; plane_index<2; plane_index++){
1467 for(orientation=level ? 1:0; orientation<4; orientation++){
1468 if(orientation==2)
continue;
1479 memset(kstate,
MID_STATE,
sizeof(kstate));
1489 for(plane_index=0; plane_index<2; plane_index++){
1514 for(plane_index=0; plane_index<2; plane_index++){
1522 for(plane_index=0; plane_index<2; plane_index++){
1526 for(i= p->
htaps/2; i; i--)
1550 for(plane_index=0; plane_index<2; plane_index++){
1576 uint32_t coef_sum= 0;
1577 int level, orientation, delta_qlog;
1580 for(orientation=level ? 1 : 0; orientation<4; orientation++){
1583 const int w= b->
width;
1585 const int stride= b->
stride;
1588 const int qdiv= (1<<16)/qmul;
1593 buf[x+y*stride]= b->
buf[x+y*stride];
1598 coef_sum+= abs(buf[x+y*stride]) * qdiv >> 16;
1603 coef_sum = (uint64_t)coef_sum * coef_sum >> 16;
1604 assert(coef_sum < INT_MAX);
1619 s->
qlog+= delta_qlog;
1624 int width = p->
width;
1626 int level, orientation, x,
y;
1629 for(orientation=level ? 1 : 0; orientation<4; orientation++){
1638 for(x=0; x<
width; x++){
1644 b->
qlog= (int)(log(352256.0/sqrt(error)) / log(pow(2.0, 1.0/
QROOT))+0.5);
1650 const AVFrame *pict,
int *got_packet)
1657 int level, orientation, plane_index, i,
y, ret;
1670 for(y=0; y<(height>>vshift); y++)
1675 width >> hshift, height >> vshift,
1714 int block_width = (width +15)>>4;
1715 int block_height= (height+15)>>4;
1724 s->
m. new_picture.f.data[0] = s-> input_picture.data[0];
1725 s->
m. last_picture_ptr= &s->
m. last_picture;
1777 for(plane_index=0; plane_index<3; plane_index++){
1787 for(plane_index=0; plane_index<3; plane_index++){
1796 if(pict->
data[plane_index])
1837 if (delta_qlog <= INT_MIN)
1850 for(orientation=level ? 1 : 0; orientation<4; orientation++){
1866 for(orientation=level ? 1 : 0; orientation<4; orientation++){
1888 pict->
data[plane_index][y*pict->
linesize[plane_index] + x];
1899 if(pict->
data[plane_index])
1958 #define OFFSET(x) offsetof(SnowContext, x)
1959 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1961 {
"memc_only",
"Only do ME/MC (I frames -> ref, P frame -> ME+MC).",
OFFSET(memc_only),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
1962 {
"no_bitstream",
"Skip final bitstream writeout.",
OFFSET(no_bitstream),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
2001 int buffer[2][width*
height];
2013 printf(
"testing 5/3 DWT\n");
2014 for(i=0; i<width*
height; i++)
2015 buffer[0][i] = buffer[1][i] =
av_lfg_get(&prng) % 54321 - 12345;
2020 for(i=0; i<width*
height; i++)
2021 if(buffer[0][i]!= buffer[1][i]) printf(
"fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
2023 printf(
"testing 9/7 DWT\n");
2025 for(i=0; i<width*
height; i++)
2026 buffer[0][i] = buffer[1][i] =
av_lfg_get(&prng) % 54321 - 12345;
2031 for(i=0; i<width*
height; i++)
2032 if(
FFABS(buffer[0][i] - buffer[1][i])>20) printf(
"fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
2035 int level, orientation, x,
y;
2036 int64_t errors[8][4];
2039 memset(errors, 0,
sizeof(errors));
2043 for(orientation=level ? 1 : 0; orientation<4; orientation++){
2050 if(orientation&1) buf+=w;
2051 if(orientation>1) buf+=stride>>1;
2053 memset(buffer[0], 0,
sizeof(
int)*width*height);
2054 buf[w/2 + h/2*
stride]= 256*256;
2057 for(x=0; x<
width; x++){
2058 int64_t d= buffer[0][x + y*
width];
2060 if(
FFABS(width/2-x)<9 &&
FFABS(height/2-y)<9 && level==2) printf(
"%8"PRId64
" ", d);
2062 if(
FFABS(height/2-y)<9 && level==2) printf(
"\n");
2064 error= (int)(sqrt(error)+0.5);
2065 errors[
level][orientation]= error;
2066 if(g) g=
av_gcd(g, error);
2070 printf(
"static int const visual_weight[][4]={\n");
2073 for(orientation=0; orientation<4; orientation++){
2074 printf(
"%8"PRId64
",", errors[level][orientation]/g);
2090 memset(buffer[0], 0,
sizeof(
int)*width*height);
2092 for(x=0; x<
width; x++){
2093 int tab[4]={0,2,3,1};
2094 buffer[0][x+width*
y]= 256*256*tab[(x&1) + 2*(y&1)];
2099 for(x=0; x<
width; x++){
2100 int64_t d= buffer[0][x + y*
width];
2102 if(
FFABS(width/2-x)<9 &&
FFABS(height/2-y)<9) printf(
"%8"PRId64
" ", d);
2104 if(
FFABS(height/2-y)<9) printf(
"\n");