Commit 240aff38 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Introduce new wg_transform_(push|read)_mf helpers.

To read MF sample properties before pushing, and update them after sucessfully reading a sample. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com>
parent f256979b
......@@ -123,6 +123,10 @@ void mf_media_type_to_wg_format(IMFMediaType *type, struct wg_format *format);
HRESULT mf_create_wg_sample(IMFSample *sample, struct wg_sample **out);
void mf_destroy_wg_sample(struct wg_sample *wg_sample);
HRESULT wg_transform_push_mf(struct wg_transform *transform, struct wg_sample *sample);
HRESULT wg_transform_read_mf(struct wg_transform *transform, struct wg_sample *sample,
struct wg_format *format);
HRESULT winegstreamer_stream_handler_create(REFIID riid, void **obj);
HRESULT h264_decoder_create(REFIID riid, void **ret);
......
......@@ -543,8 +543,7 @@ static HRESULT WINAPI transform_ProcessInput(IMFTransform *iface, DWORD id, IMFS
if (FAILED(hr = mf_create_wg_sample(sample, &wg_sample)))
return hr;
hr = wg_transform_push_data(decoder->wg_transform, wg_sample);
hr = wg_transform_push_mf(decoder->wg_transform, wg_sample);
mf_destroy_wg_sample(wg_sample);
return hr;
}
......@@ -583,8 +582,7 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
return MF_E_BUFFERTOOSMALL;
}
hr = wg_transform_read_data(decoder->wg_transform, wg_sample,
&wg_format);
hr = wg_transform_read_mf(decoder->wg_transform, wg_sample, &wg_format);
mf_destroy_wg_sample(wg_sample);
if (hr == MF_E_TRANSFORM_STREAM_CHANGE)
......
......@@ -969,8 +969,6 @@ HRESULT mf_create_wg_sample(IMFSample *sample, struct wg_sample **out)
{
DWORD current_length, max_length;
struct mf_sample *mf_sample;
LONGLONG time, duration;
UINT32 value;
BYTE *buffer;
HRESULT hr;
......@@ -981,19 +979,6 @@ HRESULT mf_create_wg_sample(IMFSample *sample, struct wg_sample **out)
if (FAILED(hr = IMFMediaBuffer_Lock(mf_sample->media_buffer, &buffer, &max_length, &current_length)))
goto out;
if (SUCCEEDED(IMFSample_GetSampleTime(sample, &time)))
{
mf_sample->wg_sample.flags |= WG_SAMPLE_FLAG_HAS_PTS;
mf_sample->wg_sample.pts = time;
}
if (SUCCEEDED(IMFSample_GetSampleDuration(sample, &duration)))
{
mf_sample->wg_sample.flags |= WG_SAMPLE_FLAG_HAS_DURATION;
mf_sample->wg_sample.duration = duration;
}
if (SUCCEEDED(IMFSample_GetUINT32(sample, &MFSampleExtension_CleanPoint, &value)) && value)
mf_sample->wg_sample.flags |= WG_SAMPLE_FLAG_SYNC_POINT;
IMFSample_AddRef((mf_sample->sample = sample));
mf_sample->wg_sample.data = buffer;
mf_sample->wg_sample.size = current_length;
......@@ -1015,8 +1000,43 @@ void mf_destroy_wg_sample(struct wg_sample *wg_sample)
struct mf_sample *mf_sample = CONTAINING_RECORD(wg_sample, struct mf_sample, wg_sample);
IMFMediaBuffer_Unlock(mf_sample->media_buffer);
IMFMediaBuffer_SetCurrentLength(mf_sample->media_buffer, wg_sample->size);
IMFMediaBuffer_Release(mf_sample->media_buffer);
IMFSample_Release(mf_sample->sample);
free(mf_sample);
}
HRESULT wg_transform_push_mf(struct wg_transform *transform, struct wg_sample *sample)
{
struct mf_sample *mf_sample = CONTAINING_RECORD(sample, struct mf_sample, wg_sample);
LONGLONG time, duration;
UINT32 value;
if (SUCCEEDED(IMFSample_GetSampleTime(mf_sample->sample, &time)))
{
mf_sample->wg_sample.flags |= WG_SAMPLE_FLAG_HAS_PTS;
mf_sample->wg_sample.pts = time;
}
if (SUCCEEDED(IMFSample_GetSampleDuration(mf_sample->sample, &duration)))
{
mf_sample->wg_sample.flags |= WG_SAMPLE_FLAG_HAS_DURATION;
mf_sample->wg_sample.duration = duration;
}
if (SUCCEEDED(IMFSample_GetUINT32(mf_sample->sample, &MFSampleExtension_CleanPoint, &value)) && value)
mf_sample->wg_sample.flags |= WG_SAMPLE_FLAG_SYNC_POINT;
return wg_transform_push_data(transform, sample);
}
HRESULT wg_transform_read_mf(struct wg_transform *transform, struct wg_sample *wg_sample,
struct wg_format *format)
{
struct mf_sample *mf_sample = CONTAINING_RECORD(wg_sample, struct mf_sample, wg_sample);
HRESULT hr;
if (FAILED(hr = wg_transform_read_data(transform, wg_sample, format)))
return hr;
IMFMediaBuffer_SetCurrentLength(mf_sample->media_buffer, wg_sample->size);
if (wg_sample->flags & WG_SAMPLE_FLAG_HAS_PTS)
IMFSample_SetSampleTime(mf_sample->sample, wg_sample->pts);
......@@ -1025,6 +1045,5 @@ void mf_destroy_wg_sample(struct wg_sample *wg_sample)
if (wg_sample->flags & WG_SAMPLE_FLAG_SYNC_POINT)
IMFSample_SetUINT32(mf_sample->sample, &MFSampleExtension_CleanPoint, 1);
IMFSample_Release(mf_sample->sample);
free(mf_sample);
return S_OK;
}
......@@ -544,7 +544,7 @@ static HRESULT WINAPI transform_ProcessInput(IMFTransform *iface, DWORD id, IMFS
return S_OK;
}
hr = wg_transform_push_data(decoder->wg_transform, wg_sample);
hr = wg_transform_push_mf(decoder->wg_transform, wg_sample);
mf_destroy_wg_sample(wg_sample);
return hr;
}
......@@ -586,7 +586,7 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
return MF_E_BUFFERTOOSMALL;
}
if (SUCCEEDED(hr = wg_transform_read_data(decoder->wg_transform, wg_sample, NULL)))
if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, wg_sample, NULL)))
{
if (wg_sample->flags & WG_SAMPLE_FLAG_INCOMPLETE)
samples[0].dwStatus |= MFT_OUTPUT_DATA_BUFFER_INCOMPLETE;
......
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