Commit 2c88b69f authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

winegstreamer: Merge audio_wma into audio field.

parent 256e9afc
......@@ -779,14 +779,14 @@ static void mf_media_type_to_wg_format_audio_wma(IMFMediaType *type, const GUID
}
format->major_type = WG_MAJOR_TYPE_AUDIO_WMA;
format->u.audio_wma.version = version;
format->u.audio_wma.bitrate = bytes_per_second * 8;
format->u.audio_wma.rate = rate;
format->u.audio_wma.depth = depth;
format->u.audio_wma.channels = channels;
format->u.audio_wma.block_align = block_align;
format->u.audio_wma.codec_data_len = codec_data_len;
memcpy(format->u.audio_wma.codec_data, codec_data, codec_data_len);
format->u.audio.version = version;
format->u.audio.bitrate = bytes_per_second * 8;
format->u.audio.rate = rate;
format->u.audio.depth = depth;
format->u.audio.channels = channels;
format->u.audio.block_align = block_align;
format->u.audio.codec_data_len = codec_data_len;
memcpy(format->u.audio.codec_data, codec_data, codec_data_len);
}
static void mf_media_type_to_wg_format_video_h264(IMFMediaType *type, struct wg_format *format)
......
......@@ -288,7 +288,7 @@ static bool amt_from_wg_format_audio_wma(AM_MEDIA_TYPE *mt, const struct wg_form
mt->majortype = MEDIATYPE_Audio;
mt->formattype = FORMAT_WaveFormatEx;
switch (format->u.audio_wma.version)
switch (format->u.audio.version)
{
case 1:
subtype = &MEDIASUBTYPE_MSAUDIO1;
......@@ -322,21 +322,21 @@ static bool amt_from_wg_format_audio_wma(AM_MEDIA_TYPE *mt, const struct wg_form
mt->subtype = *subtype;
mt->bFixedSizeSamples = TRUE;
mt->lSampleSize = format->u.audio_wma.block_align;
mt->lSampleSize = format->u.audio.block_align;
mt->cbFormat = size;
mt->pbFormat = (BYTE *)wave_format;
wave_format->wFormatTag = fmt_tag;
wave_format->nChannels = format->u.audio_wma.channels;
wave_format->nSamplesPerSec = format->u.audio_wma.rate;
wave_format->nAvgBytesPerSec = format->u.audio_wma.bitrate / 8;
wave_format->nBlockAlign = format->u.audio_wma.block_align;
wave_format->wBitsPerSample = format->u.audio_wma.depth;
wave_format->nChannels = format->u.audio.channels;
wave_format->nSamplesPerSec = format->u.audio.rate;
wave_format->nAvgBytesPerSec = format->u.audio.bitrate / 8;
wave_format->nBlockAlign = format->u.audio.block_align;
wave_format->wBitsPerSample = format->u.audio.depth;
wave_format->cbSize = codec_data_len;
if (format->u.audio_wma.codec_data_len == codec_data_len)
memcpy(wave_format+1, format->u.audio_wma.codec_data, format->u.audio_wma.codec_data_len);
if (format->u.audio.codec_data_len == codec_data_len)
memcpy(wave_format+1, format->u.audio.codec_data, format->u.audio.codec_data_len);
else
FIXME("Unexpected codec_data length; got %u, expected %lu\n", format->u.audio_wma.codec_data_len, codec_data_len);
FIXME("Unexpected codec_data length; got %u, expected %lu\n", format->u.audio.codec_data_len, codec_data_len);
return true;
}
......@@ -454,7 +454,7 @@ unsigned int wg_format_get_max_size(const struct wg_format *format)
/* Estimated max size of a compressed audio frame.
* There's no way to no way to know the real upper bound,
* so let's just use one second of decompressed size and hope it works. */
return format->u.audio_wma.rate * format->u.audio_wma.channels * format->u.audio_wma.depth / 8;
return format->u.audio.rate * format->u.audio.channels * format->u.audio.depth / 8;
case WG_MAJOR_TYPE_AUDIO_MPEG4:
case WG_MAJOR_TYPE_VIDEO_H264:
......@@ -878,33 +878,33 @@ static bool amt_to_wg_format_audio_wma(const AM_MEDIA_TYPE *mt, struct wg_format
}
if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_MSAUDIO1))
format->u.audio_wma.version = 1;
format->u.audio.version = 1;
else if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_WMAUDIO2))
format->u.audio_wma.version = 2;
format->u.audio.version = 2;
else if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_WMAUDIO3))
format->u.audio_wma.version = 3;
format->u.audio.version = 3;
else if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_WMAUDIO_LOSSLESS))
format->u.audio_wma.version = 4;
format->u.audio.version = 4;
else
assert(false);
format->major_type = WG_MAJOR_TYPE_AUDIO_WMA;
format->u.audio_wma.bitrate = audio_format->nAvgBytesPerSec * 8;
format->u.audio_wma.rate = audio_format->nSamplesPerSec;
format->u.audio_wma.depth = audio_format->wBitsPerSample;
format->u.audio_wma.channels = audio_format->nChannels;
format->u.audio_wma.block_align = audio_format->nBlockAlign;
format->u.audio_wma.codec_data_len = 0;
if (format->u.audio_wma.version == 1)
format->u.audio_wma.codec_data_len = 4;
if (format->u.audio_wma.version == 2)
format->u.audio_wma.codec_data_len = 10;
if (format->u.audio_wma.version == 3)
format->u.audio_wma.codec_data_len = 18;
if (format->u.audio_wma.version == 4)
format->u.audio_wma.codec_data_len = 18;
if (mt->cbFormat >= sizeof(WAVEFORMATEX) + format->u.audio_wma.codec_data_len)
memcpy(format->u.audio_wma.codec_data, audio_format+1, format->u.audio_wma.codec_data_len);
format->u.audio.bitrate = audio_format->nAvgBytesPerSec * 8;
format->u.audio.rate = audio_format->nSamplesPerSec;
format->u.audio.depth = audio_format->wBitsPerSample;
format->u.audio.channels = audio_format->nChannels;
format->u.audio.block_align = audio_format->nBlockAlign;
format->u.audio.codec_data_len = 0;
if (format->u.audio.version == 1)
format->u.audio.codec_data_len = 4;
if (format->u.audio.version == 2)
format->u.audio.codec_data_len = 10;
if (format->u.audio.version == 3)
format->u.audio.codec_data_len = 18;
if (format->u.audio.version == 4)
format->u.audio.codec_data_len = 18;
if (mt->cbFormat >= sizeof(WAVEFORMATEX) + format->u.audio.codec_data_len)
memcpy(format->u.audio.codec_data, audio_format+1, format->u.audio.codec_data_len);
else
FIXME("Too small format block, can't copy codec data\n");
......
......@@ -99,7 +99,9 @@ struct wg_format
*
* Uncompressed(PCM): channels, channel_mask, rate.
* MPEG1: channels, rate, layer.
* MPEG4: payload_type, codec_data_len, codec_data. */
* MPEG4: payload_type, codec_data_len, codec_data.
* WMA: channels, rate, bitrate, depth, block_align, version, layer,
* payload_type, codec_data_len, codec_data */
struct
{
wg_audio_format format;
......@@ -107,22 +109,15 @@ struct wg_format
uint32_t channels;
uint32_t channel_mask; /* In WinMM format. */
uint32_t rate;
uint32_t layer;
uint32_t payload_type;
uint32_t codec_data_len;
unsigned char codec_data[64];
} audio;
struct
{
uint32_t version;
uint32_t bitrate;
uint32_t rate;
uint32_t depth;
uint32_t channels;
uint32_t block_align;
uint32_t version;
uint32_t layer;
uint32_t payload_type;
uint32_t codec_data_len;
unsigned char codec_data[64];
} audio_wma;
} audio;
struct
{
......
......@@ -247,18 +247,18 @@ static void wg_format_from_caps_audio_wma(struct wg_format *format, const GstCap
}
format->major_type = WG_MAJOR_TYPE_AUDIO_WMA;
format->u.audio_wma.version = version;
format->u.audio_wma.bitrate = bitrate;
format->u.audio_wma.rate = rate;
format->u.audio_wma.depth = depth;
format->u.audio_wma.channels = channels;
format->u.audio_wma.block_align = block_align;
format->u.audio.version = version;
format->u.audio.bitrate = bitrate;
format->u.audio.rate = rate;
format->u.audio.depth = depth;
format->u.audio.channels = channels;
format->u.audio.block_align = block_align;
gst_buffer_map(codec_data, &map, GST_MAP_READ);
if (map.size <= sizeof(format->u.audio_wma.codec_data))
if (map.size <= sizeof(format->u.audio.codec_data))
{
format->u.audio_wma.codec_data_len = map.size;
memcpy(format->u.audio_wma.codec_data, map.data, map.size);
format->u.audio.codec_data_len = map.size;
memcpy(format->u.audio.codec_data, map.data, map.size);
}
else
GST_WARNING("Too big codec_data value (%u) in %" GST_PTR_FORMAT ".", (UINT)map.size, caps);
......@@ -639,29 +639,29 @@ static GstCaps *wg_format_to_caps_audio_wma(const struct wg_format *format)
if (!(caps = gst_caps_new_empty_simple("audio/x-wma")))
return NULL;
if (format->u.audio_wma.version)
gst_caps_set_simple(caps, "wmaversion", G_TYPE_INT, format->u.audio_wma.version, NULL);
if (format->u.audio_wma.bitrate)
gst_caps_set_simple(caps, "bitrate", G_TYPE_INT, format->u.audio_wma.bitrate, NULL);
if (format->u.audio_wma.rate)
gst_caps_set_simple(caps, "rate", G_TYPE_INT, format->u.audio_wma.rate, NULL);
if (format->u.audio_wma.depth)
gst_caps_set_simple(caps, "depth", G_TYPE_INT, format->u.audio_wma.depth, NULL);
if (format->u.audio_wma.channels)
gst_caps_set_simple(caps, "channels", G_TYPE_INT, format->u.audio_wma.channels, NULL);
if (format->u.audio_wma.block_align)
gst_caps_set_simple(caps, "block_align", G_TYPE_INT, format->u.audio_wma.block_align, NULL);
if (format->u.audio_wma.codec_data_len)
{
if (!(buffer = gst_buffer_new_and_alloc(format->u.audio_wma.codec_data_len)))
if (format->u.audio.version)
gst_caps_set_simple(caps, "wmaversion", G_TYPE_INT, format->u.audio.version, NULL);
if (format->u.audio.bitrate)
gst_caps_set_simple(caps, "bitrate", G_TYPE_INT, format->u.audio.bitrate, NULL);
if (format->u.audio.rate)
gst_caps_set_simple(caps, "rate", G_TYPE_INT, format->u.audio.rate, NULL);
if (format->u.audio.depth)
gst_caps_set_simple(caps, "depth", G_TYPE_INT, format->u.audio.depth, NULL);
if (format->u.audio.channels)
gst_caps_set_simple(caps, "channels", G_TYPE_INT, format->u.audio.channels, NULL);
if (format->u.audio.block_align)
gst_caps_set_simple(caps, "block_align", G_TYPE_INT, format->u.audio.block_align, NULL);
if (format->u.audio.codec_data_len)
{
if (!(buffer = gst_buffer_new_and_alloc(format->u.audio.codec_data_len)))
{
gst_caps_unref(caps);
return NULL;
}
gst_buffer_fill(buffer, 0, format->u.audio_wma.codec_data, format->u.audio_wma.codec_data_len);
gst_buffer_fill(buffer, 0, format->u.audio.codec_data, format->u.audio.codec_data_len);
gst_caps_set_simple(caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
gst_buffer_unref(buffer);
}
......
......@@ -349,7 +349,7 @@ static GstCaps *transform_get_parsed_caps(struct wg_format *format, const char *
gst_caps_set_simple(parsed_caps, "framed", G_TYPE_BOOLEAN, true, "mpegversion", G_TYPE_INT, 4, NULL);
break;
case WG_MAJOR_TYPE_AUDIO_WMA:
gst_caps_set_simple(parsed_caps, "wmaversion", G_TYPE_INT, format->u.audio_wma.version, NULL);
gst_caps_set_simple(parsed_caps, "wmaversion", G_TYPE_INT, format->u.audio.version, NULL);
break;
case WG_MAJOR_TYPE_VIDEO_H264:
gst_caps_set_simple(parsed_caps, "parsed", G_TYPE_BOOLEAN, true, NULL);
......
......@@ -317,19 +317,19 @@ static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWOR
goto done;
if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS,
decoder->input_format.u.audio_wma.channels)))
decoder->input_format.u.audio.channels)))
goto done;
if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND,
decoder->input_format.u.audio_wma.rate)))
decoder->input_format.u.audio.rate)))
goto done;
block_alignment = sample_size * decoder->input_format.u.audio_wma.channels / 8;
block_alignment = sample_size * decoder->input_format.u.audio.channels / 8;
if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT,
block_alignment)))
goto done;
if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND,
decoder->input_format.u.audio_wma.rate * block_alignment)))
decoder->input_format.u.audio.rate * block_alignment)))
goto done;
if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1)))
......@@ -446,7 +446,7 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF
if (flags & MFT_SET_TYPE_TEST_ONLY)
return S_OK;
decoder->input_format.u.audio_wma.depth = sample_size;
decoder->input_format.u.audio.depth = sample_size;
mf_media_type_to_wg_format(type, &decoder->output_format);
decoder->output_buf_size = 1024 * block_alignment * channel_count;
......@@ -682,13 +682,13 @@ static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD inde
memset(type->pbFormat, 0, type->cbFormat);
wfx = (WAVEFORMATEX *)type->pbFormat;
if (decoder->input_format.u.audio_wma.depth == 32)
if (decoder->input_format.u.audio.depth == 32)
wfx->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
else
wfx->wFormatTag = WAVE_FORMAT_PCM;
wfx->nChannels = decoder->input_format.u.audio_wma.channels;
wfx->nSamplesPerSec = decoder->input_format.u.audio_wma.rate;
wfx->wBitsPerSample = decoder->input_format.u.audio_wma.depth;
wfx->nChannels = decoder->input_format.u.audio.channels;
wfx->nSamplesPerSec = decoder->input_format.u.audio.rate;
wfx->wBitsPerSample = decoder->input_format.u.audio.depth;
wfx->nAvgBytesPerSec = wfx->nChannels * wfx->nSamplesPerSec * wfx->wBitsPerSample / 8;
wfx->nBlockAlign = wfx->nChannels * wfx->wBitsPerSample / 8;
......
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