mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-21 22:34:10 +00:00
winegstreamer: Don't pre-check sample size in wg_transform_read_mf().
This commit is contained in:
parent
4d1a331c66
commit
596dfad38b
|
@ -4133,7 +4133,6 @@ static void test_h264_decoder_concat_streams(void)
|
|||
{
|
||||
MFT_OUTPUT_DATA_BUFFER data = {.pSample = create_sample(NULL, 1)};
|
||||
hr = IMFTransform_ProcessOutput(transform, 0, 1, &data, &output_status);
|
||||
todo_wine
|
||||
ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#lx\n", hr);
|
||||
IMFSample_Release(data.pSample);
|
||||
hr = S_OK;
|
||||
|
|
|
@ -358,11 +358,6 @@ HRESULT wg_transform_read_mf(struct wg_transform *transform, IMFSample *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)))
|
||||
{
|
||||
|
|
|
@ -594,19 +594,19 @@ NTSTATUS wg_transform_push_data(void *args)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static bool copy_video_buffer(GstBuffer *buffer, GstCaps *caps, gsize plane_align,
|
||||
static NTSTATUS copy_video_buffer(GstBuffer *buffer, GstCaps *caps, gsize plane_align,
|
||||
struct wg_sample *sample, gsize *total_size)
|
||||
{
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
GstVideoFrame src_frame, dst_frame;
|
||||
GstVideoInfo src_info, dst_info;
|
||||
GstVideoAlignment align;
|
||||
GstBuffer *dst_buffer;
|
||||
bool ret = false;
|
||||
|
||||
if (!gst_video_info_from_caps(&src_info, caps))
|
||||
{
|
||||
GST_ERROR("Failed to get video info from caps.");
|
||||
return false;
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
dst_info = src_info;
|
||||
|
@ -615,14 +615,14 @@ static bool copy_video_buffer(GstBuffer *buffer, GstCaps *caps, gsize plane_alig
|
|||
if (sample->max_size < dst_info.size)
|
||||
{
|
||||
GST_ERROR("Output buffer is too small.");
|
||||
return false;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
if (!(dst_buffer = gst_buffer_new_wrapped_full(0, sample->data, sample->max_size,
|
||||
0, sample->max_size, 0, NULL)))
|
||||
{
|
||||
GST_ERROR("Failed to wrap wg_sample into GstBuffer");
|
||||
return false;
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
gst_buffer_set_size(dst_buffer, dst_info.size);
|
||||
*total_size = sample->size = dst_info.size;
|
||||
|
@ -635,7 +635,9 @@ static bool copy_video_buffer(GstBuffer *buffer, GstCaps *caps, gsize plane_alig
|
|||
GST_ERROR("Failed to map destination frame.");
|
||||
else
|
||||
{
|
||||
if (!(ret = gst_video_frame_copy(&dst_frame, &src_frame)))
|
||||
if (gst_video_frame_copy(&dst_frame, &src_frame))
|
||||
status = STATUS_SUCCESS;
|
||||
else
|
||||
GST_ERROR("Failed to copy video frame.");
|
||||
gst_video_frame_unmap(&dst_frame);
|
||||
}
|
||||
|
@ -643,16 +645,16 @@ static bool copy_video_buffer(GstBuffer *buffer, GstCaps *caps, gsize plane_alig
|
|||
}
|
||||
|
||||
gst_buffer_unref(dst_buffer);
|
||||
return ret;
|
||||
return status;
|
||||
}
|
||||
|
||||
static bool copy_buffer(GstBuffer *buffer, GstCaps *caps, struct wg_sample *sample,
|
||||
static NTSTATUS copy_buffer(GstBuffer *buffer, GstCaps *caps, struct wg_sample *sample,
|
||||
gsize *total_size)
|
||||
{
|
||||
GstMapInfo info;
|
||||
|
||||
if (!gst_buffer_map(buffer, &info, GST_MAP_READ))
|
||||
return false;
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
|
||||
if (sample->max_size >= info.size)
|
||||
sample->size = info.size;
|
||||
|
@ -669,14 +671,15 @@ static bool copy_buffer(GstBuffer *buffer, GstCaps *caps, struct wg_sample *samp
|
|||
gst_buffer_resize(buffer, sample->size, -1);
|
||||
|
||||
*total_size = info.size;
|
||||
return true;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS read_transform_output_data(GstBuffer *buffer, GstCaps *caps, gsize plane_align,
|
||||
struct wg_sample *sample)
|
||||
{
|
||||
bool ret, needs_copy;
|
||||
gsize total_size;
|
||||
bool needs_copy;
|
||||
NTSTATUS status;
|
||||
GstMapInfo info;
|
||||
|
||||
if (!gst_buffer_map(buffer, &info, GST_MAP_READ))
|
||||
|
@ -686,20 +689,21 @@ static NTSTATUS read_transform_output_data(GstBuffer *buffer, GstCaps *caps, gsi
|
|||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
needs_copy = info.data != sample->data;
|
||||
total_size = sample->size = info.size;
|
||||
gst_buffer_unmap(buffer, &info);
|
||||
|
||||
if ((ret = !needs_copy))
|
||||
total_size = sample->size = info.size;
|
||||
if (!needs_copy)
|
||||
status = STATUS_SUCCESS;
|
||||
else if (stream_type_from_caps(caps) == GST_STREAM_TYPE_VIDEO)
|
||||
ret = copy_video_buffer(buffer, caps, plane_align, sample, &total_size);
|
||||
status = copy_video_buffer(buffer, caps, plane_align, sample, &total_size);
|
||||
else
|
||||
ret = copy_buffer(buffer, caps, sample, &total_size);
|
||||
status = copy_buffer(buffer, caps, sample, &total_size);
|
||||
|
||||
if (!ret)
|
||||
if (status)
|
||||
{
|
||||
GST_ERROR("Failed to copy buffer %p", buffer);
|
||||
sample->size = 0;
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
return status;
|
||||
}
|
||||
|
||||
if (GST_BUFFER_PTS_IS_VALID(buffer))
|
||||
|
|
Loading…
Reference in a new issue