summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2012-12-17 13:42:13 +0100
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-12-17 13:42:13 +0100
commitfaf985e8fb7e4a851567df643cda77c524ca7f41 (patch)
tree4dfce7aff66fe74c0ca1077a8d43f0f30473ec04 /ext
parent0ec5fea211fad340954b3274eeee258809a026d2 (diff)
avcodecmap: Only set "formats" field on raw audio/video caps
Diffstat (limited to 'ext')
-rw-r--r--ext/libav/gstavaudenc.c3
-rw-r--r--ext/libav/gstavcodecmap.c25
2 files changed, 22 insertions, 6 deletions
diff --git a/ext/libav/gstavaudenc.c b/ext/libav/gstavaudenc.c
index 80f8edb..67c7653 100644
--- a/ext/libav/gstavaudenc.c
+++ b/ext/libav/gstavaudenc.c
@@ -221,8 +221,7 @@ gst_ffmpegaudenc_getcaps (GstAudioEncoder * encoder, GstCaps * filter)
/* audio needs no special care */
caps = gst_audio_encoder_proxy_getcaps (encoder, NULL, filter);
- GST_DEBUG_OBJECT (ffmpegaudenc,
- "audio caps, return template %" GST_PTR_FORMAT, caps);
+ GST_DEBUG_OBJECT (ffmpegaudenc, "audio caps, return %" GST_PTR_FORMAT, caps);
return caps;
}
diff --git a/ext/libav/gstavcodecmap.c b/ext/libav/gstavcodecmap.c
index d4ed1ca..e31378b 100644
--- a/ext/libav/gstavcodecmap.c
+++ b/ext/libav/gstavcodecmap.c
@@ -387,8 +387,6 @@ gst_ff_vid_caps_new (AVCodecContext * context, AVCodec * codec,
caps = gst_caps_new_empty_simple (mimetype);
}
- gst_ffmpeg_video_set_pix_fmts (caps, codec ? codec->pix_fmts : NULL);
-
break;
}
}
@@ -664,8 +662,6 @@ gst_ff_aud_caps_new (AVCodecContext * context, AVCodec * codec,
caps = gst_caps_new_empty_simple (mimetype);
}
- gst_ffmpeg_audio_set_sample_fmts (caps, codec ? codec->sample_fmts : NULL);
-
va_start (var_args, fieldname);
gst_caps_set_simple_valist (caps, fieldname, var_args);
va_end (var_args);
@@ -2120,6 +2116,22 @@ gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
return caps;
}
+static gboolean
+caps_has_field (GstCaps * caps, const gchar * field)
+{
+ guint i, n;
+
+ n = gst_caps_get_size (caps);
+ for (i = 0; i < n; i++) {
+ GstStructure *s = gst_caps_get_structure (caps, i);
+
+ if (gst_structure_has_field (s, field))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
GstCaps *
gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
enum CodecID codec_id, gboolean encode, AVCodec * codec)
@@ -2140,6 +2152,9 @@ gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
} else {
caps = gst_ff_aud_caps_new (context, codec, codec_id, encode, "audio/x-raw",
"layout", G_TYPE_STRING, "interleaved", NULL);
+ if (!caps_has_field (caps, "format"))
+ gst_ffmpeg_audio_set_sample_fmts (caps,
+ codec ? codec->sample_fmts : NULL);
}
return caps;
@@ -2160,6 +2175,8 @@ gst_ffmpeg_codectype_to_video_caps (AVCodecContext * context,
caps =
gst_ff_vid_caps_new (context, codec, codec_id, encode, "video/x-raw",
NULL);
+ if (!caps_has_field (caps, "format"))
+ gst_ffmpeg_video_set_pix_fmts (caps, codec ? codec->pix_fmts : NULL);
}
return caps;
}