ac3parse: fix buffer duration on blocks-per-frame change
The gst_base_parse_set_frame_rate call was predicated on a change to sample rate, duration or profile. However, the block count per frame can also change between packets, which would result in incorrect buffer durations.
This commit is contained in:
parent
abb646dcd1
commit
fd38772d3e
@ -204,6 +204,7 @@ gst_ac3_parse_reset (GstAc3Parse * ac3parse)
|
|||||||
{
|
{
|
||||||
ac3parse->channels = -1;
|
ac3parse->channels = -1;
|
||||||
ac3parse->sample_rate = -1;
|
ac3parse->sample_rate = -1;
|
||||||
|
ac3parse->blocks = -1;
|
||||||
ac3parse->eac = FALSE;
|
ac3parse->eac = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,13 +458,14 @@ gst_ac3_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||||||
GstAc3Parse *ac3parse = GST_AC3_PARSE (parse);
|
GstAc3Parse *ac3parse = GST_AC3_PARSE (parse);
|
||||||
GstBuffer *buf = frame->buffer;
|
GstBuffer *buf = frame->buffer;
|
||||||
guint fsize, rate, chans, blocks, sid;
|
guint fsize, rate, chans, blocks, sid;
|
||||||
gboolean eac;
|
gboolean eac, update_rate = FALSE;
|
||||||
|
|
||||||
if (!gst_ac3_parse_frame_header (ac3parse, buf, &fsize, &rate, &chans,
|
if (!gst_ac3_parse_frame_header (ac3parse, buf, &fsize, &rate, &chans,
|
||||||
&blocks, &sid, &eac))
|
&blocks, &sid, &eac))
|
||||||
goto broken_header;
|
goto broken_header;
|
||||||
|
|
||||||
GST_LOG_OBJECT (parse, "size: %u, rate: %u, chans: %u", fsize, rate, chans);
|
GST_LOG_OBJECT (parse, "size: %u, blocks: %u, rate: %u, chans: %u", fsize,
|
||||||
|
blocks, rate, chans);
|
||||||
|
|
||||||
if (G_UNLIKELY (sid)) {
|
if (G_UNLIKELY (sid)) {
|
||||||
/* dependent frame, no need to (ac)count for or consider further */
|
/* dependent frame, no need to (ac)count for or consider further */
|
||||||
@ -492,9 +494,18 @@ gst_ac3_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||||||
ac3parse->channels = chans;
|
ac3parse->channels = chans;
|
||||||
ac3parse->eac = eac;
|
ac3parse->eac = eac;
|
||||||
|
|
||||||
gst_base_parse_set_frame_rate (parse, rate, 256 * blocks, 2, 2);
|
update_rate = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (G_UNLIKELY (ac3parse->blocks != blocks)) {
|
||||||
|
ac3parse->blocks = blocks;
|
||||||
|
|
||||||
|
update_rate = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (G_UNLIKELY (update_rate))
|
||||||
|
gst_base_parse_set_frame_rate (parse, rate, 256 * blocks, 2, 2);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -53,6 +53,7 @@ struct _GstAc3Parse {
|
|||||||
/*< private >*/
|
/*< private >*/
|
||||||
gint sample_rate;
|
gint sample_rate;
|
||||||
gint channels;
|
gint channels;
|
||||||
|
gint blocks;
|
||||||
gboolean eac;
|
gboolean eac;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user