Merge branch 'master' into 0.11

Conflicts:
	configure.ac
	ext/ffmpeg/gstffmpegcodecmap.c
	ext/ffmpeg/gstffmpegdeinterlace.c
This commit is contained in:
Wim Taymans 2011-09-28 13:29:08 +02:00
commit afb740b897
9 changed files with 309 additions and 75 deletions

2
common

@ -1 +1 @@
Subproject commit 605cd9a65ed61505f24b840d3fe8e252be72b151
Subproject commit 11f0cd5a3fba36f85cf3e434150bfe66b1bf08d4

View file

@ -13,30 +13,10 @@ FORMATS=html
html: html-build.stamp
include $(srcdir)/../../common/upload-doc.mak
# generated basefiles
#basefiles = \
## $(DOC_MODULE).types \
# $(DOC_MODULE)-sections.txt \
# $(DOC_MODULE)-docs.sgml
# ugly hack to make -unused.sgml work
#unused-build.stamp:
# BUILDDIR=`pwd` && \
# cd $(srcdir)/tmpl && \
# ln -sf gstreamer-libs-unused.sgml \
# $$BUILDDIR/tmpl/gstreamer-libs-@GST_MAJORMINOR@-unused.sgml
# touch unused-build.stamp
# these rules are added to create parallel docs using GST_MAJORMINOR
#$(basefiles): gstreamer-libs-@GST_MAJORMINOR@%: gstreamer-libs%
# cp $< $@
#CLEANFILES = $(basefiles)
# The top-level SGML file. Change it if you want.
DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
# The directory containing the source code. Relative to $(top_srcdir).
# The directory containing the source code.
# gtk-doc will search all .c & .h files beneath here for inline comments
# documenting functions and macros.
DOC_SOURCE_DIR = $(top_srcdir)/ext/ffmpeg
@ -52,14 +32,8 @@ MKDB_OPTIONS=--sgml-mode
#FIXXREF_OPTIONS=--extra-dir=../gst/html
# Used for dependencies.
HFILE_GLOB=$(DOC_SOURCE_DIR)/*.h
CFILE_GLOB=$(DOC_SOURCE_DIR)/*.c
# this is a wingo addition
# thomasvs: another nice wingo addition would be an explanation on why
# this is useful ;)
SCANOBJ_DEPS =
HFILE_GLOB=$(top_srcdir)/ext/ffmpeg/*.h
CFILE_GLOB=$(top_srcdir)/ext/ffmpeg/*.c
# Header files to ignore when scanning.
IGNORE_HFILES =
@ -87,7 +61,7 @@ extra_files =
# CFLAGS and LDFLAGS for compiling scan program. Only needed if your app/lib
# contains GtkObjects/GObjects and you want to document signals and properties.
GTKDOC_CFLAGS = $(GST_BASE_CFLAGS) -I$(top_builddir) -I$(top_builddir)/gst-libs
GTKDOC_LIBS = $(SCANOBJ_DEPS) $(GST_BASE_LIBS)
GTKDOC_LIBS = $(GST_BASE_LIBS)
GTKDOC_CC=$(LIBTOOL) --tag=CC --mode=compile $(CC)
GTKDOC_LD=$(LIBTOOL) --tag=CC --mode=link $(CC)

View file

@ -2267,7 +2267,8 @@ gst_ffmpeg_caps_with_codecid (enum CodecID codec_id,
GST_DEBUG ("have codec data of size %d", size);
gst_buffer_unmap (buf, data, size);
} else if (context->extradata == NULL && codec_id != CODEC_ID_AAC_LATM) {
} else if (context->extradata == NULL && codec_id != CODEC_ID_AAC_LATM &&
codec_id != CODEC_ID_FLAC) {
/* no extradata, alloc dummy with 0 sized, some codecs insist on reading
* extradata anyway which makes then segfault. */
context->extradata =

View file

@ -137,6 +137,8 @@ struct _GstFFMpegDec
/* QoS stuff *//* with LOCK */
gdouble proportion;
GstClockTime earliest_time;
gint64 processed;
gint64 dropped;
/* clipping segment */
GstSegment segment;
@ -526,6 +528,8 @@ static void
gst_ffmpegdec_reset_qos (GstFFMpegDec * ffmpegdec)
{
gst_ffmpegdec_update_qos (ffmpegdec, 0.5, GST_CLOCK_TIME_NONE);
ffmpegdec->processed = 0;
ffmpegdec->dropped = 0;
}
static void
@ -810,6 +814,12 @@ gst_ffmpegdec_setcaps (GstFFMpegDec * ffmpegdec, GstCaps * caps)
}
}
/* for FLAC, don't parse if it's already parsed */
if (oclass->in_plugin->id == CODEC_ID_FLAC) {
if (gst_structure_has_field (structure, "streamheader"))
ffmpegdec->turnoff_parser = TRUE;
}
/* workaround encoder bugs */
ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
ffmpegdec->context->error_recognition = 1;
@ -1431,6 +1441,7 @@ gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
GstClockTimeDiff diff;
gdouble proportion;
GstClockTime qostime, earliest_time;
gboolean res = TRUE;
*mode_switch = FALSE;
@ -1481,11 +1492,13 @@ gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
}
no_qos:
ffmpegdec->processed++;
return TRUE;
skipping:
{
return FALSE;
res = FALSE;
goto drop_qos;
}
normal_mode:
{
@ -1494,6 +1507,7 @@ normal_mode:
*mode_switch = TRUE;
GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode %g < 0.4", proportion);
}
ffmpegdec->processed++;
return TRUE;
}
skip_frame:
@ -1504,7 +1518,27 @@ skip_frame:
GST_DEBUG_OBJECT (ffmpegdec,
"QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff);
}
return TRUE;
goto drop_qos;
}
drop_qos:
{
GstClockTime stream_time, jitter;
GstMessage *qos_msg;
ffmpegdec->dropped++;
stream_time =
gst_segment_to_stream_time (&ffmpegdec->segment, GST_FORMAT_TIME,
timestamp);
jitter = GST_CLOCK_DIFF (qostime, earliest_time);
qos_msg =
gst_message_new_qos (GST_OBJECT_CAST (ffmpegdec), FALSE, qostime,
stream_time, timestamp, GST_CLOCK_TIME_NONE);
gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
ffmpegdec->processed, ffmpegdec->dropped);
gst_element_post_message (GST_ELEMENT_CAST (ffmpegdec), qos_msg);
return res;
}
}
@ -3031,7 +3065,12 @@ gst_ffmpegdec_register (GstPlugin * plugin)
!strcmp (in_plugin->name, "mp1") ||
!strcmp (in_plugin->name, "mp2") ||
!strcmp (in_plugin->name, "libfaad") ||
!strcmp (in_plugin->name, "mpeg4aac")) {
!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")) {
GST_LOG ("Ignoring decoder %s", in_plugin->name);
goto next;
}

View file

@ -37,6 +37,47 @@
#include "gstffmpegcodecmap.h"
#include "gstffmpegutils.h"
/* Properties */
#define DEFAULT_MODE GST_FFMPEGDEINTERLACE_MODE_AUTO
enum
{
PROP_0,
PROP_MODE,
PROP_LAST
};
typedef enum
{
GST_FFMPEGDEINTERLACE_MODE_AUTO,
GST_FFMPEGDEINTERLACE_MODE_INTERLACED,
GST_FFMPEGDEINTERLACE_MODE_DISABLED
} GstFFMpegDeinterlaceMode;
#define GST_TYPE_FFMPEGDEINTERLACE_MODES (gst_ffmpegdeinterlace_modes_get_type ())
static GType
gst_ffmpegdeinterlace_modes_get_type (void)
{
static GType deinterlace_modes_type = 0;
static const GEnumValue modes_types[] = {
{GST_FFMPEGDEINTERLACE_MODE_AUTO, "Auto detection", "auto"},
{GST_FFMPEGDEINTERLACE_MODE_INTERLACED, "Force deinterlacing",
"interlaced"},
{GST_FFMPEGDEINTERLACE_MODE_DISABLED, "Run in passthrough mode",
"disabled"},
{0, NULL, NULL},
};
if (!deinterlace_modes_type) {
deinterlace_modes_type =
g_enum_register_static ("GstFFMpegDeinterlaceModes", modes_types);
}
return deinterlace_modes_type;
}
typedef struct _GstFFMpegDeinterlace
{
GstElement element;
@ -46,6 +87,14 @@ typedef struct _GstFFMpegDeinterlace
gint width, height;
gint to_size;
GstFFMpegDeinterlaceMode mode;
gboolean interlaced; /* is input interlaced? */
gboolean passthrough;
gboolean reconfigure;
GstFFMpegDeinterlaceMode new_mode;
enum PixelFormat pixfmt;
AVPicture from_frame, to_frame;
} GstFFMpegDeinterlace;
@ -68,6 +117,11 @@ typedef struct _GstFFMpegDeinterlaceClass
GType gst_ffmpegdeinterlace_get_type (void);
static void gst_ffmpegdeinterlace_set_property (GObject * self, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_ffmpegdeinterlace_get_property (GObject * self, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
@ -85,12 +139,30 @@ G_DEFINE_TYPE (GstFFMpegDeinterlace, gst_ffmpegdeinterlace, GST_TYPE_ELEMENT);
static GstFlowReturn gst_ffmpegdeinterlace_chain (GstPad * pad,
GstBuffer * inbuf);
static void
gst_ffmpegdeinterlace_class_init (GstFFMpegDeinterlaceClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gobject_class->set_property = gst_ffmpegdeinterlace_set_property;
gobject_class->get_property = gst_ffmpegdeinterlace_get_property;
/**
* GstFFMpegDeinterlace:mode
*
* This selects whether the deinterlacing methods should
* always be applied or if they should only be applied
* on content that has the "interlaced" flag on the caps.
*
* Since: 0.10.13
*/
g_object_class_install_property (gobject_class, PROP_MODE,
g_param_spec_enum ("mode", "Mode", "Deinterlace Mode",
GST_TYPE_FFMPEGDEINTERLACE_MODES,
DEFAULT_MODE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_factory));
gst_element_class_add_pad_template (element_class,
@ -101,6 +173,62 @@ gst_ffmpegdeinterlace_class_init (GstFFMpegDeinterlaceClass * klass)
"Deinterlace video", "Luca Ognibene <luogni@tin.it>");
}
static void
gst_ffmpegdeinterlace_update_passthrough (GstFFMpegDeinterlace * deinterlace)
{
deinterlace->passthrough =
(deinterlace->mode == GST_FFMPEGDEINTERLACE_MODE_DISABLED
|| (!deinterlace->interlaced
&& deinterlace->mode != GST_FFMPEGDEINTERLACE_MODE_INTERLACED));
GST_DEBUG_OBJECT (deinterlace, "Passthrough: %d", deinterlace->passthrough);
}
static gboolean
gst_ffmpegdeinterlace_sink_setcaps (GstPad * pad, GstCaps * caps)
{
GstFFMpegDeinterlace *deinterlace =
GST_FFMPEGDEINTERLACE (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (caps, 0);
AVCodecContext *ctx;
GstCaps *src_caps;
gboolean ret;
if (!gst_structure_get_int (structure, "width", &deinterlace->width))
return FALSE;
if (!gst_structure_get_int (structure, "height", &deinterlace->height))
return FALSE;
deinterlace->interlaced = FALSE;
gst_structure_get_boolean (structure, "interlaced", &deinterlace->interlaced);
gst_ffmpegdeinterlace_update_passthrough (deinterlace);
ctx = avcodec_alloc_context ();
ctx->width = deinterlace->width;
ctx->height = deinterlace->height;
ctx->pix_fmt = PIX_FMT_NB;
gst_ffmpeg_caps_with_codectype (AVMEDIA_TYPE_VIDEO, caps, ctx);
if (ctx->pix_fmt == PIX_FMT_NB) {
av_free (ctx);
return FALSE;
}
deinterlace->pixfmt = ctx->pix_fmt;
av_free (ctx);
deinterlace->to_size =
avpicture_get_size (deinterlace->pixfmt, deinterlace->width,
deinterlace->height);
src_caps = gst_caps_copy (caps);
gst_caps_set_simple (src_caps, "interlaced", G_TYPE_BOOLEAN,
deinterlace->interlaced, NULL);
ret = gst_pad_set_caps (deinterlace->srcpad, src_caps);
gst_caps_unref (src_caps);
return ret;
}
static gboolean
gst_ffmpegdeinterlace_sink_event (GstPad * pad, GstEvent * event)
{
@ -111,51 +239,18 @@ gst_ffmpegdeinterlace_sink_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CAPS:
{
GstStructure *structure;
AVCodecContext *ctx;
GstCaps *caps, *src_caps;
GstCaps *caps;
gst_event_parse_caps (event, &caps);
structure = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_int (structure, "width", &deinterlace->width) ||
!gst_structure_get_int (structure, "height", &deinterlace->height)) {
goto done;
}
ctx = avcodec_alloc_context ();
ctx->width = deinterlace->width;
ctx->height = deinterlace->height;
ctx->pix_fmt = PIX_FMT_NB;
gst_ffmpeg_caps_with_codectype (AVMEDIA_TYPE_VIDEO, caps, ctx);
if (ctx->pix_fmt == PIX_FMT_NB) {
av_free (ctx);
goto done;
}
deinterlace->pixfmt = ctx->pix_fmt;
av_free (ctx);
deinterlace->to_size =
avpicture_get_size (deinterlace->pixfmt, deinterlace->width,
deinterlace->height);
src_caps = gst_caps_copy (caps);
ret = gst_ffmpegdeinterlace_sink_setcaps (pad, caps);
gst_event_unref (event);
gst_caps_set_simple (src_caps, "interlaced", G_TYPE_BOOLEAN, FALSE, NULL);
event = gst_event_new_caps (src_caps);
gst_caps_unref (src_caps);
}
break;
}
default:
ret = gst_pad_push_event (deinterlace->srcpad, event);
break;
}
ret = gst_pad_push_event (deinterlace->srcpad, event);
done:
gst_object_unref (deinterlace);
return ret;
@ -176,6 +271,12 @@ gst_ffmpegdeinterlace_init (GstFFMpegDeinterlace * deinterlace)
gst_element_add_pad (GST_ELEMENT (deinterlace), deinterlace->srcpad);
deinterlace->pixfmt = PIX_FMT_NB;
deinterlace->interlaced = FALSE;
deinterlace->passthrough = FALSE;
deinterlace->reconfigure = FALSE;
deinterlace->mode = DEFAULT_MODE;
deinterlace->new_mode = -1;
}
static GstFlowReturn
@ -188,6 +289,28 @@ gst_ffmpegdeinterlace_chain (GstPad * pad, GstBuffer * inbuf)
guint8 *from_data, *to_data;
gsize from_size, to_size;
GST_OBJECT_LOCK (deinterlace);
if (deinterlace->reconfigure) {
if (deinterlace->new_mode != -1)
deinterlace->mode = deinterlace->new_mode;
deinterlace->new_mode = -1;
deinterlace->reconfigure = FALSE;
GST_OBJECT_UNLOCK (deinterlace);
if (gst_pad_has_current_caps (deinterlace->srcpad)) {
GstCaps *caps;
caps = gst_pad_get_current_caps (deinterlace->sinkpad);
gst_ffmpegdeinterlace_sink_setcaps (deinterlace->sinkpad, caps);
gst_caps_unref (caps);
}
} else {
GST_OBJECT_UNLOCK (deinterlace);
}
if (deinterlace->passthrough)
return gst_pad_push (deinterlace->srcpad, inbuf);
outbuf = gst_buffer_new_and_alloc (deinterlace->to_size);
from_data = gst_buffer_map (inbuf, &from_size, NULL, GST_MAP_READ);
@ -218,3 +341,52 @@ gst_ffmpegdeinterlace_register (GstPlugin * plugin)
return gst_element_register (plugin, "ffdeinterlace",
GST_RANK_NONE, GST_TYPE_FFMPEGDEINTERLACE);
}
static void
gst_ffmpegdeinterlace_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstFFMpegDeinterlace *self;
g_return_if_fail (GST_IS_FFMPEGDEINTERLACE (object));
self = GST_FFMPEGDEINTERLACE (object);
switch (prop_id) {
case PROP_MODE:{
gint new_mode;
GST_OBJECT_LOCK (self);
new_mode = g_value_get_enum (value);
if (self->mode != new_mode && gst_pad_has_current_caps (self->srcpad)) {
self->reconfigure = TRUE;
self->new_mode = new_mode;
} else {
self->mode = new_mode;
gst_ffmpegdeinterlace_update_passthrough (self);
}
GST_OBJECT_UNLOCK (self);
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec);
}
}
static void
gst_ffmpegdeinterlace_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstFFMpegDeinterlace *self;
g_return_if_fail (GST_IS_FFMPEGDEINTERLACE (object));
self = GST_FFMPEGDEINTERLACE (object);
switch (prop_id) {
case PROP_MODE:
g_value_set_enum (value, self->mode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec);
}
}

@ -1 +1 @@
Subproject commit 9459390f29ec6df63ff1878f13b7b4343811948a
Subproject commit 20ca827019a72bfacb38e73d0b8590e651818272

View file

@ -1,4 +1,5 @@
test-registry.*
elements/ffdec_adpcm
elements/ffdemux_ape
elements/postproc
.dirstamp

View file

@ -20,7 +20,8 @@ check_PROGRAMS = \
generic/plugin-test \
generic/libavcodec-locking \
elements/ffdec_adpcm \
elements/ffdemux_ape
elements/ffdemux_ape \
elements/postproc
VALGRIND_TO_FIX = \
generic/plugin-test \

View file

@ -0,0 +1,46 @@
/* GStreamer unit tests for postproc
* Copyright (C) 2011 Collabora Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gst/check/gstcheck.h>
#include <gst/gst.h>
GST_START_TEST (test_postproc_default)
{
GstElement *pp;
pp = gst_element_factory_make ("postproc_default", NULL);
fail_unless (pp != NULL, "Failed to create postproc_default!");
gst_object_unref (pp);
}
GST_END_TEST;
static Suite *
postproc_suite (void)
{
Suite *s = suite_create ("postproc");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_postproc_default);
return s;
}
GST_CHECK_MAIN (postproc)