Skip to content

Commit

Permalink
dspvdec: dynamically adapt to resolution changes
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
  • Loading branch information
Marco Ballesio authored and felipec committed Nov 21, 2011
1 parent cc3891f commit f60a030
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gstdspbase.c
Expand Up @@ -924,6 +924,30 @@ _dsp_stop(GstDspBase *self)
return TRUE;
}

gboolean gstdsp_reinit(GstDspBase *self)
{
/* deinit */
g_atomic_int_set(&self->status, GST_FLOW_WRONG_STATE);
async_queue_disable(self->ports[0]->queue);
async_queue_disable(self->ports[1]->queue);

if (!_dsp_stop(self))
gstdsp_post_error(self, "dsp stop failed");

if (self->reset)
self->reset(self);

gst_caps_replace(&self->tmp_caps, NULL);

/* init */
g_atomic_int_set(&self->status, GST_FLOW_OK);
self->done = FALSE;
async_queue_enable(self->ports[0]->queue);
async_queue_enable(self->ports[1]->queue);

return true;
}

static inline bool
buffer_is_aligned(GstBuffer *buf, dmm_buffer_t *b)
{
Expand Down
1 change: 1 addition & 0 deletions gstdspbase.h
Expand Up @@ -145,6 +145,7 @@ void du_port_alloc_buffers(du_port_t *p, guint num_buffers);
gboolean gstdsp_start(GstDspBase *self);
gboolean gstdsp_send_codec_data(GstDspBase *self, GstBuffer *buf);
gboolean gstdsp_set_codec_data_caps(GstDspBase *base, GstBuffer *buf);
gboolean gstdsp_reinit(GstDspBase *base);
void gstdsp_got_error(GstDspBase *self, guint id, const char *message);
void gstdsp_post_error(GstDspBase *self, const char *message);
void gstdsp_send_alg_ctrl(GstDspBase *self, struct dsp_node *node, dmm_buffer_t *b);
Expand Down
22 changes: 22 additions & 0 deletions gstdspvdec.c
Expand Up @@ -302,6 +302,25 @@ configure_caps(GstDspVDec *self,
gst_caps_append_structure(out, out_struc);
}

static inline gboolean need_node_reset(GstDspVDec *self, GstCaps *new_caps)
{
gint width, height;
GstStructure *struc;
GstDspBase *base = GST_DSP_BASE(self);

if (G_UNLIKELY(!base->node))
return FALSE;

struc = gst_caps_get_structure(new_caps, 0);
gst_structure_get_int(struc, "width", &width);
gst_structure_get_int(struc, "height", &height);

if (self->width == width && self->height == height)
return FALSE;

return TRUE;
}

static gboolean
sink_setcaps(GstPad *pad,
GstCaps *caps)
Expand All @@ -325,6 +344,9 @@ sink_setcaps(GstPad *pad,
}
#endif

if (need_node_reset(self, caps))
gstdsp_reinit(base);

in_struc = gst_caps_get_structure(caps, 0);

if (base->node)
Expand Down

0 comments on commit f60a030

Please sign in to comment.