| 228 | } |
| 229 | |
| 230 | int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ |
| 231 | int i; |
| 232 | int w= s->width; |
| 233 | int h= s->height; |
| 234 | InternalBuffer *buf; |
| 235 | int *picture_number; |
| 236 | |
| 237 | if(pic->data[0]!=NULL) { |
| 238 | av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n"); |
| 239 | return -1; |
| 240 | } |
| 241 | if(s->internal_buffer_count >= INTERNAL_BUFFER_SIZE) { |
| 242 | av_log(s, AV_LOG_ERROR, "internal_buffer_count overflow (missing release_buffer?)\n"); |
| 243 | return -1; |
| 244 | } |
| 245 | |
| 246 | if(avcodec_check_dimensions(s,w,h)) |
| 247 | return -1; |
| 248 | |
| 249 | if(s->internal_buffer==NULL){ |
| 250 | s->internal_buffer= av_mallocz((INTERNAL_BUFFER_SIZE+1)*sizeof(InternalBuffer)); |
| 251 | } |
| 252 | #if 0 |
| 253 | s->internal_buffer= av_fast_realloc( |
| 254 | s->internal_buffer, |
| 255 | &s->internal_buffer_size, |
| 256 | sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/ |
| 257 | ); |
| 258 | #endif |
| 259 | |
| 260 | buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; |
| 261 | picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE]).last_pic_num; //FIXME ugly hack |
| 262 | (*picture_number)++; |
| 263 | |
| 264 | if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){ |
| 265 | for(i=0; i<4; i++){ |
| 266 | av_freep(&buf->base[i]); |
| 267 | buf->data[i]= NULL; |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | if(buf->base[0]){ |
| 272 | pic->age= *picture_number - buf->last_pic_num; |
| 273 | buf->last_pic_num= *picture_number; |
| 274 | }else{ |
| 275 | int h_chroma_shift, v_chroma_shift; |
| 276 | int size[4] = {0}; |
| 277 | int tmpsize; |
| 278 | int unaligned; |
| 279 | AVPicture picture; |
| 280 | int stride_align[4]; |
| 281 | |
| 282 | avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); |
| 283 | |
| 284 | avcodec_align_dimensions2(s, &w, &h, stride_align); |
| 285 | |
| 286 | if(!(s->flags&CODEC_FLAG_EMU_EDGE)){ |
| 287 | w+= EDGE_WIDTH*2; |
nothing calls this directly
no test coverage detected