From: Rémi Bernon rbernon@codeweavers.com
Stripping the caps from the unwanted fields as needed. --- dlls/quartz/tests/mpegvideo.c | 9 ++-- dlls/winegstreamer/wg_transform.c | 80 +++++++++++++++++-------------- 2 files changed, 47 insertions(+), 42 deletions(-)
diff --git a/dlls/quartz/tests/mpegvideo.c b/dlls/quartz/tests/mpegvideo.c index 08c59e169fb..835bc5bec42 100644 --- a/dlls/quartz/tests/mpegvideo.c +++ b/dlls/quartz/tests/mpegvideo.c @@ -1201,7 +1201,7 @@ static void test_quality_control(IFilterGraph2 *graph, IBaseFilter *filter, testsource->qc = NULL; }
-static void test_send_sample(IMemInputPin *input, IMediaSample *sample, const BYTE *data, LONG len, BOOL todo) +static void test_send_sample(IMemInputPin *input, IMediaSample *sample, const BYTE *data, LONG len) { BYTE *target_data; HRESULT hr; @@ -1216,8 +1216,7 @@ static void test_send_sample(IMemInputPin *input, IMediaSample *sample, const BY ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMemInputPin_Receive(input, sample); - todo_wine_if(todo) /* 0xc00d6d61 is MF_E_TRANSFORM_STREAM_CHANGE */ - ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr); }
static void test_send_video(IMemInputPin *input, IMediaSample *sample) @@ -1248,8 +1247,8 @@ static void test_send_video(IMemInputPin *input, IMediaSample *sample) IPin *pin;
/* native won't emit anything until an unknown-sized internal buffer is filled, or EOS is announced */ - test_send_sample(input, sample, empty_mpg_frames, ARRAY_SIZE(empty_mpg_frames), TRUE); - test_send_sample(input, sample, empty_mpg_eos, ARRAY_SIZE(empty_mpg_eos), FALSE); + test_send_sample(input, sample, empty_mpg_frames, ARRAY_SIZE(empty_mpg_frames)); + test_send_sample(input, sample, empty_mpg_eos, ARRAY_SIZE(empty_mpg_eos));
hr = IMemInputPin_QueryInterface(input, &IID_IPin, (void **)&pin); ok(hr == S_OK, "Got hr %#lx.\n", hr); diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index d85da3d7633..ec08f1322c0 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -56,7 +56,6 @@ struct wg_transform bool input_is_flipped; GstElement *video_flip;
- struct wg_format output_format; GstAtomicQueue *output_queue; GstSample *output_sample; bool output_caps_changed; @@ -96,7 +95,7 @@ static GstFlowReturn transform_sink_chain_cb(GstPad *pad, GstObject *parent, Gst return GST_FLOW_ERROR; }
- if (transform->output_caps_changed) + if (transform->output_caps_changed && transform->attrs.allow_size_change) GST_MINI_OBJECT_FLAG_SET(sample, GST_SAMPLE_FLAG_WG_CAPS_CHANGED); transform->output_caps_changed = false;
@@ -188,28 +187,53 @@ static gboolean transform_sink_query_allocation(struct wg_transform *transform, return true; }
-static GstCaps *transform_format_to_caps(struct wg_transform *transform, const struct wg_format *format) +static void caps_remove_field(GstCaps *caps, const char *field) { - struct wg_format copy = *format; + guint i;
- if (format->major_type == WG_MAJOR_TYPE_VIDEO) + for (i = 0; i < gst_caps_get_size(caps); ++i) { - if (transform->attrs.allow_size_change) - copy.u.video.width = copy.u.video.height = 0; - copy.u.video.fps_n = copy.u.video.fps_d = 0; + GstStructure *structure = gst_caps_get_structure(caps, i); + gst_structure_remove_fields(structure, field, NULL); } +} + +static GstCaps *caps_strip_fields(GstCaps *caps, bool strip_size) +{ + if (stream_type_from_caps(caps) != GST_STREAM_TYPE_VIDEO) + return gst_caps_ref(caps); + + if ((caps = gst_caps_copy(caps))) + { + if (strip_size) + { + caps_remove_field(caps, "width"); + caps_remove_field(caps, "height"); + }
- return wg_format_to_caps(©); + /* strip fields which we do not support and could cause pipeline failure or spurious format changes */ + caps_remove_field(caps, "framerate"); + caps_remove_field(caps, "colorimetry"); + caps_remove_field(caps, "chroma-site"); + caps_remove_field(caps, "interlace-mode"); + caps_remove_field(caps, "pixel-aspect-ratio"); + } + + return caps; }
static gboolean transform_sink_query_caps(struct wg_transform *transform, GstQuery *query) { GstCaps *caps, *filter, *temp; + bool strip_size = false;
GST_LOG("transform %p, %"GST_PTR_FORMAT, transform, query);
gst_query_parse_caps(query, &filter); - if (!(caps = transform_format_to_caps(transform, &transform->output_format))) + if (filter && gst_structure_has_field(gst_caps_get_structure(filter, 0), "width")) + strip_size = transform->attrs.allow_size_change; + + if (!(caps = caps_strip_fields(transform->output_caps, strip_size))) return false;
if (filter) @@ -248,23 +272,6 @@ static gboolean transform_sink_query_cb(GstPad *pad, GstObject *parent, GstQuery return gst_pad_query_default(pad, parent, query); }
-static gboolean transform_output_caps_is_compatible(struct wg_transform *transform, GstCaps *caps) -{ - GstCaps *copy = gst_caps_copy(caps); - gboolean ret; - gsize i; - - for (i = 0; i < gst_caps_get_size(copy); ++i) - { - GstStructure *structure = gst_caps_get_structure(copy, i); - gst_structure_remove_fields(structure, "framerate", NULL); - } - - ret = gst_caps_is_always_compatible(transform->output_caps, copy); - gst_caps_unref(copy); - return ret; -} - static void transform_sink_event_caps(struct wg_transform *transform, GstEvent *event) { GstCaps *caps; @@ -273,9 +280,7 @@ static void transform_sink_event_caps(struct wg_transform *transform, GstEvent *
gst_event_parse_caps(event, &caps);
- transform->output_caps_changed = transform->output_caps_changed - || !transform_output_caps_is_compatible(transform, caps); - + transform->output_caps_changed = true; gst_caps_unref(transform->output_caps); transform->output_caps = gst_caps_ref(caps); } @@ -411,9 +416,8 @@ NTSTATUS wg_transform_create(void *args) if (!(transform->allocator = wg_allocator_create())) goto out; transform->attrs = *params->attrs; - transform->output_format = output_format;
- if (!(src_caps = transform_format_to_caps(transform, &input_format))) + if (!(src_caps = wg_format_to_caps(&input_format))) goto out; if (!(template = gst_pad_template_new("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps))) goto out; @@ -427,7 +431,7 @@ NTSTATUS wg_transform_create(void *args) gst_pad_set_element_private(transform->my_src, transform); gst_pad_set_query_function(transform->my_src, transform_src_query_cb);
- if (!(transform->output_caps = transform_format_to_caps(transform, &output_format))) + if (!(transform->output_caps = wg_format_to_caps(&output_format))) goto out; if (!(template = gst_pad_template_new("sink", GST_PAD_SINK, GST_PAD_ALWAYS, transform->output_caps))) goto out; @@ -610,23 +614,25 @@ NTSTATUS wg_transform_set_output_format(void *args) struct wg_transform_set_output_format_params *params = args; struct wg_transform *transform = get_transform(params->transform); const struct wg_format *format = params->format; + GstCaps *caps, *stripped; GstSample *sample; - GstCaps *caps;
- if (!(caps = transform_format_to_caps(transform, format))) + if (!(caps = wg_format_to_caps(format))) { GST_ERROR("Failed to convert format %p to caps.", format); return STATUS_UNSUCCESSFUL; } - transform->output_format = *format;
GST_INFO("transform %p output caps %"GST_PTR_FORMAT, transform, caps);
- if (transform_output_caps_is_compatible(transform, caps)) + stripped = caps_strip_fields(caps, transform->attrs.allow_size_change); + if (gst_caps_is_always_compatible(transform->output_caps, stripped)) { + gst_caps_unref(stripped); gst_caps_unref(caps); return STATUS_SUCCESS; } + gst_caps_unref(stripped);
if (!gst_pad_peer_query(transform->my_src, transform->drain_query)) {