mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
avcodecmap: Only set "formats" field on raw audio/video caps
This commit is contained in:
parent
0ec5fea211
commit
faf985e8fb
2 changed files with 22 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue