mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
ogg: Fix handling of unset granuleshift for the skeleton parser
And also add a helper function to properly clear/reset/free the GstOggStream structures.
This commit is contained in:
parent
c2dc843c7e
commit
7418ddd753
4 changed files with 52 additions and 33 deletions
|
@ -194,12 +194,8 @@ gst_ogg_pad_init (GstOggPad * pad)
|
|||
|
||||
pad->have_type = FALSE;
|
||||
pad->continued = NULL;
|
||||
pad->map.headers = NULL;
|
||||
pad->map.queued = NULL;
|
||||
|
||||
pad->map.granulerate_n = 0;
|
||||
pad->map.granulerate_d = 0;
|
||||
pad->map.granuleshift = -1;
|
||||
gst_ogg_stream_clear (&pad->map);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -210,32 +206,12 @@ gst_ogg_pad_dispose (GObject * object)
|
|||
pad->chain = NULL;
|
||||
pad->ogg = NULL;
|
||||
|
||||
g_list_foreach (pad->map.headers, (GFunc) _ogg_packet_free, NULL);
|
||||
g_list_free (pad->map.headers);
|
||||
pad->map.headers = NULL;
|
||||
g_list_foreach (pad->map.queued, (GFunc) _ogg_packet_free, NULL);
|
||||
g_list_free (pad->map.queued);
|
||||
pad->map.queued = NULL;
|
||||
|
||||
g_free (pad->map.index);
|
||||
pad->map.index = NULL;
|
||||
|
||||
/* clear continued pages */
|
||||
g_list_foreach (pad->continued, (GFunc) gst_ogg_page_free, NULL);
|
||||
g_list_free (pad->continued);
|
||||
pad->continued = NULL;
|
||||
|
||||
if (pad->map.caps) {
|
||||
gst_caps_unref (pad->map.caps);
|
||||
pad->map.caps = NULL;
|
||||
}
|
||||
|
||||
if (pad->map.taglist) {
|
||||
gst_tag_list_free (pad->map.taglist);
|
||||
pad->map.taglist = NULL;
|
||||
}
|
||||
|
||||
ogg_stream_reset (&pad->map.stream);
|
||||
gst_ogg_stream_clear (&pad->map);
|
||||
|
||||
G_OBJECT_CLASS (gst_ogg_pad_parent_class)->dispose (object);
|
||||
}
|
||||
|
|
|
@ -296,8 +296,7 @@ gst_ogg_mux_ogg_pad_destroy_notify (GstCollectData2 * data)
|
|||
GstOggPadData *oggpad = (GstOggPadData *) data;
|
||||
GstBuffer *buf;
|
||||
|
||||
ogg_stream_clear (&oggpad->map.stream);
|
||||
gst_caps_replace (&oggpad->map.caps, NULL);
|
||||
gst_ogg_stream_clear (&oggpad->map);
|
||||
|
||||
if (oggpad->pagebuffers) {
|
||||
while ((buf = g_queue_pop_head (oggpad->pagebuffers)) != NULL) {
|
||||
|
@ -466,6 +465,7 @@ gst_ogg_mux_request_new_pad (GstElement * element,
|
|||
sizeof (GstOggPadData), gst_ogg_mux_ogg_pad_destroy_notify, FALSE);
|
||||
ogg_mux->active_pads++;
|
||||
|
||||
gst_ogg_stream_clear (&oggpad->map);
|
||||
oggpad->map.serialno = serial;
|
||||
oggpad->packetno = 0;
|
||||
oggpad->pageno = 0;
|
||||
|
@ -476,8 +476,6 @@ gst_ogg_mux_request_new_pad (GstElement * element,
|
|||
oggpad->first_delta = FALSE;
|
||||
oggpad->prev_delta = FALSE;
|
||||
oggpad->data_pushed = FALSE;
|
||||
oggpad->map.headers = NULL;
|
||||
oggpad->map.queued = NULL;
|
||||
oggpad->next_granule = 0;
|
||||
oggpad->keyframe_granule = -1;
|
||||
|
||||
|
|
|
@ -643,6 +643,7 @@ setup_vp8_mapper (GstOggStream * pad, ogg_packet * packet)
|
|||
pad->granulerate_d = fps_d;
|
||||
pad->n_header_packets = 2;
|
||||
pad->frame_size = 1;
|
||||
pad->granuleshift = 0;
|
||||
|
||||
pad->caps = gst_caps_new_simple ("video/x-vp8",
|
||||
"width", G_TYPE_INT, width,
|
||||
|
@ -1207,7 +1208,7 @@ gst_ogg_map_add_fisbone (GstOggStream * pad, GstOggStream * skel_pad,
|
|||
pad->granulerate_n = GST_READ_UINT64_LE (data);
|
||||
pad->granulerate_d = GST_READ_UINT64_LE (data + 8);
|
||||
}
|
||||
if (pad->granuleshift < 0) {
|
||||
if (pad->granuleshift == -1) {
|
||||
pad->granuleshift = GST_READ_UINT8 (data + 28);
|
||||
}
|
||||
|
||||
|
@ -1479,6 +1480,7 @@ setup_ogmaudio_mapper (GstOggStream * pad, ogg_packet * packet)
|
|||
|
||||
pad->granulerate_n = GST_READ_UINT64_LE (data + 25);
|
||||
pad->granulerate_d = 1;
|
||||
pad->granuleshift = 0;
|
||||
|
||||
fourcc = GST_READ_UINT32_LE (data + 9);
|
||||
GST_DEBUG ("fourcc: %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
|
||||
|
@ -1522,6 +1524,7 @@ setup_ogmvideo_mapper (GstOggStream * pad, ogg_packet * packet)
|
|||
GST_WARNING ("timeunit is out of range");
|
||||
}
|
||||
pad->granulerate_d = (gint) CLAMP (time_unit, G_MININT, G_MAXINT);
|
||||
pad->granuleshift = 0;
|
||||
|
||||
GST_LOG ("fps = %d/%d = %.3f",
|
||||
pad->granulerate_n, pad->granulerate_d,
|
||||
|
@ -1566,6 +1569,7 @@ setup_ogmtext_mapper (GstOggStream * pad, ogg_packet * packet)
|
|||
GST_WARNING ("timeunit is out of range");
|
||||
}
|
||||
pad->granulerate_d = (gint) CLAMP (time_unit, G_MININT, G_MAXINT);
|
||||
pad->granuleshift = 0;
|
||||
|
||||
GST_LOG ("fps = %d/%d = %.3f",
|
||||
pad->granulerate_n, pad->granulerate_d,
|
||||
|
@ -1614,6 +1618,7 @@ setup_pcm_mapper (GstOggStream * pad, ogg_packet * packet)
|
|||
|
||||
pad->granulerate_n = GST_READ_UINT32_LE (data + 16);
|
||||
pad->granulerate_d = 1;
|
||||
pad->granuleshift = 0;
|
||||
GST_LOG ("sample rate: %d", pad->granulerate_n);
|
||||
|
||||
format = GST_READ_UINT32_LE (data + 12);
|
||||
|
@ -2232,10 +2237,12 @@ gst_ogg_stream_setup_map (GstOggStream * pad, ogg_packet * packet)
|
|||
|
||||
GST_DEBUG ("found mapper for '%s'", mappers[i].id);
|
||||
|
||||
if (mappers[i].setup_func)
|
||||
if (mappers[i].setup_func) {
|
||||
gst_ogg_stream_clear (pad);
|
||||
ret = mappers[i].setup_func (pad, packet);
|
||||
else
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
GST_DEBUG ("got stream type %" GST_PTR_FORMAT, pad->caps);
|
||||
|
@ -2305,3 +2312,39 @@ gst_ogg_stream_setup_map_from_caps_headers (GstOggStream * pad,
|
|||
GST_INFO ("Found headers on caps, using those to determine type");
|
||||
return gst_ogg_stream_setup_map (pad, &packet);
|
||||
}
|
||||
|
||||
static void
|
||||
_ogg_packet_free (ogg_packet * packet)
|
||||
{
|
||||
g_free (packet->packet);
|
||||
g_slice_free (ogg_packet, packet);
|
||||
}
|
||||
|
||||
void
|
||||
gst_ogg_stream_clear (GstOggStream * pad)
|
||||
{
|
||||
g_list_foreach (pad->headers, (GFunc) _ogg_packet_free, NULL);
|
||||
g_list_free (pad->headers);
|
||||
pad->headers = NULL;
|
||||
g_list_foreach (pad->queued, (GFunc) _ogg_packet_free, NULL);
|
||||
g_list_free (pad->queued);
|
||||
pad->queued = NULL;
|
||||
|
||||
g_free (pad->index);
|
||||
pad->index = NULL;
|
||||
|
||||
if (pad->caps) {
|
||||
gst_caps_unref (pad->caps);
|
||||
pad->caps = NULL;
|
||||
}
|
||||
|
||||
if (pad->taglist) {
|
||||
gst_tag_list_free (pad->taglist);
|
||||
pad->taglist = NULL;
|
||||
}
|
||||
|
||||
ogg_stream_reset (&pad->stream);
|
||||
|
||||
memset (pad, 0, sizeof (GstOggStream));
|
||||
pad->granuleshift = -1;
|
||||
}
|
||||
|
|
|
@ -108,6 +108,8 @@ struct _GstOggStream
|
|||
};
|
||||
|
||||
|
||||
void gst_ogg_stream_clear (GstOggStream *pad);
|
||||
|
||||
gboolean gst_ogg_stream_setup_map (GstOggStream * pad, ogg_packet *packet);
|
||||
gboolean gst_ogg_stream_setup_map_from_caps_headers (GstOggStream * pad,
|
||||
const GstCaps * caps);
|
||||
|
|
Loading…
Reference in a new issue