comparison snow.c @ 8214:c5276ad92ff8 libavcodec

snow: move scratch buffer from stack to malloced buffer in context This is required to ensure 16-byte alignment.
author mru
date Tue, 25 Nov 2008 00:20:49 +0000
parents 5a3907818652
children dcfdb3352dde
comparison
equal deleted inserted replaced
8213:93423820d82f 8214:c5276ad92ff8
486 int me_cache[ME_CACHE_SIZE]; 486 int me_cache[ME_CACHE_SIZE];
487 int me_cache_generation; 487 int me_cache_generation;
488 slice_buffer sb; 488 slice_buffer sb;
489 489
490 MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX) 490 MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX)
491
492 uint8_t *scratchbuf;
491 }SnowContext; 493 }SnowContext;
492 494
493 typedef struct { 495 typedef struct {
494 IDWTELEM *b0; 496 IDWTELEM *b0;
495 IDWTELEM *b1; 497 IDWTELEM *b1;
2421 BlockNode *rt= lt+1; 2423 BlockNode *rt= lt+1;
2422 BlockNode *lb= lt+b_stride; 2424 BlockNode *lb= lt+b_stride;
2423 BlockNode *rb= lb+1; 2425 BlockNode *rb= lb+1;
2424 uint8_t *block[4]; 2426 uint8_t *block[4];
2425 int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride; 2427 int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride;
2426 uint8_t tmp[src_stride*7*MB_SIZE]; //FIXME align 2428 uint8_t *tmp = s->scratchbuf;
2427 uint8_t *ptmp; 2429 uint8_t *ptmp;
2428 int x,y; 2430 int x,y;
2429 2431
2430 if(b_x<0){ 2432 if(b_x<0){
2431 lt= rt; 2433 lt= rt;
2783 const int obmc_stride= plane_index ? block_size : 2*block_size; 2785 const int obmc_stride= plane_index ? block_size : 2*block_size;
2784 const int ref_stride= s->current_picture.linesize[plane_index]; 2786 const int ref_stride= s->current_picture.linesize[plane_index];
2785 uint8_t *dst= s->current_picture.data[plane_index]; 2787 uint8_t *dst= s->current_picture.data[plane_index];
2786 uint8_t *src= s-> input_picture.data[plane_index]; 2788 uint8_t *src= s-> input_picture.data[plane_index];
2787 IDWTELEM *pred= (IDWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4; 2789 IDWTELEM *pred= (IDWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4;
2788 uint8_t cur[ref_stride*2*MB_SIZE]; //FIXME alignment 2790 uint8_t *cur = s->scratchbuf;
2789 uint8_t tmp[ref_stride*(2*MB_SIZE+HTAPS_MAX-1)]; 2791 uint8_t tmp[ref_stride*(2*MB_SIZE+HTAPS_MAX-1)];
2790 const int b_stride = s->b_width << s->block_max_depth; 2792 const int b_stride = s->b_width << s->block_max_depth;
2791 const int b_height = s->b_height<< s->block_max_depth; 2793 const int b_height = s->b_height<< s->block_max_depth;
2792 const int w= p->width; 2794 const int w= p->width;
2793 const int h= p->height; 2795 const int h= p->height;
3701 for(i=0; i<MAX_REF_FRAMES; i++) 3703 for(i=0; i<MAX_REF_FRAMES; i++)
3702 for(j=0; j<MAX_REF_FRAMES; j++) 3704 for(j=0; j<MAX_REF_FRAMES; j++)
3703 scale_mv_ref[i][j] = 256*(i+1)/(j+1); 3705 scale_mv_ref[i][j] = 256*(i+1)/(j+1);
3704 3706
3705 s->avctx->get_buffer(s->avctx, &s->mconly_picture); 3707 s->avctx->get_buffer(s->avctx, &s->mconly_picture);
3708 s->scratchbuf = av_malloc(s->mconly_picture.linesize[0]*7*MB_SIZE);
3706 3709
3707 return 0; 3710 return 0;
3708 } 3711 }
3709 3712
3710 static int common_init_after_header(AVCodecContext *avctx){ 3713 static int common_init_after_header(AVCodecContext *avctx){
4436 av_freep(&s->m.me.map); 4439 av_freep(&s->m.me.map);
4437 av_freep(&s->m.me.score_map); 4440 av_freep(&s->m.me.score_map);
4438 av_freep(&s->m.obmc_scratchpad); 4441 av_freep(&s->m.obmc_scratchpad);
4439 4442
4440 av_freep(&s->block); 4443 av_freep(&s->block);
4444 av_freep(&s->scratchbuf);
4441 4445
4442 for(i=0; i<MAX_REF_FRAMES; i++){ 4446 for(i=0; i<MAX_REF_FRAMES; i++){
4443 av_freep(&s->ref_mvs[i]); 4447 av_freep(&s->ref_mvs[i]);
4444 av_freep(&s->ref_scores[i]); 4448 av_freep(&s->ref_scores[i]);
4445 if(s->last_picture[i].data[0]) 4449 if(s->last_picture[i].data[0])