Mercurial > libavcodec.hg
comparison utils.c @ 6360:e961197141c0 libavcodec
Simplify avcodec_default_get_buffer()
author | vitor |
---|---|
date | Fri, 15 Feb 2008 20:23:49 +0000 |
parents | 8e63d869a904 |
children | c6c5bcca56d9 |
comparison
equal
deleted
inserted
replaced
6359:d5a97935b2f1 | 6360:e961197141c0 |
---|---|
29 #include "dsputil.h" | 29 #include "dsputil.h" |
30 #include "mpegvideo.h" | 30 #include "mpegvideo.h" |
31 #include "integer.h" | 31 #include "integer.h" |
32 #include "opt.h" | 32 #include "opt.h" |
33 #include "crc.h" | 33 #include "crc.h" |
34 #include "imgconvert.h" | |
34 #include <stdarg.h> | 35 #include <stdarg.h> |
35 #include <limits.h> | 36 #include <limits.h> |
36 #include <float.h> | 37 #include <float.h> |
37 #if !defined(HAVE_MKSTEMP) | 38 #if !defined(HAVE_MKSTEMP) |
38 #include <fcntl.h> | 39 #include <fcntl.h> |
269 if(buf->base[0]){ | 270 if(buf->base[0]){ |
270 pic->age= *picture_number - buf->last_pic_num; | 271 pic->age= *picture_number - buf->last_pic_num; |
271 buf->last_pic_num= *picture_number; | 272 buf->last_pic_num= *picture_number; |
272 }else{ | 273 }else{ |
273 int h_chroma_shift, v_chroma_shift; | 274 int h_chroma_shift, v_chroma_shift; |
274 int pixel_size, size[4]; | 275 int size[4] = {0}; |
276 int tmpsize; | |
275 AVPicture picture; | 277 AVPicture picture; |
276 | 278 |
277 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); | 279 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); |
278 | 280 |
279 avcodec_align_dimensions(s, &w, &h); | 281 avcodec_align_dimensions(s, &w, &h); |
282 w+= EDGE_WIDTH*2; | 284 w+= EDGE_WIDTH*2; |
283 h+= EDGE_WIDTH*2; | 285 h+= EDGE_WIDTH*2; |
284 } | 286 } |
285 avcodec_align_dimensions(s, &w, &h); | 287 avcodec_align_dimensions(s, &w, &h); |
286 | 288 |
287 avpicture_fill(&picture, NULL, s->pix_fmt, w, h); | 289 ff_fill_linesize(&picture, s->pix_fmt, w); |
288 pixel_size= picture.linesize[0]*8 / w; | 290 |
289 //av_log(NULL, AV_LOG_ERROR, "%d %d %d %d\n", (int)picture.data[1], w, h, s->pix_fmt); | 291 for (i=1; i<4; i++) |
290 assert(pixel_size>=1); | 292 picture.linesize[i] = ALIGN(picture.linesize[i], STRIDE_ALIGN); |
291 //FIXME next ensures that linesize= 2^x uvlinesize, that is needed because some MC code assumes it | 293 |
292 if(pixel_size == 3*8) | 294 /* next ensures that linesize= 2^x uvlinesize, that is needed because |
293 w= ALIGN(w, STRIDE_ALIGN<<h_chroma_shift); | 295 * some MC code assumes it */ |
296 if (picture.linesize[1]) | |
297 picture.linesize[0] = ALIGN(picture.linesize[0], picture.linesize[1]); | |
294 else | 298 else |
295 w= ALIGN(pixel_size*w, STRIDE_ALIGN<<(h_chroma_shift+3)) / pixel_size; | 299 picture.linesize[0] = ALIGN(picture.linesize[0], STRIDE_ALIGN); |
296 size[1] = avpicture_fill(&picture, NULL, s->pix_fmt, w, h); | 300 |
297 size[0] = picture.linesize[0] * h; | 301 tmpsize = ff_fill_pointer(&picture, NULL, s->pix_fmt, h); |
298 size[1] -= size[0]; | 302 |
299 size[2] = size[3] = 0; | 303 for (i=0; i<3 && picture.data[i+1]; i++) |
300 if(picture.data[2]) | 304 size[i] = picture.data[i+1] - picture.data[i]; |
301 size[1]= size[2]= size[1]/2; | 305 size[i] = tmpsize - size[i]; |
302 if(picture.data[3]) | |
303 size[3] = picture.linesize[3] * h; | |
304 | 306 |
305 buf->last_pic_num= -256*256*256*64; | 307 buf->last_pic_num= -256*256*256*64; |
306 memset(buf->base, 0, sizeof(buf->base)); | 308 memset(buf->base, 0, sizeof(buf->base)); |
307 memset(buf->data, 0, sizeof(buf->data)); | 309 memset(buf->data, 0, sizeof(buf->data)); |
308 | 310 |