Mercurial > libavcodec.hg
comparison utils.c @ 1588:de5e2acd0f80 libavcodec
initalize various uninitalized variables and avoid coded_picture_number as its not always correct (later should be reversed after fixing the picture_number mess)
author | michael |
---|---|
date | Thu, 30 Oct 2003 21:05:00 +0000 |
parents | 6b224ca24033 |
children | 932d306bf1dc |
comparison
equal
deleted
inserted
replaced
1587:b69b086f5570 | 1588:de5e2acd0f80 |
---|---|
121 | 121 |
122 typedef struct InternalBuffer{ | 122 typedef struct InternalBuffer{ |
123 int last_pic_num; | 123 int last_pic_num; |
124 uint8_t *base[4]; | 124 uint8_t *base[4]; |
125 uint8_t *data[4]; | 125 uint8_t *data[4]; |
126 int linesize[4]; | |
126 }InternalBuffer; | 127 }InternalBuffer; |
127 | 128 |
128 #define INTERNAL_BUFFER_SIZE 32 | 129 #define INTERNAL_BUFFER_SIZE 32 |
129 | 130 |
130 #define ALIGN(x, a) (((x)+(a)-1)&~((a)-1)) | 131 #define ALIGN(x, a) (((x)+(a)-1)&~((a)-1)) |
168 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ | 169 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ |
169 int i; | 170 int i; |
170 int w= s->width; | 171 int w= s->width; |
171 int h= s->height; | 172 int h= s->height; |
172 InternalBuffer *buf; | 173 InternalBuffer *buf; |
174 int *picture_number; | |
173 | 175 |
174 assert(pic->data[0]==NULL); | 176 assert(pic->data[0]==NULL); |
175 assert(INTERNAL_BUFFER_SIZE > s->internal_buffer_count); | 177 assert(INTERNAL_BUFFER_SIZE > s->internal_buffer_count); |
176 | 178 |
177 if(s->internal_buffer==NULL){ | 179 if(s->internal_buffer==NULL){ |
184 sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/ | 186 sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/ |
185 ); | 187 ); |
186 #endif | 188 #endif |
187 | 189 |
188 buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; | 190 buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; |
189 | 191 picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num; //FIXME ugly hack |
192 (*picture_number)++; | |
193 | |
190 if(buf->base[0]){ | 194 if(buf->base[0]){ |
191 pic->age= pic->coded_picture_number - buf->last_pic_num; | 195 pic->age= *picture_number - buf->last_pic_num; |
192 buf->last_pic_num= pic->coded_picture_number; | 196 buf->last_pic_num= *picture_number; |
193 }else{ | 197 }else{ |
194 int h_chroma_shift, v_chroma_shift; | 198 int h_chroma_shift, v_chroma_shift; |
195 int s_align, pixel_size; | 199 int s_align, pixel_size; |
196 | 200 |
197 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); | 201 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); |
229 | 233 |
230 for(i=0; i<3; i++){ | 234 for(i=0; i<3; i++){ |
231 const int h_shift= i==0 ? 0 : h_chroma_shift; | 235 const int h_shift= i==0 ? 0 : h_chroma_shift; |
232 const int v_shift= i==0 ? 0 : v_chroma_shift; | 236 const int v_shift= i==0 ? 0 : v_chroma_shift; |
233 | 237 |
234 pic->linesize[i]= ALIGN(pixel_size*w>>h_shift, s_align); | 238 buf->linesize[i]= ALIGN(pixel_size*w>>h_shift, s_align); |
235 | 239 |
236 buf->base[i]= av_mallocz((pic->linesize[i]*h>>v_shift)+16); //FIXME 16 | 240 buf->base[i]= av_mallocz((buf->linesize[i]*h>>v_shift)+16); //FIXME 16 |
237 if(buf->base[i]==NULL) return -1; | 241 if(buf->base[i]==NULL) return -1; |
238 memset(buf->base[i], 128, pic->linesize[i]*h>>v_shift); | 242 memset(buf->base[i], 128, buf->linesize[i]*h>>v_shift); |
239 | 243 |
240 if(s->flags&CODEC_FLAG_EMU_EDGE) | 244 if(s->flags&CODEC_FLAG_EMU_EDGE) |
241 buf->data[i] = buf->base[i]; | 245 buf->data[i] = buf->base[i]; |
242 else | 246 else |
243 buf->data[i] = buf->base[i] + ALIGN((pic->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), s_align); | 247 buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), s_align); |
244 } | 248 } |
245 pic->age= 256*256*256*64; | 249 pic->age= 256*256*256*64; |
246 pic->type= FF_BUFFER_TYPE_INTERNAL; | 250 } |
247 } | 251 pic->type= FF_BUFFER_TYPE_INTERNAL; |
248 | 252 |
249 for(i=0; i<4; i++){ | 253 for(i=0; i<4; i++){ |
250 pic->base[i]= buf->base[i]; | 254 pic->base[i]= buf->base[i]; |
251 pic->data[i]= buf->data[i]; | 255 pic->data[i]= buf->data[i]; |
256 pic->linesize[i]= buf->linesize[i]; | |
252 } | 257 } |
253 s->internal_buffer_count++; | 258 s->internal_buffer_count++; |
254 | 259 |
255 return 0; | 260 return 0; |
256 } | 261 } |