mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 15:51:11 +00:00
gst/ffmpegcolorspace/: #318353); use gst_structure_has_name().
Original commit message from CVS: * gst/ffmpegcolorspace/gstffmpegcodecmap.c: (gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_pixfmt): * gst/ffmpegcolorspace/gstffmpegcolorspace.c: (gst_ffmpegcsp_caps_remove_format_info): * gst/ffmpegcolorspace/imgconvert.c: * gst/ffmpegcolorspace/imgconvert_template.h: Forward-port fixes from the 0.8 branch (patch by Luca Ognibene, #318353); use gst_structure_has_name().
This commit is contained in:
parent
cc3190e666
commit
629092a79a
5 changed files with 118 additions and 43 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2005-11-22 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/ffmpegcolorspace/gstffmpegcodecmap.c:
|
||||
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_pixfmt):
|
||||
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
|
||||
(gst_ffmpegcsp_caps_remove_format_info):
|
||||
* gst/ffmpegcolorspace/imgconvert.c:
|
||||
* gst/ffmpegcolorspace/imgconvert_template.h:
|
||||
Forward-port fixes from the 0.8 branch (patch by Luca Ognibene,
|
||||
#318353); use gst_structure_has_name().
|
||||
|
||||
2005-11-22 Julien MOUTTE <julien@moutte.net>
|
||||
|
||||
* sys/ximage/ximagesink.c: (gst_ximagesink_event_thread),
|
||||
|
|
|
@ -150,7 +150,7 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context)
|
|||
fmt = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
|
||||
break;
|
||||
case PIX_FMT_YUV444P:
|
||||
/* .. */
|
||||
fmt = GST_MAKE_FOURCC ('Y', '4', '4', '4');
|
||||
break;
|
||||
case PIX_FMT_RGB32:
|
||||
bpp = 32;
|
||||
|
@ -201,15 +201,16 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context)
|
|||
depth = 32;
|
||||
endianness = G_BIG_ENDIAN;
|
||||
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
||||
r_mask = 0x00ff0000;
|
||||
g_mask = 0x0000ff00;
|
||||
b_mask = 0x000000ff;
|
||||
a_mask = 0xff000000;
|
||||
#else
|
||||
r_mask = 0x0000ff00;
|
||||
g_mask = 0x00ff0000;
|
||||
b_mask = 0xff000000;
|
||||
a_mask = 0x000000ff;
|
||||
#else
|
||||
r_mask = 0x00ff0000;
|
||||
g_mask = 0x0000ff00;
|
||||
b_mask = 0x000000ff;
|
||||
a_mask = 0xff000000;
|
||||
|
||||
#endif
|
||||
break;
|
||||
case PIX_FMT_YUV410P:
|
||||
|
@ -240,41 +241,48 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context)
|
|||
case PIX_FMT_AYUV4444:
|
||||
fmt = GST_MAKE_FOURCC ('A', 'Y', 'U', 'V');
|
||||
break;
|
||||
case PIX_FMT_GRAY8:
|
||||
bpp = depth = 8;
|
||||
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-gray",
|
||||
"bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
|
||||
break;
|
||||
default:
|
||||
/* give up ... */
|
||||
break;
|
||||
}
|
||||
|
||||
if (bpp != 0) {
|
||||
if (a_mask != 0) {
|
||||
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb",
|
||||
"bpp", G_TYPE_INT, bpp,
|
||||
"depth", G_TYPE_INT, depth,
|
||||
"red_mask", G_TYPE_INT, r_mask,
|
||||
"green_mask", G_TYPE_INT, g_mask,
|
||||
"blue_mask", G_TYPE_INT, b_mask,
|
||||
"alpha_mask", G_TYPE_INT, a_mask,
|
||||
"endianness", G_TYPE_INT, endianness, NULL);
|
||||
} else if (r_mask != 0) {
|
||||
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb",
|
||||
"bpp", G_TYPE_INT, bpp,
|
||||
"depth", G_TYPE_INT, depth,
|
||||
"red_mask", G_TYPE_INT, r_mask,
|
||||
"green_mask", G_TYPE_INT, g_mask,
|
||||
"blue_mask", G_TYPE_INT, b_mask,
|
||||
"endianness", G_TYPE_INT, endianness, NULL);
|
||||
} else {
|
||||
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb",
|
||||
"bpp", G_TYPE_INT, bpp,
|
||||
"depth", G_TYPE_INT, depth,
|
||||
"endianness", G_TYPE_INT, endianness, NULL);
|
||||
if (context) {
|
||||
gst_ffmpeg_set_palette (caps, context);
|
||||
if (caps == NULL) {
|
||||
if (bpp != 0) {
|
||||
if (a_mask != 0) {
|
||||
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb",
|
||||
"bpp", G_TYPE_INT, bpp,
|
||||
"depth", G_TYPE_INT, depth,
|
||||
"red_mask", G_TYPE_INT, r_mask,
|
||||
"green_mask", G_TYPE_INT, g_mask,
|
||||
"blue_mask", G_TYPE_INT, b_mask,
|
||||
"alpha_mask", G_TYPE_INT, a_mask,
|
||||
"endianness", G_TYPE_INT, endianness, NULL);
|
||||
} else if (r_mask != 0) {
|
||||
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb",
|
||||
"bpp", G_TYPE_INT, bpp,
|
||||
"depth", G_TYPE_INT, depth,
|
||||
"red_mask", G_TYPE_INT, r_mask,
|
||||
"green_mask", G_TYPE_INT, g_mask,
|
||||
"blue_mask", G_TYPE_INT, b_mask,
|
||||
"endianness", G_TYPE_INT, endianness, NULL);
|
||||
} else {
|
||||
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb",
|
||||
"bpp", G_TYPE_INT, bpp,
|
||||
"depth", G_TYPE_INT, depth,
|
||||
"endianness", G_TYPE_INT, endianness, NULL);
|
||||
if (context) {
|
||||
gst_ffmpeg_set_palette (caps, context);
|
||||
}
|
||||
}
|
||||
} else if (fmt) {
|
||||
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-yuv",
|
||||
"format", GST_TYPE_FOURCC, fmt, NULL);
|
||||
}
|
||||
} else if (fmt) {
|
||||
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-yuv",
|
||||
"format", GST_TYPE_FOURCC, fmt, NULL);
|
||||
}
|
||||
|
||||
if (caps != NULL) {
|
||||
|
@ -456,7 +464,7 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
|
|||
if (!raw)
|
||||
return;
|
||||
|
||||
if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
|
||||
if (gst_structure_has_name (structure, "video/x-raw-yuv")) {
|
||||
guint32 fourcc;
|
||||
|
||||
if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
|
||||
|
@ -482,15 +490,12 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
|
|||
case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
|
||||
context->pix_fmt = PIX_FMT_AYUV4444;
|
||||
break;
|
||||
#if 0
|
||||
case FIXME:
|
||||
case GST_MAKE_FOURCC ('Y', '4', '4', '4'):
|
||||
context->pix_fmt = PIX_FMT_YUV444P;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else if (strcmp (gst_structure_get_name (structure),
|
||||
"video/x-raw-rgb") == 0) {
|
||||
} else if (gst_structure_has_name (structure, "video/x-raw-rgb")) {
|
||||
gint bpp = 0, rmask = 0, endianness = 0, amask = 0, depth = 0;
|
||||
|
||||
if (gst_structure_get_int (structure, "bpp", &bpp) &&
|
||||
|
@ -500,9 +505,9 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
|
|||
case 32:
|
||||
if (gst_structure_get_int (structure, "alpha_mask", &amask)) {
|
||||
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
||||
if (rmask == 0x00ff0000)
|
||||
#else
|
||||
if (rmask == 0x0000ff00)
|
||||
#else
|
||||
if (rmask == 0x00ff0000)
|
||||
#endif
|
||||
context->pix_fmt = PIX_FMT_BGRA32;
|
||||
else
|
||||
|
@ -553,6 +558,16 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (gst_structure_has_name (structure, "video/x-raw-gray")) {
|
||||
gint bpp = 0;
|
||||
|
||||
if (gst_structure_get_int (structure, "bpp", &bpp)) {
|
||||
switch (bpp) {
|
||||
case 8:
|
||||
context->pix_fmt = PIX_FMT_GRAY8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps)
|
|||
int i;
|
||||
GstStructure *structure;
|
||||
GstCaps *rgbcaps;
|
||||
GstCaps *graycaps;
|
||||
|
||||
caps = gst_caps_copy (caps);
|
||||
|
||||
|
@ -117,7 +118,15 @@ gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps)
|
|||
|
||||
gst_structure_set_name (structure, "video/x-raw-rgb");
|
||||
}
|
||||
graycaps = gst_caps_copy (caps);
|
||||
|
||||
for (i = 0; i < gst_caps_get_size (graycaps); i++) {
|
||||
structure = gst_caps_get_structure (graycaps, i);
|
||||
|
||||
gst_structure_set_name (structure, "video/x-raw-gray");
|
||||
}
|
||||
|
||||
gst_caps_append (caps, graycaps);
|
||||
gst_caps_append (caps, rgbcaps);
|
||||
|
||||
return caps;
|
||||
|
|
|
@ -1674,6 +1674,7 @@ bitcopy_n (unsigned int a, int n)
|
|||
/* bgra32 handling */
|
||||
|
||||
#define RGB_NAME bgra32
|
||||
#define FMT_BGRA32
|
||||
|
||||
#define RGB_IN(r, g, b, s)\
|
||||
{\
|
||||
|
@ -1903,6 +1904,7 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_RGBA32, PIX_FMT_YUV420P, rgba32_to_yuv420p},
|
||||
{PIX_FMT_RGBA32, PIX_FMT_GRAY8, rgba32_to_gray},
|
||||
{PIX_FMT_RGBA32, PIX_FMT_AYUV4444, rgba32_to_ayuv4444},
|
||||
{PIX_FMT_BGRA32, PIX_FMT_AYUV4444, bgra32_to_ayuv4444},
|
||||
|
||||
{PIX_FMT_BGR24, PIX_FMT_RGB24, bgr24_to_rgb24},
|
||||
{PIX_FMT_BGR24, PIX_FMT_YUV420P, bgr24_to_yuv420p},
|
||||
|
|
|
@ -467,6 +467,9 @@ static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
|
|||
d += dst_wrap;
|
||||
}
|
||||
}
|
||||
#endif /* !defined(FMT_RGBA32) && defined(RGBA_OUT) */
|
||||
|
||||
#if defined(FMT_RGBA32)
|
||||
|
||||
#if !defined(rgba32_fcts_done)
|
||||
#define rgba32_fcts_done
|
||||
|
@ -527,7 +530,42 @@ static void rgba32_to_ayuv4444(AVPicture *dst, const AVPicture *src,
|
|||
|
||||
#endif /* !defined(rgba32_fcts_done) */
|
||||
|
||||
#endif /* !defined(FMT_RGBA32) && defined(RGBA_OUT) */
|
||||
#endif /* defined(FMT_RGBA32) */
|
||||
|
||||
#if defined(FMT_BGRA32)
|
||||
#if !defined(bgra32_fcts_done)
|
||||
#define bgra32_fcts_done
|
||||
|
||||
static void bgra32_to_ayuv4444(AVPicture *dst, const AVPicture *src,
|
||||
int width, int height)
|
||||
{
|
||||
int src_wrap, dst_wrap, x, y;
|
||||
int r, g, b, a;
|
||||
uint8_t *d;
|
||||
const uint8_t *p;
|
||||
|
||||
src_wrap = src->linesize[0] - width * BPP;
|
||||
dst_wrap = dst->linesize[0] - width * 4;
|
||||
d = dst->data[0];
|
||||
p = src->data[0];
|
||||
for(y=0;y<height;y++) {
|
||||
for(x=0;x<width;x++) {
|
||||
RGBA_IN(r, g, b, a, p);
|
||||
d[0] = a;
|
||||
d[1] = RGB_TO_Y_CCIR(r, g, b);
|
||||
d[2] = RGB_TO_U_CCIR(r, g, b, 0);
|
||||
d[3] = RGB_TO_V_CCIR(r, g, b, 0);
|
||||
p += BPP;
|
||||
d += 4;
|
||||
}
|
||||
p += src_wrap;
|
||||
d += dst_wrap;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !defined(bgra32_fcts_done) */
|
||||
|
||||
#endif /* defined(FMT_BGRA32) */
|
||||
|
||||
#ifndef FMT_RGB24
|
||||
|
||||
|
|
Loading…
Reference in a new issue