diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-10-30 21:05:00 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-10-30 21:05:00 +0000 |
commit | 237e49387af96d42460b50a4d2c6369112b13d7b (patch) | |
tree | 2b6487f9685597d65d9328a2d349b757dea5ec4b /libavcodec/utils.c | |
parent | f259747bc704704db7f299ddd5821280c3c4c7b3 (diff) | |
download | ffmpeg-237e49387af96d42460b50a4d2c6369112b13d7b.tar.gz |
initalize various uninitalized variables and avoid coded_picture_number as its not always correct (later should be reversed after fixing the picture_number mess)
Originally committed as revision 2454 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index ace54ef117..ae8320ed85 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -123,6 +123,7 @@ typedef struct InternalBuffer{ int last_pic_num; uint8_t *base[4]; uint8_t *data[4]; + int linesize[4]; }InternalBuffer; #define INTERNAL_BUFFER_SIZE 32 @@ -170,6 +171,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ int w= s->width; int h= s->height; InternalBuffer *buf; + int *picture_number; assert(pic->data[0]==NULL); assert(INTERNAL_BUFFER_SIZE > s->internal_buffer_count); @@ -186,10 +188,12 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ #endif buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; - + picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num; //FIXME ugly hack + (*picture_number)++; + if(buf->base[0]){ - pic->age= pic->coded_picture_number - buf->last_pic_num; - buf->last_pic_num= pic->coded_picture_number; + pic->age= *picture_number - buf->last_pic_num; + buf->last_pic_num= *picture_number; }else{ int h_chroma_shift, v_chroma_shift; int s_align, pixel_size; @@ -231,24 +235,25 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ const int h_shift= i==0 ? 0 : h_chroma_shift; const int v_shift= i==0 ? 0 : v_chroma_shift; - pic->linesize[i]= ALIGN(pixel_size*w>>h_shift, s_align); + buf->linesize[i]= ALIGN(pixel_size*w>>h_shift, s_align); - buf->base[i]= av_mallocz((pic->linesize[i]*h>>v_shift)+16); //FIXME 16 + buf->base[i]= av_mallocz((buf->linesize[i]*h>>v_shift)+16); //FIXME 16 if(buf->base[i]==NULL) return -1; - memset(buf->base[i], 128, pic->linesize[i]*h>>v_shift); + memset(buf->base[i], 128, buf->linesize[i]*h>>v_shift); if(s->flags&CODEC_FLAG_EMU_EDGE) buf->data[i] = buf->base[i]; else - buf->data[i] = buf->base[i] + ALIGN((pic->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), s_align); + buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), s_align); } pic->age= 256*256*256*64; - pic->type= FF_BUFFER_TYPE_INTERNAL; } + pic->type= FF_BUFFER_TYPE_INTERNAL; for(i=0; i<4; i++){ pic->base[i]= buf->base[i]; pic->data[i]= buf->data[i]; + pic->linesize[i]= buf->linesize[i]; } s->internal_buffer_count++; |