deinterlace2: Move output buffer from the instance struct to a function parameter

This commit is contained in:
Sebastian Dröge 2009-04-15 15:46:44 +02:00
parent b66a6f90be
commit e539615c79
5 changed files with 29 additions and 37 deletions

View file

@ -72,11 +72,11 @@ gst_deinterlace_method_init (GstDeinterlaceMethod * self)
static void
gst_deinterlace_method_deinterlace_frame (GstDeinterlaceMethod * self,
GstDeinterlace2 * parent)
GstDeinterlace2 * parent, GstBuffer * outbuf)
{
GstDeinterlaceMethodClass *klass = GST_DEINTERLACE_METHOD_GET_CLASS (self);
klass->deinterlace_frame (self, parent);
klass->deinterlace_frame (self, parent, outbuf);
}
static gint
@ -117,13 +117,13 @@ gst_deinterlace_simple_method_copy_scanline (GstDeinterlaceMethod * self,
static void
gst_deinterlace_simple_method_deinterlace_frame (GstDeinterlaceMethod * self,
GstDeinterlace2 * parent)
GstDeinterlace2 * parent, GstBuffer * outbuf)
{
GstDeinterlaceSimpleMethodClass *dsm_class =
GST_DEINTERLACE_SIMPLE_METHOD_GET_CLASS (self);
GstDeinterlaceMethodClass *dm_class = GST_DEINTERLACE_METHOD_GET_CLASS (self);
GstDeinterlaceScanlineData scanlines;
guint8 *out = GST_BUFFER_DATA (parent->out_buf);
guint8 *out = GST_BUFFER_DATA (outbuf);
guint8 *field0 = NULL, *field1 = NULL, *field2 = NULL, *field3 = NULL;
gint cur_field_idx = parent->history_count - dm_class->fields_required;
guint cur_field_flags = parent->field_history[cur_field_idx].flags;
@ -570,11 +570,6 @@ gst_deinterlace2_reset_history (GstDeinterlace2 * self)
static void
gst_deinterlace2_reset (GstDeinterlace2 * self)
{
if (self->out_buf) {
gst_buffer_unref (self->out_buf);
self->out_buf = NULL;
}
self->output_stride = 0;
self->line_length = 0;
self->frame_width = 0;
@ -748,6 +743,7 @@ gst_deinterlace2_chain (GstPad * pad, GstBuffer * buf)
GstFlowReturn ret = GST_FLOW_OK;
gint fields_required = 0;
gint cur_field_idx = 0;
GstBuffer *outbuf;
self = GST_DEINTERLACE2 (GST_PAD_PARENT (pad));
@ -781,12 +777,12 @@ gst_deinterlace2_chain (GstPad * pad, GstBuffer * buf)
/* create new buffer */
ret = gst_pad_alloc_buffer_and_set_caps (self->srcpad,
GST_BUFFER_OFFSET_NONE, self->frame_size,
GST_PAD_CAPS (self->srcpad), &self->out_buf);
GST_PAD_CAPS (self->srcpad), &outbuf);
if (ret != GST_FLOW_OK)
return ret;
/* do magic calculus */
gst_deinterlace_method_deinterlace_frame (self->method, self);
gst_deinterlace_method_deinterlace_frame (self->method, self, outbuf);
g_assert (self->history_count - 1 -
gst_deinterlace_method_get_latency (self->method) >= 0);
@ -797,14 +793,14 @@ gst_deinterlace2_chain (GstPad * pad, GstBuffer * buf)
gst_buffer_unref (gst_deinterlace2_pop_history (self));
GST_BUFFER_TIMESTAMP (self->out_buf) = timestamp;
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
if (self->fields == GST_DEINTERLACE2_ALL)
GST_BUFFER_DURATION (self->out_buf) = self->field_duration;
GST_BUFFER_DURATION (outbuf) = self->field_duration;
else
GST_BUFFER_DURATION (self->out_buf) = 2 * self->field_duration;
GST_BUFFER_DURATION (outbuf) = 2 * self->field_duration;
ret = gst_pad_push (self->srcpad, self->out_buf);
self->out_buf = NULL;
ret = gst_pad_push (self->srcpad, outbuf);
outbuf = NULL;
if (ret != GST_FLOW_OK)
return ret;
}
@ -828,12 +824,12 @@ gst_deinterlace2_chain (GstPad * pad, GstBuffer * buf)
/* create new buffer */
ret = gst_pad_alloc_buffer_and_set_caps (self->srcpad,
GST_BUFFER_OFFSET_NONE, self->frame_size,
GST_PAD_CAPS (self->srcpad), &self->out_buf);
GST_PAD_CAPS (self->srcpad), &outbuf);
if (ret != GST_FLOW_OK)
return ret;
/* do magic calculus */
gst_deinterlace_method_deinterlace_frame (self->method, self);
gst_deinterlace_method_deinterlace_frame (self->method, self, outbuf);
g_assert (self->history_count - 1 -
gst_deinterlace_method_get_latency (self->method) >= 0);
@ -844,14 +840,14 @@ gst_deinterlace2_chain (GstPad * pad, GstBuffer * buf)
gst_buffer_unref (gst_deinterlace2_pop_history (self));
GST_BUFFER_TIMESTAMP (self->out_buf) = timestamp;
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
if (self->fields == GST_DEINTERLACE2_ALL)
GST_BUFFER_DURATION (self->out_buf) = self->field_duration;
GST_BUFFER_DURATION (outbuf) = self->field_duration;
else
GST_BUFFER_DURATION (self->out_buf) = 2 * self->field_duration;
GST_BUFFER_DURATION (outbuf) = 2 * self->field_duration;
ret = gst_pad_push (self->srcpad, self->out_buf);
self->out_buf = NULL;
ret = gst_pad_push (self->srcpad, outbuf);
outbuf = NULL;
if (ret != GST_FLOW_OK)
return ret;

View file

@ -74,7 +74,7 @@ struct _GstDeinterlaceMethodClass {
guint fields_required;
guint latency;
void (*deinterlace_frame) (GstDeinterlaceMethod *self, GstDeinterlace2 * parent);
void (*deinterlace_frame) (GstDeinterlaceMethod *self, GstDeinterlace2 * parent, GstBuffer *outbuf);
const gchar *name;
const gchar *nick;
@ -193,8 +193,6 @@ struct _GstDeinterlace2
GstPad *srcpad, *sinkpad;
guint history_count;
GstDeinterlace2FieldLayout field_layout;
guint frame_size;
@ -215,9 +213,7 @@ struct _GstDeinterlace2
the program just started or a picture was skipped.
*/
GstPicture field_history[MAX_FIELD_HISTORY];
/* Current overlay buffer pointer. */
GstBuffer *out_buf;
guint history_count;
/* Overlay pitch (number of bytes between scanlines). */
guint output_stride;

View file

@ -335,7 +335,7 @@ deinterlace_greedy_packed422_scanline_mmxext (GstDeinterlaceMethodGreedyL *
static void
deinterlace_frame_di_greedy (GstDeinterlaceMethod * d_method,
GstDeinterlace2 * object)
GstDeinterlace2 * object, GstBuffer * outbuf)
{
GstDeinterlaceMethodGreedyL *self =
GST_DEINTERLACE_METHOD_GREEDY_L (d_method);
@ -349,7 +349,7 @@ deinterlace_frame_di_greedy (GstDeinterlaceMethod * d_method,
unsigned char *L3; // ptr to Line3
unsigned char *L2P; // ptr to prev Line2
unsigned char *Dest = GST_BUFFER_DATA (object->out_buf);
unsigned char *Dest = GST_BUFFER_DATA (outbuf);
// copy first even line no matter what, and the first odd line if we're
// processing an EVEN field. (note diff from other deint rtns.)

View file

@ -235,7 +235,7 @@ greedyDScaler_C (GstDeinterlaceMethodGreedyH * self, uint8_t * L1, uint8_t * L2,
static void
deinterlace_frame_di_greedyh (GstDeinterlaceMethod * d_method,
GstDeinterlace2 * object)
GstDeinterlace2 * object, GstBuffer * outbuf)
{
GstDeinterlaceMethodGreedyH *self =
GST_DEINTERLACE_METHOD_GREEDY_H (d_method);
@ -250,7 +250,7 @@ deinterlace_frame_di_greedyh (GstDeinterlaceMethod * d_method,
unsigned char *L3; // ptr to Line3
unsigned char *L2P; // ptr to prev Line2
unsigned char *Dest = GST_BUFFER_DATA (object->out_buf);
unsigned char *Dest = GST_BUFFER_DATA (outbuf);
// copy first even line no matter what, and the first odd line if we're
// processing an EVEN field. (note diff from other deint rtns.)

View file

@ -61,7 +61,7 @@
#define SEFUNC(x) Search_Effort_C_##x(src_pitch, dst_pitch, rowsize, pWeaveSrc, pWeaveSrcP, pWeaveDest, IsOdd, pCopySrc, pCopySrcP, FldHeight)
#endif
void FUNCT_NAME(GstDeinterlaceMethod *d_method, GstDeinterlace2* object)
void FUNCT_NAME(GstDeinterlaceMethod *d_method, GstDeinterlace2* object, GstBuffer *outbuf)
{
GstDeinterlaceMethodTomsMoComp *self = GST_DEINTERLACE_METHOD_TOMSMOCOMP (d_method);
long SearchEffort = self->search_effort;
@ -94,7 +94,7 @@ void FUNCT_NAME(GstDeinterlaceMethod *d_method, GstDeinterlace2* object)
IsOdd = 1;
// if we have an odd field we copy an even field and weave an odd field
pCopyDest = GST_BUFFER_DATA(object->out_buf);
pCopyDest = GST_BUFFER_DATA(outbuf);
pWeaveDest = pCopyDest + dst_pitch;
}
/* do it vice verca */
@ -102,8 +102,8 @@ void FUNCT_NAME(GstDeinterlaceMethod *d_method, GstDeinterlace2* object)
IsOdd = 0;
// if we have an even field we copy an odd field and weave an even field
pCopyDest = GST_BUFFER_DATA(object->out_buf) + dst_pitch;
pWeaveDest = GST_BUFFER_DATA(object->out_buf);
pCopyDest = GST_BUFFER_DATA(outbuf) + dst_pitch;
pWeaveDest = GST_BUFFER_DATA(outbuf);
}