Commit fc6b3233 authored by Wim Taymans's avatar Wim Taymans
Browse files

Merge branch 'master' into 0.11

Conflicts:
	configure.ac
	ext/ffmpeg/gstffmpegdec.c
parents 508d4918 37f5d703
common @ 605cd9a6
Subproject commit 69b981f10caa234ad0ff639179d0fda8505bd94b
Subproject commit 605cd9a65ed61505f24b840d3fe8e252be72b151
......@@ -1864,7 +1864,7 @@ gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
caps = gst_caps_new_empty ();
for (i = 0; codec->sample_fmts[i] != -1; i++) {
temp =
gst_ffmpeg_smpfmt_to_caps (codec->sample_fmts[0], context, codec_id);
gst_ffmpeg_smpfmt_to_caps (codec->sample_fmts[i], context, codec_id);
if (temp != NULL)
gst_caps_append (caps, temp);
}
......
......@@ -122,6 +122,7 @@ struct _GstFFMpegDec
gboolean do_padding;
gboolean debug_mv;
gboolean crop;
int max_threads;
/* QoS stuff *//* with LOCK */
gdouble proportion;
......@@ -192,6 +193,7 @@ gst_ts_info_get (GstFFMpegDec * dec, gint idx)
#define DEFAULT_DO_PADDING TRUE
#define DEFAULT_DEBUG_MV FALSE
#define DEFAULT_CROP TRUE
#define DEFAULT_MAX_THREADS 0
enum
{
......@@ -202,6 +204,7 @@ enum
PROP_DO_PADDING,
PROP_DEBUG_MV,
PROP_CROP,
PROP_MAX_THREADS,
PROP_LAST
};
......@@ -355,6 +358,8 @@ gst_ffmpegdec_class_init (GstFFMpegDecClass * klass)
gobject_class->get_property = gst_ffmpegdec_get_property;
if (klass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
int caps;
g_object_class_install_property (gobject_class, PROP_SKIPFRAME,
g_param_spec_enum ("skip-frame", "Skip frames",
"Which types of frames to skip during decoding",
......@@ -382,6 +387,15 @@ gst_ffmpegdec_class_init (GstFFMpegDecClass * klass)
"Crop images to the display region",
DEFAULT_CROP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
#endif
caps = klass->in_plugin->capabilities;
if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) {
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS,
g_param_spec_int ("max-threads", "Maximum decode threads",
"Maximum number of worker threads to spawn. (0 = auto)",
0, G_MAXINT, DEFAULT_MAX_THREADS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
}
gstelement_class->change_state = gst_ffmpegdec_change_state;
......@@ -423,6 +437,7 @@ gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec)
ffmpegdec->do_padding = DEFAULT_DO_PADDING;
ffmpegdec->debug_mv = DEFAULT_DEBUG_MV;
ffmpegdec->crop = DEFAULT_CROP;
ffmpegdec->max_threads = DEFAULT_MAX_THREADS;
ffmpegdec->format.video.par_n = -1;
ffmpegdec->format.video.fps_n = -1;
......@@ -839,6 +854,11 @@ gst_ffmpegdec_setcaps (GstFFMpegDec * ffmpegdec, GstCaps * caps)
* supports it) */
ffmpegdec->context->debug_mv = ffmpegdec->debug_mv;
if (ffmpegdec->max_threads == 0)
ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();
else
ffmpegdec->context->thread_count = ffmpegdec->max_threads;
/* open codec - we don't select an output pix_fmt yet,
* simply because we don't know! We only get it
* during playback... */
......@@ -1657,16 +1677,12 @@ flush_queued (GstFFMpegDec * ffmpegdec)
return res;
}
static AVPacket *
gst_avpacket_new (guint8 * data, guint size)
static void
gst_avpacket_init (AVPacket * packet, guint8 * data, guint size)
{
AVPacket *res;
res = g_malloc0 (sizeof (AVPacket));
res->data = data;
res->size = size;
return res;
memset (packet, 0, sizeof (AVPacket));
packet->data = data;
packet->size = size;
}
/* gst_ffmpegdec_[video|audio]_frame:
......@@ -1696,7 +1712,7 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
GstClockTime out_timestamp, out_duration, out_pts;
gint64 out_offset;
const GstTSInfo *out_info;
AVPacket *packet;
AVPacket packet;
*ret = GST_FLOW_OK;
*outbuf = NULL;
......@@ -1742,9 +1758,9 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx);
/* now decode the frame */
packet = gst_avpacket_new (data, size);
gst_avpacket_init (&packet, data, size);
len = avcodec_decode_video2 (ffmpegdec->context,
ffmpegdec->picture, &have_data, packet);
ffmpegdec->picture, &have_data, &packet);
/* restore previous state */
if (!decode)
......@@ -2106,7 +2122,7 @@ gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
GstClockTime out_timestamp, out_duration;
gint64 out_offset;
int16_t *odata;
AVPacket *packet;
AVPacket packet;
GST_DEBUG_OBJECT (ffmpegdec,
"size:%d, offset:%" G_GINT64_FORMAT ", ts:%" GST_TIME_FORMAT ", dur:%"
......@@ -2118,8 +2134,8 @@ gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
odata = gst_buffer_map (*outbuf, NULL, NULL, GST_MAP_WRITE);
packet = gst_avpacket_new (data, size);
len = avcodec_decode_audio3 (ffmpegdec->context, odata, &have_data, packet);
gst_avpacket_init (&packet, data, size);
len = avcodec_decode_audio3 (ffmpegdec->context, odata, &have_data, &packet);
GST_DEBUG_OBJECT (ffmpegdec,
"Decode audio: len=%d, have_data=%d", len, have_data);
......@@ -2865,6 +2881,9 @@ gst_ffmpegdec_set_property (GObject * object,
case PROP_CROP:
ffmpegdec->crop = g_value_get_boolean (value);
break;
case PROP_MAX_THREADS:
ffmpegdec->max_threads = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -2896,6 +2915,9 @@ gst_ffmpegdec_get_property (GObject * object,
case PROP_CROP:
g_value_set_boolean (value, ffmpegdec->crop);
break;
case PROP_MAX_THREADS:
g_value_set_int (value, ffmpegdec->max_threads);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -3033,6 +3055,14 @@ gst_ffmpegdec_register (GstPlugin * plugin)
case CODEC_ID_MP3:
rank = GST_RANK_NONE;
break;
/* TEMPORARILY DISABLING AC3/EAC3/DTS for 0.10.12 release
* due to downmixing failure.
* See Bug #608892 for more details */
case CODEC_ID_EAC3:
case CODEC_ID_AC3:
case CODEC_ID_DTS:
rank = GST_RANK_NONE;
break;
default:
rank = GST_RANK_MARGINAL;
break;
......
......@@ -21,6 +21,10 @@
#include "config.h"
#endif
#include "gstffmpegutils.h"
#include <unistd.h>
#ifdef __APPLE__
#include <sys/sysctl.h>
#endif
G_CONST_RETURN gchar *
gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
......@@ -440,3 +444,37 @@ new_aligned_buffer (gint size)
return buf;
}
int
gst_ffmpeg_auto_max_threads (void)
{
static gsize n_threads = 0;
if (g_once_init_enter (&n_threads)) {
int n = 1;
#if defined(_WIN32)
{
const char *s = getenv ("NUMBER_OF_PROCESSORS");
if (s) {
n = atoi (s);
}
}
#elif defined(__APPLE__)
{
int mib[] = { CTL_HW, HW_NCPU };
size_t dataSize = sizeof (int);
if (sysctl (mib, 2, &n_threads, &dataSize, NULL, 0)) {
n = 1;
}
}
#else
n = sysconf (_SC_NPROCESSORS_CONF);
#endif
if (n < 1)
n = 1;
g_once_init_leave (&n_threads, n);
}
return (int) (n_threads);
}
......@@ -80,6 +80,8 @@ gst_ffmpeg_time_gst_to_ff (guint64 time, AVRational base)
void
gst_ffmpeg_init_pix_fmt_info(void);
int
gst_ffmpeg_auto_max_threads(void);
G_CONST_RETURN gchar *
gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
......
libav @ 9c709f05
Subproject commit 371266daa3df35c424203fff0ce2e6de0e33a29d
Subproject commit 9c709f053474dd74890f32662b7d7010e5cc0b0d
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment