mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
gst/ffmpegcolorspace/: Add 2 new caps arrangements, for 24-bit RGB and BGR in 32-bits, but at the other end of the wo...
Original commit message from CVS: * gst/ffmpegcolorspace/avcodec.h: * gst/ffmpegcolorspace/gstffmpegcodecmap.c: (gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_pixfmt), (gst_ffmpegcsp_avpicture_fill): * gst/ffmpegcolorspace/imgconvert.c: (img_convert), (img_get_alpha_info): Add 2 new caps arrangements, for 24-bit RGB and BGR in 32-bits, but at the other end of the word. Fixes: #387073. Add some inconsequential branch hints in a couple of places.
This commit is contained in:
parent
d07b7ac539
commit
3da0606ffc
4 changed files with 174 additions and 5 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2006-12-22 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* gst/ffmpegcolorspace/avcodec.h:
|
||||
* gst/ffmpegcolorspace/gstffmpegcodecmap.c:
|
||||
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_pixfmt),
|
||||
(gst_ffmpegcsp_avpicture_fill):
|
||||
* gst/ffmpegcolorspace/imgconvert.c: (img_convert),
|
||||
(img_get_alpha_info):
|
||||
Add 2 new caps arrangements, for 24-bit RGB and BGR in 32-bits, but at the
|
||||
other end of the word. Fixes: #387073.
|
||||
|
||||
Add some inconsequential branch hints in a couple of places.
|
||||
|
||||
2006-12-21 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/ffmpegcolorspace/gstffmpegcodecmap.c:
|
||||
|
|
|
@ -62,7 +62,9 @@ enum PixelFormat {
|
|||
PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
|
||||
PIX_FMT_BGRA32, ///< Packed pixel, 4 bytes per pixel, ARGBARGB...
|
||||
PIX_FMT_RGB32, ///< Packed pixel, 4 bytes per pixel, BGRXBGRX..., stored in cpu endianness
|
||||
PIX_FMT_xRGB32, ///< Packed pixel, 4 bytes per pixel, XBGRXBGR..., stored in cpu endianness
|
||||
PIX_FMT_BGR32, ///< Packed pixel, 4 bytes per pixel, XRGBXRGB...
|
||||
PIX_FMT_BGRx32, ///< Packed pixel, 4 bytes per pixel, RGBXRGBX...
|
||||
PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
|
||||
PIX_FMT_YVU410P, ///< Planar YVU 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
|
||||
PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
|
||||
|
|
|
@ -222,6 +222,34 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context)
|
|||
r_mask = 0x00ff0000;
|
||||
g_mask = 0x0000ff00;
|
||||
b_mask = 0x000000ff;
|
||||
#endif
|
||||
break;
|
||||
case PIX_FMT_xRGB32:
|
||||
bpp = 32;
|
||||
depth = 24;
|
||||
endianness = G_BIG_ENDIAN;
|
||||
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
||||
r_mask = 0xff000000;
|
||||
g_mask = 0x00ff0000;
|
||||
b_mask = 0x0000ff00;
|
||||
#else
|
||||
r_mask = 0x000000ff;
|
||||
g_mask = 0x0000ff00;
|
||||
b_mask = 0x00ff0000;
|
||||
#endif
|
||||
break;
|
||||
case PIX_FMT_BGRx32:
|
||||
bpp = 32;
|
||||
depth = 24;
|
||||
endianness = G_BIG_ENDIAN;
|
||||
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
||||
r_mask = 0x000000ff;
|
||||
g_mask = 0x0000ff00;
|
||||
b_mask = 0x00ff0000;
|
||||
#else
|
||||
r_mask = 0xff000000;
|
||||
g_mask = 0x00ff0000;
|
||||
b_mask = 0x0000ff00;
|
||||
#endif
|
||||
break;
|
||||
case PIX_FMT_RGBA32:
|
||||
|
@ -581,6 +609,20 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
|
|||
if (rmask == 0x00ff0000)
|
||||
#endif
|
||||
context->pix_fmt = PIX_FMT_BGR32;
|
||||
|
||||
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
||||
if (rmask == 0xff000000)
|
||||
#else
|
||||
if (rmask == 0x000000ff)
|
||||
#endif
|
||||
context->pix_fmt = PIX_FMT_xRGB32;
|
||||
|
||||
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
||||
if (rmask == 0x000000ff)
|
||||
#else
|
||||
if (rmask == 0xff000000)
|
||||
#endif
|
||||
context->pix_fmt = PIX_FMT_BGRx32;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
|
@ -730,6 +772,8 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
|
|||
case PIX_FMT_RGBA32:
|
||||
case PIX_FMT_BGR32:
|
||||
case PIX_FMT_BGRA32:
|
||||
case PIX_FMT_xRGB32:
|
||||
case PIX_FMT_BGRx32:
|
||||
stride = width * 4;
|
||||
size = stride * height;
|
||||
picture->data[0] = ptr;
|
||||
|
|
|
@ -222,6 +222,28 @@ static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
|
|||
/* .y_chroma_shift = */ 0,
|
||||
/* .depth = */ 8,
|
||||
},
|
||||
/* [PIX_FMT_RGB32] = */ {
|
||||
/* .format = */ PIX_FMT_xRGB32,
|
||||
/* .name = */ "xrgb32",
|
||||
/* .nb_channels = */ 4,
|
||||
/* .color_type = */ FF_COLOR_RGB,
|
||||
/* .pixel_type = */ FF_PIXEL_PACKED,
|
||||
/* .is_alpha = */ 0,
|
||||
/* .x_chroma_shift = */ 0,
|
||||
/* .y_chroma_shift = */ 0,
|
||||
/* .depth = */ 8,
|
||||
},
|
||||
/* [PIX_FMT_BGR32] = */ {
|
||||
/* .format = */ PIX_FMT_BGRx32,
|
||||
/* .name = */ "bgrx32",
|
||||
/* .nb_channels = */ 4,
|
||||
/* .color_type = */ FF_COLOR_RGB,
|
||||
/* .pixel_type = */ FF_PIXEL_PACKED,
|
||||
/* .is_alpha = */ 0,
|
||||
/* .x_chroma_shift = */ 0,
|
||||
/* .y_chroma_shift = */ 0,
|
||||
/* .depth = */ 8,
|
||||
},
|
||||
/* [PIX_FMT_RGBA32] = */ {
|
||||
/* .format = */ PIX_FMT_RGBA32,
|
||||
/* .name = */ "rgba32",
|
||||
|
@ -1651,6 +1673,67 @@ bitcopy_n (unsigned int a, int n)
|
|||
|
||||
#include "imgconvert_template.h"
|
||||
|
||||
/* xrgb32 handling */
|
||||
|
||||
#define RGB_NAME xrgb32
|
||||
#define FMT_RGBA32
|
||||
|
||||
#define RGB_IN(r, g, b, s)\
|
||||
{\
|
||||
unsigned int v = ((const uint32_t *)(s))[0];\
|
||||
r = (v >> 24) & 0xff;\
|
||||
g = (v >> 16) & 0xff;\
|
||||
b = (v >> 8) & 0xff;\
|
||||
}
|
||||
|
||||
#define RGBA_IN(r, g, b, a, s)\
|
||||
{\
|
||||
unsigned int v = ((const uint32_t *)(s))[0];\
|
||||
a = 0xff;\
|
||||
r = (v >> 24) & 0xff;\
|
||||
g = (v >> 16) & 0xff;\
|
||||
b = (v >> 8) & 0xff;\
|
||||
}
|
||||
|
||||
#define RGBA_OUT(d, r, g, b, a)\
|
||||
{\
|
||||
((uint32_t *)(d))[0] = (r << 24) | (g << 16) | (b << 8) | a;\
|
||||
}
|
||||
|
||||
#define BPP 4
|
||||
|
||||
#include "imgconvert_template.h"
|
||||
|
||||
/* bgrx32 handling */
|
||||
|
||||
#define RGB_NAME bgrx32
|
||||
|
||||
#define RGB_IN(r, g, b, s)\
|
||||
{\
|
||||
unsigned int v = ((const uint32_t *)(s))[0];\
|
||||
r = (v) & 0xff;\
|
||||
g = (v >> 8) & 0xff;\
|
||||
b = (v >> 16) & 0xff;\
|
||||
}
|
||||
|
||||
#define RGBA_IN(r, g, b, a, s)\
|
||||
{\
|
||||
unsigned int v = ((const uint32_t *)(s))[0];\
|
||||
a = 0xff;\
|
||||
r = (v) & 0xff;\
|
||||
g = (v >> 8) & 0xff;\
|
||||
b = (v >> 16) & 0xff;\
|
||||
}
|
||||
|
||||
#define RGBA_OUT(d, r, g, b, a)\
|
||||
{\
|
||||
((uint32_t *)(d))[0] = r | (g << 8) | (b << 16) | (a << 24);\
|
||||
}
|
||||
|
||||
#define BPP 4
|
||||
|
||||
#include "imgconvert_template.h"
|
||||
|
||||
/* rgba32 handling */
|
||||
|
||||
#define RGB_NAME rgba32
|
||||
|
@ -1861,6 +1944,8 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_YUV420P, PIX_FMT_RGB24, yuv420p_to_rgb24},
|
||||
{PIX_FMT_YUV420P, PIX_FMT_RGB32, yuv420p_to_rgb32},
|
||||
{PIX_FMT_YUV420P, PIX_FMT_BGR32, yuv420p_to_bgr32},
|
||||
{PIX_FMT_YUV420P, PIX_FMT_xRGB32, yuv420p_to_xrgb32},
|
||||
{PIX_FMT_YUV420P, PIX_FMT_BGRx32, yuv420p_to_bgrx32},
|
||||
{PIX_FMT_YUV420P, PIX_FMT_RGBA32, yuv420p_to_rgba32},
|
||||
{PIX_FMT_YUV420P, PIX_FMT_BGRA32, yuv420p_to_bgra32},
|
||||
|
||||
|
@ -1875,6 +1960,8 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_YUVJ420P, PIX_FMT_RGB24, yuvj420p_to_rgb24},
|
||||
{PIX_FMT_YUVJ420P, PIX_FMT_RGB32, yuvj420p_to_rgb32},
|
||||
{PIX_FMT_YUVJ420P, PIX_FMT_BGR32, yuvj420p_to_bgr32},
|
||||
{PIX_FMT_YUVJ420P, PIX_FMT_RGB32, yuvj420p_to_xrgb32},
|
||||
{PIX_FMT_YUVJ420P, PIX_FMT_BGR32, yuvj420p_to_bgrx32},
|
||||
{PIX_FMT_YUVJ420P, PIX_FMT_RGBA32, yuvj420p_to_rgba32},
|
||||
{PIX_FMT_YUVJ420P, PIX_FMT_BGRA32, yuvj420p_to_bgra32},
|
||||
|
||||
|
@ -1891,6 +1978,8 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_RGB24, PIX_FMT_RGB555, rgb24_to_rgb555},
|
||||
{PIX_FMT_RGB24, PIX_FMT_RGB32, rgb24_to_rgb32},
|
||||
{PIX_FMT_RGB24, PIX_FMT_BGR32, rgb24_to_bgr32},
|
||||
{PIX_FMT_RGB24, PIX_FMT_xRGB32, rgb24_to_xrgb32},
|
||||
{PIX_FMT_RGB24, PIX_FMT_BGRx32, rgb24_to_bgrx32},
|
||||
{PIX_FMT_RGB24, PIX_FMT_RGBA32, rgb24_to_rgba32},
|
||||
{PIX_FMT_RGB24, PIX_FMT_BGR24, rgb24_to_bgr24},
|
||||
{PIX_FMT_RGB24, PIX_FMT_BGRA32, rgb24_to_bgra32},
|
||||
|
@ -1907,8 +1996,14 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_RGB32, PIX_FMT_YUV420P, rgb32_to_yuv420p},
|
||||
{PIX_FMT_RGB32, PIX_FMT_GRAY8, rgb32_to_gray},
|
||||
|
||||
{PIX_FMT_xRGB32, PIX_FMT_RGB24, xrgb32_to_rgb24},
|
||||
{PIX_FMT_xRGB32, PIX_FMT_PAL8, xrgb32_to_pal8},
|
||||
{PIX_FMT_xRGB32, PIX_FMT_YUV420P, xrgb32_to_yuv420p},
|
||||
{PIX_FMT_xRGB32, PIX_FMT_GRAY8, xrgb32_to_gray},
|
||||
|
||||
{PIX_FMT_RGBA32, PIX_FMT_BGRA32, rgba32_to_bgra32},
|
||||
{PIX_FMT_RGBA32, PIX_FMT_BGR32, rgba32_to_bgr32},
|
||||
{PIX_FMT_RGBA32, PIX_FMT_BGRx32, rgba32_to_bgrx32},
|
||||
{PIX_FMT_RGBA32, PIX_FMT_RGB24, rgba32_to_rgb24},
|
||||
{PIX_FMT_RGBA32, PIX_FMT_RGB555, rgba32_to_rgb555},
|
||||
{PIX_FMT_RGBA32, PIX_FMT_PAL8, rgba32_to_pal8},
|
||||
|
@ -1926,6 +2021,11 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_BGR32, PIX_FMT_YUV420P, bgr32_to_yuv420p},
|
||||
{PIX_FMT_BGR32, PIX_FMT_GRAY8, bgr32_to_gray},
|
||||
|
||||
{PIX_FMT_BGRx32, PIX_FMT_RGB24, bgrx32_to_rgb24},
|
||||
{PIX_FMT_BGRx32, PIX_FMT_RGBA32, bgrx32_to_rgba32},
|
||||
{PIX_FMT_BGRx32, PIX_FMT_YUV420P, bgrx32_to_yuv420p},
|
||||
{PIX_FMT_BGRx32, PIX_FMT_GRAY8, bgrx32_to_gray},
|
||||
|
||||
{PIX_FMT_BGRA32, PIX_FMT_RGB24, bgra32_to_rgb24},
|
||||
{PIX_FMT_BGRA32, PIX_FMT_RGBA32, bgra32_to_rgba32},
|
||||
{PIX_FMT_BGRA32, PIX_FMT_YUV420P, bgra32_to_yuv420p},
|
||||
|
@ -1947,6 +2047,8 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_GRAY8, PIX_FMT_BGR24, gray_to_bgr24},
|
||||
{PIX_FMT_GRAY8, PIX_FMT_RGB32, gray_to_rgb32},
|
||||
{PIX_FMT_GRAY8, PIX_FMT_BGR32, gray_to_bgr32},
|
||||
{PIX_FMT_GRAY8, PIX_FMT_xRGB32, gray_to_xrgb32},
|
||||
{PIX_FMT_GRAY8, PIX_FMT_BGRx32, gray_to_bgrx32},
|
||||
{PIX_FMT_GRAY8, PIX_FMT_RGBA32, gray_to_rgba32},
|
||||
{PIX_FMT_GRAY8, PIX_FMT_BGRA32, gray_to_bgra32},
|
||||
{PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, gray_to_monowhite},
|
||||
|
@ -1962,6 +2064,8 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_PAL8, PIX_FMT_RGB24, pal8_to_rgb24},
|
||||
{PIX_FMT_PAL8, PIX_FMT_RGB32, pal8_to_rgb32},
|
||||
{PIX_FMT_PAL8, PIX_FMT_BGR32, pal8_to_bgr32},
|
||||
{PIX_FMT_PAL8, PIX_FMT_xRGB32, pal8_to_xrgb32},
|
||||
{PIX_FMT_PAL8, PIX_FMT_BGRx32, pal8_to_bgrx32},
|
||||
{PIX_FMT_PAL8, PIX_FMT_RGBA32, pal8_to_rgba32},
|
||||
{PIX_FMT_PAL8, PIX_FMT_BGRA32, pal8_to_bgra32},
|
||||
|
||||
|
@ -2029,13 +2133,13 @@ img_convert (AVPicture * dst, int dst_pix_fmt,
|
|||
ConvertEntry *ce;
|
||||
AVPicture tmp1, *tmp = &tmp1;
|
||||
|
||||
if (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB ||
|
||||
dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB)
|
||||
if (G_UNLIKELY (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB ||
|
||||
dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB))
|
||||
return -1;
|
||||
if (src_width <= 0 || src_height <= 0)
|
||||
if (G_UNLIKELY (src_width <= 0 || src_height <= 0))
|
||||
return 0;
|
||||
|
||||
if (!inited) {
|
||||
if (G_UNLIKELY (!inited)) {
|
||||
inited = 1;
|
||||
img_convert_init ();
|
||||
}
|
||||
|
@ -2045,7 +2149,7 @@ img_convert (AVPicture * dst, int dst_pix_fmt,
|
|||
|
||||
dst_pix = get_pix_fmt_info (dst_pix_fmt);
|
||||
src_pix = get_pix_fmt_info (src_pix_fmt);
|
||||
if (src_pix_fmt == dst_pix_fmt) {
|
||||
if (G_UNLIKELY (src_pix_fmt == dst_pix_fmt)) {
|
||||
/* no conversion needed: just copy */
|
||||
img_copy (dst, src, dst_pix_fmt, dst_width, dst_height);
|
||||
return 0;
|
||||
|
@ -2302,6 +2406,12 @@ img_get_alpha_info (const AVPicture * src, int pix_fmt, int width, int height)
|
|||
case PIX_FMT_BGR32:
|
||||
ret = get_alpha_info_bgr32 (src, width, height);
|
||||
break;
|
||||
case PIX_FMT_xRGB32:
|
||||
ret = get_alpha_info_xrgb32 (src, width, height);
|
||||
break;
|
||||
case PIX_FMT_BGRx32:
|
||||
ret = get_alpha_info_bgrx32 (src, width, height);
|
||||
break;
|
||||
case PIX_FMT_RGBA32:
|
||||
ret = get_alpha_info_rgba32 (src, width, height);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue