celtdec: Handle lookahead, discont
This commit is contained in:
parent
2390d3a31c
commit
05a1e071b9
@ -609,6 +609,7 @@ celt_dec_chain_parse_data (GstCeltDec * dec, GstBuffer * buf,
|
|||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
gint16 *out_data;
|
gint16 *out_data;
|
||||||
gint error = CELT_OK;
|
gint error = CELT_OK;
|
||||||
|
int skip = 0;
|
||||||
|
|
||||||
if (timestamp != -1) {
|
if (timestamp != -1) {
|
||||||
dec->segment.last_stop = timestamp;
|
dec->segment.last_stop = timestamp;
|
||||||
@ -636,6 +637,10 @@ celt_dec_chain_parse_data (GstCeltDec * dec, GstBuffer * buf,
|
|||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dec->discont) {
|
||||||
|
celt_mode_info (dec->mode, CELT_GET_LOOKAHEAD, &skip);
|
||||||
|
}
|
||||||
|
|
||||||
res = gst_pad_alloc_buffer_and_set_caps (dec->srcpad,
|
res = gst_pad_alloc_buffer_and_set_caps (dec->srcpad,
|
||||||
GST_BUFFER_OFFSET_NONE, dec->frame_size * dec->header.nb_channels * 2,
|
GST_BUFFER_OFFSET_NONE, dec->frame_size * dec->header.nb_channels * 2,
|
||||||
GST_PAD_CAPS (dec->srcpad), &outbuf);
|
GST_PAD_CAPS (dec->srcpad), &outbuf);
|
||||||
@ -655,6 +660,14 @@ celt_dec_chain_parse_data (GstCeltDec * dec, GstBuffer * buf,
|
|||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skip > 0) {
|
||||||
|
GST_ERROR ("skipping %d samples", skip);
|
||||||
|
GST_BUFFER_DATA (outbuf) = GST_BUFFER_DATA (outbuf) +
|
||||||
|
skip * dec->header.nb_channels * 2;
|
||||||
|
GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (outbuf) -
|
||||||
|
skip * dec->header.nb_channels * 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (dec->granulepos == -1) {
|
if (dec->granulepos == -1) {
|
||||||
if (dec->segment.format != GST_FORMAT_TIME) {
|
if (dec->segment.format != GST_FORMAT_TIME) {
|
||||||
GST_WARNING_OBJECT (dec, "segment not initialized or not TIME format");
|
GST_WARNING_OBJECT (dec, "segment not initialized or not TIME format");
|
||||||
@ -672,6 +685,10 @@ celt_dec_chain_parse_data (GstCeltDec * dec, GstBuffer * buf,
|
|||||||
gst_util_uint64_scale_int (dec->granulepos - dec->frame_size, GST_SECOND,
|
gst_util_uint64_scale_int (dec->granulepos - dec->frame_size, GST_SECOND,
|
||||||
dec->header.sample_rate);
|
dec->header.sample_rate);
|
||||||
GST_BUFFER_DURATION (outbuf) = dec->frame_duration;
|
GST_BUFFER_DURATION (outbuf) = dec->frame_duration;
|
||||||
|
if (dec->discont) {
|
||||||
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
|
||||||
|
dec->discont = 0;
|
||||||
|
}
|
||||||
|
|
||||||
dec->granulepos += dec->frame_size;
|
dec->granulepos += dec->frame_size;
|
||||||
dec->segment.last_stop += dec->frame_duration;
|
dec->segment.last_stop += dec->frame_duration;
|
||||||
@ -696,6 +713,10 @@ celt_dec_chain (GstPad * pad, GstBuffer * buf)
|
|||||||
|
|
||||||
dec = GST_CELT_DEC (gst_pad_get_parent (pad));
|
dec = GST_CELT_DEC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
|
if (GST_BUFFER_IS_DISCONT (buf)) {
|
||||||
|
dec->discont = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (dec->packetno == 0)
|
if (dec->packetno == 0)
|
||||||
res = celt_dec_chain_parse_header (dec, buf);
|
res = celt_dec_chain_parse_header (dec, buf);
|
||||||
else if (dec->packetno == 1)
|
else if (dec->packetno == 1)
|
||||||
|
@ -58,6 +58,7 @@ struct _GstCeltDec {
|
|||||||
|
|
||||||
GstSegment segment; /* STREAM LOCK */
|
GstSegment segment; /* STREAM LOCK */
|
||||||
gint64 granulepos; /* -1 = needs to be set from current time */
|
gint64 granulepos; /* -1 = needs to be set from current time */
|
||||||
|
gboolean discont;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstCeltDecClass {
|
struct _GstCeltDecClass {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user