[PATCH v3 01/12] winegstreamer: Utilize gst_audio_info_to_caps for media type translation.
Zebediah Figura (she/her)
zfigura at codeweavers.com
Wed Dec 2 14:39:33 CST 2020
On 12/2/20 1:54 PM, Derek Lesho wrote:
> Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
> ---
> dlls/winegstreamer/mfplat.c | 44 +++++++++++++++----------------------
> 1 file changed, 18 insertions(+), 26 deletions(-)
>
> diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c
> index 3d224a5accc..c5b133c824e 100644
> --- a/dlls/winegstreamer/mfplat.c
> +++ b/dlls/winegstreamer/mfplat.c
> @@ -669,31 +669,32 @@ GstCaps *caps_from_mf_media_type(IMFMediaType *type)
> }
> else if (IsEqualGUID(&major_type, &MFMediaType_Audio))
> {
> - DWORD rate, channels, channel_mask, bitrate;
> + DWORD rate = -1, channels = -1, channel_mask = -1, bitrate = -1;
> +
> + IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &rate);
> + IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_NUM_CHANNELS, &channels);
> + IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_CHANNEL_MASK, &channel_mask);
> + IMFMediaType_GetUINT32(type, &MF_MT_AVG_BITRATE, &bitrate);
>
> if (IsEqualGUID(&subtype, &MFAudioFormat_Float))
> {
> - output = gst_caps_new_empty_simple("audio/x-raw");
> + GstAudioInfo float_info;
>
> - gst_caps_set_simple(output, "format", G_TYPE_STRING, "F32LE", NULL);
> - gst_caps_set_simple(output, "layout", G_TYPE_STRING, "interleaved", NULL);
> + gst_audio_info_set_format(&float_info, GST_AUDIO_FORMAT_F32LE, rate, channels, NULL);
> + output = gst_audio_info_to_caps(&float_info);
> }
> else if (IsEqualGUID(&subtype, &MFAudioFormat_PCM))
> {
> + GstAudioFormat pcm_format;
> + GstAudioInfo pcm_info;
> DWORD bits_per_sample;
>
> if (SUCCEEDED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &bits_per_sample)))
> {
> - char format[6];
> - char type;
> -
> - type = bits_per_sample > 8 ? 'S' : 'U';
> -
> - output = gst_caps_new_empty_simple("audio/x-raw");
> -
> - sprintf(format, "%c%u%s", type, bits_per_sample, bits_per_sample > 8 ? "LE" : "");
> + pcm_format = gst_audio_format_build_integer(bits_per_sample > 8, G_LITTLE_ENDIAN, bits_per_sample, bits_per_sample);
>
> - gst_caps_set_simple(output, "format", G_TYPE_STRING, format, NULL);
> + gst_audio_info_set_format(&pcm_info, pcm_format, rate, channels, NULL);
> + output = gst_audio_info_to_caps(&pcm_info);
> }
> else
> {
> @@ -707,23 +708,14 @@ GstCaps *caps_from_mf_media_type(IMFMediaType *type)
> return NULL;
> }
>
> - if (SUCCEEDED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &rate)))
> - {
> + if (rate != -1)
> gst_caps_set_simple(output, "rate", G_TYPE_INT, rate, NULL);
> - }
> - if (SUCCEEDED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_NUM_CHANNELS, &channels)))
> - {
> + if (channels != -1)
> gst_caps_set_simple(output, "channels", G_TYPE_INT, channels, NULL);
> - }
"rate" and "channels" are already set by gst_audio_info_to_caps().
> - if (SUCCEEDED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_CHANNEL_MASK, &channel_mask)))
> - {
> + if (channel_mask != -1)
> gst_caps_set_simple(output, "channel-mask", GST_TYPE_BITMASK, (guint64) channel_mask, NULL);
> - }
> -
> - if (SUCCEEDED(IMFMediaType_GetUINT32(type, &MF_MT_AVG_BITRATE, &bitrate)))
> - {
> + if (bitrate != -1)
> gst_caps_set_simple(output, "bitrate", G_TYPE_INT, bitrate, NULL);
> - }
>
> return output;
> }
>
I only just now notice this, but MF_MT_AVG_BITRATE is a video type
attribute, not an audio type attribute; I suspect it should be removed
from this function...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x0D9D358A07A17840.asc
Type: application/pgp-keys
Size: 1769 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20201202/505da73e/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20201202/505da73e/attachment.sig>
More information about the wine-devel
mailing list