comparison snow.c @ 5652:941e5deeb2a4 libavcodec

rename HTAPS -> HTAPS_MAX (later is correct after the previous change)
author michael
date Sat, 08 Sep 2007 14:52:21 +0000
parents ab023c9f03d0
children ff44e77914ca
comparison
equal deleted inserted replaced
5651:ab023c9f03d0 5652:941e5deeb2a4
392 }; 392 };
393 393
394 #define LOG2_MB_SIZE 4 394 #define LOG2_MB_SIZE 4
395 #define MB_SIZE (1<<LOG2_MB_SIZE) 395 #define MB_SIZE (1<<LOG2_MB_SIZE)
396 #define ENCODER_EXTRA_BITS 4 396 #define ENCODER_EXTRA_BITS 4
397 #define HTAPS 8 397 #define HTAPS_MAX 8
398 398
399 typedef struct x_and_coeff{ 399 typedef struct x_and_coeff{
400 int16_t x; 400 int16_t x;
401 uint16_t coeff; 401 uint16_t coeff;
402 } x_and_coeff; 402 } x_and_coeff;
421 int width; 421 int width;
422 int height; 422 int height;
423 SubBand band[MAX_DECOMPOSITIONS][4]; 423 SubBand band[MAX_DECOMPOSITIONS][4];
424 424
425 int htaps; 425 int htaps;
426 int8_t hcoeff[HTAPS/2]; 426 int8_t hcoeff[HTAPS_MAX/2];
427 int diag_mc; 427 int diag_mc;
428 int fast_mc; 428 int fast_mc;
429 429
430 int last_htaps; 430 int last_htaps;
431 int8_t last_hcoeff[HTAPS/2]; 431 int8_t last_hcoeff[HTAPS_MAX/2];
432 int last_diag_mc; 432 int last_diag_mc;
433 }Plane; 433 }Plane;
434 434
435 typedef struct SnowContext{ 435 typedef struct SnowContext{
436 // MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independent of MpegEncContext, so this will be removed then (FIXME/XXX) 436 // MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independent of MpegEncContext, so this will be removed then (FIXME/XXX)
2189 0,1,0,0, 2189 0,1,0,0,
2190 15 2190 15
2191 }; 2191 };
2192 2192
2193 int x, y, b, r, l; 2193 int x, y, b, r, l;
2194 int16_t tmpIt [64*(32+HTAPS)]; 2194 int16_t tmpIt [64*(32+HTAPS_MAX)];
2195 uint8_t tmp2t[3][stride*(32+HTAPS)]; 2195 uint8_t tmp2t[3][stride*(32+HTAPS_MAX)];
2196 int16_t *tmpI= tmpIt; 2196 int16_t *tmpI= tmpIt;
2197 uint8_t *tmp2= tmp2t[0]; 2197 uint8_t *tmp2= tmp2t[0];
2198 uint8_t *hpel[11]; 2198 uint8_t *hpel[11];
2199 START_TIMER 2199 START_TIMER
2200 assert(dx<16 && dy<16); 2200 assert(dx<16 && dy<16);
2204 b= needs[l] | needs[r]; 2204 b= needs[l] | needs[r];
2205 if(p && !p->diag_mc) 2205 if(p && !p->diag_mc)
2206 b= 15; 2206 b= 15;
2207 2207
2208 if(b&5){ 2208 if(b&5){
2209 for(y=0; y < b_h+HTAPS-1; y++){ 2209 for(y=0; y < b_h+HTAPS_MAX-1; y++){
2210 for(x=0; x < b_w; x++){ 2210 for(x=0; x < b_w; x++){
2211 int a_1=src[x + HTAPS/2-4]; 2211 int a_1=src[x + HTAPS_MAX/2-4];
2212 int a0= src[x + HTAPS/2-3]; 2212 int a0= src[x + HTAPS_MAX/2-3];
2213 int a1= src[x + HTAPS/2-2]; 2213 int a1= src[x + HTAPS_MAX/2-2];
2214 int a2= src[x + HTAPS/2-1]; 2214 int a2= src[x + HTAPS_MAX/2-1];
2215 int a3= src[x + HTAPS/2+0]; 2215 int a3= src[x + HTAPS_MAX/2+0];
2216 int a4= src[x + HTAPS/2+1]; 2216 int a4= src[x + HTAPS_MAX/2+1];
2217 int a5= src[x + HTAPS/2+2]; 2217 int a5= src[x + HTAPS_MAX/2+2];
2218 int a6= src[x + HTAPS/2+3]; 2218 int a6= src[x + HTAPS_MAX/2+3];
2219 int am=0; 2219 int am=0;
2220 if(!p || p->fast_mc){ 2220 if(!p || p->fast_mc){
2221 am= 20*(a2+a3) - 5*(a1+a4) + (a0+a5); 2221 am= 20*(a2+a3) - 5*(a1+a4) + (a0+a5);
2222 tmpI[x]= am; 2222 tmpI[x]= am;
2223 am= (am+16)>>5; 2223 am= (am+16)>>5;
2234 tmp2+= stride; 2234 tmp2+= stride;
2235 src += stride; 2235 src += stride;
2236 } 2236 }
2237 src -= stride*y; 2237 src -= stride*y;
2238 } 2238 }
2239 src += HTAPS/2 - 1; 2239 src += HTAPS_MAX/2 - 1;
2240 tmp2= tmp2t[1]; 2240 tmp2= tmp2t[1];
2241 2241
2242 if(b&2){ 2242 if(b&2){
2243 for(y=0; y < b_h; y++){ 2243 for(y=0; y < b_h; y++){
2244 for(x=0; x < b_w+1; x++){ 2244 for(x=0; x < b_w+1; x++){
2245 int a_1=src[x + (HTAPS/2-4)*stride]; 2245 int a_1=src[x + (HTAPS_MAX/2-4)*stride];
2246 int a0= src[x + (HTAPS/2-3)*stride]; 2246 int a0= src[x + (HTAPS_MAX/2-3)*stride];
2247 int a1= src[x + (HTAPS/2-2)*stride]; 2247 int a1= src[x + (HTAPS_MAX/2-2)*stride];
2248 int a2= src[x + (HTAPS/2-1)*stride]; 2248 int a2= src[x + (HTAPS_MAX/2-1)*stride];
2249 int a3= src[x + (HTAPS/2+0)*stride]; 2249 int a3= src[x + (HTAPS_MAX/2+0)*stride];
2250 int a4= src[x + (HTAPS/2+1)*stride]; 2250 int a4= src[x + (HTAPS_MAX/2+1)*stride];
2251 int a5= src[x + (HTAPS/2+2)*stride]; 2251 int a5= src[x + (HTAPS_MAX/2+2)*stride];
2252 int a6= src[x + (HTAPS/2+3)*stride]; 2252 int a6= src[x + (HTAPS_MAX/2+3)*stride];
2253 int am=0; 2253 int am=0;
2254 if(!p || p->fast_mc) 2254 if(!p || p->fast_mc)
2255 am= (20*(a2+a3) - 5*(a1+a4) + (a0+a5) + 16)>>5; 2255 am= (20*(a2+a3) - 5*(a1+a4) + (a0+a5) + 16)>>5;
2256 else 2256 else
2257 am= (p->hcoeff[0]*(a2+a3) + p->hcoeff[1]*(a1+a4) + p->hcoeff[2]*(a0+a5) + p->hcoeff[3]*(a_1+a6) + 32)>>6; 2257 am= (p->hcoeff[0]*(a2+a3) + p->hcoeff[1]*(a1+a4) + p->hcoeff[2]*(a0+a5) + p->hcoeff[3]*(a_1+a6) + 32)>>6;
2262 src += stride; 2262 src += stride;
2263 tmp2+= stride; 2263 tmp2+= stride;
2264 } 2264 }
2265 src -= stride*y; 2265 src -= stride*y;
2266 } 2266 }
2267 src += stride*(HTAPS/2 - 1); 2267 src += stride*(HTAPS_MAX/2 - 1);
2268 tmp2= tmp2t[2]; 2268 tmp2= tmp2t[2];
2269 tmpI= tmpIt; 2269 tmpI= tmpIt;
2270 if(b&4){ 2270 if(b&4){
2271 for(y=0; y < b_h; y++){ 2271 for(y=0; y < b_h; y++){
2272 for(x=0; x < b_w; x++){ 2272 for(x=0; x < b_w; x++){
2273 int a_1=tmpI[x + (HTAPS/2-4)*64]; 2273 int a_1=tmpI[x + (HTAPS_MAX/2-4)*64];
2274 int a0= tmpI[x + (HTAPS/2-3)*64]; 2274 int a0= tmpI[x + (HTAPS_MAX/2-3)*64];
2275 int a1= tmpI[x + (HTAPS/2-2)*64]; 2275 int a1= tmpI[x + (HTAPS_MAX/2-2)*64];
2276 int a2= tmpI[x + (HTAPS/2-1)*64]; 2276 int a2= tmpI[x + (HTAPS_MAX/2-1)*64];
2277 int a3= tmpI[x + (HTAPS/2+0)*64]; 2277 int a3= tmpI[x + (HTAPS_MAX/2+0)*64];
2278 int a4= tmpI[x + (HTAPS/2+1)*64]; 2278 int a4= tmpI[x + (HTAPS_MAX/2+1)*64];
2279 int a5= tmpI[x + (HTAPS/2+2)*64]; 2279 int a5= tmpI[x + (HTAPS_MAX/2+2)*64];
2280 int a6= tmpI[x + (HTAPS/2+3)*64]; 2280 int a6= tmpI[x + (HTAPS_MAX/2+3)*64];
2281 int am=0; 2281 int am=0;
2282 if(!p || p->fast_mc) 2282 if(!p || p->fast_mc)
2283 am= (20*(a2+a3) - 5*(a1+a4) + (a0+a5) + 512)>>10; 2283 am= (20*(a2+a3) - 5*(a1+a4) + (a0+a5) + 512)>>10;
2284 else 2284 else
2285 am= (p->hcoeff[0]*(a2+a3) + p->hcoeff[1]*(a1+a4) + p->hcoeff[2]*(a0+a5) + p->hcoeff[3]*(a_1+a6) + 2048)>>12; 2285 am= (p->hcoeff[0]*(a2+a3) + p->hcoeff[1]*(a1+a4) + p->hcoeff[2]*(a0+a5) + p->hcoeff[3]*(a_1+a6) + 2048)>>12;
2290 tmp2+= stride; 2290 tmp2+= stride;
2291 } 2291 }
2292 } 2292 }
2293 2293
2294 hpel[ 0]= src; 2294 hpel[ 0]= src;
2295 hpel[ 1]= tmp2t[0] + stride*(HTAPS/2-1); 2295 hpel[ 1]= tmp2t[0] + stride*(HTAPS_MAX/2-1);
2296 hpel[ 2]= src + 1; 2296 hpel[ 2]= src + 1;
2297 2297
2298 hpel[ 4]= tmp2t[1]; 2298 hpel[ 4]= tmp2t[1];
2299 hpel[ 5]= tmp2t[2]; 2299 hpel[ 5]= tmp2t[2];
2300 hpel[ 6]= tmp2t[1] + 1; 2300 hpel[ 6]= tmp2t[1] + 1;
2338 STOP_TIMER("mc_block") 2338 STOP_TIMER("mc_block")
2339 } 2339 }
2340 2340
2341 #define mca(dx,dy,b_w)\ 2341 #define mca(dx,dy,b_w)\
2342 static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, int stride, int h){\ 2342 static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, int stride, int h){\
2343 uint8_t tmp[stride*(b_w+HTAPS-1)];\ 2343 uint8_t tmp[stride*(b_w+HTAPS_MAX-1)];\
2344 assert(h==b_w);\ 2344 assert(h==b_w);\
2345 mc_block(NULL, dst, src-(HTAPS/2-1)-(HTAPS/2-1)*stride, tmp, stride, b_w, b_w, dx, dy);\ 2345 mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, tmp, stride, b_w, b_w, dx, dy);\
2346 } 2346 }
2347 2347
2348 mca( 0, 0,16) 2348 mca( 0, 0,16)
2349 mca( 8, 0,16) 2349 mca( 8, 0,16)
2350 mca( 0, 8,16) 2350 mca( 0, 8,16)
2399 int mx= block->mx*scale; 2399 int mx= block->mx*scale;
2400 int my= block->my*scale; 2400 int my= block->my*scale;
2401 const int dx= mx&15; 2401 const int dx= mx&15;
2402 const int dy= my&15; 2402 const int dy= my&15;
2403 const int tab_index= 3 - (b_w>>2) + (b_w>>4); 2403 const int tab_index= 3 - (b_w>>2) + (b_w>>4);
2404 sx += (mx>>4) - (HTAPS/2-1); 2404 sx += (mx>>4) - (HTAPS_MAX/2-1);
2405 sy += (my>>4) - (HTAPS/2-1); 2405 sy += (my>>4) - (HTAPS_MAX/2-1);
2406 src += sx + sy*stride; 2406 src += sx + sy*stride;
2407 if( (unsigned)sx >= w - b_w - (HTAPS-2) 2407 if( (unsigned)sx >= w - b_w - (HTAPS_MAX-2)
2408 || (unsigned)sy >= h - b_h - (HTAPS-2)){ 2408 || (unsigned)sy >= h - b_h - (HTAPS_MAX-2)){
2409 ff_emulated_edge_mc(tmp + MB_SIZE, src, stride, b_w+HTAPS-1, b_h+HTAPS-1, sx, sy, w, h); 2409 ff_emulated_edge_mc(tmp + MB_SIZE, src, stride, b_w+HTAPS_MAX-1, b_h+HTAPS_MAX-1, sx, sy, w, h);
2410 src= tmp + MB_SIZE; 2410 src= tmp + MB_SIZE;
2411 } 2411 }
2412 // assert(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h); 2412 // assert(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h);
2413 // assert(!(b_w&(b_w-1))); 2413 // assert(!(b_w&(b_w-1)));
2414 assert(b_w>1 && b_h>1); 2414 assert(b_w>1 && b_h>1);
2858 const int ref_stride= s->current_picture.linesize[plane_index]; 2858 const int ref_stride= s->current_picture.linesize[plane_index];
2859 uint8_t *dst= s->current_picture.data[plane_index]; 2859 uint8_t *dst= s->current_picture.data[plane_index];
2860 uint8_t *src= s-> input_picture.data[plane_index]; 2860 uint8_t *src= s-> input_picture.data[plane_index];
2861 IDWTELEM *pred= (IDWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4; 2861 IDWTELEM *pred= (IDWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4;
2862 uint8_t cur[ref_stride*2*MB_SIZE]; //FIXME alignment 2862 uint8_t cur[ref_stride*2*MB_SIZE]; //FIXME alignment
2863 uint8_t tmp[ref_stride*(2*MB_SIZE+HTAPS-1)]; 2863 uint8_t tmp[ref_stride*(2*MB_SIZE+HTAPS_MAX-1)];
2864 const int b_stride = s->b_width << s->block_max_depth; 2864 const int b_stride = s->b_width << s->block_max_depth;
2865 const int b_height = s->b_height<< s->block_max_depth; 2865 const int b_height = s->b_height<< s->block_max_depth;
2866 const int w= p->width; 2866 const int w= p->width;
2867 const int h= p->height; 2867 const int h= p->height;
2868 int distortion; 2868 int distortion;
3651 for(plane_index=0; plane_index<2; plane_index++){ 3651 for(plane_index=0; plane_index<2; plane_index++){
3652 int htaps, i, sum=0, absum=0; 3652 int htaps, i, sum=0, absum=0;
3653 Plane *p= &s->plane[plane_index]; 3653 Plane *p= &s->plane[plane_index];
3654 p->diag_mc= get_rac(&s->c, s->header_state); 3654 p->diag_mc= get_rac(&s->c, s->header_state);
3655 htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2; 3655 htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2;
3656 if((unsigned)htaps > HTAPS || htaps==0) 3656 if((unsigned)htaps > HTAPS_MAX || htaps==0)
3657 return -1; 3657 return -1;
3658 p->htaps= htaps; 3658 p->htaps= htaps;
3659 for(i= htaps/2; i; i--){ 3659 for(i= htaps/2; i; i--){
3660 p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1)); 3660 p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1));
3661 sum += p->hcoeff[i]; 3661 sum += p->hcoeff[i];