Mercurial > libavcodec.hg
comparison imgconvert.c @ 1231:b88dfc4bbf8c libavcodec
* introducing new public interface in imgconvert.c
+ avcodec_get_pix_fmt
converts textual representation of pixel format into
the actual id. Complements avcodec_get_pix_fmt_name.
+ avpicture_layout
serializes given picture into a flat array.
Complements avpicture_fill.
* adding a new option -pix_fmt to the ffmpeg, in order to control
pixel format for the codecs that do support it, like rawvideo,
for example.
* reducing complexity of the rawvideo codec by splitting it in two
and making it more reliable via hooking up to the avpicture_layout.
Plus adding new FourCC as described here: http://www.fourcc.org
* A tiny fix for avienc.c that makes avih and video strf consistent
regarding codec FourCC.
author | romansh |
---|---|
date | Wed, 07 May 2003 19:01:45 +0000 |
parents | 0aa744ab1c07 |
children | 5d2376294fbf |
comparison
equal
deleted
inserted
replaced
1230:31d090bae36c | 1231:b88dfc4bbf8c |
---|---|
220 { | 220 { |
221 if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB) | 221 if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB) |
222 return "???"; | 222 return "???"; |
223 else | 223 else |
224 return pix_fmt_info[pix_fmt].name; | 224 return pix_fmt_info[pix_fmt].name; |
225 } | |
226 | |
227 enum PixelFormat avcodec_get_pix_fmt(const char* name) | |
228 { | |
229 int i; | |
230 | |
231 for (i=0; i < PIX_FMT_NB; i++) | |
232 if (!strcmp(pix_fmt_info[i].name, name)) | |
233 break; | |
234 return i; | |
225 } | 235 } |
226 | 236 |
227 /* Picture field are filled with 'ptr' addresses. Also return size */ | 237 /* Picture field are filled with 'ptr' addresses. Also return size */ |
228 int avpicture_fill(AVPicture *picture, uint8_t *ptr, | 238 int avpicture_fill(AVPicture *picture, uint8_t *ptr, |
229 int pix_fmt, int width, int height) | 239 int pix_fmt, int width, int height) |
301 picture->data[3] = NULL; | 311 picture->data[3] = NULL; |
302 return -1; | 312 return -1; |
303 } | 313 } |
304 } | 314 } |
305 | 315 |
316 int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height, | |
317 unsigned char *dest, int dest_size) | |
318 { | |
319 PixFmtInfo* pf = &pix_fmt_info[pix_fmt]; | |
320 int i, j, w, h, data_planes; | |
321 unsigned char* s; | |
322 int size = avpicture_get_size(pix_fmt, width, height); | |
323 | |
324 if (size > dest_size) | |
325 return -1; | |
326 | |
327 if (pf->pixel_type == FF_PIXEL_PACKED) { | |
328 if (pix_fmt == PIX_FMT_YUV422 || pix_fmt == PIX_FMT_RGB565 || | |
329 pix_fmt == PIX_FMT_RGB555) | |
330 w = width * 2; | |
331 else | |
332 w = width * (pf->depth * pf->nb_channels / 8); | |
333 data_planes = 1; | |
334 h = height; | |
335 } else { | |
336 data_planes = pf->nb_channels; | |
337 w = width; | |
338 h = height; | |
339 } | |
340 | |
341 for (i=0; i<data_planes; i++) { | |
342 if (i == 1) { | |
343 w = width >> pf->x_chroma_shift; | |
344 h = height >> pf->y_chroma_shift; | |
345 } | |
346 s = src->data[i]; | |
347 for(j=0; j<h; j++) { | |
348 memcpy(dest, s, w); | |
349 dest += w; | |
350 s += src->linesize[i]; | |
351 } | |
352 } | |
353 | |
354 return size; | |
355 } | |
356 | |
306 int avpicture_get_size(int pix_fmt, int width, int height) | 357 int avpicture_get_size(int pix_fmt, int width, int height) |
307 { | 358 { |
308 AVPicture dummy_pict; | 359 AVPicture dummy_pict; |
309 return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height); | 360 return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height); |
310 } | 361 } |