summaryrefslogtreecommitdiff
path: root/ext/ffmpeg/gstffmpegmux.c
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2007-12-17 20:31:35 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2007-12-17 20:31:35 +0000
commita0bae2f656e1e42dc45b278eab86780589956d72 (patch)
tree99b54e9e3e569a9a371b21c9d16bb279f5cf77c9 /ext/ffmpeg/gstffmpegmux.c
parentf6186655c5507c6cc1bbce09b397e6d89078205b (diff)
ext/ffmpeg/: Add GIF (animations and single images) decoding and encoding support.
Original commit message from CVS: * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps), (gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_get_codecid_longname): * ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_loop), (gst_ffmpegdemux_register): * ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_collected), (gst_ffmpegmux_register): Add GIF (animations and single images) decoding and encoding support. Fixes #503249.
Diffstat (limited to 'ext/ffmpeg/gstffmpegmux.c')
-rw-r--r--ext/ffmpeg/gstffmpegmux.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/ext/ffmpeg/gstffmpegmux.c b/ext/ffmpeg/gstffmpegmux.c
index 3962d0a..3c0efdc 100644
--- a/ext/ffmpeg/gstffmpegmux.c
+++ b/ext/ffmpeg/gstffmpegmux.c
@@ -525,6 +525,7 @@ gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
if (best_pad != NULL) {
GstBuffer *buf;
AVPacket pkt;
+ gboolean need_free = FALSE;
/* push out current buffer */
buf = gst_collect_pads_pop (ffmpegmux->collect,
@@ -536,8 +537,30 @@ gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
pkt.pts = gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (buf),
ffmpegmux->context->streams[best_pad->padnum]->time_base);
pkt.dts = pkt.pts;
- pkt.data = GST_BUFFER_DATA (buf);
- pkt.size = GST_BUFFER_SIZE (buf);
+
+ if (strcmp (ffmpegmux->context->oformat->name, "gif") == 0) {
+ AVStream *st = ffmpegmux->context->streams[best_pad->padnum];
+ AVPicture src, dst;
+
+ need_free = TRUE;
+ pkt.size = st->codec->width * st->codec->height * 3;
+ pkt.data = g_malloc (pkt.size);
+
+ dst.data[0] = pkt.data;
+ dst.data[1] = NULL;
+ dst.data[2] = NULL;
+ dst.linesize[0] = st->codec->width * 3;
+
+ gst_ffmpeg_avpicture_fill (&src, GST_BUFFER_DATA (buf),
+ PIX_FMT_RGB24, st->codec->width, st->codec->height);
+
+ gst_ffmpeg_img_convert (&dst, PIX_FMT_RGB24,
+ &src, PIX_FMT_RGB24, st->codec->width, st->codec->height);
+ } else {
+ pkt.data = GST_BUFFER_DATA (buf);
+ pkt.size = GST_BUFFER_SIZE (buf);
+ }
+
pkt.stream_index = best_pad->padnum;
pkt.flags = 0;
@@ -552,6 +575,8 @@ gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
pkt.duration = 0;
av_write_frame (ffmpegmux->context, &pkt);
gst_buffer_unref (buf);
+ if (need_free)
+ g_free (pkt.data);
} else {
/* close down */
av_write_trailer (ffmpegmux->context);
@@ -725,6 +750,12 @@ gst_ffmpegmux_register (GstPlugin * plugin)
const gint rates[] = { 44100, 22050, 11025 };
gst_ffmpeg_mux_simple_caps_set_int_list (audiosinkcaps, "rate", 3, rates);
+ } else if (strcmp (in_plugin->name, "gif") == 0) {
+ if (videosinkcaps)
+ gst_caps_unref (videosinkcaps);
+
+ videosinkcaps =
+ gst_caps_from_string ("video/x-raw-rgb, bpp=(int)24, depth=(int)24");
}
/* create a cache for these properties */