h263parse: allocate H263Params struct on the stack

It's flat and not kept around for longer.
This commit is contained in:
Tim-Philipp Müller 2011-03-03 00:57:09 +00:00
parent 88cd418bc9
commit e9b29e9dc7
3 changed files with 9 additions and 15 deletions

View File

@ -179,7 +179,8 @@ out:
} }
static void static void
gst_h263_parse_set_src_caps (GstH263Parse * h263parse, H263Params * params) gst_h263_parse_set_src_caps (GstH263Parse * h263parse,
const H263Params * params)
{ {
GstStructure *st; GstStructure *st;
GstCaps *caps, *sink_caps; GstCaps *caps, *sink_caps;
@ -283,7 +284,7 @@ gst_h263_parse_check_valid_frame (GstBaseParse * parse,
/* If this is the first frame, parse and set srcpad caps */ /* If this is the first frame, parse and set srcpad caps */
if (h263parse->state == PARSING) { if (h263parse->state == PARSING) {
H263Params *params = NULL; H263Params params = { 0, };
GstFlowReturn res; GstFlowReturn res;
res = gst_h263_parse_get_params (&params, buffer, FALSE, &h263parse->state); res = gst_h263_parse_get_params (&params, buffer, FALSE, &h263parse->state);
@ -293,11 +294,8 @@ gst_h263_parse_check_valid_frame (GstBaseParse * parse,
GST_BASE_PARSE_FORMAT_PASSTHROUGH, TRUE); GST_BASE_PARSE_FORMAT_PASSTHROUGH, TRUE);
} else { } else {
/* Set srcpad caps since we now have sufficient information to do so */ /* Set srcpad caps since we now have sufficient information to do so */
gst_h263_parse_set_src_caps (h263parse, params); gst_h263_parse_set_src_caps (h263parse, &params);
} }
if (params)
g_free (params);
} }
*skipsize = psc_pos; *skipsize = psc_pos;
@ -325,7 +323,7 @@ gst_h263_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
GstH263Parse *h263parse; GstH263Parse *h263parse;
GstBuffer *buffer; GstBuffer *buffer;
GstFlowReturn res; GstFlowReturn res;
H263Params *params = NULL; H263Params params = { 0, };
h263parse = GST_H263_PARSE (parse); h263parse = GST_H263_PARSE (parse);
buffer = frame->buffer; buffer = frame->buffer;
@ -348,12 +346,12 @@ gst_h263_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
gst_buffer_set_caps (buffer, gst_buffer_set_caps (buffer,
GST_PAD_CAPS (GST_BASE_PARSE_SRC_PAD (GST_BASE_PARSE (h263parse)))); GST_PAD_CAPS (GST_BASE_PARSE_SRC_PAD (GST_BASE_PARSE (h263parse))));
if (gst_h263_parse_is_delta_unit (params)) if (gst_h263_parse_is_delta_unit (&params))
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DELTA_UNIT); GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
else else
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT); GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
out: out:
g_free (params);
return res; return res;
} }

View File

@ -40,7 +40,7 @@ gst_h263_parse_is_delta_unit (const H263Params * params)
* extract a subset of the data (for now, it quits once we have the picture * extract a subset of the data (for now, it quits once we have the picture
* type. */ * type. */
GstFlowReturn GstFlowReturn
gst_h263_parse_get_params (H263Params ** params_p, GstBuffer * buffer, gst_h263_parse_get_params (H263Params * params, GstBuffer * buffer,
gboolean fast, H263ParseState * state) gboolean fast, H263ParseState * state)
{ {
static const guint8 partable[6][2] = { static const guint8 partable[6][2] = {
@ -72,16 +72,12 @@ gst_h263_parse_get_params (H263Params ** params_p, GstBuffer * buffer,
"Extended PType" "Extended PType"
}; };
H263Params *params;
GstBitReader br; GstBitReader br;
guint8 tr; guint8 tr;
guint32 psc, temp32; guint32 psc, temp32;
guint8 temp8, pquant; guint8 temp8, pquant;
gboolean hasplusptype; gboolean hasplusptype;
*params_p = g_new0 (H263Params, 1);
params = *params_p;
/* FIXME: we can optimise a little by checking the value of available /* FIXME: we can optimise a little by checking the value of available
* instead of calling using the bit reader's get_bits_* functions. */ * instead of calling using the bit reader's get_bits_* functions. */
gst_bit_reader_init_from_buffer (&br, buffer); gst_bit_reader_init_from_buffer (&br, buffer);

View File

@ -133,7 +133,7 @@ struct _H263Params
gboolean gst_h263_parse_is_delta_unit (const H263Params * params); gboolean gst_h263_parse_is_delta_unit (const H263Params * params);
GstFlowReturn gst_h263_parse_get_params (H263Params ** params_p, GstFlowReturn gst_h263_parse_get_params (H263Params * params_p,
GstBuffer * buffer, GstBuffer * buffer,
gboolean fast, gboolean fast,
H263ParseState * state); H263ParseState * state);