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>
|
2015-06-27 18:08:46 +00:00
|
|
|
#include <libavutil/channel_layout.h>
|
2002-11-06 23:53:46 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2019-09-10 15:30:07 +00:00
|
|
|
#include <gst/base/gstbytewriter.h>
|
2002-11-06 23:53:46 +00:00
|
|
|
|
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
|
|
|
|
2018-07-18 10:41:50 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (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);
|
2015-06-30 17:18:53 +00:00
|
|
|
static gboolean gst_ffmpegauddec_propose_allocation (GstAudioDecoder * decoder,
|
|
|
|
GstQuery * query);
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2013-08-29 14:53:28 +00:00
|
|
|
static gboolean gst_ffmpegauddec_start (GstAudioDecoder * decoder);
|
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,
|
2015-06-27 18:08:46 +00:00
|
|
|
AVCodecContext * context, AVFrame * frame, gboolean force);
|
2005-05-06 07:47:50 +00:00
|
|
|
|
2020-12-29 16:15:16 +00:00
|
|
|
static GstFlowReturn gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec,
|
|
|
|
gboolean force);
|
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);
|
|
|
|
|
2017-01-02 03:36:09 +00:00
|
|
|
gst_caps_unref (sinkcaps);
|
|
|
|
gst_caps_unref (srccaps);
|
|
|
|
|
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
|
|
|
|
2013-08-29 14:53:28 +00:00
|
|
|
gstaudiodecoder_class->start = GST_DEBUG_FUNCPTR (gst_ffmpegauddec_start);
|
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);
|
2015-06-30 17:18:53 +00:00
|
|
|
gstaudiodecoder_class->propose_allocation =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_ffmpegauddec_propose_allocation);
|
2018-07-18 10:41:50 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
|
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);
|
2013-08-29 14:53:28 +00:00
|
|
|
ffmpegdec->context->opaque = ffmpegdec;
|
2003-06-07 00:41:32 +00:00
|
|
|
ffmpegdec->opened = FALSE;
|
2009-05-13 10:37:42 +00:00
|
|
|
|
2015-06-27 18:25:36 +00:00
|
|
|
ffmpegdec->frame = av_frame_alloc ();
|
|
|
|
|
2018-07-03 22:18:44 +00:00
|
|
|
GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_DECODER_SINK_PAD (ffmpegdec));
|
2015-08-15 10:30:26 +00:00
|
|
|
gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST
|
|
|
|
(ffmpegdec), TRUE);
|
2015-08-14 11:21:51 +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
|
|
|
|
2015-06-27 18:25:36 +00:00
|
|
|
av_frame_free (&ffmpegdec->frame);
|
2022-01-16 17:33:47 +00:00
|
|
|
avcodec_free_context (&ffmpegdec->context);
|
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 */
|
2013-08-29 14:53:28 +00:00
|
|
|
static gboolean
|
|
|
|
gst_ffmpegauddec_close (GstFFMpegAudDec * ffmpegdec, gboolean reset)
|
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
|
|
|
{
|
2013-08-29 14:53:28 +00:00
|
|
|
GstFFMpegAudDecClass *oclass;
|
|
|
|
|
|
|
|
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
|
|
|
|
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 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;
|
|
|
|
|
2022-01-16 17:33:47 +00:00
|
|
|
av_freep (&ffmpegdec->context->extradata);
|
2013-08-29 14:53:28 +00:00
|
|
|
|
|
|
|
if (reset) {
|
2022-01-16 17:33:47 +00:00
|
|
|
avcodec_free_context (&ffmpegdec->context);
|
|
|
|
ffmpegdec->context = avcodec_alloc_context3 (oclass->in_plugin);
|
|
|
|
if (ffmpegdec->context == NULL) {
|
2013-08-29 14:53:28 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "Failed to set context defaults");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ffmpegdec->context->opaque = ffmpegdec;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_ffmpegauddec_start (GstAudioDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstFFMpegAudDec *ffmpegdec = (GstFFMpegAudDec *) decoder;
|
|
|
|
GstFFMpegAudDecClass *oclass;
|
|
|
|
|
|
|
|
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (ffmpegdec);
|
2022-01-16 17:33:47 +00:00
|
|
|
avcodec_free_context (&ffmpegdec->context);
|
|
|
|
ffmpegdec->context = avcodec_alloc_context3 (oclass->in_plugin);
|
|
|
|
if (ffmpegdec->context == NULL) {
|
2013-08-29 14:53:28 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "Failed to set context defaults");
|
|
|
|
GST_OBJECT_UNLOCK (ffmpegdec);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ffmpegdec->context->opaque = ffmpegdec;
|
2022-10-04 19:27:36 +00:00
|
|
|
|
|
|
|
/* FIXME: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1474 */
|
|
|
|
if ((oclass->in_plugin->capabilities & AV_CODEC_CAP_DELAY) != 0
|
|
|
|
&& (oclass->in_plugin->id == AV_CODEC_ID_WMAV1
|
|
|
|
|| oclass->in_plugin->id == AV_CODEC_ID_WMAV2)) {
|
|
|
|
ffmpegdec->context->flags2 |= AV_CODEC_FLAG2_SKIP_MANUAL;
|
|
|
|
}
|
|
|
|
|
2013-08-29 14:53:28 +00:00
|
|
|
GST_OBJECT_UNLOCK (ffmpegdec);
|
|
|
|
|
|
|
|
return TRUE;
|
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);
|
2013-08-29 14:53:28 +00:00
|
|
|
gst_ffmpegauddec_close (ffmpegdec, FALSE);
|
2015-06-30 17:18:53 +00:00
|
|
|
g_free (ffmpegdec->padded);
|
|
|
|
ffmpegdec->padded = NULL;
|
|
|
|
ffmpegdec->padded_size = 0;
|
2012-11-19 11:57:19 +00:00
|
|
|
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:
|
|
|
|
{
|
2013-08-29 14:53:28 +00:00
|
|
|
gst_ffmpegauddec_close (ffmpegdec, TRUE);
|
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
|
|
|
}
|
|
|
|
|
2015-06-30 17:18:53 +00:00
|
|
|
static gboolean
|
|
|
|
gst_ffmpegauddec_propose_allocation (GstAudioDecoder * decoder,
|
|
|
|
GstQuery * query)
|
|
|
|
{
|
|
|
|
GstAllocationParams params;
|
|
|
|
|
|
|
|
gst_allocation_params_init (¶ms);
|
|
|
|
params.flags = GST_MEMORY_FLAG_ZERO_PADDED;
|
|
|
|
params.align = 15;
|
2018-04-30 19:41:40 +00:00
|
|
|
params.padding = AV_INPUT_BUFFER_PADDING_SIZE;
|
2015-06-30 17:18:53 +00:00
|
|
|
/* we would like to have some padding so that we don't have to
|
|
|
|
* memcpy. We don't suggest an allocator. */
|
|
|
|
gst_query_add_allocation_param (query, NULL, ¶ms);
|
|
|
|
|
|
|
|
return GST_AUDIO_DECODER_CLASS (parent_class)->propose_allocation (decoder,
|
|
|
|
query);
|
|
|
|
}
|
|
|
|
|
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);
|
2020-12-29 16:15:16 +00:00
|
|
|
gst_ffmpegauddec_drain (ffmpegdec, FALSE);
|
2009-06-09 14:34:04 +00:00
|
|
|
GST_OBJECT_LOCK (ffmpegdec);
|
2013-08-29 14:53:28 +00:00
|
|
|
if (!gst_ffmpegauddec_close (ffmpegdec, TRUE)) {
|
|
|
|
GST_OBJECT_UNLOCK (ffmpegdec);
|
|
|
|
return FALSE;
|
|
|
|
}
|
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
|
|
|
|
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
|
2015-06-27 18:08:46 +00:00
|
|
|
settings_changed (GstFFMpegAudDec * ffmpegdec, AVFrame * frame)
|
|
|
|
{
|
|
|
|
GstAudioFormat format;
|
2018-07-23 13:16:10 +00:00
|
|
|
GstAudioLayout layout;
|
2018-06-29 19:46:00 +00:00
|
|
|
gint channels = av_get_channel_layout_nb_channels (frame->channel_layout);
|
2015-06-27 18:08:46 +00:00
|
|
|
|
2022-09-29 11:42:21 +00:00
|
|
|
if (channels == 0)
|
|
|
|
channels = frame->channels;
|
|
|
|
|
2018-07-23 13:16:10 +00:00
|
|
|
format = gst_ffmpeg_smpfmt_to_audioformat (frame->format, &layout);
|
2015-06-27 18:08:46 +00:00
|
|
|
if (format == GST_AUDIO_FORMAT_UNKNOWN)
|
|
|
|
return TRUE;
|
|
|
|
|
2018-07-23 13:16:10 +00:00
|
|
|
return !(ffmpegdec->info.rate == frame->sample_rate &&
|
2015-06-27 18:08:46 +00:00
|
|
|
ffmpegdec->info.channels == channels &&
|
2018-07-23 13:16:10 +00:00
|
|
|
ffmpegdec->info.finfo->format == format &&
|
|
|
|
ffmpegdec->info.layout == layout);
|
2015-06-27 18:08:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_ffmpegauddec_negotiate (GstFFMpegAudDec * ffmpegdec,
|
|
|
|
AVCodecContext * context, AVFrame * frame, 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;
|
2012-11-19 11:57:19 +00:00
|
|
|
GstAudioFormat format;
|
2018-07-23 13:16:10 +00:00
|
|
|
GstAudioLayout layout;
|
2015-06-27 18:08:46 +00:00
|
|
|
gint channels;
|
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
|
|
|
|
2018-07-23 13:16:10 +00:00
|
|
|
format = gst_ffmpeg_smpfmt_to_audioformat (frame->format, &layout);
|
2012-11-19 11:57:19 +00:00
|
|
|
if (format == GST_AUDIO_FORMAT_UNKNOWN)
|
|
|
|
goto no_caps;
|
2018-06-29 19:46:00 +00:00
|
|
|
channels = av_get_channel_layout_nb_channels (frame->channel_layout);
|
2015-07-25 06:54:20 +00:00
|
|
|
if (channels == 0)
|
2018-06-29 19:46:00 +00:00
|
|
|
channels = frame->channels;
|
2015-06-27 18:08:46 +00:00
|
|
|
if (channels == 0)
|
|
|
|
goto no_caps;
|
2012-06-14 10:41:34 +00:00
|
|
|
|
2015-06-27 18:08:46 +00:00
|
|
|
if (!force && !settings_changed (ffmpegdec, frame))
|
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,
|
2018-07-23 13:16:10 +00:00
|
|
|
"Renegotiating audio from %dHz@%dchannels (%d, interleaved=%d) "
|
|
|
|
"to %dHz@%dchannels (%d, interleaved=%d)",
|
2012-11-19 11:57:19 +00:00
|
|
|
ffmpegdec->info.rate, ffmpegdec->info.channels,
|
2018-07-23 13:16:10 +00:00
|
|
|
ffmpegdec->info.finfo->format,
|
|
|
|
ffmpegdec->info.layout == GST_AUDIO_LAYOUT_INTERLEAVED,
|
|
|
|
frame->sample_rate, channels, format,
|
|
|
|
layout == GST_AUDIO_LAYOUT_INTERLEAVED);
|
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
|
|
|
|
2018-06-29 19:46:00 +00:00
|
|
|
gst_ffmpeg_channel_layout_to_gst (frame->channel_layout, channels, pos);
|
2012-06-14 10:41:34 +00:00
|
|
|
memcpy (ffmpegdec->ffmpeg_layout, pos,
|
2015-06-27 18:08:46 +00:00
|
|
|
sizeof (GstAudioChannelPosition) * channels);
|
2011-04-04 11:18:13 +00:00
|
|
|
|
2012-06-14 10:41:34 +00:00
|
|
|
/* Get GStreamer channel layout */
|
2015-06-27 18:08:46 +00:00
|
|
|
gst_audio_channel_positions_to_valid_order (pos, channels);
|
2012-11-20 10:39:45 +00:00
|
|
|
ffmpegdec->needs_reorder =
|
2015-06-27 18:08:46 +00:00
|
|
|
memcmp (pos, ffmpegdec->ffmpeg_layout, sizeof (pos[0]) * channels) != 0;
|
2012-11-19 11:57:19 +00:00
|
|
|
gst_audio_info_set_format (&ffmpegdec->info, format,
|
2018-06-29 19:46:00 +00:00
|
|
|
frame->sample_rate, channels, pos);
|
2018-07-23 13:16:10 +00:00
|
|
|
ffmpegdec->info.layout = layout;
|
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));
|
2013-10-02 10:45:44 +00:00
|
|
|
memset (&ffmpegdec->info, 0, sizeof (ffmpegdec->info));
|
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
|
|
|
}
|
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
/*
|
|
|
|
* Returns: whether a frame was decoded
|
|
|
|
*/
|
|
|
|
static gboolean
|
2012-04-07 09:14:45 +00:00
|
|
|
gst_ffmpegauddec_audio_frame (GstFFMpegAudDec * ffmpegdec,
|
2019-09-10 15:30:07 +00:00
|
|
|
AVCodec * in_plugin, GstBuffer ** outbuf, GstFlowReturn * ret,
|
|
|
|
gboolean * need_more_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
|
|
|
{
|
2018-07-01 00:21:46 +00:00
|
|
|
gboolean got_frame = FALSE;
|
|
|
|
gint res;
|
2011-04-29 16:40:36 +00:00
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
res = avcodec_receive_frame (ffmpegdec->context, ffmpegdec->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
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
if (res >= 0) {
|
2013-01-26 12:50:49 +00:00
|
|
|
gint nsamples, channels, byte_per_sample;
|
|
|
|
gsize output_size;
|
2018-07-23 13:16:10 +00:00
|
|
|
gboolean planar;
|
2011-04-04 11:18:13 +00:00
|
|
|
|
2015-06-27 18:25:36 +00:00
|
|
|
if (!gst_ffmpegauddec_negotiate (ffmpegdec, ffmpegdec->context,
|
|
|
|
ffmpegdec->frame, FALSE)) {
|
2012-12-04 19:45:28 +00:00
|
|
|
*outbuf = NULL;
|
|
|
|
*ret = GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
goto beach;
|
|
|
|
}
|
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
got_frame = TRUE;
|
|
|
|
|
2013-01-26 12:50:49 +00:00
|
|
|
channels = ffmpegdec->info.channels;
|
2015-06-27 18:25:36 +00:00
|
|
|
nsamples = ffmpegdec->frame->nb_samples;
|
2013-01-26 12:50:49 +00:00
|
|
|
byte_per_sample = ffmpegdec->info.finfo->width / 8;
|
2020-10-27 10:33:29 +00:00
|
|
|
planar = av_sample_fmt_is_planar (ffmpegdec->frame->format);
|
2018-07-23 13:16:10 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (ffmpegdec->info.layout == (planar ?
|
|
|
|
GST_AUDIO_LAYOUT_NON_INTERLEAVED : GST_AUDIO_LAYOUT_INTERLEAVED),
|
|
|
|
GST_FLOW_NOT_NEGOTIATED);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "Creating output buffer");
|
2013-01-26 12:50:49 +00:00
|
|
|
|
2015-06-27 18:25:36 +00:00
|
|
|
/* ffmpegdec->frame->linesize[0] might contain padding, allocate only what's needed */
|
2013-01-26 12:50:49 +00:00
|
|
|
output_size = nsamples * byte_per_sample * channels;
|
|
|
|
|
2018-07-23 13:16:10 +00:00
|
|
|
*outbuf =
|
|
|
|
gst_audio_decoder_allocate_output_buffer (GST_AUDIO_DECODER
|
|
|
|
(ffmpegdec), output_size);
|
|
|
|
|
|
|
|
if (planar) {
|
|
|
|
gint i;
|
|
|
|
GstAudioMeta *meta;
|
|
|
|
|
|
|
|
meta = gst_buffer_add_audio_meta (*outbuf, &ffmpegdec->info, nsamples,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
for (i = 0; i < channels; i++) {
|
|
|
|
gst_buffer_fill (*outbuf, meta->offsets[i],
|
|
|
|
ffmpegdec->frame->extended_data[i], nsamples * byte_per_sample);
|
2012-12-04 19:45:28 +00:00
|
|
|
}
|
2012-11-20 10:39:45 +00:00
|
|
|
} else {
|
2015-06-27 18:25:36 +00:00
|
|
|
gst_buffer_fill (*outbuf, 0, ffmpegdec->frame->data[0], output_size);
|
2012-11-20 10:39:45 +00:00
|
|
|
}
|
|
|
|
|
2014-01-03 15:26:10 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "Buffer created. Size: %" G_GSIZE_FORMAT,
|
|
|
|
output_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
|
|
|
|
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);
|
|
|
|
}
|
2014-01-16 12:45:58 +00:00
|
|
|
|
|
|
|
/* Mark corrupted frames as corrupted */
|
2015-06-27 18:25:36 +00:00
|
|
|
if (ffmpegdec->frame->flags & AV_FRAME_FLAG_CORRUPT)
|
2014-01-16 12:45:58 +00:00
|
|
|
GST_BUFFER_FLAG_SET (*outbuf, GST_BUFFER_FLAG_CORRUPTED);
|
2018-07-01 00:21:46 +00:00
|
|
|
} else if (res == AVERROR (EAGAIN)) {
|
2022-03-08 14:05:17 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "Need more 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
|
|
|
*outbuf = NULL;
|
2019-09-10 15:30:07 +00:00
|
|
|
*need_more_data = TRUE;
|
2018-07-31 16:35:22 +00:00
|
|
|
} else if (res == AVERROR_EOF) {
|
2018-07-01 00:21:46 +00:00
|
|
|
*ret = GST_FLOW_EOS;
|
2018-07-31 16:35:22 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "Context was entirely flushed");
|
2018-07-01 00:21:46 +00:00
|
|
|
} else if (res < 0) {
|
2022-03-08 14:05:17 +00:00
|
|
|
GST_AUDIO_DECODER_ERROR (ffmpegdec, 1, STREAM, DECODE, (NULL),
|
|
|
|
("Audio decoding error"), *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
|
|
|
}
|
|
|
|
|
|
|
|
beach:
|
2015-06-27 18:25:36 +00:00
|
|
|
av_frame_unref (ffmpegdec->frame);
|
2023-01-09 12:23:56 +00:00
|
|
|
GST_DEBUG_OBJECT (ffmpegdec, "return flow %s, out %p, got_frame %d",
|
|
|
|
gst_flow_get_name (*ret), *outbuf, got_frame);
|
2018-07-01 00:21:46 +00:00
|
|
|
return got_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
|
|
|
}
|
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
/*
|
|
|
|
* Returns: whether a frame was decoded
|
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
|
|
|
*/
|
2018-07-01 00:21:46 +00:00
|
|
|
static gboolean
|
2019-09-10 15:30:07 +00:00
|
|
|
gst_ffmpegauddec_frame (GstFFMpegAudDec * ffmpegdec, GstFlowReturn * ret,
|
|
|
|
gboolean * need_more_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-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;
|
2018-07-01 00:21:46 +00:00
|
|
|
gboolean got_frame = FALSE;
|
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
|
|
|
|
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
|
|
|
|
|
|
|
*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
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
got_frame =
|
2019-09-10 15:30:07 +00:00
|
|
|
gst_ffmpegauddec_audio_frame (ffmpegdec, oclass->in_plugin, &outbuf, ret,
|
|
|
|
need_more_data);
|
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) {
|
2019-02-26 00:00:33 +00:00
|
|
|
GST_LOG_OBJECT (ffmpegdec, "Decoded data, buffer %" GST_PTR_FORMAT, outbuf);
|
|
|
|
*ret =
|
|
|
|
gst_audio_decoder_finish_subframe (GST_AUDIO_DECODER_CAST (ffmpegdec),
|
|
|
|
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:
|
2018-07-01 00:21:46 +00:00
|
|
|
return got_frame;
|
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");
|
2018-07-01 00:21:46 +00:00
|
|
|
goto beach;
|
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
|
|
|
}
|
2005-01-18 23:19:46 +00:00
|
|
|
}
|
|
|
|
|
2020-09-14 11:30:35 +00:00
|
|
|
static GstFlowReturn
|
2020-12-29 16:15:16 +00:00
|
|
|
gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec, gboolean force)
|
2008-01-18 17:48:21 +00:00
|
|
|
{
|
2020-09-14 11:30:35 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2019-02-26 00:00:33 +00:00
|
|
|
gboolean got_any_frames = FALSE;
|
2019-09-10 15:30:07 +00:00
|
|
|
gboolean need_more_data = FALSE;
|
2019-04-29 06:22:52 +00:00
|
|
|
gboolean got_frame;
|
2008-01-18 17:48:21 +00:00
|
|
|
|
2019-04-29 06:22:52 +00:00
|
|
|
if (avcodec_send_packet (ffmpegdec->context, NULL))
|
|
|
|
goto send_packet_failed;
|
2008-01-18 17:48:21 +00:00
|
|
|
|
2022-10-04 19:27:36 +00:00
|
|
|
/* FIXME: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1474 */
|
|
|
|
if (!(ffmpegdec->context->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
|
|
|
|
do {
|
|
|
|
got_frame = gst_ffmpegauddec_frame (ffmpegdec, &ret, &need_more_data);
|
|
|
|
if (got_frame)
|
|
|
|
got_any_frames = TRUE;
|
|
|
|
} while (got_frame && !need_more_data);
|
|
|
|
}
|
2019-04-29 06:22:52 +00:00
|
|
|
avcodec_flush_buffers (ffmpegdec->context);
|
2012-12-17 14:58:37 +00:00
|
|
|
|
2020-09-30 13:13:28 +00:00
|
|
|
/* FFMpeg will return AVERROR_EOF if it's internal was fully drained
|
|
|
|
* then we are translating it to GST_FLOW_EOS. However, because this behavior
|
|
|
|
* is fully internal stuff of this implementation and gstaudiodecoder
|
|
|
|
* baseclass doesn't convert this GST_FLOW_EOS to GST_FLOW_OK,
|
|
|
|
* convert this flow returned here */
|
|
|
|
if (ret == GST_FLOW_EOS)
|
|
|
|
ret = GST_FLOW_OK;
|
|
|
|
|
2020-12-29 16:15:16 +00:00
|
|
|
if (got_any_frames || force) {
|
2020-09-14 17:12:23 +00:00
|
|
|
GstFlowReturn new_ret =
|
2020-09-14 11:30:35 +00:00
|
|
|
gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), NULL, 1);
|
2018-07-31 16:35:22 +00:00
|
|
|
|
2020-09-14 17:12:23 +00:00
|
|
|
if (ret == GST_FLOW_OK)
|
|
|
|
ret = new_ret;
|
|
|
|
}
|
|
|
|
|
2020-09-14 11:30:35 +00:00
|
|
|
done:
|
|
|
|
return ret;
|
2019-08-01 20:27:35 +00:00
|
|
|
|
2018-07-31 16:35:22 +00:00
|
|
|
send_packet_failed:
|
|
|
|
GST_WARNING_OBJECT (ffmpegdec, "send packet failed, could not drain decoder");
|
2020-09-14 11:30:35 +00:00
|
|
|
goto done;
|
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;
|
2018-07-01 00:21:46 +00:00
|
|
|
guint8 *data;
|
2012-01-24 13:40:37 +00:00
|
|
|
GstMapInfo map;
|
2018-07-01 00:21:46 +00:00
|
|
|
gint size;
|
2019-02-26 00:00:33 +00:00
|
|
|
gboolean got_any_frames = FALSE;
|
2018-07-01 00:21:46 +00:00
|
|
|
gboolean got_frame;
|
2005-08-16 09:50:03 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2018-07-01 00:21:46 +00:00
|
|
|
gboolean is_header;
|
|
|
|
AVPacket packet;
|
2019-09-10 15:30:07 +00:00
|
|
|
GstAudioClippingMeta *clipping_meta = NULL;
|
|
|
|
guint32 num_clipped_samples = 0;
|
|
|
|
gboolean fully_clipped = FALSE;
|
|
|
|
gboolean need_more_data = FALSE;
|
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) {
|
2020-12-29 16:15:16 +00:00
|
|
|
return gst_ffmpegauddec_drain (ffmpegdec, FALSE);
|
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);
|
2016-04-29 10:06:07 +00:00
|
|
|
is_header = GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_HEADER);
|
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
|
|
|
|
2019-09-10 15:30:07 +00:00
|
|
|
/* mpegaudioparse is setting buffer flags for the Xing/LAME header. This
|
|
|
|
* should not be passed to the decoder as it results in unnecessary silence
|
|
|
|
* samples to be output */
|
|
|
|
if (oclass->in_plugin->id == AV_CODEC_ID_MP3 &&
|
|
|
|
GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_DECODE_ONLY) &&
|
|
|
|
GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_DROPPABLE)) {
|
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
return gst_audio_decoder_finish_frame (decoder, NULL, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
clipping_meta = gst_buffer_get_audio_clipping_meta (inbuf);
|
|
|
|
|
2012-01-24 13:40:37 +00:00
|
|
|
gst_buffer_map (inbuf, &map, GST_MAP_READ);
|
2011-04-04 10:23:05 +00:00
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
data = map.data;
|
|
|
|
size = map.size;
|
2011-04-04 10:23:05 +00:00
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
if (size > 0 && (!GST_MEMORY_IS_ZERO_PADDED (map.memory)
|
2018-04-30 19:41:40 +00:00
|
|
|
|| (map.maxsize - map.size) < AV_INPUT_BUFFER_PADDING_SIZE)) {
|
2015-06-30 17:18:53 +00:00
|
|
|
/* add padding */
|
2018-07-01 00:21:46 +00:00
|
|
|
if (ffmpegdec->padded_size < size + AV_INPUT_BUFFER_PADDING_SIZE) {
|
|
|
|
ffmpegdec->padded_size = size + AV_INPUT_BUFFER_PADDING_SIZE;
|
2015-06-30 17:18:53 +00:00
|
|
|
ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size);
|
|
|
|
GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d",
|
|
|
|
ffmpegdec->padded_size);
|
|
|
|
}
|
2018-07-18 10:41:50 +00:00
|
|
|
GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, ffmpegdec,
|
2015-06-30 17:18:53 +00:00
|
|
|
"Copy input to add padding");
|
2018-07-01 00:21:46 +00:00
|
|
|
memcpy (ffmpegdec->padded, data, size);
|
|
|
|
memset (ffmpegdec->padded + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
2015-06-30 17:18:53 +00:00
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
data = ffmpegdec->padded;
|
2015-06-30 17:18:53 +00:00
|
|
|
}
|
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
gst_avpacket_init (&packet, data, size);
|
2015-06-30 17:18:53 +00:00
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
if (!packet.size)
|
2020-06-30 16:33:56 +00:00
|
|
|
goto unmap;
|
2004-12-17 13:08:13 +00:00
|
|
|
|
2019-09-10 15:30:07 +00:00
|
|
|
if (clipping_meta != NULL) {
|
|
|
|
if (clipping_meta->format == GST_FORMAT_DEFAULT) {
|
|
|
|
uint8_t *p = av_packet_new_side_data (&packet, AV_PKT_DATA_SKIP_SAMPLES,
|
|
|
|
10);
|
|
|
|
if (p != NULL) {
|
|
|
|
GstByteWriter writer;
|
|
|
|
guint32 start = clipping_meta->start;
|
|
|
|
guint32 end = clipping_meta->end;
|
|
|
|
|
|
|
|
num_clipped_samples = start + end;
|
|
|
|
|
|
|
|
gst_byte_writer_init_with_data (&writer, p, 10, FALSE);
|
|
|
|
gst_byte_writer_put_uint32_le (&writer, start);
|
|
|
|
gst_byte_writer_put_uint32_le (&writer, end);
|
|
|
|
GST_LOG_OBJECT (ffmpegdec, "buffer has clipping metadata; added skip "
|
|
|
|
"side data to avpacket with start %u and end %u", start, end);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
GST_WARNING_OBJECT (ffmpegdec,
|
|
|
|
"buffer has clipping metadata in unsupported format %s",
|
|
|
|
gst_format_get_name (clipping_meta->format));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
if (avcodec_send_packet (ffmpegdec->context, &packet) < 0) {
|
2023-02-28 12:00:26 +00:00
|
|
|
av_packet_free_side_data (&packet);
|
2018-07-01 00:21:46 +00:00
|
|
|
goto send_packet_failed;
|
|
|
|
}
|
2023-02-28 12:00:26 +00:00
|
|
|
av_packet_free_side_data (&packet);
|
2015-06-30 17:18:53 +00:00
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
do {
|
2012-06-14 10:41:34 +00:00
|
|
|
/* decode a frame of audio now */
|
2019-09-10 15:30:07 +00:00
|
|
|
got_frame = gst_ffmpegauddec_frame (ffmpegdec, &ret, &need_more_data);
|
2015-06-30 17:18:53 +00:00
|
|
|
|
2019-02-26 00:00:33 +00:00
|
|
|
if (got_frame)
|
|
|
|
got_any_frames = TRUE;
|
|
|
|
|
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 */
|
2012-11-19 11:57:19 +00:00
|
|
|
break;
|
2008-09-04 14:08:50 +00:00
|
|
|
}
|
2019-09-10 15:30:07 +00:00
|
|
|
} while (got_frame && !need_more_data);
|
|
|
|
|
|
|
|
/* The frame was fully clipped if we have samples to be clipped and
|
|
|
|
* it's either more than the known fixed frame size, or the decoder returned
|
|
|
|
* that it needs more data (EAGAIN) and we didn't decode any frames at all.
|
|
|
|
*/
|
|
|
|
fully_clipped = (clipping_meta != NULL && num_clipped_samples > 0)
|
|
|
|
&& ((ffmpegdec->context->frame_size != 0
|
|
|
|
&& num_clipped_samples >= ffmpegdec->context->frame_size)
|
|
|
|
|| (need_more_data && !got_any_frames));
|
|
|
|
|
|
|
|
if (is_header || got_any_frames || fully_clipped) {
|
2020-09-14 17:12:23 +00:00
|
|
|
/* Even if previous return wasn't GST_FLOW_OK, we need to call
|
|
|
|
* _finish_frame() since baseclass is expecting that _finish_frame()
|
|
|
|
* is followed by _finish_subframe()
|
|
|
|
*/
|
|
|
|
GstFlowReturn new_ret =
|
2016-04-29 09:55:19 +00:00
|
|
|
gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), NULL, 1);
|
2020-09-14 17:12:23 +00:00
|
|
|
|
|
|
|
/* Only override the flow return value if previously did have a GST_FLOW_OK.
|
|
|
|
* Failure to do this would result in skipping downstream issues caught in
|
|
|
|
* earlier steps. */
|
|
|
|
if (ret == GST_FLOW_OK)
|
|
|
|
ret = new_ret;
|
2019-02-26 00:00:33 +00:00
|
|
|
}
|
2012-12-03 19:38:53 +00:00
|
|
|
|
2020-06-30 16:33:56 +00:00
|
|
|
unmap:
|
|
|
|
gst_buffer_unmap (inbuf, &map);
|
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
|
2018-07-01 00:21:46 +00:00
|
|
|
done:
|
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));
|
2018-07-01 00:21:46 +00:00
|
|
|
ret = GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
send_packet_failed:
|
|
|
|
{
|
2022-03-08 14:05:17 +00:00
|
|
|
GST_AUDIO_DECODER_ERROR (ffmpegdec, 1, STREAM, DECODE, (NULL),
|
|
|
|
("Audio decoding error"), ret);
|
|
|
|
|
|
|
|
if (ret == GST_FLOW_OK) {
|
|
|
|
/* Even if ffmpeg was not able to decode current audio frame,
|
|
|
|
* we should call gst_audio_decoder_finish_frame() so that baseclass
|
|
|
|
* can clear its internal status and can respect timestamp of later
|
|
|
|
* incoming buffers */
|
|
|
|
ret = gst_ffmpegauddec_drain (ffmpegdec, TRUE);
|
|
|
|
}
|
2020-06-30 16:33:56 +00:00
|
|
|
goto unmap;
|
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
|
|
|
}
|
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;
|
2018-06-29 19:20:36 +00:00
|
|
|
void *i = 0;
|
2004-09-22 07:53:48 +00:00
|
|
|
gint rank;
|
2004-03-29 16:39:18 +00:00
|
|
|
|
2007-12-17 12:43:06 +00:00
|
|
|
GST_LOG ("Registering decoders");
|
|
|
|
|
2018-06-29 19:20:36 +00:00
|
|
|
while ((in_plugin = (AVCodec *) av_codec_iterate (&i))) {
|
2003-11-02 13:12:14 +00:00
|
|
|
gchar *type_name;
|
2007-12-17 12:43:06 +00:00
|
|
|
|
|
|
|
/* only decoders */
|
2012-12-05 09:52:34 +00:00
|
|
|
if (!av_codec_is_decoder (in_plugin)
|
|
|
|
|| in_plugin->type != AVMEDIA_TYPE_AUDIO) {
|
2018-06-29 19:20:36 +00:00
|
|
|
continue;
|
2007-12-17 12:43:06 +00:00
|
|
|
}
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2016-07-22 11:54:21 +00:00
|
|
|
/* no quasi codecs, please */
|
|
|
|
if (in_plugin->id == AV_CODEC_ID_PCM_S16LE_PLANAR ||
|
|
|
|
(in_plugin->id >= AV_CODEC_ID_PCM_S16LE &&
|
|
|
|
in_plugin->id <= AV_CODEC_ID_PCM_BLURAY) ||
|
|
|
|
(in_plugin->id >= AV_CODEC_ID_PCM_S8_PLANAR &&
|
2018-06-29 19:21:30 +00:00
|
|
|
in_plugin->id <= AV_CODEC_ID_PCM_F24LE))
|
2018-06-29 19:20:36 +00:00
|
|
|
continue;
|
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);
|
2018-06-29 19:20:36 +00:00
|
|
|
continue;
|
2009-03-10 20:11:43 +00:00
|
|
|
}
|
|
|
|
|
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);
|
2018-06-29 19:20:36 +00:00
|
|
|
continue;
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
2003-06-07 00:41:32 +00:00
|
|
|
|
2002-03-19 04:09:41 +00:00
|
|
|
/* construct the type */
|
2016-01-07 17:13:29 +00:00
|
|
|
type_name = g_strdup_printf ("avdec_%s", in_plugin->name);
|
|
|
|
g_strdelimit (type_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:
|
2014-08-06 08:14:17 +00:00
|
|
|
case AV_CODEC_ID_AAC:
|
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;
|
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);
|
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;
|
|
|
|
}
|