mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 20:42:30 +00:00
Simplify gst_vaapidecode_set_caps() and fix memory leak.
This commit is contained in:
parent
6f5e593abd
commit
710ab89fca
1 changed files with 10 additions and 13 deletions
|
@ -334,19 +334,17 @@ static gboolean
|
||||||
gst_vaapidecode_set_caps(GstPad *pad, GstCaps *caps)
|
gst_vaapidecode_set_caps(GstPad *pad, GstCaps *caps)
|
||||||
{
|
{
|
||||||
GstVaapiDecode * const decode = GST_VAAPIDECODE(GST_OBJECT_PARENT(pad));
|
GstVaapiDecode * const decode = GST_VAAPIDECODE(GST_OBJECT_PARENT(pad));
|
||||||
GstPad *other_pad;
|
|
||||||
GstCaps *other_caps = NULL;
|
GstCaps *other_caps = NULL;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
const GValue *v_width, *v_height, *v_framerate, *v_par;
|
const GValue *v_width, *v_height, *v_framerate, *v_par;
|
||||||
|
gboolean success;
|
||||||
|
|
||||||
if (pad == decode->sinkpad) {
|
g_return_val_if_fail(pad == decode->sinkpad, FALSE);
|
||||||
other_pad = decode->srcpad;
|
decode->decoder_caps = gst_caps_ref(caps);
|
||||||
other_caps = gst_caps_from_string(gst_vaapidecode_src_caps_str);
|
|
||||||
}
|
other_caps = gst_caps_from_string(gst_vaapidecode_src_caps_str);
|
||||||
else {
|
if (!other_caps)
|
||||||
other_pad = decode->sinkpad;
|
return FALSE;
|
||||||
other_caps = gst_caps_from_string(gst_vaapidecode_sink_caps_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Negotiation succeeded, so now configure ourselves */
|
/* Negotiation succeeded, so now configure ourselves */
|
||||||
structure = gst_caps_get_structure(caps, 0);
|
structure = gst_caps_get_structure(caps, 0);
|
||||||
|
@ -355,9 +353,6 @@ gst_vaapidecode_set_caps(GstPad *pad, GstCaps *caps)
|
||||||
v_framerate = gst_structure_get_value(structure, "framerate");
|
v_framerate = gst_structure_get_value(structure, "framerate");
|
||||||
v_par = gst_structure_get_value(structure, "pixel-aspect-ratio");
|
v_par = gst_structure_get_value(structure, "pixel-aspect-ratio");
|
||||||
|
|
||||||
if (pad == decode->sinkpad)
|
|
||||||
decode->decoder_caps = gst_caps_ref(caps);
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure(other_caps, 0);
|
structure = gst_caps_get_structure(other_caps, 0);
|
||||||
gst_structure_set_value(structure, "width", v_width);
|
gst_structure_set_value(structure, "width", v_width);
|
||||||
gst_structure_set_value(structure, "height", v_height);
|
gst_structure_set_value(structure, "height", v_height);
|
||||||
|
@ -366,7 +361,9 @@ gst_vaapidecode_set_caps(GstPad *pad, GstCaps *caps)
|
||||||
if (v_par)
|
if (v_par)
|
||||||
gst_structure_set_value(structure, "pixel-aspect-ratio", v_par);
|
gst_structure_set_value(structure, "pixel-aspect-ratio", v_par);
|
||||||
|
|
||||||
return gst_pad_set_caps(other_pad, other_caps);
|
success = gst_pad_set_caps(decode->srcpad, other_caps);
|
||||||
|
gst_caps_unref(other_caps);
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
|
Loading…
Reference in a new issue