avcodecmap: Only set "formats" field on raw audio/video caps

This commit is contained in:
Sebastian Dröge 2012-12-17 13:42:13 +01:00
parent 0ec5fea211
commit faf985e8fb
2 changed files with 22 additions and 6 deletions

View file

@ -221,8 +221,7 @@ gst_ffmpegaudenc_getcaps (GstAudioEncoder * encoder, GstCaps * filter)
/* audio needs no special care */ /* audio needs no special care */
caps = gst_audio_encoder_proxy_getcaps (encoder, NULL, filter); caps = gst_audio_encoder_proxy_getcaps (encoder, NULL, filter);
GST_DEBUG_OBJECT (ffmpegaudenc, GST_DEBUG_OBJECT (ffmpegaudenc, "audio caps, return %" GST_PTR_FORMAT, caps);
"audio caps, return template %" GST_PTR_FORMAT, caps);
return caps; return caps;
} }

View file

@ -387,8 +387,6 @@ gst_ff_vid_caps_new (AVCodecContext * context, AVCodec * codec,
caps = gst_caps_new_empty_simple (mimetype); caps = gst_caps_new_empty_simple (mimetype);
} }
gst_ffmpeg_video_set_pix_fmts (caps, codec ? codec->pix_fmts : NULL);
break; break;
} }
} }
@ -664,8 +662,6 @@ gst_ff_aud_caps_new (AVCodecContext * context, AVCodec * codec,
caps = gst_caps_new_empty_simple (mimetype); caps = gst_caps_new_empty_simple (mimetype);
} }
gst_ffmpeg_audio_set_sample_fmts (caps, codec ? codec->sample_fmts : NULL);
va_start (var_args, fieldname); va_start (var_args, fieldname);
gst_caps_set_simple_valist (caps, fieldname, var_args); gst_caps_set_simple_valist (caps, fieldname, var_args);
va_end (var_args); va_end (var_args);
@ -2120,6 +2116,22 @@ gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
return caps; 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 * GstCaps *
gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context, gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
enum CodecID codec_id, gboolean encode, AVCodec * codec) enum CodecID codec_id, gboolean encode, AVCodec * codec)
@ -2140,6 +2152,9 @@ gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
} else { } else {
caps = gst_ff_aud_caps_new (context, codec, codec_id, encode, "audio/x-raw", caps = gst_ff_aud_caps_new (context, codec, codec_id, encode, "audio/x-raw",
"layout", G_TYPE_STRING, "interleaved", NULL); "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; return caps;
@ -2160,6 +2175,8 @@ gst_ffmpeg_codectype_to_video_caps (AVCodecContext * context,
caps = caps =
gst_ff_vid_caps_new (context, codec, codec_id, encode, "video/x-raw", gst_ff_vid_caps_new (context, codec, codec_id, encode, "video/x-raw",
NULL); NULL);
if (!caps_has_field (caps, "format"))
gst_ffmpeg_video_set_pix_fmts (caps, codec ? codec->pix_fmts : NULL);
} }
return caps; return caps;
} }