diff options
author | Roman Shaposhnik <roman@shaposhnik.org> | 2003-05-07 19:01:45 +0000 |
---|---|---|
committer | Roman Shaposhnik <roman@shaposhnik.org> | 2003-05-07 19:01:45 +0000 |
commit | 631670888d4ff9ca08c9d0804082511a1bc587a5 (patch) | |
tree | 2bf2601c9204d6d3097f93cda618a25eb0d4bb74 /libavcodec/imgconvert.c | |
parent | 4e80eb21afd02747592e9fb9cfe2679401b7857e (diff) | |
download | ffmpeg-631670888d4ff9ca08c9d0804082511a1bc587a5.tar.gz |
* 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.
Originally committed as revision 1842 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/imgconvert.c')
-rw-r--r-- | libavcodec/imgconvert.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 01c0415f81..7b5645fd01 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -224,6 +224,16 @@ const char *avcodec_get_pix_fmt_name(int pix_fmt) return pix_fmt_info[pix_fmt].name; } +enum PixelFormat avcodec_get_pix_fmt(const char* name) +{ + int i; + + for (i=0; i < PIX_FMT_NB; i++) + if (!strcmp(pix_fmt_info[i].name, name)) + break; + return i; +} + /* Picture field are filled with 'ptr' addresses. Also return size */ int avpicture_fill(AVPicture *picture, uint8_t *ptr, int pix_fmt, int width, int height) @@ -303,6 +313,47 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr, } } +int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height, + unsigned char *dest, int dest_size) +{ + PixFmtInfo* pf = &pix_fmt_info[pix_fmt]; + int i, j, w, h, data_planes; + unsigned char* s; + int size = avpicture_get_size(pix_fmt, width, height); + + if (size > dest_size) + return -1; + + if (pf->pixel_type == FF_PIXEL_PACKED) { + if (pix_fmt == PIX_FMT_YUV422 || pix_fmt == PIX_FMT_RGB565 || + pix_fmt == PIX_FMT_RGB555) + w = width * 2; + else + w = width * (pf->depth * pf->nb_channels / 8); + data_planes = 1; + h = height; + } else { + data_planes = pf->nb_channels; + w = width; + h = height; + } + + for (i=0; i<data_planes; i++) { + if (i == 1) { + w = width >> pf->x_chroma_shift; + h = height >> pf->y_chroma_shift; + } + s = src->data[i]; + for(j=0; j<h; j++) { + memcpy(dest, s, w); + dest += w; + s += src->linesize[i]; + } + } + + return size; +} + int avpicture_get_size(int pix_fmt, int width, int height) { AVPicture dummy_pict; |