2002-11-06 23:53:46 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
2003-06-07 00:41:32 +00:00
|
|
|
* This file:
|
|
|
|
* Copyright (c) 2002-2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2002-11-06 23:53:46 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2004-01-12 04:15:46 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2002-11-26 14:50:05 +00:00
|
|
|
#include "config.h"
|
2004-01-12 04:15:46 +00:00
|
|
|
#endif
|
2003-10-26 11:30:18 +00:00
|
|
|
#include <gst/gst.h>
|
2002-11-26 14:50:05 +00:00
|
|
|
#ifdef HAVE_FFMPEG_UNINSTALLED
|
|
|
|
#include <avcodec.h>
|
|
|
|
#else
|
|
|
|
#include <ffmpeg/avcodec.h>
|
|
|
|
#endif
|
2003-06-07 00:41:32 +00:00
|
|
|
#include <string.h>
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2003-06-07 00:41:32 +00:00
|
|
|
#include "gstffmpegcodecmap.h"
|
|
|
|
|
|
|
|
/* this macro makes a caps width fixed or unfixed width/height
|
|
|
|
* properties depending on whether we've got a context.
|
|
|
|
*
|
|
|
|
* See below for why we use this.
|
2004-03-15 00:01:03 +00:00
|
|
|
*
|
|
|
|
* We should actually do this stuff at the end, like in riff-media.c,
|
|
|
|
* but I'm too lazy today. Maybe later.
|
2003-06-07 00:41:32 +00:00
|
|
|
*/
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
#define GST_FF_VID_CAPS_NEW(mimetype, props...) \
|
|
|
|
(context != NULL) ? \
|
|
|
|
gst_caps_new_simple (mimetype, \
|
|
|
|
"width", G_TYPE_INT, context->width, \
|
|
|
|
"height", G_TYPE_INT, context->height, \
|
|
|
|
"framerate", G_TYPE_DOUBLE, 1. * context->frame_rate / \
|
|
|
|
context->frame_rate_base, \
|
|
|
|
##props, NULL) \
|
|
|
|
: \
|
|
|
|
gst_caps_new_simple (mimetype, \
|
|
|
|
"width", GST_TYPE_INT_RANGE, 16, 4096, \
|
|
|
|
"height", GST_TYPE_INT_RANGE, 16, 4096, \
|
|
|
|
"framerate", GST_TYPE_DOUBLE_RANGE, 0., G_MAXDOUBLE, \
|
|
|
|
##props, NULL)
|
2003-06-07 00:41:32 +00:00
|
|
|
|
|
|
|
/* same for audio - now with channels/sample rate
|
|
|
|
*/
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
#define GST_FF_AUD_CAPS_NEW(mimetype, props...) \
|
|
|
|
(context != NULL) ? \
|
|
|
|
gst_caps_new_simple (mimetype, \
|
|
|
|
"rate", G_TYPE_INT, context->sample_rate, \
|
|
|
|
"channels", G_TYPE_INT, context->channels, \
|
|
|
|
##props, NULL) \
|
|
|
|
: \
|
|
|
|
gst_caps_new_simple (mimetype, \
|
|
|
|
##props, NULL)
|
2003-06-07 00:41:32 +00:00
|
|
|
|
|
|
|
/* Convert a FFMPEG codec ID and optional AVCodecContext
|
|
|
|
* to a GstCaps. If the context is ommitted, no fixed values
|
|
|
|
* for video/audio size will be included in the GstCaps
|
|
|
|
*
|
|
|
|
* CodecID is primarily meant for compressed data GstCaps!
|
2004-03-15 00:01:03 +00:00
|
|
|
*
|
|
|
|
* encode is a special parameter. gstffmpegdec will say
|
|
|
|
* FALSE, gstffmpegenc will say TRUE. The output caps
|
|
|
|
* depends on this, in such a way that it will be very
|
|
|
|
* specific, defined, fixed and correct caps for encoders,
|
|
|
|
* yet very wide, "forgiving" caps for decoders. Example
|
|
|
|
* for mp3: decode: audio/mpeg,mpegversion=1,layer=[1-3]
|
|
|
|
* but encode: audio/mpeg,mpegversion=1,layer=3,bitrate=x,
|
|
|
|
* rate=x,channels=x.
|
2003-06-07 00:41:32 +00:00
|
|
|
*/
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
GstCaps *
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
|
|
|
|
AVCodecContext * context, gboolean encode)
|
2002-11-06 23:53:46 +00:00
|
|
|
{
|
2003-06-07 00:41:32 +00:00
|
|
|
GstCaps *caps = NULL;
|
2004-03-15 00:01:03 +00:00
|
|
|
gboolean buildcaps = FALSE;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-25 21:37:26 +00:00
|
|
|
switch (codec_id) {
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_MPEG1VIDEO:
|
2004-03-15 00:01:03 +00:00
|
|
|
/* For decoding, CODEC_ID_MPEG2VIDEO is preferred... So omit here */
|
|
|
|
if (encode) {
|
|
|
|
/* FIXME: bitrate */
|
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/mpeg",
|
2004-03-29 16:39:18 +00:00
|
|
|
"mpegversion", G_TYPE_INT, 1,
|
|
|
|
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_MPEG2VIDEO:
|
|
|
|
if (encode) {
|
|
|
|
/* FIXME: bitrate */
|
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/mpeg",
|
2004-03-29 16:39:18 +00:00
|
|
|
"mpegversion", G_TYPE_INT, 2,
|
|
|
|
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
} else {
|
|
|
|
/* decode both MPEG-1 and MPEG-2; width/height/fps are all in
|
|
|
|
* the MPEG video stream headers, so may be omitted from caps. */
|
|
|
|
caps = gst_caps_new_simple ("video/mpeg",
|
2004-03-29 16:39:18 +00:00
|
|
|
"mpegversion", GST_TYPE_INT_RANGE, 1, 2,
|
|
|
|
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2004-03-15 00:01:03 +00:00
|
|
|
|
|
|
|
case CODEC_ID_MPEG2VIDEO_XVMC:
|
|
|
|
/* this is a special ID - don't need it in GStreamer, I think */
|
|
|
|
break;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
/* I don't know the exact differences between those... Anyone? */
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_H263:
|
2003-06-07 00:41:32 +00:00
|
|
|
case CODEC_ID_H263P:
|
|
|
|
case CODEC_ID_H263I:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-h263");
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_RV10:
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_RV20:
|
|
|
|
do {
|
|
|
|
gint version = (codec_id == CODEC_ID_RV10) ? 1 : 2;
|
|
|
|
|
|
|
|
/* FIXME: context->sub_id must be filled in during decoding */
|
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-pn-realvideo",
|
2004-03-29 16:39:18 +00:00
|
|
|
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
|
|
|
"rmversion", G_TYPE_INT, version, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
} while (0);
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_MP2:
|
2004-03-15 00:01:03 +00:00
|
|
|
/* we use CODEC_ID_MP3 for decoding */
|
|
|
|
if (encode) {
|
|
|
|
/* FIXME: bitrate */
|
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/mpeg",
|
2004-03-29 16:39:18 +00:00
|
|
|
"mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 2, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_MP3:
|
|
|
|
if (encode) {
|
|
|
|
/* FIXME: bitrate */
|
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/mpeg",
|
2004-03-29 16:39:18 +00:00
|
|
|
"mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
} else {
|
|
|
|
/* Decodes MPEG-1 layer 1/2/3. Samplerate, channels et al are
|
|
|
|
* in the MPEG audio header, so may be omitted from caps. */
|
|
|
|
caps = gst_caps_new_simple ("audio/mpeg",
|
2004-03-29 16:39:18 +00:00
|
|
|
"mpegversion", G_TYPE_INT, 1,
|
|
|
|
"layer", GST_TYPE_INT_RANGE, 1, 3, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
case CODEC_ID_VORBIS:
|
2004-03-15 00:01:03 +00:00
|
|
|
/* This one is disabled for several reasons:
|
|
|
|
* - GStreamer already has perfect Ogg and Vorbis support
|
|
|
|
* - The ffmpeg implementation depends on libvorbis/libogg,
|
|
|
|
* which are not included in the ffmpeg that GStreamer ships.
|
|
|
|
* - The ffmpeg implementation depends on shared objects between
|
|
|
|
* the ogg demuxer and vorbis decoder, which GStreamer doesn't.
|
|
|
|
*/
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2004-03-15 00:01:03 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_AC3:
|
2004-03-15 00:01:03 +00:00
|
|
|
/* Decoding is disabled, because:
|
|
|
|
* - it depends on liba52, which we don't ship in ffmpeg.
|
|
|
|
* - we already have a liba52 plugin ourselves.
|
|
|
|
*/
|
|
|
|
if (encode) {
|
|
|
|
/* FIXME: bitrate */
|
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-ac3");
|
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
/* MJPEG is normal JPEG, Motion-JPEG and Quicktime MJPEG-A. MJPEGB
|
|
|
|
* is Quicktime's MJPEG-B. LJPEG is lossless JPEG. I don't know what
|
|
|
|
* sp5x is, but it's apparently something JPEG... We don't separate
|
|
|
|
* between those in GStreamer. Should we (at least between MJPEG,
|
|
|
|
* MJPEG-B and sp5x decoding...)? */
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_MJPEG:
|
2003-01-07 20:42:56 +00:00
|
|
|
case CODEC_ID_MJPEGB:
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_LJPEG:
|
|
|
|
case CODEC_ID_SP5X:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-jpeg");
|
2003-01-07 20:42:56 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_MPEG4:
|
2004-03-15 00:01:03 +00:00
|
|
|
if (encode) {
|
|
|
|
/* I'm not exactly sure what ffmpeg outputs... ffmpeg itself uses
|
|
|
|
* the AVI fourcc 'DIVX', but 'mp4v' for Quicktime... */
|
|
|
|
/* FIXME: bitrate */
|
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/mpeg",
|
2004-03-29 16:39:18 +00:00
|
|
|
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
|
|
|
"mpegversion", G_TYPE_INT, 4, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
} else {
|
|
|
|
/* The trick here is to separate xvid, divx, mpeg4, 3ivx et al */
|
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/mpeg",
|
2004-03-29 16:39:18 +00:00
|
|
|
"mpegversion", G_TYPE_INT, 4,
|
|
|
|
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
gst_caps_append (caps, GST_FF_VID_CAPS_NEW ("video/x-divx",
|
2004-03-29 16:39:18 +00:00
|
|
|
"divxversion", GST_TYPE_INT_RANGE, 4, 5, NULL));
|
2004-03-15 00:01:03 +00:00
|
|
|
gst_caps_append (caps, GST_FF_VID_CAPS_NEW ("video/x-xvid"));
|
|
|
|
gst_caps_append (caps, GST_FF_VID_CAPS_NEW ("video/x-3ivx"));
|
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2003-06-17 11:44:11 +00:00
|
|
|
case CODEC_ID_RAWVIDEO:
|
2004-03-15 00:01:03 +00:00
|
|
|
caps = gst_ffmpeg_codectype_to_caps (CODEC_TYPE_VIDEO, context);
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_MSMPEG4V1:
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_MSMPEG4V2:
|
|
|
|
case CODEC_ID_MSMPEG4V3:
|
2004-03-15 00:01:03 +00:00
|
|
|
do {
|
|
|
|
gint version = 41 + codec_id - CODEC_ID_MSMPEG4V1;
|
|
|
|
|
|
|
|
/* encode-FIXME: bitrate */
|
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-msmpeg",
|
2004-03-29 16:39:18 +00:00
|
|
|
"msmpegversion", G_TYPE_INT, version, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
if (!encode && codec_id == CODEC_ID_MSMPEG4V3) {
|
|
|
|
gst_caps_append (caps, GST_FF_VID_CAPS_NEW ("video/x-divx",
|
2004-03-29 16:39:18 +00:00
|
|
|
"divxversion", G_TYPE_INT, 3, NULL));
|
2004-03-15 00:01:03 +00:00
|
|
|
}
|
|
|
|
} while (0);
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_WMV1:
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_WMV2:
|
|
|
|
do {
|
|
|
|
gint version = (codec_id == CODEC_ID_WMV1) ? 1 : 2;
|
|
|
|
|
|
|
|
/* encode-FIXME: bitrate */
|
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-wmv",
|
2004-03-29 16:39:18 +00:00
|
|
|
"wmvversion", G_TYPE_INT, version, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
} while (0);
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_FLV1:
|
|
|
|
buildcaps = TRUE;
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_SVQ1:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-svq",
|
2004-03-29 16:39:18 +00:00
|
|
|
"svqversion", G_TYPE_INT, 1, NULL);
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
|
|
|
case CODEC_ID_SVQ3:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-svq",
|
2004-03-29 16:39:18 +00:00
|
|
|
"svqversion", G_TYPE_INT, 3,
|
|
|
|
"halfpel_flag", GST_TYPE_INT_RANGE, 0, 1,
|
|
|
|
"thirdpel_flag", GST_TYPE_INT_RANGE, 0, 1,
|
|
|
|
"low_delay", GST_TYPE_INT_RANGE, 0, 1,
|
|
|
|
"unknown_svq3_flag", GST_TYPE_INT_RANGE, 0, 1, NULL);
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2003-07-06 20:49:15 +00:00
|
|
|
case CODEC_ID_DVAUDIO:
|
2004-03-15 00:01:03 +00:00
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-dv");
|
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2003-07-06 20:49:15 +00:00
|
|
|
case CODEC_ID_DVVIDEO:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/dv");
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_WMAV1:
|
|
|
|
case CODEC_ID_WMAV2:
|
2004-03-15 00:01:03 +00:00
|
|
|
do {
|
|
|
|
gint version = (codec_id == CODEC_ID_WMAV1) ? 1 : 2;
|
|
|
|
|
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-wma",
|
2004-03-29 16:39:18 +00:00
|
|
|
"wmaversion", G_TYPE_INT, version,
|
|
|
|
"flags1", GST_TYPE_INT_RANGE, G_MININT, G_MAXINT,
|
|
|
|
"flags2", GST_TYPE_INT_RANGE, G_MININT, G_MAXINT,
|
|
|
|
"block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
|
|
|
|
"bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
} while (0);
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_MACE3:
|
|
|
|
case CODEC_ID_MACE6:
|
2004-03-15 00:01:03 +00:00
|
|
|
do {
|
|
|
|
gint version = (codec_id == CODEC_ID_MACE3) ? 3 : 6;
|
|
|
|
|
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-mace",
|
2004-03-29 16:39:18 +00:00
|
|
|
"maceversion", G_TYPE_INT, version, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
} while (0);
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2003-01-07 20:42:56 +00:00
|
|
|
case CODEC_ID_HUFFYUV:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-huffyuv");
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_CYUV:
|
2004-03-15 00:01:03 +00:00
|
|
|
buildcaps = TRUE;
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_H264:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-h264");
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_INDEO3:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-indeo",
|
2004-03-29 16:39:18 +00:00
|
|
|
"indeoversion", G_TYPE_INT, 3, NULL);
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_VP3:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-vp3");
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_THEORA:
|
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-theora");
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_AAC:
|
2003-06-07 00:41:32 +00:00
|
|
|
case CODEC_ID_MPEG4AAC:
|
2004-03-15 00:01:03 +00:00
|
|
|
/* ffmpeg uses libfaac/libfaad for those. We do not ship these as
|
|
|
|
* part of ffmpeg, so defining those is useless. Besides, we have
|
|
|
|
* our own faad/faac plugins. */
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_ASV1:
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_ASV2:
|
|
|
|
buildcaps = TRUE;
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
|
2003-06-17 11:44:11 +00:00
|
|
|
case CODEC_ID_FFV1:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-ffv",
|
2004-03-29 16:39:18 +00:00
|
|
|
"ffvversion", G_TYPE_INT, 1, NULL);
|
2003-06-17 11:44:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_4XM:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-4xm");
|
2003-06-17 11:44:11 +00:00
|
|
|
break;
|
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
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:
|
|
|
|
case CODEC_ID_RPZA:
|
|
|
|
buildcaps = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_CINEPAK:
|
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-cinepak");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_WS_VQA:
|
|
|
|
case CODEC_ID_MSRLE:
|
|
|
|
case CODEC_ID_MSVIDEO1:
|
|
|
|
case CODEC_ID_IDCIN:
|
|
|
|
case CODEC_ID_8BPS:
|
|
|
|
case CODEC_ID_SMC:
|
|
|
|
case CODEC_ID_FLIC:
|
|
|
|
case CODEC_ID_TRUEMOTION1:
|
|
|
|
case CODEC_ID_VMDVIDEO:
|
|
|
|
case CODEC_ID_VMDAUDIO:
|
|
|
|
case CODEC_ID_MSZH:
|
|
|
|
case CODEC_ID_ZLIB:
|
|
|
|
case CODEC_ID_QTRLE:
|
|
|
|
buildcaps = TRUE;
|
|
|
|
break;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
/* weird quasi-codecs for the demuxers only */
|
2003-06-17 11:44:11 +00:00
|
|
|
case CODEC_ID_PCM_S16LE:
|
|
|
|
case CODEC_ID_PCM_S16BE:
|
|
|
|
case CODEC_ID_PCM_U16LE:
|
|
|
|
case CODEC_ID_PCM_U16BE:
|
|
|
|
case CODEC_ID_PCM_S8:
|
|
|
|
case CODEC_ID_PCM_U8:
|
|
|
|
do {
|
2003-07-06 20:49:15 +00:00
|
|
|
gint width = 0, depth = 0, endianness = 0;
|
2004-03-29 16:39:18 +00:00
|
|
|
gboolean signedness = FALSE; /* blabla */
|
2003-06-17 11:44:11 +00:00
|
|
|
|
|
|
|
switch (codec_id) {
|
|
|
|
case CODEC_ID_PCM_S16LE:
|
2004-03-29 16:39:18 +00:00
|
|
|
width = 16;
|
|
|
|
depth = 16;
|
2003-06-17 11:44:11 +00:00
|
|
|
endianness = G_LITTLE_ENDIAN;
|
|
|
|
signedness = TRUE;
|
|
|
|
break;
|
|
|
|
case CODEC_ID_PCM_S16BE:
|
2004-03-29 16:39:18 +00:00
|
|
|
width = 16;
|
|
|
|
depth = 16;
|
2003-06-17 11:44:11 +00:00
|
|
|
endianness = G_BIG_ENDIAN;
|
|
|
|
signedness = TRUE;
|
|
|
|
break;
|
|
|
|
case CODEC_ID_PCM_U16LE:
|
2004-03-29 16:39:18 +00:00
|
|
|
width = 16;
|
|
|
|
depth = 16;
|
2003-06-17 11:44:11 +00:00
|
|
|
endianness = G_LITTLE_ENDIAN;
|
|
|
|
signedness = FALSE;
|
|
|
|
break;
|
|
|
|
case CODEC_ID_PCM_U16BE:
|
2004-03-29 16:39:18 +00:00
|
|
|
width = 16;
|
|
|
|
depth = 16;
|
2003-06-17 11:44:11 +00:00
|
|
|
endianness = G_BIG_ENDIAN;
|
|
|
|
signedness = FALSE;
|
|
|
|
break;
|
|
|
|
case CODEC_ID_PCM_S8:
|
2004-03-29 16:39:18 +00:00
|
|
|
width = 8;
|
|
|
|
depth = 8;
|
2003-06-17 11:44:11 +00:00
|
|
|
endianness = G_BYTE_ORDER;
|
|
|
|
signedness = TRUE;
|
|
|
|
break;
|
|
|
|
case CODEC_ID_PCM_U8:
|
2004-03-29 16:39:18 +00:00
|
|
|
width = 8;
|
|
|
|
depth = 8;
|
2003-06-17 11:44:11 +00:00
|
|
|
endianness = G_BYTE_ORDER;
|
|
|
|
signedness = FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
g_assert (0); /* don't worry, we never get here */
|
2003-06-17 11:44:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-raw-int",
|
2004-03-29 16:39:18 +00:00
|
|
|
"width", G_TYPE_INT, width,
|
|
|
|
"depth", G_TYPE_INT, depth,
|
|
|
|
"endianness", G_TYPE_INT, endianness,
|
|
|
|
"signed", G_TYPE_BOOLEAN, signedness, NULL);
|
2003-06-17 11:44:11 +00:00
|
|
|
} while (0);
|
|
|
|
break;
|
|
|
|
|
2003-07-06 20:49:15 +00:00
|
|
|
case CODEC_ID_PCM_MULAW:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-mulaw");
|
2003-07-06 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_PCM_ALAW:
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-alaw");
|
2003-07-06 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_ADPCM_IMA_QT:
|
|
|
|
case CODEC_ID_ADPCM_IMA_WAV:
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_ADPCM_IMA_DK3:
|
|
|
|
case CODEC_ID_ADPCM_IMA_DK4:
|
|
|
|
case CODEC_ID_ADPCM_IMA_WS:
|
|
|
|
case CODEC_ID_ADPCM_IMA_SMJPEG:
|
2002-11-06 23:53:46 +00:00
|
|
|
case CODEC_ID_ADPCM_MS:
|
2003-07-06 20:49:15 +00:00
|
|
|
case CODEC_ID_ADPCM_4XM:
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_ADPCM_XA:
|
|
|
|
case CODEC_ID_ADPCM_ADX:
|
|
|
|
case CODEC_ID_ADPCM_EA:
|
|
|
|
case CODEC_ID_ADPCM_G726:
|
|
|
|
do {
|
|
|
|
gchar *layout = NULL;
|
|
|
|
|
|
|
|
switch (codec_id) {
|
|
|
|
case CODEC_ID_ADPCM_IMA_QT:
|
|
|
|
layout = "quicktime";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_IMA_WAV:
|
|
|
|
layout = "wav";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_IMA_DK3:
|
|
|
|
layout = "dk3";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_IMA_DK4:
|
|
|
|
layout = "dk4";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_IMA_WS:
|
|
|
|
layout = "westwood";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_IMA_SMJPEG:
|
|
|
|
layout = "smjpeg";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_MS:
|
|
|
|
layout = "microsoft";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_4XM:
|
|
|
|
layout = "4xm";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_XA:
|
|
|
|
layout = "xa";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_ADX:
|
|
|
|
layout = "adx";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_EA:
|
|
|
|
layout = "ea";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_ADPCM_G726:
|
|
|
|
layout = "g726";
|
|
|
|
break;
|
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
g_assert (0); /* don't worry, we never get here */
|
2004-03-15 00:01:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: someone please check whether we need additional properties
|
|
|
|
* in this caps definition. */
|
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-adpcm",
|
2004-03-29 16:39:18 +00:00
|
|
|
"layout", G_TYPE_STRING, layout, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
} while (0);
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_ID_AMR_NB:
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_AMR_WB:
|
|
|
|
/* what's this? ffmpeg uses external libs here that we don't include
|
|
|
|
* so there's no point in defining those. Still, I want to know what
|
|
|
|
* it actually is... */
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
|
2003-10-26 12:10:01 +00:00
|
|
|
case CODEC_ID_RA_144:
|
2003-07-06 20:49:15 +00:00
|
|
|
case CODEC_ID_RA_288:
|
2004-03-15 00:01:03 +00:00
|
|
|
do {
|
|
|
|
gint version = (codec_id == CODEC_ID_RA_144) ? 1 : 2;
|
|
|
|
|
|
|
|
/* FIXME: properties? */
|
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-pn-realaudio",
|
2004-03-29 16:39:18 +00:00
|
|
|
"raversion", G_TYPE_INT, version, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
} while (0);
|
2003-10-26 12:10:01 +00:00
|
|
|
break;
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_ROQ_DPCM:
|
|
|
|
case CODEC_ID_INTERPLAY_DPCM:
|
|
|
|
case CODEC_ID_XAN_DPCM:
|
|
|
|
do {
|
|
|
|
gchar *layout = NULL;
|
|
|
|
|
|
|
|
switch (codec_id) {
|
|
|
|
case CODEC_ID_ROQ_DPCM:
|
|
|
|
layout = "roq";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_INTERPLAY_DPCM:
|
|
|
|
layout = "interplay";
|
|
|
|
break;
|
|
|
|
case CODEC_ID_XAN_DPCM:
|
|
|
|
layout = "xan";
|
|
|
|
break;
|
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
g_assert (0); /* don't worry, we never get here */
|
2004-03-15 00:01:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: someone please check whether we need additional properties
|
|
|
|
* in this caps definition. */
|
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-dpcm",
|
2004-03-29 16:39:18 +00:00
|
|
|
"layout", G_TYPE_STRING, layout, NULL);
|
2004-03-15 00:01:03 +00:00
|
|
|
} while (0);
|
|
|
|
break;
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
case CODEC_ID_FLAC:
|
|
|
|
/* Note that ffmpeg has no encoder yet, but just for safety. In the
|
|
|
|
* encoder case, we want to add things like samplerate, channels... */
|
|
|
|
if (!encode) {
|
|
|
|
caps = gst_caps_new_simple ("audio/x-flac", NULL);
|
|
|
|
}
|
2004-03-07 22:02:15 +00:00
|
|
|
break;
|
|
|
|
|
2003-06-07 00:41:32 +00:00
|
|
|
default:
|
2004-03-15 00:01:03 +00:00
|
|
|
g_warning ("Unknown codec ID %d, please add here", codec_id);
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
if (buildcaps) {
|
|
|
|
AVCodec *codec;
|
|
|
|
|
|
|
|
if ((codec = avcodec_find_decoder (codec_id)) ||
|
|
|
|
(codec = avcodec_find_encoder (codec_id))) {
|
|
|
|
gchar *mime = NULL;
|
|
|
|
|
|
|
|
switch (codec->type) {
|
|
|
|
case CODEC_TYPE_VIDEO:
|
|
|
|
mime = g_strdup_printf ("video/x-gst_ff-%s", codec->name);
|
|
|
|
caps = GST_FF_VID_CAPS_NEW (mime);
|
|
|
|
g_free (mime);
|
|
|
|
break;
|
|
|
|
case CODEC_TYPE_AUDIO:
|
|
|
|
mime = g_strdup_printf ("audio/x-gst_ff-%s", codec->name);
|
|
|
|
caps = GST_FF_AUD_CAPS_NEW (mime);
|
|
|
|
g_free (mime);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-07 00:41:32 +00:00
|
|
|
if (caps != NULL) {
|
2003-12-22 01:46:58 +00:00
|
|
|
char *str = gst_caps_to_string (caps);
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
GST_DEBUG ("caps for codec_id=%d: %s", codec_id, str);
|
2004-03-15 00:01:03 +00:00
|
|
|
g_free (str);
|
2003-07-06 20:49:15 +00:00
|
|
|
} else {
|
2003-12-22 01:46:58 +00:00
|
|
|
GST_WARNING ("No caps found for codec_id=%d", codec_id);
|
2003-06-07 00:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a FFMPEG Pixel Format and optional AVCodecContext
|
|
|
|
* to a GstCaps. If the context is ommitted, no fixed values
|
|
|
|
* for video/audio size will be included in the GstCaps
|
|
|
|
*
|
|
|
|
* See below for usefullness
|
|
|
|
*/
|
|
|
|
|
|
|
|
static GstCaps *
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context)
|
2003-06-07 00:41:32 +00:00
|
|
|
{
|
|
|
|
GstCaps *caps = NULL;
|
|
|
|
|
|
|
|
int bpp = 0, depth = 0, endianness = 0;
|
|
|
|
gulong g_mask = 0, r_mask = 0, b_mask = 0;
|
|
|
|
guint32 fmt = 0;
|
|
|
|
|
|
|
|
switch (pix_fmt) {
|
|
|
|
case PIX_FMT_YUV420P:
|
2004-03-29 16:39:18 +00:00
|
|
|
fmt = GST_MAKE_FOURCC ('I', '4', '2', '0');
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
case PIX_FMT_YUV422:
|
2004-03-29 16:39:18 +00:00
|
|
|
fmt = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
case PIX_FMT_RGB24:
|
|
|
|
bpp = depth = 24;
|
|
|
|
endianness = G_BIG_ENDIAN;
|
2004-03-29 16:39:18 +00:00
|
|
|
r_mask = 0xff0000;
|
|
|
|
g_mask = 0x00ff00;
|
|
|
|
b_mask = 0x0000ff;
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
case PIX_FMT_BGR24:
|
|
|
|
bpp = depth = 24;
|
2003-07-06 20:49:15 +00:00
|
|
|
endianness = G_BIG_ENDIAN;
|
2004-03-29 16:39:18 +00:00
|
|
|
r_mask = 0x0000ff;
|
|
|
|
g_mask = 0x00ff00;
|
|
|
|
b_mask = 0xff0000;
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
case PIX_FMT_YUV422P:
|
2004-03-29 16:39:18 +00:00
|
|
|
fmt = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
case PIX_FMT_YUV444P:
|
|
|
|
/* .. */
|
|
|
|
break;
|
|
|
|
case PIX_FMT_RGBA32:
|
2004-03-29 16:39:18 +00:00
|
|
|
bpp = 32;
|
|
|
|
depth = 24;
|
2003-07-06 20:49:15 +00:00
|
|
|
endianness = G_BIG_ENDIAN;
|
|
|
|
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
2004-03-29 16:39:18 +00:00
|
|
|
r_mask = 0x00ff0000;
|
|
|
|
g_mask = 0x0000ff00;
|
|
|
|
b_mask = 0x000000ff;
|
|
|
|
#else
|
|
|
|
r_mask = 0x0000ff00;
|
|
|
|
g_mask = 0x00ff0000;
|
|
|
|
b_mask = 0xff000000;
|
2003-07-06 20:49:15 +00:00
|
|
|
#endif
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
case PIX_FMT_YUV410P:
|
2004-03-29 16:39:18 +00:00
|
|
|
fmt = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
case PIX_FMT_YUV411P:
|
2004-03-29 16:39:18 +00:00
|
|
|
fmt = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
case PIX_FMT_RGB565:
|
|
|
|
bpp = depth = 16;
|
|
|
|
endianness = G_BYTE_ORDER;
|
2004-03-29 16:39:18 +00:00
|
|
|
r_mask = 0xf800;
|
|
|
|
g_mask = 0x07e0;
|
|
|
|
b_mask = 0x001f;
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
case PIX_FMT_RGB555:
|
2004-03-29 16:39:18 +00:00
|
|
|
bpp = 16;
|
|
|
|
depth = 15;
|
2003-06-07 00:41:32 +00:00
|
|
|
endianness = G_BYTE_ORDER;
|
2004-03-29 16:39:18 +00:00
|
|
|
r_mask = 0x7c00;
|
|
|
|
g_mask = 0x03e0;
|
|
|
|
b_mask = 0x001f;
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* give up ... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bpp != 0) {
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb",
|
2004-03-29 16:39:18 +00:00
|
|
|
"bpp", G_TYPE_INT, bpp,
|
|
|
|
"depth", G_TYPE_INT, depth,
|
|
|
|
"red_mask", G_TYPE_INT, r_mask,
|
2003-12-22 01:46:58 +00:00
|
|
|
"green_mask", G_TYPE_INT, g_mask,
|
2004-03-29 16:39:18 +00:00
|
|
|
"blue_mask", G_TYPE_INT, b_mask,
|
|
|
|
"endianness", G_TYPE_INT, endianness, NULL);
|
2003-06-07 00:41:32 +00:00
|
|
|
} else if (fmt) {
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_VID_CAPS_NEW ("video/x-raw-yuv",
|
2004-03-29 16:39:18 +00:00
|
|
|
"format", GST_TYPE_FOURCC, fmt, NULL);
|
2003-06-07 00:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (caps != NULL) {
|
2003-12-22 01:46:58 +00:00
|
|
|
char *str = gst_caps_to_string (caps);
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
GST_DEBUG ("caps for pix_fmt=%d: %s", pix_fmt, str);
|
2004-03-29 16:39:18 +00:00
|
|
|
g_free (str);
|
2003-07-06 20:49:15 +00:00
|
|
|
} else {
|
2003-12-22 01:46:58 +00:00
|
|
|
GST_WARNING ("No caps found for pix_fmt=%d", pix_fmt);
|
2003-06-07 00:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a FFMPEG Sample Format and optional AVCodecContext
|
|
|
|
* to a GstCaps. If the context is ommitted, no fixed values
|
|
|
|
* for video/audio size will be included in the GstCaps
|
|
|
|
*
|
|
|
|
* See below for usefullness
|
|
|
|
*/
|
|
|
|
|
|
|
|
static GstCaps *
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
|
|
|
|
AVCodecContext * context)
|
2003-06-07 00:41:32 +00:00
|
|
|
{
|
|
|
|
GstCaps *caps = NULL;
|
|
|
|
|
|
|
|
int bpp = 0;
|
|
|
|
gboolean signedness = FALSE;
|
|
|
|
|
|
|
|
switch (sample_fmt) {
|
|
|
|
case SAMPLE_FMT_S16:
|
|
|
|
signedness = TRUE;
|
|
|
|
bpp = 16;
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
default:
|
2003-06-07 00:41:32 +00:00
|
|
|
/* .. */
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-06-07 00:41:32 +00:00
|
|
|
if (bpp) {
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = GST_FF_AUD_CAPS_NEW ("audio/x-raw-int",
|
2004-03-29 16:39:18 +00:00
|
|
|
"signed", G_TYPE_BOOLEAN, signedness,
|
|
|
|
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
|
|
|
"width", G_TYPE_INT, bpp, "depth", G_TYPE_INT, bpp, NULL);
|
2003-06-07 00:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (caps != NULL) {
|
2003-12-22 01:46:58 +00:00
|
|
|
char *str = gst_caps_to_string (caps);
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
GST_DEBUG ("caps for sample_fmt=%d: %s", sample_fmt, str);
|
2004-03-29 16:39:18 +00:00
|
|
|
g_free (str);
|
2003-07-06 20:49:15 +00:00
|
|
|
} else {
|
2003-12-22 01:46:58 +00:00
|
|
|
GST_WARNING ("No caps found for sample_fmt=%d", sample_fmt);
|
2003-06-07 00:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a FFMPEG codec Type and optional AVCodecContext
|
|
|
|
* to a GstCaps. If the context is ommitted, no fixed values
|
|
|
|
* for video/audio size will be included in the GstCaps
|
|
|
|
*
|
|
|
|
* CodecType is primarily meant for uncompressed data GstCaps!
|
|
|
|
*/
|
|
|
|
|
|
|
|
GstCaps *
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
|
|
|
|
AVCodecContext * context)
|
2003-06-07 00:41:32 +00:00
|
|
|
{
|
2003-12-22 01:46:58 +00:00
|
|
|
GstCaps *caps;
|
2003-06-07 00:41:32 +00:00
|
|
|
|
|
|
|
switch (codec_type) {
|
|
|
|
case CODEC_TYPE_VIDEO:
|
|
|
|
if (context) {
|
|
|
|
caps = gst_ffmpeg_pixfmt_to_caps (context->pix_fmt, context);
|
|
|
|
} else {
|
|
|
|
GstCaps *temp;
|
|
|
|
enum PixelFormat i;
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = gst_caps_new_empty ();
|
2003-06-07 00:41:32 +00:00
|
|
|
for (i = 0; i < PIX_FMT_NB; i++) {
|
|
|
|
temp = gst_ffmpeg_pixfmt_to_caps (i, NULL);
|
|
|
|
if (temp != NULL) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gst_caps_append (caps, temp);
|
2003-06-07 00:41:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_TYPE_AUDIO:
|
|
|
|
if (context) {
|
|
|
|
caps = gst_ffmpeg_smpfmt_to_caps (context->sample_fmt, context);
|
|
|
|
} else {
|
|
|
|
GstCaps *temp;
|
|
|
|
enum SampleFormat i;
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = gst_caps_new_empty ();
|
2003-06-07 00:41:32 +00:00
|
|
|
for (i = 0; i <= SAMPLE_FMT_S16; i++) {
|
|
|
|
temp = gst_ffmpeg_smpfmt_to_caps (i, NULL);
|
|
|
|
if (temp != NULL) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gst_caps_append (caps, temp);
|
2003-06-07 00:41:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* .. */
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = NULL;
|
2003-06-07 00:41:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
2003-06-07 20:45:56 +00:00
|
|
|
|
2003-11-07 19:59:28 +00:00
|
|
|
|
|
|
|
/* Construct the context extradata from caps
|
|
|
|
* when needed.
|
|
|
|
*/
|
|
|
|
static void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpeg_caps_to_extradata (const GstCaps * caps, AVCodecContext * context)
|
2003-11-07 19:59:28 +00:00
|
|
|
{
|
2003-12-22 01:46:58 +00:00
|
|
|
GstStructure *structure;
|
2003-11-07 19:59:28 +00:00
|
|
|
const gchar *mimetype;
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
g_return_if_fail (gst_caps_get_size (caps) == 1);
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
mimetype = gst_structure_get_name (structure);
|
2003-11-07 19:59:28 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
if (!strcmp (mimetype, "audio/x-wma")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint flags1, flags2, wmaversion = 0;
|
2003-11-07 19:59:28 +00:00
|
|
|
|
2004-01-20 21:22:46 +00:00
|
|
|
if (!gst_structure_get_int (structure, "flags1", &flags1) ||
|
2004-03-29 16:39:18 +00:00
|
|
|
!gst_structure_get_int (structure, "flags2", &flags2) ||
|
|
|
|
!gst_structure_get_int (structure, "wmaversion", &wmaversion)) {
|
2003-12-22 01:46:58 +00:00
|
|
|
g_warning ("invalid caps for audio/x-wma");
|
2003-11-07 19:59:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
/*
|
|
|
|
* Rebuild context data from flags1 & flags2
|
|
|
|
* see wmadec in ffmpeg/libavcodec/wmadec.c
|
|
|
|
*/
|
|
|
|
gst_structure_get_int (structure, "wmaversion", &wmaversion);
|
|
|
|
switch (wmaversion) {
|
|
|
|
case 1:
|
2004-03-29 16:39:18 +00:00
|
|
|
/* FIXME: is this freed with g_free? If not, don't use g_malloc */
|
|
|
|
context->extradata = (guint8 *) g_malloc0 (4);
|
|
|
|
((guint8 *) context->extradata)[0] = flags1;
|
|
|
|
((guint8 *) context->extradata)[2] = flags2;
|
|
|
|
context->extradata_size = 4;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
case 2:
|
2004-03-29 16:39:18 +00:00
|
|
|
/* FIXME: is this freed with g_free? If not, don't use g_malloc */
|
|
|
|
context->extradata = (guint8 *) g_malloc0 (6);
|
|
|
|
((guint8 *) context->extradata)[0] = flags1;
|
|
|
|
((guint8 *) context->extradata)[1] = flags1 >> 8;
|
|
|
|
((guint8 *) context->extradata)[2] = flags1 >> 16;
|
|
|
|
((guint8 *) context->extradata)[3] = flags1 >> 24;
|
|
|
|
((guint8 *) context->extradata)[4] = flags2;
|
|
|
|
((guint8 *) context->extradata)[5] = flags2 >> 8;
|
|
|
|
context->extradata_size = 6;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
g_warning ("Unknown wma version %d\n", wmaversion);
|
|
|
|
break;
|
2003-11-07 19:59:28 +00:00
|
|
|
}
|
2004-01-26 20:01:36 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
if (!strcmp (mimetype, "video/x-svq")) {
|
2004-01-26 20:01:36 +00:00
|
|
|
gint version = 0;
|
|
|
|
|
|
|
|
if (!gst_structure_get_int (structure, "svqversion", &version)) {
|
|
|
|
g_warning ("invalid caps for video/x-svq");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (version == 3) {
|
|
|
|
gint halfpel_flag, thirdpel_flag, low_delay, unknown_svq3_flag;
|
|
|
|
guint16 flags;
|
|
|
|
|
|
|
|
if (!gst_structure_get_int (structure, "halfpel_flag", &halfpel_flag) ||
|
|
|
|
!gst_structure_get_int (structure, "thirdpel_flag", &thirdpel_flag) ||
|
2004-03-29 16:39:18 +00:00
|
|
|
!gst_structure_get_int (structure, "low_delay", &low_delay) ||
|
|
|
|
!gst_structure_get_int (structure, "unknown_svq3_flag",
|
|
|
|
&unknown_svq3_flag)) {
|
|
|
|
g_warning ("invalid caps for video/x-svq");
|
|
|
|
return;
|
|
|
|
}
|
2004-01-26 20:01:36 +00:00
|
|
|
|
|
|
|
context->extradata = (guint8 *) g_malloc0 (0x64);
|
|
|
|
g_stpcpy (context->extradata, "SVQ3");
|
|
|
|
flags = 1 << 3;
|
|
|
|
flags |= low_delay;
|
|
|
|
flags = flags << 2;
|
|
|
|
flags |= unknown_svq3_flag;
|
|
|
|
flags = flags << 6;
|
|
|
|
flags |= halfpel_flag;
|
|
|
|
flags = flags << 1;
|
|
|
|
flags |= thirdpel_flag;
|
|
|
|
flags = flags << 3;
|
|
|
|
|
2004-02-02 22:37:33 +00:00
|
|
|
flags = GUINT16_FROM_LE (flags);
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2004-01-26 20:01:36 +00:00
|
|
|
memcpy (context->extradata + 0x62, &flags, 2);
|
|
|
|
context->extradata_size = 0x64;
|
|
|
|
}
|
2003-11-07 19:59:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-07 20:45:56 +00:00
|
|
|
/* Convert a GstCaps (audio/raw) to a FFMPEG SampleFmt
|
|
|
|
* and other audio properties in a AVCodecContext.
|
|
|
|
*
|
|
|
|
* For usefullness, see below
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpeg_caps_to_smpfmt (const GstCaps * caps, AVCodecContext * context)
|
2003-06-07 20:45:56 +00:00
|
|
|
{
|
2003-12-22 01:46:58 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
gint depth = 0, width = 0, endianness = 0;
|
|
|
|
gboolean signedness = FALSE;
|
|
|
|
|
|
|
|
g_return_if_fail (gst_caps_get_size (caps) == 1);
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (gst_structure_get_int (structure, "width", &width) &&
|
|
|
|
gst_structure_get_int (structure, "depth", &depth) &&
|
|
|
|
gst_structure_get_int (structure, "signed", &signedness) &&
|
|
|
|
gst_structure_get_int (structure, "endianness", &endianness)) {
|
2003-06-07 20:45:56 +00:00
|
|
|
if (width == 16 && depth == 16 &&
|
|
|
|
endianness == G_BYTE_ORDER && signedness == TRUE) {
|
|
|
|
context->sample_fmt = SAMPLE_FMT_S16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
gst_structure_get_int (structure, "channels", &context->channels);
|
|
|
|
gst_structure_get_int (structure, "rate", &context->sample_rate);
|
|
|
|
gst_structure_get_int (structure, "block_align", &context->block_align);
|
|
|
|
gst_structure_get_int (structure, "bitrate", &context->bit_rate);
|
2003-11-05 23:19:38 +00:00
|
|
|
|
2003-11-07 19:59:28 +00:00
|
|
|
gst_ffmpeg_caps_to_extradata (caps, context);
|
2003-06-07 20:45:56 +00:00
|
|
|
}
|
|
|
|
|
2003-11-05 23:19:38 +00:00
|
|
|
|
2003-06-07 20:45:56 +00:00
|
|
|
/* Convert a GstCaps (video/raw) to a FFMPEG PixFmt
|
|
|
|
* and other video properties in a AVCodecContext.
|
|
|
|
*
|
|
|
|
* For usefullness, see below
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps, AVCodecContext * context)
|
2003-06-07 20:45:56 +00:00
|
|
|
{
|
2003-12-22 01:46:58 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
gdouble fps;
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
g_return_if_fail (gst_caps_get_size (caps) == 1);
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
gst_structure_get_int (structure, "width", &context->width);
|
|
|
|
gst_structure_get_int (structure, "height", &context->height);
|
2003-06-07 20:45:56 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (gst_structure_get_double (structure, "framerate", &fps)) {
|
Several encoding changes: for video, double check the pix_fmt after opening the AVCodec. The pix_fmt will be changed ...
Original commit message from CVS:
Several encoding changes:
* for video, double check the pix_fmt after opening the AVCodec. The pix_fmt
will be changed to the preferred pix_fmt instead of that opening the
codec fails. We fail when it has changed (then, ffmpeg doesn't like it).
* for video, set the correct timestamp.
* for audio, do *not* set the frame_size: most codecs don't like it. Instead,
keep a cache of buffers and always give data of size "frame_size". Maybe
I should have used bytestream here, I'm not sure. This works, though.
I can now create mpeg1 video, mp2 and ac3 audio. I didn't test any others yet.
I also didn't start working on integration with any of the muxers yet, that's
all one big TODO. One thing at a time, please. :).
2003-11-12 10:42:36 +00:00
|
|
|
context->frame_rate = fps * DEFAULT_FRAME_RATE_BASE;
|
|
|
|
context->frame_rate_base = DEFAULT_FRAME_RATE_BASE;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
|
|
|
|
guint32 fourcc;
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
|
2003-11-25 04:48:31 +00:00
|
|
|
switch (fourcc) {
|
2004-03-29 16:39:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
|
|
|
|
context->pix_fmt = PIX_FMT_YUV422;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
|
|
|
|
context->pix_fmt = PIX_FMT_YUV420P;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
|
|
|
|
context->pix_fmt = PIX_FMT_YUV411P;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
|
|
|
|
context->pix_fmt = PIX_FMT_YUV422P;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
|
|
|
|
context->pix_fmt = PIX_FMT_YUV410P;
|
|
|
|
break;
|
2003-10-26 11:30:18 +00:00
|
|
|
#if 0
|
2004-03-29 16:39:18 +00:00
|
|
|
case FIXME:
|
|
|
|
context->pix_fmt = PIX_FMT_YUV444P;
|
|
|
|
break;
|
2003-10-26 11:30:18 +00:00
|
|
|
#endif
|
2003-11-25 04:48:31 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (strcmp (gst_structure_get_name (structure),
|
|
|
|
"video/x-raw-rgb") == 0) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint bpp = 0, rmask = 0, endianness = 0;
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (gst_structure_get_int (structure, "bpp", &bpp) &&
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_structure_get_int (structure, "endianness", &endianness) &&
|
|
|
|
gst_structure_get_int (structure, "red_mask", &rmask)) {
|
2003-11-25 04:48:31 +00:00
|
|
|
switch (bpp) {
|
|
|
|
case 32:
|
2003-11-28 20:06:18 +00:00
|
|
|
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
2003-12-17 22:38:22 +00:00
|
|
|
if (rmask == 0x00ff0000)
|
2003-11-28 20:06:18 +00:00
|
|
|
#else
|
2003-12-17 22:38:22 +00:00
|
|
|
if (rmask == 0x0000ff00)
|
2003-11-28 20:06:18 +00:00
|
|
|
#endif
|
|
|
|
context->pix_fmt = PIX_FMT_RGBA32;
|
2003-11-25 04:48:31 +00:00
|
|
|
break;
|
|
|
|
case 24:
|
2003-11-28 20:06:18 +00:00
|
|
|
if (rmask == 0x0000FF)
|
|
|
|
context->pix_fmt = PIX_FMT_BGR24;
|
|
|
|
else
|
|
|
|
context->pix_fmt = PIX_FMT_RGB24;
|
2004-03-29 16:39:18 +00:00
|
|
|
break;
|
2003-11-25 04:48:31 +00:00
|
|
|
case 16:
|
2003-11-28 20:06:18 +00:00
|
|
|
if (endianness == G_BYTE_ORDER)
|
|
|
|
context->pix_fmt = PIX_FMT_RGB565;
|
2004-03-29 16:39:18 +00:00
|
|
|
break;
|
2003-11-25 04:48:31 +00:00
|
|
|
case 15:
|
2003-11-28 20:06:18 +00:00
|
|
|
if (endianness == G_BYTE_ORDER)
|
|
|
|
context->pix_fmt = PIX_FMT_RGB555;
|
2004-03-29 16:39:18 +00:00
|
|
|
break;
|
2003-11-25 04:48:31 +00:00
|
|
|
default:
|
|
|
|
/* nothing */
|
2004-03-29 16:39:18 +00:00
|
|
|
break;
|
2003-11-25 04:48:31 +00:00
|
|
|
}
|
2003-06-07 20:45:56 +00:00
|
|
|
}
|
|
|
|
}
|
2004-01-26 20:01:36 +00:00
|
|
|
|
|
|
|
gst_ffmpeg_caps_to_extradata (caps, context);
|
2003-06-07 20:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a GstCaps and a FFMPEG codec Type to a
|
|
|
|
* AVCodecContext. If the context is ommitted, no fixed values
|
|
|
|
* for video/audio size will be included in the context
|
|
|
|
*
|
|
|
|
* CodecType is primarily meant for uncompressed data GstCaps!
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpeg_caps_to_codectype (enum CodecType type,
|
|
|
|
const GstCaps * caps, AVCodecContext * context)
|
2003-06-07 20:45:56 +00:00
|
|
|
{
|
|
|
|
if (context == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case CODEC_TYPE_VIDEO:
|
|
|
|
gst_ffmpeg_caps_to_pixfmt (caps, context);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CODEC_TYPE_AUDIO:
|
|
|
|
gst_ffmpeg_caps_to_smpfmt (caps, context);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* unknown */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-06-08 13:30:10 +00:00
|
|
|
|
|
|
|
/* _formatid_to_caps () is meant for muxers/demuxers, it
|
|
|
|
* transforms a name (ffmpeg way of ID'ing these, why don't
|
|
|
|
* they have unique numerical IDs?) to the corresponding
|
|
|
|
* caps belonging to that mux-format
|
|
|
|
*
|
|
|
|
* Note: we don't need any additional info because the caps
|
|
|
|
* isn't supposed to contain any useful info besides the
|
|
|
|
* media type anyway
|
|
|
|
*/
|
|
|
|
|
|
|
|
GstCaps *
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpeg_formatid_to_caps (const gchar * format_name)
|
2003-06-08 13:30:10 +00:00
|
|
|
{
|
|
|
|
GstCaps *caps = NULL;
|
|
|
|
|
|
|
|
if (!strcmp (format_name, "mpeg")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = gst_caps_new_simple ("video/mpeg",
|
2004-03-29 16:39:18 +00:00
|
|
|
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
|
2003-06-08 13:30:10 +00:00
|
|
|
} else if (!strcmp (format_name, "mpegts")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = gst_caps_new_simple ("video/mpegts",
|
2004-03-29 16:39:18 +00:00
|
|
|
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
|
2003-06-08 13:30:10 +00:00
|
|
|
} else if (!strcmp (format_name, "rm")) {
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
caps = gst_caps_new_simple ("application/x-pn-realmedia",
|
2004-03-29 16:39:18 +00:00
|
|
|
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
|
2003-06-08 13:30:10 +00:00
|
|
|
} else if (!strcmp (format_name, "asf")) {
|
2004-03-29 16:39:18 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-ms-asf", NULL);
|
2003-06-08 13:30:10 +00:00
|
|
|
} else if (!strcmp (format_name, "avi")) {
|
2004-03-29 16:39:18 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-msvideo", NULL);
|
2003-06-08 13:30:10 +00:00
|
|
|
} else if (!strcmp (format_name, "wav")) {
|
2004-03-29 16:39:18 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-wav", NULL);
|
2003-06-08 13:30:10 +00:00
|
|
|
} else if (!strcmp (format_name, "swf")) {
|
2004-03-29 16:39:18 +00:00
|
|
|
caps = gst_caps_new_simple ("application/x-shockwave-flash", NULL);
|
2003-06-08 13:30:10 +00:00
|
|
|
} else if (!strcmp (format_name, "au")) {
|
2004-03-29 16:39:18 +00:00
|
|
|
caps = gst_caps_new_simple ("audio/x-au", NULL);
|
2004-03-05 02:40:34 +00:00
|
|
|
} else if (!strcmp (format_name, "mov_mp4_m4a_3gp")) {
|
2004-03-29 16:39:18 +00:00
|
|
|
caps = gst_caps_new_simple ("video/quicktime", NULL);
|
2003-06-08 13:30:10 +00:00
|
|
|
} else if (!strcmp (format_name, "dv")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-dv",
|
2004-03-29 16:39:18 +00:00
|
|
|
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
|
2003-06-08 13:30:10 +00:00
|
|
|
} else if (!strcmp (format_name, "4xm")) {
|
2004-03-29 16:39:18 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-4xm", NULL);
|
2004-03-05 02:40:34 +00:00
|
|
|
} else if (!strcmp (format_name, "matroska")) {
|
2004-03-29 16:39:18 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-matroska", NULL);
|
2003-06-08 13:30:10 +00:00
|
|
|
} else {
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
GST_WARNING ("Could not create stream format caps for %s", format_name);
|
|
|
|
name = g_strdup_printf ("application/x-gst_ff-%s", format_name);
|
|
|
|
caps = gst_caps_new_simple (name, NULL);
|
|
|
|
g_free (name);
|
2003-06-08 13:30:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
/* Convert a GstCaps to a FFMPEG codec ID. Size et all
|
|
|
|
* are omitted, that can be queried by the user itself,
|
|
|
|
* we're not eating the GstCaps or anything
|
|
|
|
* A pointer to an allocated context is also needed for
|
2004-03-15 00:01:03 +00:00
|
|
|
* optional extra info
|
|
|
|
*
|
|
|
|
* FIXME: lots of ffmpeg decoders need more properties...
|
2003-07-06 20:49:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
enum CodecID
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
|
2003-07-06 20:49:15 +00:00
|
|
|
{
|
|
|
|
enum CodecID id = CODEC_ID_NONE;
|
|
|
|
const gchar *mimetype;
|
2003-12-22 01:46:58 +00:00
|
|
|
const GstStructure *structure;
|
2004-03-29 16:39:18 +00:00
|
|
|
gboolean video = FALSE, audio = FALSE; /* we want to be sure! */
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (caps != NULL, CODEC_ID_NONE);
|
2003-12-22 01:46:58 +00:00
|
|
|
g_return_val_if_fail (gst_caps_get_size (caps) == 1, CODEC_ID_NONE);
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
mimetype = gst_structure_get_name (structure);
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2003-11-28 20:06:18 +00:00
|
|
|
if (!strcmp (mimetype, "video/x-raw-rgb")) {
|
|
|
|
|
|
|
|
id = CODEC_ID_RAWVIDEO;
|
|
|
|
|
|
|
|
if (context != NULL) {
|
|
|
|
gint bpp = 0, endianness = 0, rmask = 0;
|
|
|
|
enum PixelFormat pix_fmt = -1;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_structure_get_int (structure, "bpp", &bpp);
|
2003-12-22 01:46:58 +00:00
|
|
|
gst_structure_get_int (structure, "endianness", &endianness);
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_structure_get_int (structure, "rmask", &rmask);
|
|
|
|
|
2003-11-28 20:06:18 +00:00
|
|
|
switch (bpp) {
|
|
|
|
case 15:
|
|
|
|
if (endianness == G_BYTE_ORDER) {
|
|
|
|
pix_fmt = PIX_FMT_RGB555;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
if (endianness == G_BYTE_ORDER) {
|
|
|
|
pix_fmt = PIX_FMT_RGB565;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
if (rmask == 0xff0000) {
|
|
|
|
pix_fmt = PIX_FMT_RGB24;
|
|
|
|
} else {
|
|
|
|
pix_fmt = PIX_FMT_BGR24;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
ext/ffmpeg/: fix typo in RGB masks, and move back to "old" colorspace capsnego code until whoever wrote this new crap...
Original commit message from CVS:
2003-12-24 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/ffmpeg/gstffmpegcodecmap.c:
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_getcaps),
(gst_ffmpegcsp_srcconnect_func), (gst_ffmpegcsp_sinkconnect),
(gst_ffmpegcsp_srcconnect), (gst_ffmpegcsp_get_type),
(gst_ffmpegcsp_base_init), (gst_ffmpegcsp_class_init),
(gst_ffmpegcsp_init), (gst_ffmpegcsp_chain),
(gst_ffmpegcsp_change_state), (gst_ffmpegcsp_set_property),
(gst_ffmpegcsp_get_property), (gst_ffmpegcsp_register):
fix typo in RGB masks, and move back to "old" colorspace
capsnego code until whoever wrote this new crap has actually
tested it so that it works.
And yes, this works, keep it that way please.
2003-12-24 00:12:16 +00:00
|
|
|
if (rmask == 0x00ff0000) {
|
2003-11-28 20:06:18 +00:00
|
|
|
#else
|
ext/ffmpeg/: fix typo in RGB masks, and move back to "old" colorspace capsnego code until whoever wrote this new crap...
Original commit message from CVS:
2003-12-24 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/ffmpeg/gstffmpegcodecmap.c:
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_getcaps),
(gst_ffmpegcsp_srcconnect_func), (gst_ffmpegcsp_sinkconnect),
(gst_ffmpegcsp_srcconnect), (gst_ffmpegcsp_get_type),
(gst_ffmpegcsp_base_init), (gst_ffmpegcsp_class_init),
(gst_ffmpegcsp_init), (gst_ffmpegcsp_chain),
(gst_ffmpegcsp_change_state), (gst_ffmpegcsp_set_property),
(gst_ffmpegcsp_get_property), (gst_ffmpegcsp_register):
fix typo in RGB masks, and move back to "old" colorspace
capsnego code until whoever wrote this new crap has actually
tested it so that it works.
And yes, this works, keep it that way please.
2003-12-24 00:12:16 +00:00
|
|
|
if (rmask == 0x0000ff00) {
|
2003-11-28 20:06:18 +00:00
|
|
|
#endif
|
|
|
|
pix_fmt = PIX_FMT_RGBA32;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only set if actually recognized! */
|
|
|
|
if (pix_fmt != -1) {
|
|
|
|
video = TRUE;
|
|
|
|
context->pix_fmt = pix_fmt;
|
|
|
|
} else {
|
|
|
|
id = CODEC_ID_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "video/x-raw-yuv")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
id = CODEC_ID_RAWVIDEO;
|
|
|
|
|
|
|
|
if (context != NULL) {
|
|
|
|
guint32 fmt_fcc = 0;
|
|
|
|
enum PixelFormat pix_fmt = -1;
|
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
gst_structure_get_fourcc (structure, "format", &fmt_fcc);
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
switch (fmt_fcc) {
|
2004-03-29 16:39:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
|
2003-07-06 20:49:15 +00:00
|
|
|
pix_fmt = PIX_FMT_YUV422;
|
|
|
|
break;
|
2004-03-29 16:39:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
|
2003-07-06 20:49:15 +00:00
|
|
|
pix_fmt = PIX_FMT_YUV420P;
|
|
|
|
break;
|
2004-03-29 16:39:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
|
2003-07-06 20:49:15 +00:00
|
|
|
pix_fmt = PIX_FMT_YUV411P;
|
|
|
|
break;
|
2004-03-29 16:39:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
|
2003-07-06 20:49:15 +00:00
|
|
|
pix_fmt = PIX_FMT_YUV422P;
|
|
|
|
break;
|
2004-03-29 16:39:18 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
|
2003-07-06 20:49:15 +00:00
|
|
|
pix_fmt = PIX_FMT_YUV410P;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only set if actually recognized! */
|
|
|
|
if (pix_fmt != -1) {
|
|
|
|
video = TRUE;
|
|
|
|
context->pix_fmt = pix_fmt;
|
|
|
|
} else {
|
|
|
|
id = CODEC_ID_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "audio/x-raw-int")) {
|
|
|
|
|
|
|
|
gint depth = 0, width = 0, endianness = 0;
|
2004-03-29 16:39:18 +00:00
|
|
|
gboolean signedness = FALSE; /* bla default value */
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
gst_structure_get_int (structure, "endianness", &endianness);
|
|
|
|
gst_structure_get_boolean (structure, "signed", &signedness);
|
|
|
|
gst_structure_get_int (structure, "width", &width);
|
|
|
|
gst_structure_get_int (structure, "depth", &depth);
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (context) {
|
|
|
|
context->sample_rate = 0;
|
|
|
|
context->channels = 0;
|
|
|
|
gst_structure_get_int (structure, "channels", &context->channels);
|
|
|
|
gst_structure_get_int (structure, "rate", &context->sample_rate);
|
|
|
|
}
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (depth == width) {
|
|
|
|
switch (depth) {
|
2004-03-29 16:39:18 +00:00
|
|
|
case 8:
|
|
|
|
if (signedness) {
|
|
|
|
id = CODEC_ID_PCM_S8;
|
|
|
|
} else {
|
|
|
|
id = CODEC_ID_PCM_U8;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
switch (endianness) {
|
|
|
|
case G_BIG_ENDIAN:
|
|
|
|
if (signedness) {
|
|
|
|
id = CODEC_ID_PCM_S16BE;
|
|
|
|
} else {
|
|
|
|
id = CODEC_ID_PCM_U16BE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case G_LITTLE_ENDIAN:
|
|
|
|
if (signedness) {
|
|
|
|
id = CODEC_ID_PCM_S16LE;
|
|
|
|
} else {
|
|
|
|
id = CODEC_ID_PCM_U16LE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
}
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (id != CODEC_ID_NONE) {
|
2004-03-29 16:39:18 +00:00
|
|
|
audio = TRUE;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "audio/x-mulaw")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
id = CODEC_ID_PCM_MULAW;
|
|
|
|
audio = TRUE;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "audio/x-alaw")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
id = CODEC_ID_PCM_ALAW;
|
|
|
|
audio = TRUE;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-dv")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
id = CODEC_ID_DVVIDEO;
|
|
|
|
video = TRUE;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "audio/x-dv")) { /* ??? */
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
id = CODEC_ID_DVAUDIO;
|
|
|
|
audio = TRUE;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-h263")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_H263; /* or H263[IP] */
|
2003-07-06 20:49:15 +00:00
|
|
|
video = TRUE;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/mpeg")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
gboolean sys_strm = TRUE;
|
|
|
|
gint mpegversion = 0;
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
gst_structure_get_boolean (structure, "systemstream", &sys_strm);
|
|
|
|
gst_structure_get_int (structure, "mpegversion", &mpegversion);
|
|
|
|
if (!sys_strm) {
|
2003-07-06 20:49:15 +00:00
|
|
|
switch (mpegversion) {
|
|
|
|
case 1:
|
|
|
|
id = CODEC_ID_MPEG1VIDEO;
|
|
|
|
break;
|
2004-03-15 00:01:03 +00:00
|
|
|
case 2:
|
|
|
|
id = CODEC_ID_MPEG2VIDEO;
|
|
|
|
break;
|
2003-07-06 20:49:15 +00:00
|
|
|
case 4:
|
|
|
|
id = CODEC_ID_MPEG4;
|
2004-03-15 00:01:03 +00:00
|
|
|
if (context) {
|
2004-03-29 16:39:18 +00:00
|
|
|
context->codec_tag = GST_MAKE_FOURCC ('m', 'p', '4', 'v');
|
2004-03-15 00:01:03 +00:00
|
|
|
}
|
2003-07-06 20:49:15 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
video = TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-jpeg")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_MJPEG; /* A... B... */
|
2003-07-06 20:49:15 +00:00
|
|
|
video = TRUE;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-wmv")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint wmvversion = 0;
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "wmvversion", &wmvversion);
|
|
|
|
|
|
|
|
switch (wmvversion) {
|
|
|
|
case 1:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_WMV1;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
case 2:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_WMV2;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
/* ... */
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
}
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
video = TRUE;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "application/ogg")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
id = CODEC_ID_VORBIS;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "audio/mpeg")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint layer = 0;
|
|
|
|
gint mpegversion = 0;
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
if (gst_structure_get_int (structure, "mpegversion", &mpegversion)) {
|
2003-12-18 09:31:48 +00:00
|
|
|
switch (mpegversion) {
|
2004-03-29 16:39:18 +00:00
|
|
|
case 2: /* ffmpeg uses faad for both... */
|
2003-12-18 09:31:48 +00:00
|
|
|
case 4:
|
|
|
|
id = CODEC_ID_MPEG4AAC;
|
2003-07-06 20:49:15 +00:00
|
|
|
break;
|
2003-12-18 09:31:48 +00:00
|
|
|
case 1:
|
2003-12-22 01:46:58 +00:00
|
|
|
if (gst_structure_get_int (structure, "layer", &layer)) {
|
2003-12-18 09:31:48 +00:00
|
|
|
switch (layer) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
id = CODEC_ID_MP2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
id = CODEC_ID_MP3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-07-06 20:49:15 +00:00
|
|
|
default:
|
|
|
|
/* ... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
audio = TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "audio/x-wma")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint wmaversion = 0;
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "wmaversion", &wmaversion);
|
|
|
|
|
|
|
|
switch (wmaversion) {
|
|
|
|
case 1:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_WMAV1;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
case 2:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_WMAV2;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
/* ... */
|
|
|
|
break;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
audio = TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "audio/x-ac3")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
id = CODEC_ID_AC3;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-msmpeg")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint msmpegversion = 0;
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "msmpegversion", &msmpegversion);
|
|
|
|
|
|
|
|
switch (msmpegversion) {
|
|
|
|
case 41:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_MSMPEG4V1;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
case 42:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_MSMPEG4V2;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
case 43:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_MSMPEG4V3;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
/* ... */
|
|
|
|
break;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
video = TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-svq")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint svqversion = 0;
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "svqversion", &svqversion);
|
|
|
|
|
|
|
|
switch (svqversion) {
|
|
|
|
case 1:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_SVQ1;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
case 3:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_SVQ3;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
/* ... */
|
|
|
|
break;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
video = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "video/x-huffyuv")) {
|
|
|
|
|
|
|
|
id = CODEC_ID_HUFFYUV;
|
|
|
|
video = TRUE;
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "audio/x-mace")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint maceversion = 0;
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "maceversion", &maceversion);
|
|
|
|
switch (maceversion) {
|
|
|
|
case 3:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_MACE3;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
case 6:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_MACE6;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
/* ... */
|
|
|
|
break;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
audio = TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-theora")) {
|
|
|
|
|
|
|
|
id = CODEC_ID_THEORA;
|
|
|
|
video = TRUE;
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "video/x-vp3")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
id = CODEC_ID_VP3;
|
|
|
|
video = TRUE;
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "video/x-indeo")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint indeoversion = 0;
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "indeoversion", &indeoversion);
|
|
|
|
switch (indeoversion) {
|
|
|
|
case 3:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_INDEO3;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
/* ... */
|
|
|
|
break;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
video = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "video/x-divx")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint divxversion = 0;
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "divxversion", &divxversion);
|
|
|
|
switch (divxversion) {
|
|
|
|
case 3:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_MSMPEG4V3;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
case 4:
|
|
|
|
case 5:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_MPEG4;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
/* ... */
|
|
|
|
break;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
if (context) {
|
2004-03-29 16:39:18 +00:00
|
|
|
context->codec_tag = GST_MAKE_FOURCC ('D', 'I', 'V', 'X');
|
2004-03-15 00:01:03 +00:00
|
|
|
}
|
|
|
|
|
2003-07-06 20:49:15 +00:00
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
video = TRUE;
|
|
|
|
}
|
|
|
|
|
configure.ac: Fix configure check for mpeg2enc. We need 1.6.1.93 instead of 1.6.1.92, since the pkg-config file of 1....
Original commit message from CVS:
2004-01-01 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Fix configure check for mpeg2enc. We need 1.6.1.93 instead of
1.6.1.92, since the pkg-config file of 1.6.1.92 is borked and
it therefore uses the wrong include paths. Too bad... Note
that 1.6.1.93 is not release yet. ;).
Also add a check for mplex, which is now using the lib'ified
mplex from mjpegtools, too.
* ext/ffmpeg/gstffmpegcodecmap.c:
Add codec_tag for 3ivx/xvid. For xvid, this should fix playback
issues. I don't think ffmpeg handles 3ivx correctly, so this
probably won't work. But it won't hurt either.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect),
(gst_ffmpegenc_chain_audio):
Fix memleak in audio encoding. Close codec if open fails, this
calls the cleanup routines so we can re-use the context.
* ext/mpeg2enc/gstmpeg2enc.cc:
Fix pad template names/types, fix memory issue with getcaps().
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encoder.hh:
Fix compile issue with new caps system (const thingy).
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.hh:
We read a first frame right on initing, so that we have a caps
when we init the output. This caps is cached in padprivate and
read as first frame.
* ext/mplex/Makefile.am:
* ext/mplex/gstmplex.cc:
* ext/mplex/gstmplex.h:
* ext/mplex/gstmplex.hh:
* ext/mplex/gstmplexibitstream.cc:
* ext/mplex/gstmplexibitstream.hh:
* ext/mplex/gstmplexjob.cc:
* ext/mplex/gstmplexjob.hh:
* ext/mplex/gstmplexoutputstream.cc:
* ext/mplex/gstmplexoutputstream.hh:
We wrap mjpegtools mplex. So I rewrote the plugin. The old plugin
had issues, didn't do capsnego, supported only a subset of the
mplex features and required a mplex fork in our local CVS. Plus
that it worked agaist a very old mplex version. Rewriting was
faster than updating it.
* gst-libs/ext/Makefile.am:
* gst-libs/ext/mplex/INSTRUCT:
* gst-libs/ext/mplex/Makefile.am:
* gst-libs/ext/mplex/README:
* gst-libs/ext/mplex/TODO:
* gst-libs/ext/mplex/ac3strm_in.cc:
* gst-libs/ext/mplex/audiostrm.hh:
* gst-libs/ext/mplex/audiostrm_out.cc:
* gst-libs/ext/mplex/aunit.hh:
* gst-libs/ext/mplex/bits.cc:
* gst-libs/ext/mplex/bits.hh:
* gst-libs/ext/mplex/buffer.cc:
* gst-libs/ext/mplex/buffer.hh:
* gst-libs/ext/mplex/fastintfns.h:
* gst-libs/ext/mplex/format_codes.h:
* gst-libs/ext/mplex/inputstrm.cc:
* gst-libs/ext/mplex/inputstrm.hh:
* gst-libs/ext/mplex/lpcmstrm_in.cc:
* gst-libs/ext/mplex/mjpeg_logging.cc:
* gst-libs/ext/mplex/mjpeg_logging.h:
* gst-libs/ext/mplex/mjpeg_types.h:
* gst-libs/ext/mplex/mpastrm_in.cc:
* gst-libs/ext/mplex/mpegconsts.cc:
* gst-libs/ext/mplex/mpegconsts.h:
* gst-libs/ext/mplex/mplexconsts.hh:
* gst-libs/ext/mplex/multplex.cc:
* gst-libs/ext/mplex/outputstream.hh:
* gst-libs/ext/mplex/padstrm.cc:
* gst-libs/ext/mplex/padstrm.hh:
* gst-libs/ext/mplex/stillsstream.cc:
* gst-libs/ext/mplex/stillsstream.hh:
* gst-libs/ext/mplex/systems.cc:
* gst-libs/ext/mplex/systems.hh:
* gst-libs/ext/mplex/vector.cc:
* gst-libs/ext/mplex/vector.hh:
* gst-libs/ext/mplex/videostrm.hh:
* gst-libs/ext/mplex/videostrm_in.cc:
* gst-libs/ext/mplex/videostrm_out.cc:
* gst-libs/ext/mplex/yuv4mpeg.cc:
* gst-libs/ext/mplex/yuv4mpeg.h:
* gst-libs/ext/mplex/yuv4mpeg_intern.h:
* gst-libs/ext/mplex/yuv4mpeg_ratio.cc:
We don't fork mjpegtools' mplex in our CVS anymore.
* gst/avi/gstavidemux.c: (gst_avi_demux_src_getcaps),
(gst_avi_demux_add_stream):
* gst/avi/gstavidemux.h:
Add getcaps() function for proper caps nego. This makes some
parts of AVI playback/reading work.
* sys/ximage/ximagesink.c: (gst_ximagesink_sinkconnect):
Resize window on new capsnego. This is probably wrong, but
I'm still committing it because with current capsnego, the
first successfull capsnego is auto-fixated, therefore rounded
down to the lowest values in the caps. this results in a 16x16
XWindow that is not reized when real capsnego finishes.
Dave, I see more cases of this, do you know a proper solution?
* tools/gst-launch-ext.in:
Fix MPEG-4 AAC (Apple iPod/iTunes) file commandline.
2004-01-01 22:45:56 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-3ivx")) {
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
id = CODEC_ID_MPEG4;
|
|
|
|
video = TRUE;
|
|
|
|
|
configure.ac: Fix configure check for mpeg2enc. We need 1.6.1.93 instead of 1.6.1.92, since the pkg-config file of 1....
Original commit message from CVS:
2004-01-01 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Fix configure check for mpeg2enc. We need 1.6.1.93 instead of
1.6.1.92, since the pkg-config file of 1.6.1.92 is borked and
it therefore uses the wrong include paths. Too bad... Note
that 1.6.1.93 is not release yet. ;).
Also add a check for mplex, which is now using the lib'ified
mplex from mjpegtools, too.
* ext/ffmpeg/gstffmpegcodecmap.c:
Add codec_tag for 3ivx/xvid. For xvid, this should fix playback
issues. I don't think ffmpeg handles 3ivx correctly, so this
probably won't work. But it won't hurt either.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect),
(gst_ffmpegenc_chain_audio):
Fix memleak in audio encoding. Close codec if open fails, this
calls the cleanup routines so we can re-use the context.
* ext/mpeg2enc/gstmpeg2enc.cc:
Fix pad template names/types, fix memory issue with getcaps().
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encoder.hh:
Fix compile issue with new caps system (const thingy).
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.hh:
We read a first frame right on initing, so that we have a caps
when we init the output. This caps is cached in padprivate and
read as first frame.
* ext/mplex/Makefile.am:
* ext/mplex/gstmplex.cc:
* ext/mplex/gstmplex.h:
* ext/mplex/gstmplex.hh:
* ext/mplex/gstmplexibitstream.cc:
* ext/mplex/gstmplexibitstream.hh:
* ext/mplex/gstmplexjob.cc:
* ext/mplex/gstmplexjob.hh:
* ext/mplex/gstmplexoutputstream.cc:
* ext/mplex/gstmplexoutputstream.hh:
We wrap mjpegtools mplex. So I rewrote the plugin. The old plugin
had issues, didn't do capsnego, supported only a subset of the
mplex features and required a mplex fork in our local CVS. Plus
that it worked agaist a very old mplex version. Rewriting was
faster than updating it.
* gst-libs/ext/Makefile.am:
* gst-libs/ext/mplex/INSTRUCT:
* gst-libs/ext/mplex/Makefile.am:
* gst-libs/ext/mplex/README:
* gst-libs/ext/mplex/TODO:
* gst-libs/ext/mplex/ac3strm_in.cc:
* gst-libs/ext/mplex/audiostrm.hh:
* gst-libs/ext/mplex/audiostrm_out.cc:
* gst-libs/ext/mplex/aunit.hh:
* gst-libs/ext/mplex/bits.cc:
* gst-libs/ext/mplex/bits.hh:
* gst-libs/ext/mplex/buffer.cc:
* gst-libs/ext/mplex/buffer.hh:
* gst-libs/ext/mplex/fastintfns.h:
* gst-libs/ext/mplex/format_codes.h:
* gst-libs/ext/mplex/inputstrm.cc:
* gst-libs/ext/mplex/inputstrm.hh:
* gst-libs/ext/mplex/lpcmstrm_in.cc:
* gst-libs/ext/mplex/mjpeg_logging.cc:
* gst-libs/ext/mplex/mjpeg_logging.h:
* gst-libs/ext/mplex/mjpeg_types.h:
* gst-libs/ext/mplex/mpastrm_in.cc:
* gst-libs/ext/mplex/mpegconsts.cc:
* gst-libs/ext/mplex/mpegconsts.h:
* gst-libs/ext/mplex/mplexconsts.hh:
* gst-libs/ext/mplex/multplex.cc:
* gst-libs/ext/mplex/outputstream.hh:
* gst-libs/ext/mplex/padstrm.cc:
* gst-libs/ext/mplex/padstrm.hh:
* gst-libs/ext/mplex/stillsstream.cc:
* gst-libs/ext/mplex/stillsstream.hh:
* gst-libs/ext/mplex/systems.cc:
* gst-libs/ext/mplex/systems.hh:
* gst-libs/ext/mplex/vector.cc:
* gst-libs/ext/mplex/vector.hh:
* gst-libs/ext/mplex/videostrm.hh:
* gst-libs/ext/mplex/videostrm_in.cc:
* gst-libs/ext/mplex/videostrm_out.cc:
* gst-libs/ext/mplex/yuv4mpeg.cc:
* gst-libs/ext/mplex/yuv4mpeg.h:
* gst-libs/ext/mplex/yuv4mpeg_intern.h:
* gst-libs/ext/mplex/yuv4mpeg_ratio.cc:
We don't fork mjpegtools' mplex in our CVS anymore.
* gst/avi/gstavidemux.c: (gst_avi_demux_src_getcaps),
(gst_avi_demux_add_stream):
* gst/avi/gstavidemux.h:
Add getcaps() function for proper caps nego. This makes some
parts of AVI playback/reading work.
* sys/ximage/ximagesink.c: (gst_ximagesink_sinkconnect):
Resize window on new capsnego. This is probably wrong, but
I'm still committing it because with current capsnego, the
first successfull capsnego is auto-fixated, therefore rounded
down to the lowest values in the caps. this results in a 16x16
XWindow that is not reized when real capsnego finishes.
Dave, I see more cases of this, do you know a proper solution?
* tools/gst-launch-ext.in:
Fix MPEG-4 AAC (Apple iPod/iTunes) file commandline.
2004-01-01 22:45:56 +00:00
|
|
|
if (context) {
|
2004-03-29 16:39:18 +00:00
|
|
|
context->codec_tag = GST_MAKE_FOURCC ('3', 'I', 'V', 'X');
|
configure.ac: Fix configure check for mpeg2enc. We need 1.6.1.93 instead of 1.6.1.92, since the pkg-config file of 1....
Original commit message from CVS:
2004-01-01 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Fix configure check for mpeg2enc. We need 1.6.1.93 instead of
1.6.1.92, since the pkg-config file of 1.6.1.92 is borked and
it therefore uses the wrong include paths. Too bad... Note
that 1.6.1.93 is not release yet. ;).
Also add a check for mplex, which is now using the lib'ified
mplex from mjpegtools, too.
* ext/ffmpeg/gstffmpegcodecmap.c:
Add codec_tag for 3ivx/xvid. For xvid, this should fix playback
issues. I don't think ffmpeg handles 3ivx correctly, so this
probably won't work. But it won't hurt either.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect),
(gst_ffmpegenc_chain_audio):
Fix memleak in audio encoding. Close codec if open fails, this
calls the cleanup routines so we can re-use the context.
* ext/mpeg2enc/gstmpeg2enc.cc:
Fix pad template names/types, fix memory issue with getcaps().
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encoder.hh:
Fix compile issue with new caps system (const thingy).
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.hh:
We read a first frame right on initing, so that we have a caps
when we init the output. This caps is cached in padprivate and
read as first frame.
* ext/mplex/Makefile.am:
* ext/mplex/gstmplex.cc:
* ext/mplex/gstmplex.h:
* ext/mplex/gstmplex.hh:
* ext/mplex/gstmplexibitstream.cc:
* ext/mplex/gstmplexibitstream.hh:
* ext/mplex/gstmplexjob.cc:
* ext/mplex/gstmplexjob.hh:
* ext/mplex/gstmplexoutputstream.cc:
* ext/mplex/gstmplexoutputstream.hh:
We wrap mjpegtools mplex. So I rewrote the plugin. The old plugin
had issues, didn't do capsnego, supported only a subset of the
mplex features and required a mplex fork in our local CVS. Plus
that it worked agaist a very old mplex version. Rewriting was
faster than updating it.
* gst-libs/ext/Makefile.am:
* gst-libs/ext/mplex/INSTRUCT:
* gst-libs/ext/mplex/Makefile.am:
* gst-libs/ext/mplex/README:
* gst-libs/ext/mplex/TODO:
* gst-libs/ext/mplex/ac3strm_in.cc:
* gst-libs/ext/mplex/audiostrm.hh:
* gst-libs/ext/mplex/audiostrm_out.cc:
* gst-libs/ext/mplex/aunit.hh:
* gst-libs/ext/mplex/bits.cc:
* gst-libs/ext/mplex/bits.hh:
* gst-libs/ext/mplex/buffer.cc:
* gst-libs/ext/mplex/buffer.hh:
* gst-libs/ext/mplex/fastintfns.h:
* gst-libs/ext/mplex/format_codes.h:
* gst-libs/ext/mplex/inputstrm.cc:
* gst-libs/ext/mplex/inputstrm.hh:
* gst-libs/ext/mplex/lpcmstrm_in.cc:
* gst-libs/ext/mplex/mjpeg_logging.cc:
* gst-libs/ext/mplex/mjpeg_logging.h:
* gst-libs/ext/mplex/mjpeg_types.h:
* gst-libs/ext/mplex/mpastrm_in.cc:
* gst-libs/ext/mplex/mpegconsts.cc:
* gst-libs/ext/mplex/mpegconsts.h:
* gst-libs/ext/mplex/mplexconsts.hh:
* gst-libs/ext/mplex/multplex.cc:
* gst-libs/ext/mplex/outputstream.hh:
* gst-libs/ext/mplex/padstrm.cc:
* gst-libs/ext/mplex/padstrm.hh:
* gst-libs/ext/mplex/stillsstream.cc:
* gst-libs/ext/mplex/stillsstream.hh:
* gst-libs/ext/mplex/systems.cc:
* gst-libs/ext/mplex/systems.hh:
* gst-libs/ext/mplex/vector.cc:
* gst-libs/ext/mplex/vector.hh:
* gst-libs/ext/mplex/videostrm.hh:
* gst-libs/ext/mplex/videostrm_in.cc:
* gst-libs/ext/mplex/videostrm_out.cc:
* gst-libs/ext/mplex/yuv4mpeg.cc:
* gst-libs/ext/mplex/yuv4mpeg.h:
* gst-libs/ext/mplex/yuv4mpeg_intern.h:
* gst-libs/ext/mplex/yuv4mpeg_ratio.cc:
We don't fork mjpegtools' mplex in our CVS anymore.
* gst/avi/gstavidemux.c: (gst_avi_demux_src_getcaps),
(gst_avi_demux_add_stream):
* gst/avi/gstavidemux.h:
Add getcaps() function for proper caps nego. This makes some
parts of AVI playback/reading work.
* sys/ximage/ximagesink.c: (gst_ximagesink_sinkconnect):
Resize window on new capsnego. This is probably wrong, but
I'm still committing it because with current capsnego, the
first successfull capsnego is auto-fixated, therefore rounded
down to the lowest values in the caps. this results in a 16x16
XWindow that is not reized when real capsnego finishes.
Dave, I see more cases of this, do you know a proper solution?
* tools/gst-launch-ext.in:
Fix MPEG-4 AAC (Apple iPod/iTunes) file commandline.
2004-01-01 22:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "video/x-xvid")) {
|
|
|
|
|
|
|
|
id = CODEC_ID_MPEG4;
|
|
|
|
video = TRUE;
|
|
|
|
|
|
|
|
if (context) {
|
2004-03-29 16:39:18 +00:00
|
|
|
context->codec_tag = GST_MAKE_FOURCC ('X', 'V', 'I', 'D');
|
configure.ac: Fix configure check for mpeg2enc. We need 1.6.1.93 instead of 1.6.1.92, since the pkg-config file of 1....
Original commit message from CVS:
2004-01-01 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Fix configure check for mpeg2enc. We need 1.6.1.93 instead of
1.6.1.92, since the pkg-config file of 1.6.1.92 is borked and
it therefore uses the wrong include paths. Too bad... Note
that 1.6.1.93 is not release yet. ;).
Also add a check for mplex, which is now using the lib'ified
mplex from mjpegtools, too.
* ext/ffmpeg/gstffmpegcodecmap.c:
Add codec_tag for 3ivx/xvid. For xvid, this should fix playback
issues. I don't think ffmpeg handles 3ivx correctly, so this
probably won't work. But it won't hurt either.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect),
(gst_ffmpegenc_chain_audio):
Fix memleak in audio encoding. Close codec if open fails, this
calls the cleanup routines so we can re-use the context.
* ext/mpeg2enc/gstmpeg2enc.cc:
Fix pad template names/types, fix memory issue with getcaps().
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encoder.hh:
Fix compile issue with new caps system (const thingy).
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.hh:
We read a first frame right on initing, so that we have a caps
when we init the output. This caps is cached in padprivate and
read as first frame.
* ext/mplex/Makefile.am:
* ext/mplex/gstmplex.cc:
* ext/mplex/gstmplex.h:
* ext/mplex/gstmplex.hh:
* ext/mplex/gstmplexibitstream.cc:
* ext/mplex/gstmplexibitstream.hh:
* ext/mplex/gstmplexjob.cc:
* ext/mplex/gstmplexjob.hh:
* ext/mplex/gstmplexoutputstream.cc:
* ext/mplex/gstmplexoutputstream.hh:
We wrap mjpegtools mplex. So I rewrote the plugin. The old plugin
had issues, didn't do capsnego, supported only a subset of the
mplex features and required a mplex fork in our local CVS. Plus
that it worked agaist a very old mplex version. Rewriting was
faster than updating it.
* gst-libs/ext/Makefile.am:
* gst-libs/ext/mplex/INSTRUCT:
* gst-libs/ext/mplex/Makefile.am:
* gst-libs/ext/mplex/README:
* gst-libs/ext/mplex/TODO:
* gst-libs/ext/mplex/ac3strm_in.cc:
* gst-libs/ext/mplex/audiostrm.hh:
* gst-libs/ext/mplex/audiostrm_out.cc:
* gst-libs/ext/mplex/aunit.hh:
* gst-libs/ext/mplex/bits.cc:
* gst-libs/ext/mplex/bits.hh:
* gst-libs/ext/mplex/buffer.cc:
* gst-libs/ext/mplex/buffer.hh:
* gst-libs/ext/mplex/fastintfns.h:
* gst-libs/ext/mplex/format_codes.h:
* gst-libs/ext/mplex/inputstrm.cc:
* gst-libs/ext/mplex/inputstrm.hh:
* gst-libs/ext/mplex/lpcmstrm_in.cc:
* gst-libs/ext/mplex/mjpeg_logging.cc:
* gst-libs/ext/mplex/mjpeg_logging.h:
* gst-libs/ext/mplex/mjpeg_types.h:
* gst-libs/ext/mplex/mpastrm_in.cc:
* gst-libs/ext/mplex/mpegconsts.cc:
* gst-libs/ext/mplex/mpegconsts.h:
* gst-libs/ext/mplex/mplexconsts.hh:
* gst-libs/ext/mplex/multplex.cc:
* gst-libs/ext/mplex/outputstream.hh:
* gst-libs/ext/mplex/padstrm.cc:
* gst-libs/ext/mplex/padstrm.hh:
* gst-libs/ext/mplex/stillsstream.cc:
* gst-libs/ext/mplex/stillsstream.hh:
* gst-libs/ext/mplex/systems.cc:
* gst-libs/ext/mplex/systems.hh:
* gst-libs/ext/mplex/vector.cc:
* gst-libs/ext/mplex/vector.hh:
* gst-libs/ext/mplex/videostrm.hh:
* gst-libs/ext/mplex/videostrm_in.cc:
* gst-libs/ext/mplex/videostrm_out.cc:
* gst-libs/ext/mplex/yuv4mpeg.cc:
* gst-libs/ext/mplex/yuv4mpeg.h:
* gst-libs/ext/mplex/yuv4mpeg_intern.h:
* gst-libs/ext/mplex/yuv4mpeg_ratio.cc:
We don't fork mjpegtools' mplex in our CVS anymore.
* gst/avi/gstavidemux.c: (gst_avi_demux_src_getcaps),
(gst_avi_demux_add_stream):
* gst/avi/gstavidemux.h:
Add getcaps() function for proper caps nego. This makes some
parts of AVI playback/reading work.
* sys/ximage/ximagesink.c: (gst_ximagesink_sinkconnect):
Resize window on new capsnego. This is probably wrong, but
I'm still committing it because with current capsnego, the
first successfull capsnego is auto-fixated, therefore rounded
down to the lowest values in the caps. this results in a 16x16
XWindow that is not reized when real capsnego finishes.
Dave, I see more cases of this, do you know a proper solution?
* tools/gst-launch-ext.in:
Fix MPEG-4 AAC (Apple iPod/iTunes) file commandline.
2004-01-01 22:45:56 +00:00
|
|
|
}
|
|
|
|
|
2003-07-06 20:49:15 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-ffv")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
gint ffvversion = 0;
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "ffvversion", &ffvversion);
|
|
|
|
switch (ffvversion) {
|
|
|
|
case 1:
|
2004-03-29 16:39:18 +00:00
|
|
|
id = CODEC_ID_FFV1;
|
|
|
|
break;
|
2003-12-22 01:46:58 +00:00
|
|
|
default:
|
2004-03-29 16:39:18 +00:00
|
|
|
/* ... */
|
|
|
|
break;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
video = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "x-adpcm")) {
|
2003-12-22 01:46:58 +00:00
|
|
|
const gchar *layout;
|
|
|
|
|
|
|
|
layout = gst_structure_get_string (structure, "layout");
|
|
|
|
if (layout == NULL) {
|
|
|
|
/* break */
|
|
|
|
} else if (!strcmp (layout, "quicktime")) {
|
|
|
|
id = CODEC_ID_ADPCM_IMA_QT;
|
|
|
|
} else if (!strcmp (layout, "microsoft")) {
|
|
|
|
id = CODEC_ID_ADPCM_MS;
|
|
|
|
} else if (!strcmp (layout, "wav")) {
|
|
|
|
id = CODEC_ID_ADPCM_IMA_WAV;
|
|
|
|
} else if (!strcmp (layout, "4xm")) {
|
|
|
|
id = CODEC_ID_ADPCM_4XM;
|
2004-03-15 00:01:03 +00:00
|
|
|
} else if (!strcmp (layout, "smjpeg")) {
|
|
|
|
id = CODEC_ID_ADPCM_IMA_SMJPEG;
|
|
|
|
} else if (!strcmp (layout, "dk3")) {
|
|
|
|
id = CODEC_ID_ADPCM_IMA_DK3;
|
|
|
|
} else if (!strcmp (layout, "dk4")) {
|
|
|
|
id = CODEC_ID_ADPCM_IMA_DK4;
|
|
|
|
} else if (!strcmp (layout, "westwood")) {
|
|
|
|
id = CODEC_ID_ADPCM_IMA_WS;
|
|
|
|
} else if (!strcmp (layout, "xa")) {
|
|
|
|
id = CODEC_ID_ADPCM_XA;
|
|
|
|
} else if (!strcmp (layout, "adx")) {
|
|
|
|
id = CODEC_ID_ADPCM_ADX;
|
|
|
|
} else if (!strcmp (layout, "ea")) {
|
|
|
|
id = CODEC_ID_ADPCM_EA;
|
|
|
|
} else if (!strcmp (layout, "g726")) {
|
|
|
|
id = CODEC_ID_ADPCM_G726;
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
audio = TRUE;
|
|
|
|
}
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-07-06 20:49:15 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-4xm")) {
|
|
|
|
|
|
|
|
id = CODEC_ID_4XM;
|
|
|
|
video = TRUE;
|
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
} else if (!strcmp (mimetype, "audio/x-dpcm")) {
|
|
|
|
const gchar *layout;
|
|
|
|
|
|
|
|
layout = gst_structure_get_string (structure, "layout");
|
2003-07-06 20:49:15 +00:00
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
if (!strcmp (layout, "roq")) {
|
|
|
|
id = CODEC_ID_ROQ_DPCM;
|
|
|
|
} else if (!strcmp (layout, "interplay")) {
|
|
|
|
id = CODEC_ID_INTERPLAY_DPCM;
|
|
|
|
} else if (!strcmp (layout, "xan")) {
|
|
|
|
id = CODEC_ID_XAN_DPCM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
audio = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "audio/x-flax")) {
|
|
|
|
|
|
|
|
id = CODEC_ID_FLAC;
|
|
|
|
audio = TRUE;
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "video/x-cinepak")) {
|
|
|
|
|
|
|
|
id = CODEC_ID_CINEPAK;
|
|
|
|
video = TRUE;
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "video/x-pn-realvideo")) {
|
|
|
|
|
|
|
|
gint rmversion;
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "rmversion", &rmversion);
|
|
|
|
|
|
|
|
switch (rmversion) {
|
|
|
|
case 1:
|
|
|
|
id = CODEC_ID_RV10;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
id = CODEC_ID_RV20;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* .. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
video = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!strcmp (mimetype, "audio/x-pn-realaudio")) {
|
|
|
|
|
|
|
|
gint raversion;
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
gst_structure_get_int (structure, "raversion", &raversion);
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
switch (raversion) {
|
|
|
|
case 1:
|
|
|
|
id = CODEC_ID_RA_144;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
id = CODEC_ID_RA_288;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* .. */
|
|
|
|
break;
|
|
|
|
}
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2004-03-15 00:01:03 +00:00
|
|
|
if (id != CODEC_ID_NONE) {
|
|
|
|
audio = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!strncmp (mimetype, "audio/x-gst_ff-", 15) ||
|
2004-03-29 16:39:18 +00:00
|
|
|
!strncmp (mimetype, "video/x-gst_ff-", 15)) {
|
2004-03-15 00:01:03 +00:00
|
|
|
|
|
|
|
gchar ext[16];
|
|
|
|
AVCodec *codec;
|
|
|
|
|
|
|
|
if (strlen (mimetype) <= 30 &&
|
|
|
|
sscanf (mimetype, "%*s/x-gst_ff-%s", &ext) == 1) {
|
|
|
|
if ((codec = avcodec_find_decoder_by_name (ext)) ||
|
|
|
|
(codec = avcodec_find_encoder_by_name (ext))) {
|
|
|
|
id = codec->id;
|
|
|
|
if (mimetype[0] == 'v')
|
|
|
|
video = TRUE;
|
|
|
|
else if (mimetype[0] == 'a')
|
|
|
|
audio = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2003-07-06 20:49:15 +00:00
|
|
|
|
|
|
|
if (context != NULL) {
|
|
|
|
if (video == TRUE) {
|
|
|
|
gst_ffmpeg_caps_to_pixfmt (caps, context);
|
|
|
|
context->codec_type = CODEC_TYPE_VIDEO;
|
|
|
|
} else if (audio == TRUE) {
|
|
|
|
gst_ffmpeg_caps_to_smpfmt (caps, context);
|
|
|
|
context->codec_type = CODEC_TYPE_AUDIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
context->codec_id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id != CODEC_ID_NONE) {
|
2003-12-22 01:46:58 +00:00
|
|
|
char *str = gst_caps_to_string (caps);
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2003-12-22 01:46:58 +00:00
|
|
|
GST_DEBUG ("The id=%d belongs to the caps %s", id, str);
|
2004-03-29 16:39:18 +00:00
|
|
|
g_free (str);
|
2003-07-06 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|