2002-03-20 21:44:42 +00:00
|
|
|
/* GStreamer
|
2001-12-23 13:25:04 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
2012-11-19 11:57:19 +00:00
|
|
|
* Copyright (C) <2012> Collabora Ltd.
|
|
|
|
* Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
2001-12-23 13:25:04 +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
|
2012-11-04 00:22:16 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2001-12-23 13:25:04 +00:00
|
|
|
*/
|
|
|
|
|
2004-01-12 04:15:46 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2003-06-07 00:41:32 +00:00
|
|
|
#include "config.h"
|
2004-01-12 04:15:46 +00:00
|
|
|
#endif
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
#include <assert.h>
|
2001-12-23 13:25:04 +00:00
|
|
|
#include <string.h>
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2008-10-30 12:05:45 +00:00
|
|
|
#include <libavcodec/avcodec.h>
|
2002-11-06 23:53:46 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2012-09-10 15:53:54 +00:00
|
|
|
#include "gstav.h"
|
|
|
|
#include "gstavcodecmap.h"
|
|
|
|
#include "gstavutils.h"
|
2012-11-19 09:29:00 +00:00
|
|
|
#include "gstavauddec.h"
|
2002-11-25 21:37:26 +00:00
|
|
|
|
2012-03-14 10:53:42 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_PERFORMANCE);
|
|
|
|
|
2007-02-16 11:48:15 +00:00
|
|
|
/* A number of function prototypes are given so we can refer to them later. */
|
2012-04-07 09:14:45 +00:00
|
|
|
static void gst_ffmpegauddec_base_init (GstFFMpegAudDecClass * klass);
|
|
|
|
static void gst_ffmpegauddec_class_init (GstFFMpegAudDecClass * klass);
|
|
|
|
static void gst_ffmpegauddec_init (GstFFMpegAudDec * ffmpegdec);
|
|
|
|
static void gst_ffmpegauddec_finalize (GObject * object);
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
static gboolean gst_ffmpegauddec_stop (GstAudioDecoder * decoder);
|
|
|
|
static void gst_ffmpegauddec_flush (GstAudioDecoder * decoder, gboolean hard);
|
|
|
|
static gboolean gst_ffmpegauddec_set_format (GstAudioDecoder * decoder,
|
2012-06-14 10:41:34 +00:00
|
|
|
GstCaps * caps);
|
2012-11-19 11:57:19 +00:00
|
|
|
static GstFlowReturn gst_ffmpegauddec_handle_frame (GstAudioDecoder * decoder,
|
|
|
|
GstBuffer * inbuf);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
static gboolean gst_ffmpegauddec_negotiate (GstFFMpegAudDec * ffmpegdec,
|
2009-05-12 09:16:43 +00:00
|
|
|
gboolean force);
|
2005-05-06 07:47:50 +00:00
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
static void gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec);
|
2009-06-09 14:34:04 +00:00
|
|
|
|
2012-04-12 17:41:52 +00:00
|
|
|
#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("avdec-params")
|
2007-02-16 11:48:15 +00:00
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
2003-11-02 13:12:14 +00:00
|
|
|
static void
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_base_init (GstFFMpegAudDecClass * klass)
|
2003-11-02 13:12:14 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
GstPadTemplate *sinktempl, *srctempl;
|
2009-10-22 20:27:28 +00:00
|
|
|
GstCaps *sinkcaps, *srccaps;
|
|
|
|
AVCodec *in_plugin;
|
2012-04-07 09:14:45 +00:00
|
|
|
gchar *longname, *description;
|
2003-11-02 13:12:14 +00:00
|
|
|
|
2009-11-02 08:05:13 +00:00
|
|
|
in_plugin =
|
|
|
|
(AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
|
2007-02-16 11:48:15 +00:00
|
|
|
GST_FFDEC_PARAMS_QDATA);
|
2009-11-02 08:05:13 +00:00
|
|
|
g_assert (in_plugin != NULL);
|
2009-10-22 20:27:28 +00:00
|
|
|
|
2003-11-02 13:12:14 +00:00
|
|
|
/* construct the element details struct */
|
2012-04-12 17:41:52 +00:00
|
|
|
longname = g_strdup_printf ("libav %s decoder", in_plugin->long_name);
|
|
|
|
description = g_strdup_printf ("libav %s decoder", in_plugin->name);
|
2012-04-09 23:59:24 +00:00
|
|
|
gst_element_class_set_metadata (element_class, longname,
|
2012-04-07 09:14:45 +00:00
|
|
|
"Codec/Decoder/Audio", description,
|
2010-03-24 10:51:26 +00:00
|
|
|
"Wim Taymans <wim.taymans@gmail.com>, "
|
2007-12-17 12:43:06 +00:00
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>, "
|
2010-03-24 10:51:26 +00:00
|
|
|
"Edward Hervey <bilboed@bilboed.com>");
|
|
|
|
g_free (longname);
|
|
|
|
g_free (description);
|
2003-11-02 13:12:14 +00:00
|
|
|
|
2009-10-22 20:27:28 +00:00
|
|
|
/* get the caps */
|
|
|
|
sinkcaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, FALSE);
|
|
|
|
if (!sinkcaps) {
|
|
|
|
GST_DEBUG ("Couldn't get sink caps for decoder '%s'", in_plugin->name);
|
|
|
|
sinkcaps = gst_caps_from_string ("unknown/unknown");
|
|
|
|
}
|
2012-04-07 09:14:45 +00:00
|
|
|
srccaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
|
|
|
|
in_plugin->id, FALSE, in_plugin);
|
2009-10-22 20:27:28 +00:00
|
|
|
if (!srccaps) {
|
|
|
|
GST_DEBUG ("Couldn't get source caps for decoder '%s'", in_plugin->name);
|
2012-12-12 15:42:09 +00:00
|
|
|
srccaps = gst_caps_from_string ("audio/x-raw");
|
2009-10-22 20:27:28 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 13:12:14 +00:00
|
|
|
/* pad templates */
|
|
|
|
sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
|
2009-10-22 20:27:28 +00:00
|
|
|
GST_PAD_ALWAYS, sinkcaps);
|
|
|
|
srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
|
2003-11-02 13:12:14 +00:00
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class, srctempl);
|
|
|
|
gst_element_class_add_pad_template (element_class, sinktempl);
|
|
|
|
|
2009-10-22 20:27:28 +00:00
|
|
|
klass->in_plugin = in_plugin;
|
2003-11-02 13:12:14 +00:00
|
|
|
klass->srctempl = srctempl;
|
|
|
|
klass->sinktempl = sinktempl;
|
|
|
|
}
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
static void
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_class_init (GstFFMpegAudDecClass * klass)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
2005-01-31 10:45:20 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2012-11-19 11:57:19 +00:00
|
|
|
GstAudioDecoderClass *gstaudiodecoder_class = GST_AUDIO_DECODER_CLASS (klass);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-11-04 22:31:05 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
gobject_class->finalize = gst_ffmpegauddec_finalize;
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
gstaudiodecoder_class->stop = GST_DEBUG_FUNCPTR (gst_ffmpegauddec_stop);
|
|
|
|
gstaudiodecoder_class->set_format =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_ffmpegauddec_set_format);
|
|
|
|
gstaudiodecoder_class->handle_frame =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_ffmpegauddec_handle_frame);
|
|
|
|
gstaudiodecoder_class->flush = GST_DEBUG_FUNCPTR (gst_ffmpegauddec_flush);
|
2003-06-07 00:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_init (GstFFMpegAudDec * ffmpegdec)
|
2003-06-07 00:41:32 +00:00
|
|
|
{
|
2012-12-05 18:25:37 +00:00
|
|
|
GstFFMpegAudDecClass *klass =
|
|
|
|
(GstFFMpegAudDecClass *) G_OBJECT_GET_CLASS (ffmpegdec);
|
|
|
|
|
2003-06-07 00:41:32 +00:00
|
|
|
/* some ffmpeg data */
|
2012-12-05 18:25:37 +00:00
|
|
|
ffmpegdec->context = avcodec_alloc_context3 (klass->in_plugin);
|
2003-06-07 00:41:32 +00:00
|
|
|
ffmpegdec->opened = FALSE;
|
2009-05-13 10:37:42 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
gst_audio_decoder_set_drainable (GST_AUDIO_DECODER (ffmpegdec), TRUE);
|
|
|
|
gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (ffmpegdec), TRUE);
|
2003-06-07 00:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_finalize (GObject * object)
|
2003-06-07 00:41:32 +00:00
|
|
|
{
|
2012-04-07 09:14:45 +00:00
|
|
|
GstFFMpegAudDec *ffmpegdec = (GstFFMpegAudDec *) object;
|
2003-11-04 22:31:05 +00:00
|
|
|
|
2011-04-29 16:35:55 +00:00
|
|
|
if (ffmpegdec->context != NULL)
|
2008-08-29 09:59:29 +00:00
|
|
|
av_free (ffmpegdec->context);
|
2012-11-19 11:57:19 +00:00
|
|
|
ffmpegdec->context = NULL;
|
2008-10-15 11:28:05 +00:00
|
|
|
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
/* With LOCK */
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
static void
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_close (GstFFMpegAudDec * ffmpegdec)
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
{
|
2012-06-14 10:41:34 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegdec, "closing libav codec");
|
ext/ffmpeg/gstffmpegdec.c: Reenable pad_alloc, seem to work now.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_close), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer), (get_output_buffer),
(gst_ffmpegdec_video_frame), (gst_ffmpegdec_audio_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_set_property), (gst_ffmpegdec_get_property):
Reenable pad_alloc, seem to work now.
Added property to easily disable it later on.
Remove some old code that tried hard to break the get_buffer
functions. Fixes #321662.
2008-01-22 16:32:23 +00:00
|
|
|
|
2011-12-11 05:25:23 +00:00
|
|
|
gst_caps_replace (&ffmpegdec->last_caps, NULL);
|
2012-12-17 14:58:37 +00:00
|
|
|
gst_buffer_replace (&ffmpegdec->outbuf, NULL);
|
2011-12-11 05:25:23 +00:00
|
|
|
|
2012-12-17 15:35:36 +00:00
|
|
|
gst_ffmpeg_avcodec_close (ffmpegdec->context);
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
ffmpegdec->opened = FALSE;
|
|
|
|
|
|
|
|
if (ffmpegdec->context->extradata) {
|
|
|
|
av_free (ffmpegdec->context->extradata);
|
|
|
|
ffmpegdec->context->extradata = NULL;
|
|
|
|
}
|
2012-11-19 11:57:19 +00:00
|
|
|
}
|
2004-12-17 13:08:13 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
static gboolean
|
|
|
|
gst_ffmpegauddec_stop (GstAudioDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstFFMpegAudDec *ffmpegdec = (GstFFMpegAudDec *) decoder;
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (ffmpegdec);
|
|
|
|
gst_ffmpegauddec_close (ffmpegdec);
|
|
|
|
GST_OBJECT_UNLOCK (ffmpegdec);
|
|
|
|
gst_audio_info_init (&ffmpegdec->info);
|
|
|
|
gst_caps_replace (&ffmpegdec->last_caps, NULL);
|
|
|
|
|
|
|
|
return TRUE;
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
}
|
|
|
|
|
2006-03-22 11:36:38 +00:00
|
|
|
/* with LOCK */
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
static gboolean
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_open (GstFFMpegAudDec * ffmpegdec)
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
{
|
2012-04-07 09:14:45 +00:00
|
|
|
GstFFMpegAudDecClass *oclass;
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
|
2005-12-16 16:23:05 +00:00
|
|
|
if (gst_ffmpeg_avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0)
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
goto could_not_open;
|
|
|
|
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
ffmpegdec->opened = TRUE;
|
|
|
|
|
2012-06-14 10:41:34 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegdec, "Opened libav codec %s, id %d",
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
oclass->in_plugin->name, oclass->in_plugin->id);
|
2005-01-19 15:34:14 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
gst_audio_info_init (&ffmpegdec->info);
|
ext/ffmpeg/: Add simple query functions. Seeking is only cosmetic, it's not actually filled in yet (in ffmpegdec).
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_negotiate), (gst_ffmpegdec_chain):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_loop):
Add simple query functions. Seeking is only cosmetic, it's not
actually filled in yet (in ffmpegdec).
2005-01-18 21:33:42 +00:00
|
|
|
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
return TRUE;
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
could_not_open:
|
|
|
|
{
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_close (ffmpegdec);
|
2012-06-14 10:41:34 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "avdec_%s: Failed to open libav codec",
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
oclass->in_plugin->name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
}
|
|
|
|
|
2012-11-20 10:39:45 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
|
|
|
GstMapInfo map;
|
|
|
|
} BufferInfo;
|
|
|
|
|
|
|
|
/* called when ffmpeg wants us to allocate a buffer to write the decoded frame
|
|
|
|
* into. We try to give it memory from our pool */
|
|
|
|
static int
|
|
|
|
gst_ffmpegauddec_get_buffer (AVCodecContext * context, AVFrame * frame)
|
|
|
|
{
|
|
|
|
GstFFMpegAudDec *ffmpegdec;
|
|
|
|
GstAudioInfo *info;
|
2012-12-04 19:45:28 +00:00
|
|
|
BufferInfo *buffer_info;
|
2012-11-20 10:39:45 +00:00
|
|
|
|
|
|
|
ffmpegdec = (GstFFMpegAudDec *) context->opaque;
|
|
|
|
if (G_UNLIKELY (!gst_ffmpegauddec_negotiate (ffmpegdec, FALSE)))
|
|
|
|
goto negotiate_failed;
|
|
|
|
|
2012-12-04 19:45:28 +00:00
|
|
|
/* Always use the default allocator for planar audio formats because
|
|
|
|
* we will have to copy and deinterleave later anyway */
|
|
|
|
if (av_sample_fmt_is_planar (ffmpegdec->context->sample_fmt))
|
|
|
|
goto fallback;
|
|
|
|
|
2012-11-20 10:39:45 +00:00
|
|
|
info = gst_audio_decoder_get_audio_info (GST_AUDIO_DECODER (ffmpegdec));
|
|
|
|
|
2012-12-04 19:45:28 +00:00
|
|
|
buffer_info = g_slice_new (BufferInfo);
|
2012-11-20 10:39:45 +00:00
|
|
|
buffer_info->buffer =
|
|
|
|
gst_audio_decoder_allocate_output_buffer (GST_AUDIO_DECODER (ffmpegdec),
|
|
|
|
frame->nb_samples * info->bpf);
|
|
|
|
gst_buffer_map (buffer_info->buffer, &buffer_info->map, GST_MAP_WRITE);
|
|
|
|
frame->opaque = buffer_info;
|
|
|
|
frame->data[0] = buffer_info->map.data;
|
2012-12-12 13:04:38 +00:00
|
|
|
frame->extended_data = frame->data;
|
2012-11-20 10:39:45 +00:00
|
|
|
frame->linesize[0] = buffer_info->map.size;
|
|
|
|
frame->type = FF_BUFFER_TYPE_USER;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
/* fallbacks */
|
|
|
|
negotiate_failed:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed");
|
|
|
|
goto fallback;
|
|
|
|
}
|
|
|
|
fallback:
|
|
|
|
{
|
|
|
|
return avcodec_default_get_buffer (context, frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-10 09:31:32 +00:00
|
|
|
static gboolean
|
2012-11-19 11:57:19 +00:00
|
|
|
gst_ffmpegauddec_set_format (GstAudioDecoder * decoder, GstCaps * caps)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
2012-11-19 11:57:19 +00:00
|
|
|
GstFFMpegAudDec *ffmpegdec = (GstFFMpegAudDec *) decoder;
|
2012-04-07 09:14:45 +00:00
|
|
|
GstFFMpegAudDecClass *oclass;
|
2005-11-28 11:25:56 +00:00
|
|
|
gboolean ret = TRUE;
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
|
2011-06-02 16:39:07 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "setcaps called");
|
2005-09-19 13:45:38 +00:00
|
|
|
|
2006-03-22 11:36:38 +00:00
|
|
|
GST_OBJECT_LOCK (ffmpegdec);
|
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
if (ffmpegdec->last_caps && gst_caps_is_equal (ffmpegdec->last_caps, caps)) {
|
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "same caps");
|
|
|
|
GST_OBJECT_UNLOCK (ffmpegdec);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_caps_replace (&ffmpegdec->last_caps, caps);
|
|
|
|
|
2003-06-07 00:41:32 +00:00
|
|
|
/* close old session */
|
2009-06-09 14:34:04 +00:00
|
|
|
if (ffmpegdec->opened) {
|
|
|
|
GST_OBJECT_UNLOCK (ffmpegdec);
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_drain (ffmpegdec);
|
2009-06-09 14:34:04 +00:00
|
|
|
GST_OBJECT_LOCK (ffmpegdec);
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_close (ffmpegdec);
|
2009-11-09 18:19:25 +00:00
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-07 20:45:13 +00:00
|
|
|
/* get size and so */
|
ext/ffmpeg/gstffmpegcodecmap.*: Change some function names to reflect that they don't really _return_ something, but ...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_get_palette),
(gst_ffmpeg_set_palette), (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_smpfmt),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_caps_with_codectype),
(gst_ffmpeg_caps_with_codecid), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Change some function names to reflect that they don't really
_return_ something, but rather _use_ something to fill a
AVCodecContext. s/to/with/. Restructure the extradata handling,
it's now not picking up the type from the caps but rather
using the type as provided in the function. This is a lot
cleaner. Implement MS RLE palette pickup.
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_pad_link):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_connect):
Sync with the above function name changes.
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_close),
(gst_ffmpegdec_open), (gst_ffmpegdec_connect),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state):
Add some hacks to convert palette-based raw image formats to
RGBA32. Ugly, but I don't know how else to handle palette-based
RGB, since img_convert() (and thus ffcolorspace) doesn't accept
a palette as argument.
2004-04-16 01:28:36 +00:00
|
|
|
gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
|
|
|
|
oclass->in_plugin->type, caps, ffmpegdec->context);
|
2005-09-19 13:45:38 +00:00
|
|
|
|
2004-09-20 12:29:03 +00:00
|
|
|
/* workaround encoder bugs */
|
|
|
|
ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
|
2012-12-04 17:28:11 +00:00
|
|
|
ffmpegdec->context->err_recognition = 1;
|
2007-04-12 10:56:42 +00:00
|
|
|
|
2012-11-20 10:39:45 +00:00
|
|
|
ffmpegdec->context->opaque = ffmpegdec;
|
|
|
|
ffmpegdec->context->get_buffer = gst_ffmpegauddec_get_buffer;
|
|
|
|
ffmpegdec->context->reget_buffer = NULL;
|
2012-12-04 21:09:05 +00:00
|
|
|
ffmpegdec->context->release_buffer = NULL;
|
2012-11-20 10:39:45 +00:00
|
|
|
|
2003-06-07 00:41:32 +00:00
|
|
|
/* open codec - we don't select an output pix_fmt yet,
|
|
|
|
* simply because we don't know! We only get it
|
|
|
|
* during playback... */
|
2012-04-07 09:14:45 +00:00
|
|
|
if (!gst_ffmpegauddec_open (ffmpegdec))
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
goto open_failed;
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
done:
|
|
|
|
GST_OBJECT_UNLOCK (ffmpegdec);
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
return ret;
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
/* ERRORS */
|
|
|
|
open_failed:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "Failed to open");
|
2005-11-28 11:25:56 +00:00
|
|
|
ret = FALSE;
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
goto done;
|
2004-12-16 12:47:43 +00:00
|
|
|
}
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
}
|
|
|
|
|
2004-12-16 12:47:43 +00:00
|
|
|
static gboolean
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_negotiate (GstFFMpegAudDec * ffmpegdec, gboolean force)
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
{
|
2012-04-07 09:14:45 +00:00
|
|
|
GstFFMpegAudDecClass *oclass;
|
|
|
|
gint depth;
|
2012-11-19 11:57:19 +00:00
|
|
|
GstAudioFormat format;
|
2012-06-14 10:41:34 +00:00
|
|
|
GstAudioChannelPosition pos[64] = { 0, };
|
2008-01-26 15:20:10 +00:00
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
ext/ffmpeg/gstffmpegdec.c: Reenable pad_alloc, seem to work now.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_close), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer), (get_output_buffer),
(gst_ffmpegdec_video_frame), (gst_ffmpegdec_audio_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_set_property), (gst_ffmpegdec_get_property):
Reenable pad_alloc, seem to work now.
Added property to easily disable it later on.
Remove some old code that tried hard to break the get_buffer
functions. Fixes #321662.
2008-01-22 16:32:23 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
depth = av_smp_format_depth (ffmpegdec->context->sample_fmt) * 8;
|
|
|
|
format = gst_ffmpeg_smpfmt_to_audioformat (ffmpegdec->context->sample_fmt);
|
|
|
|
if (format == GST_AUDIO_FORMAT_UNKNOWN)
|
|
|
|
goto no_caps;
|
2012-06-14 10:41:34 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
if (!force && ffmpegdec->info.rate ==
|
2012-04-07 09:14:45 +00:00
|
|
|
ffmpegdec->context->sample_rate &&
|
2012-11-19 11:57:19 +00:00
|
|
|
ffmpegdec->info.channels == ffmpegdec->context->channels &&
|
|
|
|
ffmpegdec->info.finfo->depth == depth)
|
2012-04-07 09:14:45 +00:00
|
|
|
return TRUE;
|
2010-02-04 12:26:16 +00:00
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec,
|
|
|
|
"Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)",
|
2012-11-19 11:57:19 +00:00
|
|
|
ffmpegdec->info.rate, ffmpegdec->info.channels,
|
|
|
|
ffmpegdec->info.finfo->depth,
|
2012-04-07 09:14:45 +00:00
|
|
|
ffmpegdec->context->sample_rate, ffmpegdec->context->channels, depth);
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
|
2012-12-11 17:25:41 +00:00
|
|
|
gst_ffmpeg_channel_layout_to_gst (ffmpegdec->context->channel_layout,
|
|
|
|
ffmpegdec->context->channels, pos);
|
2012-06-14 10:41:34 +00:00
|
|
|
memcpy (ffmpegdec->ffmpeg_layout, pos,
|
|
|
|
sizeof (GstAudioChannelPosition) * ffmpegdec->context->channels);
|
2011-04-04 11:18:13 +00:00
|
|
|
|
2012-06-14 10:41:34 +00:00
|
|
|
/* Get GStreamer channel layout */
|
2012-11-19 11:57:19 +00:00
|
|
|
gst_audio_channel_positions_to_valid_order (pos,
|
|
|
|
ffmpegdec->context->channels);
|
2012-11-20 10:39:45 +00:00
|
|
|
ffmpegdec->needs_reorder =
|
|
|
|
memcmp (pos, ffmpegdec->ffmpeg_layout,
|
|
|
|
sizeof (pos[0]) * ffmpegdec->context->channels) != 0;
|
2012-11-19 11:57:19 +00:00
|
|
|
gst_audio_info_set_format (&ffmpegdec->info, format,
|
|
|
|
ffmpegdec->context->sample_rate, ffmpegdec->context->channels, pos);
|
2011-07-29 11:40:30 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
if (!gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (ffmpegdec),
|
|
|
|
&ffmpegdec->info))
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
goto caps_failed;
|
2008-11-05 17:05:46 +00:00
|
|
|
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
return TRUE;
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
/* ERRORS */
|
|
|
|
no_caps:
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
{
|
2012-06-14 10:41:34 +00:00
|
|
|
#ifdef HAVE_LIBAV_UNINSTALLED
|
2011-01-31 23:28:33 +00:00
|
|
|
/* using internal ffmpeg snapshot */
|
|
|
|
GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
|
2012-06-14 10:41:34 +00:00
|
|
|
("Could not find GStreamer caps mapping for libav codec '%s'.",
|
2011-01-31 23:28:33 +00:00
|
|
|
oclass->in_plugin->name), (NULL));
|
|
|
|
#else
|
|
|
|
/* using external ffmpeg */
|
|
|
|
GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
|
2012-06-14 10:41:34 +00:00
|
|
|
("Could not find GStreamer caps mapping for libav codec '%s', and "
|
2011-01-31 23:28:33 +00:00
|
|
|
"you are using an external libavcodec. This is most likely due to "
|
|
|
|
"a packaging problem and/or libavcodec having been upgraded to a "
|
|
|
|
"version that is not compatible with this version of "
|
2012-06-14 10:41:34 +00:00
|
|
|
"gstreamer-libav. Make sure your gstreamer-libav and libavcodec "
|
2011-01-31 23:28:33 +00:00
|
|
|
"packages come from the same source/repository.",
|
|
|
|
oclass->in_plugin->name), (NULL));
|
|
|
|
#endif
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
return FALSE;
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
}
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
caps_failed:
|
2011-07-29 11:40:30 +00:00
|
|
|
{
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
|
2012-06-14 10:41:34 +00:00
|
|
|
("Could not set caps for libav decoder (%s), not fixed?",
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
oclass->in_plugin->name));
|
2004-12-16 12:47:43 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2011-07-29 11:40:30 +00:00
|
|
|
}
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
}
|
|
|
|
|
2011-06-29 14:22:48 +00:00
|
|
|
static void
|
|
|
|
gst_avpacket_init (AVPacket * packet, guint8 * data, guint size)
|
2011-04-21 10:52:04 +00:00
|
|
|
{
|
2011-06-29 14:22:48 +00:00
|
|
|
memset (packet, 0, sizeof (AVPacket));
|
|
|
|
packet->data = data;
|
|
|
|
packet->size = size;
|
2011-04-21 10:52:04 +00:00
|
|
|
}
|
|
|
|
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
static gint
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_audio_frame (GstFFMpegAudDec * ffmpegdec,
|
2009-03-04 20:58:08 +00:00
|
|
|
AVCodec * in_plugin, guint8 * data, guint size,
|
2012-11-19 11:57:19 +00:00
|
|
|
GstBuffer ** outbuf, GstFlowReturn * ret)
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
{
|
|
|
|
gint len = -1;
|
2007-12-17 12:43:06 +00:00
|
|
|
gint have_data = AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
2011-06-29 14:22:48 +00:00
|
|
|
AVPacket packet;
|
2012-11-20 10:39:45 +00:00
|
|
|
AVFrame frame;
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "size: %d", size);
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
|
2011-06-29 14:22:48 +00:00
|
|
|
gst_avpacket_init (&packet, data, size);
|
2012-11-20 10:39:45 +00:00
|
|
|
memset (&frame, 0, sizeof (frame));
|
2012-12-12 15:57:19 +00:00
|
|
|
avcodec_get_frame_defaults (&frame);
|
2012-11-20 10:39:45 +00:00
|
|
|
len = avcodec_decode_audio4 (ffmpegdec->context, &frame, &have_data, &packet);
|
2011-04-29 16:40:36 +00:00
|
|
|
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec,
|
|
|
|
"Decode audio: len=%d, have_data=%d", len, have_data);
|
|
|
|
|
|
|
|
if (len >= 0 && have_data > 0) {
|
2012-11-20 10:39:45 +00:00
|
|
|
BufferInfo *buffer_info = frame.opaque;
|
2013-01-26 12:50:49 +00:00
|
|
|
gint nsamples, channels, byte_per_sample;
|
|
|
|
gsize output_size;
|
2011-04-04 11:18:13 +00:00
|
|
|
|
2012-12-04 19:45:28 +00:00
|
|
|
if (!gst_ffmpegauddec_negotiate (ffmpegdec, FALSE)) {
|
|
|
|
*outbuf = NULL;
|
|
|
|
*ret = GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
len = -1;
|
|
|
|
goto beach;
|
|
|
|
}
|
|
|
|
|
2013-01-26 12:50:49 +00:00
|
|
|
channels = ffmpegdec->info.channels;
|
|
|
|
nsamples = frame.nb_samples;
|
|
|
|
byte_per_sample = ffmpegdec->info.finfo->width / 8;
|
|
|
|
|
|
|
|
/* frame.linesize[0] might contain padding, allocate only what's needed */
|
|
|
|
output_size = nsamples * byte_per_sample * channels;
|
|
|
|
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "Creating output buffer");
|
2012-11-20 10:39:45 +00:00
|
|
|
if (buffer_info) {
|
2012-12-04 21:09:05 +00:00
|
|
|
*outbuf = buffer_info->buffer;
|
|
|
|
gst_buffer_unmap (buffer_info->buffer, &buffer_info->map);
|
|
|
|
g_slice_free (BufferInfo, buffer_info);
|
|
|
|
frame.opaque = NULL;
|
2012-12-12 13:04:38 +00:00
|
|
|
} else if (av_sample_fmt_is_planar (ffmpegdec->context->sample_fmt)
|
2013-01-26 12:50:49 +00:00
|
|
|
&& channels > 1) {
|
2012-12-04 19:45:28 +00:00
|
|
|
gint i, j;
|
|
|
|
GstMapInfo minfo;
|
|
|
|
|
2013-01-25 19:40:15 +00:00
|
|
|
/* note: linesize[0] might contain padding, allocate only what's needed */
|
2012-12-04 19:45:28 +00:00
|
|
|
*outbuf =
|
|
|
|
gst_audio_decoder_allocate_output_buffer (GST_AUDIO_DECODER
|
2013-01-26 12:50:49 +00:00
|
|
|
(ffmpegdec), output_size);
|
2012-12-04 19:45:28 +00:00
|
|
|
|
|
|
|
gst_buffer_map (*outbuf, &minfo, GST_MAP_WRITE);
|
2012-12-12 13:04:38 +00:00
|
|
|
|
2012-12-04 19:45:28 +00:00
|
|
|
switch (ffmpegdec->info.finfo->width) {
|
|
|
|
case 8:{
|
|
|
|
guint8 *odata = minfo.data;
|
|
|
|
|
|
|
|
for (i = 0; i < nsamples; i++) {
|
|
|
|
for (j = 0; j < channels; j++) {
|
2012-12-12 13:04:38 +00:00
|
|
|
odata[j] = ((const guint8 *) frame.extended_data[j])[i];
|
2012-12-04 19:45:28 +00:00
|
|
|
}
|
|
|
|
odata += channels;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 16:{
|
|
|
|
guint16 *odata = (guint16 *) minfo.data;
|
|
|
|
|
|
|
|
for (i = 0; i < nsamples; i++) {
|
|
|
|
for (j = 0; j < channels; j++) {
|
2012-12-12 13:04:38 +00:00
|
|
|
odata[j] = ((const guint16 *) frame.extended_data[j])[i];
|
2012-12-04 19:45:28 +00:00
|
|
|
}
|
|
|
|
odata += channels;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 32:{
|
|
|
|
guint32 *odata = (guint32 *) minfo.data;
|
|
|
|
|
|
|
|
for (i = 0; i < nsamples; i++) {
|
|
|
|
for (j = 0; j < channels; j++) {
|
2012-12-12 13:04:38 +00:00
|
|
|
odata[j] = ((const guint32 *) frame.extended_data[j])[i];
|
2012-12-04 19:45:28 +00:00
|
|
|
}
|
|
|
|
odata += channels;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 64:{
|
|
|
|
guint64 *odata = (guint64 *) minfo.data;
|
|
|
|
|
|
|
|
for (i = 0; i < nsamples; i++) {
|
|
|
|
for (j = 0; j < channels; j++) {
|
2012-12-12 13:04:38 +00:00
|
|
|
odata[j] = ((const guint64 *) frame.extended_data[j])[i];
|
2012-12-04 19:45:28 +00:00
|
|
|
}
|
|
|
|
odata += channels;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_buffer_unmap (*outbuf, &minfo);
|
2012-11-20 10:39:45 +00:00
|
|
|
} else {
|
2012-12-04 19:45:28 +00:00
|
|
|
*outbuf =
|
|
|
|
gst_audio_decoder_allocate_output_buffer (GST_AUDIO_DECODER
|
2013-01-26 12:50:49 +00:00
|
|
|
(ffmpegdec), output_size);
|
|
|
|
gst_buffer_fill (*outbuf, 0, frame.data[0], output_size);
|
2012-11-20 10:39:45 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "Buffer created. Size: %d", have_data);
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
|
2012-01-10 09:45:42 +00:00
|
|
|
/* Reorder channels to the GStreamer channel order */
|
2012-11-20 10:39:45 +00:00
|
|
|
if (ffmpegdec->needs_reorder) {
|
|
|
|
*outbuf = gst_buffer_make_writable (*outbuf);
|
|
|
|
gst_audio_buffer_reorder_channels (*outbuf, ffmpegdec->info.finfo->format,
|
|
|
|
ffmpegdec->info.channels, ffmpegdec->ffmpeg_layout,
|
|
|
|
ffmpegdec->info.position);
|
|
|
|
}
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
} else {
|
|
|
|
*outbuf = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
beach:
|
2006-08-29 09:28:20 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
|
|
|
|
*ret, *outbuf, len);
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
/* gst_ffmpegauddec_frame:
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
* ffmpegdec:
|
|
|
|
* data: pointer to the data to decode
|
|
|
|
* size: size of data in bytes
|
|
|
|
* got_data: 0 if no data was decoded, != 0 otherwise.
|
2006-09-05 17:16:05 +00:00
|
|
|
* in_time: timestamp of data
|
|
|
|
* in_duration: duration of data
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
* ret: GstFlowReturn to return in the chain function
|
|
|
|
*
|
|
|
|
* Decode the given frame and pushes it downstream.
|
|
|
|
*
|
|
|
|
* Returns: Number of bytes used in decoding, -1 on error/failure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gint
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_frame (GstFFMpegAudDec * ffmpegdec,
|
2012-11-19 11:57:19 +00:00
|
|
|
guint8 * data, guint size, gint * got_data, GstFlowReturn * ret)
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
{
|
2012-04-07 09:14:45 +00:00
|
|
|
GstFFMpegAudDecClass *oclass;
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
GstBuffer *outbuf = NULL;
|
|
|
|
gint have_data = 0, len = 0;
|
|
|
|
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
if (G_UNLIKELY (ffmpegdec->context->codec == NULL))
|
|
|
|
goto no_codec;
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegdec, "data:%p, size:%d", data, size);
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
|
|
|
|
*ret = GST_FLOW_OK;
|
|
|
|
ffmpegdec->context->frame_number++;
|
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
2006-09-05 17:16:05 +00:00
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
len =
|
|
|
|
gst_ffmpegauddec_audio_frame (ffmpegdec, oclass->in_plugin, data, size,
|
2012-11-19 11:57:19 +00:00
|
|
|
&outbuf, ret);
|
2005-11-14 16:00:38 +00:00
|
|
|
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
if (outbuf)
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
have_data = 1;
|
|
|
|
|
2005-01-18 23:19:46 +00:00
|
|
|
if (len < 0 || have_data < 0) {
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
GST_WARNING_OBJECT (ffmpegdec,
|
2012-04-12 17:41:52 +00:00
|
|
|
"avdec_%s: decoding error (len: %d, have_data: %d)",
|
2005-01-18 23:19:46 +00:00
|
|
|
oclass->in_plugin->name, len, have_data);
|
|
|
|
*got_data = 0;
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
goto beach;
|
2005-01-18 23:19:46 +00:00
|
|
|
} else if (len == 0 && have_data == 0) {
|
|
|
|
*got_data = 0;
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
goto beach;
|
2005-01-18 23:19:46 +00:00
|
|
|
} else {
|
2005-01-19 16:08:17 +00:00
|
|
|
/* this is where I lost my last clue on ffmpeg... */
|
2007-01-09 14:53:36 +00:00
|
|
|
*got_data = 1;
|
2005-01-18 23:19:46 +00:00
|
|
|
}
|
2005-11-14 16:00:38 +00:00
|
|
|
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
if (outbuf) {
|
2012-12-03 19:38:53 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegdec, "Decoded data, now storing buffer %p", outbuf);
|
2012-11-19 11:57:19 +00:00
|
|
|
|
2012-12-17 14:58:37 +00:00
|
|
|
if (ffmpegdec->outbuf)
|
|
|
|
ffmpegdec->outbuf = gst_buffer_append (ffmpegdec->outbuf, outbuf);
|
|
|
|
else
|
|
|
|
ffmpegdec->outbuf = outbuf;
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "We didn't get a decoded buffer");
|
2005-01-18 23:19:46 +00:00
|
|
|
}
|
|
|
|
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
beach:
|
2005-01-18 23:19:46 +00:00
|
|
|
return len;
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_codec:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (ffmpegdec, "no codec context");
|
|
|
|
return -1;
|
|
|
|
}
|
2005-01-18 23:19:46 +00:00
|
|
|
}
|
|
|
|
|
2008-01-18 17:48:21 +00:00
|
|
|
static void
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec)
|
2008-01-18 17:48:21 +00:00
|
|
|
{
|
2012-04-07 09:14:45 +00:00
|
|
|
GstFFMpegAudDecClass *oclass;
|
2008-01-18 17:48:21 +00:00
|
|
|
|
2012-04-07 09:14:45 +00:00
|
|
|
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
2008-01-18 17:48:21 +00:00
|
|
|
|
|
|
|
if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {
|
|
|
|
gint have_data, len, try = 0;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (ffmpegdec,
|
2012-04-12 17:41:52 +00:00
|
|
|
"codec has delay capabilities, calling until libav has drained everything");
|
2008-01-18 17:48:21 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
GstFlowReturn ret;
|
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
len = gst_ffmpegauddec_frame (ffmpegdec, NULL, 0, &have_data, &ret);
|
2008-01-18 17:48:21 +00:00
|
|
|
if (len < 0 || have_data == 0)
|
|
|
|
break;
|
|
|
|
} while (try++ < 10);
|
|
|
|
}
|
2012-12-17 14:58:37 +00:00
|
|
|
|
|
|
|
if (ffmpegdec->outbuf)
|
|
|
|
gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec),
|
|
|
|
ffmpegdec->outbuf, 1);
|
|
|
|
ffmpegdec->outbuf = NULL;
|
2008-01-18 17:48:21 +00:00
|
|
|
}
|
|
|
|
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
static void
|
2012-11-19 11:57:19 +00:00
|
|
|
gst_ffmpegauddec_flush (GstAudioDecoder * decoder, gboolean hard)
|
2012-03-12 12:50:46 +00:00
|
|
|
{
|
2012-11-19 11:57:19 +00:00
|
|
|
GstFFMpegAudDec *ffmpegdec = (GstFFMpegAudDec *) decoder;
|
2012-03-12 12:50:46 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
if (ffmpegdec->opened) {
|
|
|
|
avcodec_flush_buffers (ffmpegdec->context);
|
2012-03-12 12:50:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
static GstFlowReturn
|
2012-11-19 11:57:19 +00:00
|
|
|
gst_ffmpegauddec_handle_frame (GstAudioDecoder * decoder, GstBuffer * inbuf)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
2012-04-07 09:14:45 +00:00
|
|
|
GstFFMpegAudDec *ffmpegdec;
|
|
|
|
GstFFMpegAudDecClass *oclass;
|
2011-04-04 14:37:42 +00:00
|
|
|
guint8 *data, *bdata;
|
2012-01-24 13:40:37 +00:00
|
|
|
GstMapInfo map;
|
2006-09-05 15:34:00 +00:00
|
|
|
gint size, bsize, len, have_data;
|
2005-08-16 09:50:03 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2003-06-17 11:44:38 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
ffmpegdec = (GstFFMpegAudDec *) decoder;
|
ext/ffmpeg/:
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_finalize),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_src_event), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer),
(gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
2006-04-08 10:51:32 +00:00
|
|
|
|
|
|
|
if (G_UNLIKELY (!ffmpegdec->opened))
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
goto not_negotiated;
|
2005-11-14 16:00:38 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
if (inbuf == NULL) {
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_drain (ffmpegdec);
|
2012-11-19 11:57:19 +00:00
|
|
|
return GST_FLOW_OK;
|
2010-10-06 10:30:57 +00:00
|
|
|
}
|
2010-02-19 19:33:06 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
inbuf = gst_buffer_ref (inbuf);
|
2006-09-05 15:34:00 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
2012-04-03 09:52:05 +00:00
|
|
|
|
2006-02-06 17:51:41 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegdec,
|
2012-12-21 10:03:27 +00:00
|
|
|
"Received new data of size %" G_GSIZE_FORMAT ", offset:%" G_GUINT64_FORMAT
|
|
|
|
", ts:%" GST_TIME_FORMAT ", dur:%" GST_TIME_FORMAT,
|
2012-06-14 10:41:34 +00:00
|
|
|
gst_buffer_get_size (inbuf), GST_BUFFER_OFFSET (inbuf),
|
2012-11-19 11:57:19 +00:00
|
|
|
GST_TIME_ARGS (GST_BUFFER_PTS (inbuf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (inbuf)));
|
2010-10-07 15:46:22 +00:00
|
|
|
|
2004-12-17 13:08:13 +00:00
|
|
|
/* workarounds, functions write to buffers:
|
|
|
|
* libavcodec/svq1.c:svq1_decode_frame writes to the given buffer.
|
|
|
|
* libavcodec/svq3.c:svq3_decode_slice_header too.
|
|
|
|
* ffmpeg devs know about it and will fix it (they said). */
|
2013-05-06 22:56:22 +00:00
|
|
|
if (oclass->in_plugin->id == AV_CODEC_ID_SVQ1 ||
|
|
|
|
oclass->in_plugin->id == AV_CODEC_ID_SVQ3) {
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
inbuf = gst_buffer_make_writable (inbuf);
|
2004-12-17 13:08:13 +00:00
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2012-01-24 13:40:37 +00:00
|
|
|
gst_buffer_map (inbuf, &map, GST_MAP_READ);
|
2011-04-04 10:23:05 +00:00
|
|
|
|
2012-01-24 13:40:37 +00:00
|
|
|
bdata = map.data;
|
|
|
|
bsize = map.size;
|
2011-04-04 10:23:05 +00:00
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
do {
|
2012-11-19 11:57:19 +00:00
|
|
|
data = bdata;
|
|
|
|
size = bsize;
|
2004-12-17 13:08:13 +00:00
|
|
|
|
2012-06-14 10:41:34 +00:00
|
|
|
/* decode a frame of audio now */
|
2012-11-19 11:57:19 +00:00
|
|
|
len = gst_ffmpegauddec_frame (ffmpegdec, data, size, &have_data, &ret);
|
2006-09-05 17:16:05 +00:00
|
|
|
|
2008-01-18 12:18:08 +00:00
|
|
|
if (ret != GST_FLOW_OK) {
|
2008-01-26 15:20:10 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s",
|
|
|
|
gst_flow_get_name (ret));
|
2012-03-19 09:29:34 +00:00
|
|
|
/* bad flow return, make sure we discard all data and exit */
|
2008-01-18 12:18:08 +00:00
|
|
|
bsize = 0;
|
|
|
|
break;
|
|
|
|
}
|
ext/ffmpeg/gstffmpegdec.c: Make some enums const.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_lowres_get_type),
(gst_ffmpegdec_skipframe_get_type), (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (clip_video_buffer), (check_keyframe),
(get_output_buffer), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Make some enums const.
Cleanups, refactoring.
Better video frame clipping.
Timestamp fixe: use timestamp from incomming buffer even if there
is no input framerate given (as this is totally unrelated).
2006-07-19 16:35:13 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
if (len == 0 && !have_data) {
|
|
|
|
/* nothing was decoded, this could be because no data was available or
|
|
|
|
* because we were skipping frames.
|
|
|
|
* If we have no context we must exit and wait for more data, we keep the
|
|
|
|
* data we tried. */
|
|
|
|
GST_LOG_OBJECT (ffmpegdec, "Decoding didn't return any data, breaking");
|
|
|
|
break;
|
|
|
|
} else if (len < 0) {
|
|
|
|
/* a decoding error happened, we must break and try again with next data. */
|
|
|
|
GST_LOG_OBJECT (ffmpegdec, "Decoding error, breaking");
|
|
|
|
bsize = 0;
|
|
|
|
break;
|
2008-09-04 14:08:50 +00:00
|
|
|
}
|
2012-11-19 11:57:19 +00:00
|
|
|
/* prepare for the next round, for codecs with a context we did this
|
|
|
|
* already when using the parser. */
|
|
|
|
bsize -= len;
|
|
|
|
bdata += len;
|
2008-01-18 12:18:08 +00:00
|
|
|
|
ext/ffmpeg/gstffmpegdec.c: Split out audio and video frame decoding.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init),
(gst_ffmpegdec_query), (gst_ffmpegdec_update_qos),
(gst_ffmpegdec_reset_qos), (gst_ffmpegdec_read_qos),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer),
(gst_ffmpegdec_add_pixel_aspect_ratio), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_do_qos), (gst_ffmpegdec_video_frame),
(gst_ffmpegdec_audio_frame), (gst_ffmpegdec_frame),
(gst_ffmpegdec_flush_pcache), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain):
Split out audio and video frame decoding.
Added dropping/clipping of decoded buffers.
Ran gst-indent on code.
Small non-invasive code cleanups.
2006-06-02 12:29:38 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0). bsize:%d , bdata:%p",
|
|
|
|
bsize, bdata);
|
2005-01-19 15:41:35 +00:00
|
|
|
} while (bsize > 0);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2012-01-24 13:40:37 +00:00
|
|
|
gst_buffer_unmap (inbuf, &map);
|
2012-11-19 11:57:19 +00:00
|
|
|
gst_buffer_unref (inbuf);
|
2011-04-04 10:23:05 +00:00
|
|
|
|
2012-12-17 14:58:37 +00:00
|
|
|
if (ffmpegdec->outbuf)
|
|
|
|
ret =
|
|
|
|
gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec),
|
|
|
|
ffmpegdec->outbuf, 1);
|
|
|
|
ffmpegdec->outbuf = NULL;
|
2012-12-03 19:38:53 +00:00
|
|
|
|
2012-11-19 11:57:19 +00:00
|
|
|
if (bsize > 0) {
|
2005-07-22 16:07:02 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize);
|
2004-12-17 13:08:13 +00:00
|
|
|
}
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
|
2005-08-16 09:50:03 +00:00
|
|
|
return ret;
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
not_negotiated:
|
|
|
|
{
|
2012-04-07 09:14:45 +00:00
|
|
|
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
|
2012-04-12 17:41:52 +00:00
|
|
|
("avdec_%s: input format was not set before data start",
|
Backport BRANCH-THREADED to HEAD, fix a bit.
Original commit message from CVS:
* configure.ac:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_with_codecid):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_class_init),
(gst_ffmpegdec_init), (gst_ffmpegdec_query), (gst_ffmpegdec_event),
(gst_ffmpegdec_open), (gst_ffmpegdec_setcaps),
(gst_ffmpegdec_get_buffer), (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_sink_event),
(gst_ffmpegdec_chain), (gst_ffmpegdec_change_state),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_class_init),
(gst_ffmpegenc_init), (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_setcaps), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/libpostproc/Makefile.am:
Backport BRANCH-THREADED to HEAD, fix a bit.
2005-08-05 15:29:56 +00:00
|
|
|
oclass->in_plugin->name));
|
|
|
|
return GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_register (GstPlugin * plugin)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
|
|
|
GTypeInfo typeinfo = {
|
2012-04-07 09:14:45 +00:00
|
|
|
sizeof (GstFFMpegAudDecClass),
|
|
|
|
(GBaseInitFunc) gst_ffmpegauddec_base_init,
|
2001-12-23 13:25:04 +00:00
|
|
|
NULL,
|
2012-04-07 09:14:45 +00:00
|
|
|
(GClassInitFunc) gst_ffmpegauddec_class_init,
|
2001-12-23 13:25:04 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2012-04-07 09:14:45 +00:00
|
|
|
sizeof (GstFFMpegAudDec),
|
2001-12-23 13:25:04 +00:00
|
|
|
0,
|
2012-04-07 09:14:45 +00:00
|
|
|
(GInstanceInitFunc) gst_ffmpegauddec_init,
|
2001-12-23 13:25:04 +00:00
|
|
|
};
|
|
|
|
GType type;
|
|
|
|
AVCodec *in_plugin;
|
2004-09-22 07:53:48 +00:00
|
|
|
gint rank;
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2008-10-30 12:05:45 +00:00
|
|
|
in_plugin = av_codec_next (NULL);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2007-12-17 12:43:06 +00:00
|
|
|
GST_LOG ("Registering decoders");
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
while (in_plugin) {
|
2003-11-02 13:12:14 +00:00
|
|
|
gchar *type_name;
|
2007-12-17 12:43:06 +00:00
|
|
|
gchar *plugin_name;
|
|
|
|
|
|
|
|
/* only decoders */
|
2012-12-05 09:52:34 +00:00
|
|
|
if (!av_codec_is_decoder (in_plugin)
|
|
|
|
|| in_plugin->type != AVMEDIA_TYPE_AUDIO) {
|
2007-12-17 12:43:06 +00:00
|
|
|
goto next;
|
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2003-06-17 11:44:38 +00:00
|
|
|
/* no quasi-codecs, please */
|
2013-05-06 22:56:22 +00:00
|
|
|
if (in_plugin->id >= AV_CODEC_ID_PCM_S16LE &&
|
|
|
|
in_plugin->id <= AV_CODEC_ID_PCM_BLURAY) {
|
2003-06-17 11:44:38 +00:00
|
|
|
goto next;
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
2003-06-17 11:44:38 +00:00
|
|
|
|
2009-03-10 20:11:43 +00:00
|
|
|
/* No decoders depending on external libraries (we don't build them, but
|
|
|
|
* people who build against an external ffmpeg might have them.
|
|
|
|
* We have native gstreamer plugins for all of those libraries anyway. */
|
|
|
|
if (!strncmp (in_plugin->name, "lib", 3)) {
|
|
|
|
GST_DEBUG
|
|
|
|
("Not using external library decoder %s. Use the gstreamer-native ones instead.",
|
|
|
|
in_plugin->name);
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
2008-10-15 11:28:05 +00:00
|
|
|
GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
|
2008-06-13 17:06:55 +00:00
|
|
|
|
2007-12-17 12:43:06 +00:00
|
|
|
/* no codecs for which we're GUARANTEED to have better alternatives */
|
2009-01-24 16:59:11 +00:00
|
|
|
/* MP1 : Use MP3 for decoding */
|
2007-12-17 12:43:06 +00:00
|
|
|
/* MP2 : Use MP3 for decoding */
|
2009-07-29 18:49:56 +00:00
|
|
|
/* Theora: Use libtheora based theoradec */
|
2012-04-07 09:14:45 +00:00
|
|
|
if (!strcmp (in_plugin->name, "vorbis") ||
|
2008-01-04 22:14:50 +00:00
|
|
|
!strcmp (in_plugin->name, "wavpack") ||
|
2009-01-24 16:59:11 +00:00
|
|
|
!strcmp (in_plugin->name, "mp1") ||
|
2008-05-26 07:43:00 +00:00
|
|
|
!strcmp (in_plugin->name, "mp2") ||
|
|
|
|
!strcmp (in_plugin->name, "libfaad") ||
|
2011-09-02 20:25:16 +00:00
|
|
|
!strcmp (in_plugin->name, "mpeg4aac") ||
|
|
|
|
!strcmp (in_plugin->name, "ass") ||
|
|
|
|
!strcmp (in_plugin->name, "srt") ||
|
|
|
|
!strcmp (in_plugin->name, "pgssub") ||
|
|
|
|
!strcmp (in_plugin->name, "dvdsub") ||
|
|
|
|
!strcmp (in_plugin->name, "dvbsub")) {
|
2007-12-17 12:43:06 +00:00
|
|
|
GST_LOG ("Ignoring decoder %s", in_plugin->name);
|
2001-12-23 13:25:04 +00:00
|
|
|
goto next;
|
|
|
|
}
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-03-19 04:09:41 +00:00
|
|
|
/* construct the type */
|
2007-12-17 12:43:06 +00:00
|
|
|
plugin_name = g_strdup ((gchar *) in_plugin->name);
|
|
|
|
g_strdelimit (plugin_name, NULL, '_');
|
2012-04-12 17:41:52 +00:00
|
|
|
type_name = g_strdup_printf ("avdec_%s", plugin_name);
|
2007-12-17 12:43:06 +00:00
|
|
|
g_free (plugin_name);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2009-06-05 11:19:03 +00:00
|
|
|
type = g_type_from_name (type_name);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2009-06-05 11:19:03 +00:00
|
|
|
if (!type) {
|
|
|
|
/* create the gtype now */
|
2012-11-19 11:57:19 +00:00
|
|
|
type =
|
|
|
|
g_type_register_static (GST_TYPE_AUDIO_DECODER, type_name, &typeinfo,
|
|
|
|
0);
|
2009-11-02 08:05:13 +00:00
|
|
|
g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) in_plugin);
|
2009-06-05 11:19:03 +00:00
|
|
|
}
|
2004-09-22 07:53:48 +00:00
|
|
|
|
|
|
|
/* (Ronald) MPEG-4 gets a higher priority because it has been well-
|
|
|
|
* tested and by far outperforms divxdec/xviddec - so we prefer it.
|
2004-12-19 23:41:03 +00:00
|
|
|
* msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
|
2005-04-21 19:01:36 +00:00
|
|
|
* VC1/WMV3 are not working and thus unpreferred for now. */
|
2004-09-22 07:53:48 +00:00
|
|
|
switch (in_plugin->id) {
|
2013-05-06 22:56:22 +00:00
|
|
|
case AV_CODEC_ID_RA_144:
|
|
|
|
case AV_CODEC_ID_RA_288:
|
|
|
|
case AV_CODEC_ID_COOK:
|
2004-09-22 07:53:48 +00:00
|
|
|
rank = GST_RANK_PRIMARY;
|
|
|
|
break;
|
2012-04-07 09:14:45 +00:00
|
|
|
/* SIPR: decoder should have a higher rank than realaudiodec.
|
2010-05-25 11:55:14 +00:00
|
|
|
*/
|
2013-05-06 22:56:22 +00:00
|
|
|
case AV_CODEC_ID_SIPR:
|
2006-04-21 15:48:17 +00:00
|
|
|
rank = GST_RANK_SECONDARY;
|
|
|
|
break;
|
2013-05-06 22:56:22 +00:00
|
|
|
case AV_CODEC_ID_MP3:
|
2011-01-07 17:08:15 +00:00
|
|
|
rank = GST_RANK_NONE;
|
|
|
|
break;
|
2007-08-14 14:29:36 +00:00
|
|
|
default:
|
|
|
|
rank = GST_RANK_MARGINAL;
|
|
|
|
break;
|
2004-09-22 07:53:48 +00:00
|
|
|
}
|
|
|
|
if (!gst_element_register (plugin, type_name, rank, type)) {
|
ext/: Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly some added codecs, some API changes, etc. Also add...
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.h:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_caps_to_pixfmt), (gst_ffmpeg_formatid_get_codecids),
(gst_ffmpeg_caps_to_codecid), (gst_ffmpeg_get_codecid_longname),
(gst_ffmpeg_img_convert):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_negotiate),
(gst_ffmpegdec_frame), (gst_ffmpegdec_chain),
(gst_ffmpegdec_register):
* ext/ffmpeg/gstffmpegdeinterlace.c:
(gst_ffmpegdeinterlace_getcaps), (gst_ffmpegdeinterlace_pad_link):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps),
(gst_ffmpegenc_link), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_chain_audio):
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_write):
* ext/ffmpeg/gstffmpegscale.c: (gst_ffmpegscale_pad_link):
* ext/libpostproc/gstpostproc.c: (gst_postproc_chain):
Update to ffmpeg snapshot of Jul 20 2005 4:00 PM GMT. Mostly
some added codecs, some API changes, etc. Also adds a VOB muxer
for MPEG-2 video and adds h264 to .mp4 muxing.
2005-07-20 15:40:57 +00:00
|
|
|
g_warning ("Failed to register %s", type_name);
|
2004-02-02 20:27:13 +00:00
|
|
|
g_free (type_name);
|
2003-11-02 13:12:14 +00:00
|
|
|
return FALSE;
|
2004-02-02 20:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (type_name);
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
next:
|
2008-10-30 12:05:45 +00:00
|
|
|
in_plugin = av_codec_next (in_plugin);
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
2007-12-17 12:43:06 +00:00
|
|
|
GST_LOG ("Finished Registering decoders");
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|