diff options
author | Luca Abeni <lucabe72@email.it> | 2006-08-28 14:56:47 +0000 |
---|---|---|
committer | Luca Abeni <lucabe72@email.it> | 2006-08-28 14:56:47 +0000 |
commit | 00b2fa864e33bc6d8acd16f62ff7d7ad8cf626fd (patch) | |
tree | ce645a71f2d5ba62b60414aaf9b0899a9ac944ca /libavcodec | |
parent | be484a2cc9bac45d1804c1e3374843f9c54e68f7 (diff) | |
download | ffmpeg-00b2fa864e33bc6d8acd16f62ff7d7ad8cf626fd.tar.gz |
Minimal support for the new pixel formats in libavcodec
Originally committed as revision 6115 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/imgconvert.c | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 209d977084..521e31af17 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -235,6 +235,111 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { .depth = 8, .x_chroma_shift = 2, .y_chroma_shift = 0, }, + [PIX_FMT_BGR32] = { + .name = "bgr32", + .nb_channels = 4, .is_alpha = 1, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 8, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, + [PIX_FMT_BGR565] = { + .name = "bgr565", + .nb_channels = 3, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 5, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, + [PIX_FMT_BGR555] = { + .name = "bgr555", + .nb_channels = 4, .is_alpha = 1, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 5, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, + [PIX_FMT_RGB8] = { + .name = "rgb8", + .nb_channels = 1, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 8, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, + [PIX_FMT_RGB4] = { + .name = "rgb4", + .nb_channels = 1, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 4, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, + [PIX_FMT_RGB4_BYTE] = { + .name = "rgb4_byte", + .nb_channels = 1, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 8, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, + [PIX_FMT_BGR8] = { + .name = "bgr8", + .nb_channels = 1, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 8, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, + [PIX_FMT_BGR4] = { + .name = "bgr4", + .nb_channels = 1, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 4, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, + [PIX_FMT_BGR4_BYTE] = { + .name = "bgr4_byte", + .nb_channels = 1, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 8, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, + [PIX_FMT_NV12] = { + .name = "nv12", + .nb_channels = 2, + .color_type = FF_COLOR_YUV, + .pixel_type = FF_PIXEL_PLANAR, + .depth = 8, + .x_chroma_shift = 1, .y_chroma_shift = 1, + }, + [PIX_FMT_NV21] = { + .name = "nv12", + .nb_channels = 2, + .color_type = FF_COLOR_YUV, + .pixel_type = FF_PIXEL_PLANAR, + .depth = 8, + .x_chroma_shift = 1, .y_chroma_shift = 1, + }, + + [PIX_FMT_BGR32_1] = { + .name = "bgr32_1", + .nb_channels = 4, .is_alpha = 1, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 8, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, + [PIX_FMT_RGB32_1] = { + .name = "rgb32_1", + .nb_channels = 4, .is_alpha = 1, + .color_type = FF_COLOR_RGB, + .pixel_type = FF_PIXEL_PACKED, + .depth = 8, + .x_chroma_shift = 0, .y_chroma_shift = 0, + }, }; void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift) @@ -292,6 +397,18 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr, picture->linesize[1] = w2; picture->linesize[2] = w2; return size + 2 * size2; + case PIX_FMT_NV12: + case PIX_FMT_NV21: + w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift; + h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift; + size2 = w2 * h2 * 2; + picture->data[0] = ptr; + picture->data[1] = picture->data[0] + size; + picture->data[2] = NULL; + picture->linesize[0] = width; + picture->linesize[1] = w2; + picture->linesize[2] = 0; + return size + 2 * size2; case PIX_FMT_RGB24: case PIX_FMT_BGR24: picture->data[0] = ptr; @@ -300,11 +417,16 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr, picture->linesize[0] = width * 3; return size * 3; case PIX_FMT_RGBA32: + case PIX_FMT_BGR32: + case PIX_FMT_RGB32_1: + case PIX_FMT_BGR32_1: picture->data[0] = ptr; picture->data[1] = NULL; picture->data[2] = NULL; picture->linesize[0] = width * 4; return size * 4; + case PIX_FMT_BGR555: + case PIX_FMT_BGR565: case PIX_FMT_RGB555: case PIX_FMT_RGB565: case PIX_FMT_YUV422: @@ -325,12 +447,23 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr, picture->data[2] = NULL; picture->linesize[0] = width + width/2; return size + size/2; + case PIX_FMT_RGB8: + case PIX_FMT_BGR8: + case PIX_FMT_RGB4_BYTE: + case PIX_FMT_BGR4_BYTE: case PIX_FMT_GRAY8: picture->data[0] = ptr; picture->data[1] = NULL; picture->data[2] = NULL; picture->linesize[0] = width; return size; + case PIX_FMT_RGB4: + case PIX_FMT_BGR4: + picture->data[0] = ptr; + picture->data[1] = NULL; + picture->data[2] = NULL; + picture->linesize[0] = width / 2; + return size / 2; case PIX_FMT_MONOWHITE: case PIX_FMT_MONOBLACK: picture->data[0] = ptr; @@ -370,6 +503,8 @@ int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height, if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) { if (pix_fmt == PIX_FMT_YUV422 || pix_fmt == PIX_FMT_UYVY422 || + pix_fmt == PIX_FMT_BGR565 || + pix_fmt == PIX_FMT_BGR565 || pix_fmt == PIX_FMT_RGB565 || pix_fmt == PIX_FMT_RGB555) w = width * 2; @@ -484,6 +619,8 @@ static int avg_bits_per_pixel(int pix_fmt) case PIX_FMT_UYVY422: case PIX_FMT_RGB565: case PIX_FMT_RGB555: + case PIX_FMT_BGR565: + case PIX_FMT_BGR555: bits = 16; break; case PIX_FMT_UYVY411: @@ -602,6 +739,8 @@ void img_copy(AVPicture *dst, const AVPicture *src, case PIX_FMT_UYVY422: case PIX_FMT_RGB565: case PIX_FMT_RGB555: + case PIX_FMT_BGR565: + case PIX_FMT_BGR555: bits = 16; break; case PIX_FMT_UYVY411: |