slomo gst-ffmpeg: gst-ffmpeg/ gst-ffmpeg/ext/ffmpeg/
[email protected] Fri, 12 Dec 2008 23:55:55 -0800 (PST)
| Newsgroups | gmane.comp.video.gstreamer.cvs |
|---|---|
| Message-ID | <[email protected]> |
CVS Root: /cvs/gstreamer
Module: gst-ffmpeg
Changes by: slomo
Date: Sat Dec 13 2008 07:55:55 UTC
Log message:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ff_channel_layout_to_gst),
(gst_ff_aud_caps_new):
* ext/ffmpeg/gstffmpegcodecmap.h:
Set the channel layout if it's exposed by the decoder.
Fixes bug #548002.
Modified files:
. : ChangeLog
ext/ffmpeg : Makefile.am gstffmpegcodecmap.c
gstffmpegcodecmap.h
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-ffmpeg/ChangeLog.diff?r1=1.532&r2=1.533
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-ffmpeg/ext/ffmpeg/Makefile.am.diff?r1=1.37&r2=1.38
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-ffmpeg/ext/ffmpeg/gstffmpegcodecmap.c.diff?r1=1.172&r2=1.173
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-ffmpeg/ext/ffmpeg/gstffmpegcodecmap.h.diff?r1=1.25&r2=1.26
====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-ffmpeg/ChangeLog,v
retrieving revision 1.532
retrieving revision 1.533
diff -u -d -r1.532 -r1.533
--- ChangeLog 13 Dec 2008 06:51:26 -0000 1.532
+++ ChangeLog 13 Dec 2008 07:55:40 -0000 1.533
@@ -1,5 +1,14 @@
2008-12-13 Sebastian Dröge <[email protected]>
+ * ext/ffmpeg/Makefile.am:
+ * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ff_channel_layout_to_gst),
+ (gst_ff_aud_caps_new):
+ * ext/ffmpeg/gstffmpegcodecmap.h:
+ Set the channel layout if it's exposed by the decoder.
+ Fixes bug #548002.
+
+2008-12-13 Sebastian Dröge <[email protected]>
* ffmpegrev:
Update ffmpeg revision to 16086 and update to the corresponding
swscale revision.
Index: Makefile.am
RCS file: /cvs/gstreamer/gst-ffmpeg/ext/ffmpeg/Makefile.am,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- Makefile.am 4 Nov 2008 12:49:40 -0000 1.37
+++ Makefile.am 13 Dec 2008 07:55:40 -0000 1.38
@@ -15,7 +15,7 @@
libgstffmpeg_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \
$(FFMPEG_CFLAGS)
-libgstffmpeg_la_LIBADD = $(FFMPEG_LIBS) $(GST_BASE_LIBS) $(LIBM) $(WIN32_LIBS) -lz -lbz2
+libgstffmpeg_la_LIBADD = $(FFMPEG_LIBS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LIBM) $(WIN32_LIBS) -lz -lbz2
libgstffmpeg_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(DARWIN_LDFLAGS)
libgstffmpeg_la_LIBTOOLFLAGS = --tag=disable-static
Index: gstffmpegcodecmap.c
RCS file: /cvs/gstreamer/gst-ffmpeg/ext/ffmpeg/gstffmpegcodecmap.c,v
retrieving revision 1.172
retrieving revision 1.173
diff -u -d -r1.172 -r1.173
--- gstffmpegcodecmap.c 7 Nov 2008 11:43:42 -0000 1.172
+++ gstffmpegcodecmap.c 13 Dec 2008 07:55:40 -0000 1.173
@@ -70,6 +70,98 @@
}
}
+/* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
+static const struct
+{
+ guint64 ff;
+ GstAudioChannelPosition gst;
+} _ff_to_gst_layout[] = {
+ {
+ CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
+ CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
+ CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
+ CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
+ CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
+ CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
+ CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
+ CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
+ CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
+ CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
+ CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
+ CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+ CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+ CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+ CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+ CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+ CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+ CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+ CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
+ CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
+};
+static GstAudioChannelPosition *
+gst_ff_channel_layout_to_gst (guint64 channel_layout, guint channels)
+ guint nchannels = 0, i, j;
+ GstAudioChannelPosition *pos = NULL;
+ gboolean none_layout = FALSE;
+ for (i = 0; i < 64; i++) {
+ if ((channel_layout & (G_GUINT64_CONSTANT (1) << i)) != 0) {
+ nchannels++;
+ }
+ }
+ if (channel_layout == 0) {
+ nchannels = channels;
+ none_layout = TRUE;
+ if (nchannels != channels) {
+ GST_ERROR ("Number of channels is different (%u != %u)", channels,
+ nchannels);
+ return NULL;
+ pos = g_new (GstAudioChannelPosition, nchannels);
+ for (i = 0, j = 0; i < G_N_ELEMENTS (_ff_to_gst_layout); i++) {
+ if ((channel_layout & _ff_to_gst_layout[i].ff) != 0) {
+ pos[j++] = _ff_to_gst_layout[i].gst;
+ if (_ff_to_gst_layout[i].gst == GST_AUDIO_CHANNEL_POSITION_NONE)
+ none_layout = TRUE;
+ if (j != nchannels) {
+ GST_WARNING ("Unknown channels in channel layout - assuming NONE layout");
+ if (!gst_audio_check_channel_positions (pos, nchannels)) {
+ GST_ERROR ("Invalid channel layout - assuming NONE layout");
+ if (none_layout) {
+ if (nchannels == 1) {
+ pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO;
+ } else if (nchannels == 2) {
+ pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+ pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+ } else {
+ for (i = 0; i < nchannels; i++)
+ pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
+ if (nchannels == 1 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER)
+ pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO;
+ return pos;
+}
/* this macro makes a caps width fixed or unfixed width/height
* properties depending on whether we've got a context.
*
@@ -197,9 +289,19 @@
/* fixed, non-probing context */
if (context != NULL && context->channels != -1) {
+ GstAudioChannelPosition *pos;
caps = gst_caps_new_simple (mimetype,
"rate", G_TYPE_INT, context->sample_rate,
"channels", G_TYPE_INT, context->channels, NULL);
+ pos =
+ gst_ff_channel_layout_to_gst (context->channel_layout,
+ context->channels);
+ if (pos != NULL) {
+ gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
+ g_free (pos);
} else {
gint maxchannels = 2;
const gint *rates = NULL;
@@ -243,6 +345,11 @@
default:
break;
}
+ /* TODO: handle context->channel_layouts here to set
+ * the list of channel layouts supported by the encoder.
+ * Unfortunately no encoder uses this yet....
+ */
}
/* regardless of encode/decode, open up channels if applicable */
@@ -1396,7 +1503,7 @@
if (caps != NULL) {
- GST_DEBUG ("caps for pix_fmt=%d: %"GST_PTR_FORMAT, pix_fmt, caps);
+ GST_DEBUG ("caps for pix_fmt=%d: %" GST_PTR_FORMAT, pix_fmt, caps);
GST_LOG ("No caps found for pix_fmt=%d", pix_fmt);
@@ -1439,7 +1546,7 @@
- GST_LOG ("caps for sample_fmt=%d: %"GST_PTR_FORMAT, sample_fmt, caps);
+ GST_LOG ("caps for sample_fmt=%d: %" GST_PTR_FORMAT, sample_fmt, caps);
GST_LOG ("No caps found for sample_fmt=%d", sample_fmt);
@@ -2769,9 +2876,9 @@
if (id != CODEC_ID_NONE) {
- GST_DEBUG ("The id=%d belongs to the caps %"GST_PTR_FORMAT, id, caps);
+ GST_DEBUG ("The id=%d belongs to the caps %" GST_PTR_FORMAT, id, caps);
- GST_WARNING ("Couldn't figure out the id for caps %"GST_PTR_FORMAT, caps);
+ GST_WARNING ("Couldn't figure out the id for caps %" GST_PTR_FORMAT, caps);
return id;
Index: gstffmpegcodecmap.h
RCS file: /cvs/gstreamer/gst-ffmpeg/ext/ffmpeg/gstffmpegcodecmap.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- gstffmpegcodecmap.h 30 Oct 2008 12:05:44 -0000 1.25
+++ gstffmpegcodecmap.h 13 Dec 2008 07:55:40 -0000 1.26
@@ -27,6 +27,8 @@
#endif
#include <gst/gst.h>
+#include <gst/audio/multichannel.h>
/*
* _codecid_to_caps () gets the GstCaps that belongs to
* a certain CodecID for a pad with compressed data.
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
gstreamer-cvs-verbose mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose