mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 23:06:49 +00:00
ext/ffmpeg/gstffmpegcodecmap.c: Generalized palette functions, add actual mimetypes for wing commander formats.
Original commit message from CVS: * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps), (gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid): Generalized palette functions, add actual mimetypes for wing commander formats. * ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_chain): Ffmpeg has internal palette functions, so I noticed. * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_chain): Actually remove all palette code.
This commit is contained in:
parent
530ec15806
commit
3cf593d824
4 changed files with 45 additions and 42 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2004-10-02 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||
|
||||
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
|
||||
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
|
||||
Generalized palette functions, add actual mimetypes for wing
|
||||
commander formats.
|
||||
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_chain):
|
||||
Ffmpeg has internal palette functions, so I noticed.
|
||||
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_chain):
|
||||
Actually remove all palette code.
|
||||
|
||||
2004-10-02 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||
|
||||
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_loop):
|
||||
|
|
|
@ -401,13 +401,17 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
|
|||
caps = GST_FF_VID_CAPS_NEW ("video/x-4xm", NULL);
|
||||
break;
|
||||
|
||||
case CODEC_ID_XAN_WC3:
|
||||
case CODEC_ID_XAN_WC4:
|
||||
caps = GST_FF_VID_CAPS_NEW ("video/x-xan",
|
||||
"wcversion", G_TYPE_INT, 3 - CODEC_ID_XAN_WC3 + codec_id, NULL);
|
||||
break;
|
||||
|
||||
case CODEC_ID_VCR1:
|
||||
case CODEC_ID_CLJR:
|
||||
case CODEC_ID_MDEC:
|
||||
case CODEC_ID_ROQ:
|
||||
case CODEC_ID_INTERPLAY_VIDEO:
|
||||
case CODEC_ID_XAN_WC3:
|
||||
case CODEC_ID_XAN_WC4:
|
||||
buildcaps = TRUE;
|
||||
break;
|
||||
|
||||
|
@ -427,7 +431,6 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
|
|||
if (context) {
|
||||
gst_caps_set_simple (caps,
|
||||
"depth", G_TYPE_INT, (gint) context->bits_per_sample, NULL);
|
||||
gst_ffmpeg_set_palette (caps, context);
|
||||
} else {
|
||||
gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
|
||||
}
|
||||
|
@ -694,6 +697,11 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
|
|||
gst_buffer_unref (data);
|
||||
}
|
||||
|
||||
/* palette */
|
||||
if (context) {
|
||||
gst_ffmpeg_set_palette (caps, context);
|
||||
}
|
||||
|
||||
str = gst_caps_to_string (caps);
|
||||
GST_DEBUG ("caps for codec_id=%d: %s", codec_id, str);
|
||||
g_free (str);
|
||||
|
@ -1172,7 +1180,6 @@ gst_ffmpeg_caps_with_codecid (enum CodecID codec_id,
|
|||
|
||||
if (gst_structure_get_int (str, "depth", &depth))
|
||||
context->bits_per_sample = depth;
|
||||
gst_ffmpeg_get_palette (caps, context);
|
||||
} while (0);
|
||||
break;
|
||||
|
||||
|
@ -1184,6 +1191,7 @@ gst_ffmpeg_caps_with_codecid (enum CodecID codec_id,
|
|||
switch (codec_type) {
|
||||
case CODEC_TYPE_VIDEO:
|
||||
gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
|
||||
gst_ffmpeg_get_palette (caps, context);
|
||||
break;
|
||||
case CODEC_TYPE_AUDIO:
|
||||
gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
|
||||
|
@ -1604,6 +1612,23 @@ gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
|
|||
video = TRUE;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp (mimetype, "video/x-xan")) {
|
||||
gint wcversion = 0;
|
||||
|
||||
if ((gst_structure_get_int (structure, "wcversion", &wcversion))) {
|
||||
switch (wcversion) {
|
||||
case 3:
|
||||
id = CODEC_ID_XAN_WC3;
|
||||
video = TRUE;
|
||||
break;
|
||||
case 4:
|
||||
id = CODEC_ID_XAN_WC4;
|
||||
video = TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (!strncmp (mimetype, "audio/x-gst_ff-", 15) ||
|
||||
!strncmp (mimetype, "video/x-gst_ff-", 15)) {
|
||||
gchar ext[16];
|
||||
|
|
|
@ -351,54 +351,25 @@ gst_ffmpegcsp_chain (GstPad * pad, GstData * data)
|
|||
if (space->from_pixfmt == space->to_pixfmt) {
|
||||
outbuf = inbuf;
|
||||
} else {
|
||||
enum PixelFormat from_pixfmt =
|
||||
(space->from_pixfmt == PIX_FMT_PAL8) ?
|
||||
PIX_FMT_RGBA32 : space->from_pixfmt;
|
||||
guint size = avpicture_get_size (space->to_pixfmt,
|
||||
space->width, space->height);
|
||||
GstBuffer *inbuf2;
|
||||
|
||||
if (from_pixfmt != space->from_pixfmt) {
|
||||
/* manual conversion from palette to RGBA32 */
|
||||
gint x, y, pix, wd = space->width;
|
||||
guint8 *dest;
|
||||
guint32 conv;
|
||||
AVPaletteControl *pal = space->palette;
|
||||
|
||||
inbuf2 = gst_buffer_new_and_alloc (4 *
|
||||
space->width * space->height);
|
||||
dest = GST_BUFFER_DATA (inbuf2);
|
||||
|
||||
for (y = 0; y < space->height; y++) {
|
||||
for (x = 0; x < space->width; x++) {
|
||||
pix = GST_BUFFER_DATA (inbuf)[y * wd + x];
|
||||
conv = pal->palette[pix];
|
||||
dest[(y * wd + x) * 4] = ((guint8 *) &conv)[0];
|
||||
dest[(y * wd + x) * 4 + 1] = ((guint8 *) &conv)[1];
|
||||
dest[(y * wd + x) * 4 + 2] = ((guint8 *) &conv)[2];
|
||||
dest[(y * wd + x) * 4 + 3] = ((guint8 *) &conv)[3];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inbuf2 = inbuf;
|
||||
}
|
||||
|
||||
outbuf = gst_pad_alloc_buffer (space->srcpad, GST_BUFFER_OFFSET_NONE, size);
|
||||
|
||||
/* convert */
|
||||
avpicture_fill ((AVPicture *) space->from_frame, GST_BUFFER_DATA (inbuf2),
|
||||
from_pixfmt, space->width, space->height);
|
||||
avpicture_fill ((AVPicture *) space->from_frame, GST_BUFFER_DATA (inbuf),
|
||||
space->from_pixfmt, space->width, space->height);
|
||||
if (space->palette)
|
||||
space->from_frame->data[1] = (uint8_t *) space->palette;
|
||||
avpicture_fill ((AVPicture *) space->to_frame, GST_BUFFER_DATA (outbuf),
|
||||
space->to_pixfmt, space->width, space->height);
|
||||
img_convert ((AVPicture *) space->to_frame, space->to_pixfmt,
|
||||
(AVPicture *) space->from_frame, from_pixfmt,
|
||||
(AVPicture *) space->from_frame, space->from_pixfmt,
|
||||
space->width, space->height);
|
||||
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
|
||||
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
|
||||
|
||||
if (inbuf != inbuf2)
|
||||
gst_buffer_unref (inbuf2);
|
||||
gst_buffer_unref (inbuf);
|
||||
}
|
||||
|
||||
|
|
|
@ -472,13 +472,9 @@ gst_ffmpegdec_chain (GstPad * pad, GstData * _data)
|
|||
if (have_data) {
|
||||
if (!GST_PAD_CAPS (ffmpegdec->srcpad)) {
|
||||
GstCaps *caps;
|
||||
enum PixelFormat orig_fmt = ffmpegdec->context->pix_fmt;
|
||||
|
||||
ffmpegdec->context->pix_fmt = (orig_fmt == PIX_FMT_PAL8) ?
|
||||
PIX_FMT_RGBA32 : orig_fmt;
|
||||
caps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type,
|
||||
ffmpegdec->context);
|
||||
ffmpegdec->context->pix_fmt = orig_fmt;
|
||||
|
||||
/* add in pixel-aspect-ratio if we have it */
|
||||
if (caps && ffmpegdec->par) {
|
||||
|
|
Loading…
Reference in a new issue