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

winegstreamer: Create wg_sample from IMFSample within of wg_transform_read_mf.

parent 4845d46d
......@@ -545,7 +545,6 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
{
struct color_convert *impl = impl_from_IMFTransform(iface);
MFT_OUTPUT_STREAM_INFO info;
struct wg_sample *wg_sample;
HRESULT hr;
TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface, flags, count, samples, status);
......@@ -563,21 +562,10 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info)))
return hr;
if (FAILED(hr = wg_sample_create_mf(samples[0].pSample, &wg_sample)))
return hr;
if (wg_sample->max_size < info.cbSize)
{
wg_sample_release(wg_sample);
return MF_E_BUFFERTOOSMALL;
}
if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, wg_sample, NULL,
&samples[0].dwStatus)))
if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, samples->pSample,
info.cbSize, NULL, &samples->dwStatus)))
wg_sample_queue_flush(impl->wg_sample_queue, false);
wg_sample_release(wg_sample);
return hr;
}
......
......@@ -134,8 +134,8 @@ HRESULT wg_transform_push_mf(struct wg_transform *transform, IMFSample *sample,
struct wg_sample_queue *queue);
HRESULT wg_transform_push_quartz(struct wg_transform *transform, struct wg_sample *sample,
struct wg_sample_queue *queue);
HRESULT wg_transform_read_mf(struct wg_transform *transform, struct wg_sample *sample,
struct wg_format *format, DWORD *flags);
HRESULT wg_transform_read_mf(struct wg_transform *transform, IMFSample *sample,
DWORD sample_size, struct wg_format *format, DWORD *flags);
HRESULT wg_transform_read_quartz(struct wg_transform *transform, struct wg_sample *sample);
HRESULT winegstreamer_stream_handler_create(REFIID riid, void **obj);
......
......@@ -592,7 +592,6 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status)
{
struct h264_decoder *decoder = impl_from_IMFTransform(iface);
struct wg_sample *wg_sample;
struct wg_format wg_format;
UINT32 sample_size;
UINT64 frame_rate;
......@@ -617,21 +616,10 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
decoder->wg_format.u.video.height, &sample_size)))
return hr;
if (FAILED(hr = wg_sample_create_mf(samples[0].pSample, &wg_sample)))
return hr;
if (wg_sample->max_size < sample_size)
{
wg_sample_release(wg_sample);
return MF_E_BUFFERTOOSMALL;
}
if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, wg_sample, &wg_format,
&samples[0].dwStatus)))
if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, samples->pSample,
sample_size, &wg_format, &samples->dwStatus)))
wg_sample_queue_flush(decoder->wg_sample_queue, false);
wg_sample_release(wg_sample);
if (hr == MF_E_TRANSFORM_STREAM_CHANGE)
{
decoder->wg_format = wg_format;
......
......@@ -526,7 +526,6 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
{
struct resampler *impl = impl_from_IMFTransform(iface);
MFT_OUTPUT_STREAM_INFO info;
struct wg_sample *wg_sample;
HRESULT hr;
TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface, flags, count, samples, status);
......@@ -547,22 +546,10 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info)))
return hr;
if (FAILED(hr = wg_sample_create_mf(samples[0].pSample, &wg_sample)))
return hr;
wg_sample->size = 0;
if (wg_sample->max_size < info.cbSize)
{
wg_sample_release(wg_sample);
return MF_E_BUFFERTOOSMALL;
}
if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, wg_sample, NULL,
&samples[0].dwStatus)))
if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, samples->pSample,
info.cbSize, NULL, &samples->dwStatus)))
wg_sample_queue_flush(impl->wg_sample_queue, false);
wg_sample_release(wg_sample);
return hr;
}
......
......@@ -526,7 +526,6 @@ static HRESULT WINAPI video_processor_ProcessOutput(IMFTransform *iface, DWORD f
{
struct video_processor *impl = impl_from_IMFTransform(iface);
MFT_OUTPUT_STREAM_INFO info;
struct wg_sample *wg_sample;
HRESULT hr;
TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface, flags, count, samples, status);
......@@ -544,21 +543,10 @@ static HRESULT WINAPI video_processor_ProcessOutput(IMFTransform *iface, DWORD f
if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info)))
return hr;
if (FAILED(hr = wg_sample_create_mf(samples[0].pSample, &wg_sample)))
return hr;
if (wg_sample->max_size < info.cbSize)
{
wg_sample_release(wg_sample);
return MF_E_BUFFERTOOSMALL;
}
if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, wg_sample, NULL,
&samples[0].dwStatus)))
if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, samples->pSample,
info.cbSize, NULL, &samples->dwStatus)))
wg_sample_queue_flush(impl->wg_sample_queue, false);
wg_sample_release(wg_sample);
return hr;
}
......
......@@ -285,34 +285,50 @@ HRESULT wg_transform_push_mf(struct wg_transform *transform, IMFSample *sample,
return hr;
}
HRESULT wg_transform_read_mf(struct wg_transform *transform, struct wg_sample *wg_sample,
struct wg_format *format, DWORD *flags)
HRESULT wg_transform_read_mf(struct wg_transform *transform, IMFSample *sample,
DWORD sample_size, struct wg_format *format, DWORD *flags)
{
struct sample *sample = unsafe_mf_from_wg_sample(wg_sample);
struct wg_sample *wg_sample;
IMFMediaBuffer *buffer;
HRESULT hr;
TRACE_(mfplat)("transform %p, wg_sample %p, format %p, flags %p.\n", transform, wg_sample, format, flags);
TRACE_(mfplat)("transform %p, sample %p, format %p, flags %p.\n", transform, sample, format, flags);
if (FAILED(hr = wg_sample_create_mf(sample, &wg_sample)))
return hr;
wg_sample->size = 0;
if (wg_sample->max_size < sample_size)
{
wg_sample_release(wg_sample);
return MF_E_BUFFERTOOSMALL;
}
if (FAILED(hr = wg_transform_read_data(transform, wg_sample, format)))
{
if (hr == MF_E_TRANSFORM_STREAM_CHANGE && !format)
FIXME("Unexpected stream format change!\n");
wg_sample_release(wg_sample);
return hr;
}
if (FAILED(hr = IMFMediaBuffer_SetCurrentLength(sample->u.mf.buffer, wg_sample->size)))
return hr;
if (wg_sample->flags & WG_SAMPLE_FLAG_INCOMPLETE)
*flags |= MFT_OUTPUT_DATA_BUFFER_INCOMPLETE;
if (wg_sample->flags & WG_SAMPLE_FLAG_HAS_PTS)
IMFSample_SetSampleTime(sample->u.mf.sample, wg_sample->pts);
IMFSample_SetSampleTime(sample, wg_sample->pts);
if (wg_sample->flags & WG_SAMPLE_FLAG_HAS_DURATION)
IMFSample_SetSampleDuration(sample->u.mf.sample, wg_sample->duration);
IMFSample_SetSampleDuration(sample, wg_sample->duration);
if (wg_sample->flags & WG_SAMPLE_FLAG_SYNC_POINT)
IMFSample_SetUINT32(sample->u.mf.sample, &MFSampleExtension_CleanPoint, 1);
IMFSample_SetUINT32(sample, &MFSampleExtension_CleanPoint, 1);
return S_OK;
if (SUCCEEDED(hr = IMFSample_ConvertToContiguousBuffer(sample, &buffer)))
{
hr = IMFMediaBuffer_SetCurrentLength(buffer, wg_sample->size);
IMFMediaBuffer_Release(buffer);
}
wg_sample_release(wg_sample);
return hr;
}
HRESULT wg_transform_push_quartz(struct wg_transform *transform, struct wg_sample *wg_sample,
......
......@@ -548,7 +548,6 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
{
struct wma_decoder *decoder = impl_from_IMFTransform(iface);
MFT_OUTPUT_STREAM_INFO info;
struct wg_sample *wg_sample;
HRESULT hr;
TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface, flags, count, samples, status);
......@@ -569,22 +568,10 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags,
if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info)))
return hr;
if (FAILED(hr = wg_sample_create_mf(samples[0].pSample, &wg_sample)))
return hr;
wg_sample->size = 0;
if (wg_sample->max_size < info.cbSize)
{
wg_sample_release(wg_sample);
return MF_E_BUFFERTOOSMALL;
}
if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, wg_sample, NULL,
&samples[0].dwStatus)))
if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, samples->pSample,
info.cbSize, NULL, &samples->dwStatus)))
wg_sample_queue_flush(decoder->wg_sample_queue, false);
wg_sample_release(wg_sample);
return hr;
}
......
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