mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
flacparse: fix playback if sample number does not start at 0
This reverts commit 29b807685d
, while
fixing the original breaking tests/check/pipelines/flacdec.
This commit is contained in:
parent
29b807685d
commit
f35238794c
2 changed files with 15 additions and 5 deletions
|
@ -801,7 +801,7 @@ gst_flac_parse_handle_frame (GstBaseParse * parse,
|
||||||
framesize = map.size;
|
framesize = map.size;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if ((GST_READ_UINT16_BE (map.data) & 0xfffe) == 0xfff8) {
|
} else if ((GST_READ_UINT16_BE (map.data) & 0xfffe) == 0xfff8) {
|
||||||
gboolean ret;
|
gboolean ret, is_first = !flacparse->strategy_checked;
|
||||||
guint next;
|
guint next;
|
||||||
|
|
||||||
flacparse->offset = GST_BUFFER_OFFSET (buffer);
|
flacparse->offset = GST_BUFFER_OFFSET (buffer);
|
||||||
|
@ -811,9 +811,15 @@ gst_flac_parse_handle_frame (GstBaseParse * parse,
|
||||||
GST_DEBUG_OBJECT (flacparse, "Found sync code");
|
GST_DEBUG_OBJECT (flacparse, "Found sync code");
|
||||||
ret = gst_flac_parse_frame_is_valid (flacparse, map.data, map.size, &next);
|
ret = gst_flac_parse_frame_is_valid (flacparse, map.data, map.size, &next);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
if (is_first) {
|
||||||
|
GST_INFO_OBJECT (flacparse, "First sample number is %" G_GUINT64_FORMAT,
|
||||||
|
flacparse->sample_number);
|
||||||
|
flacparse->first_sample_number = flacparse->sample_number;
|
||||||
|
}
|
||||||
framesize = next;
|
framesize = next;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're at EOS and the frame was not valid, drop it! */
|
/* If we're at EOS and the frame was not valid, drop it! */
|
||||||
if (G_UNLIKELY (GST_BASE_PARSE_DRAINING (flacparse))) {
|
if (G_UNLIKELY (GST_BASE_PARSE_DRAINING (flacparse))) {
|
||||||
GST_WARNING_OBJECT (flacparse, "EOS");
|
GST_WARNING_OBJECT (flacparse, "EOS");
|
||||||
|
@ -1543,6 +1549,7 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame,
|
||||||
GstBuffer *buffer = frame->buffer, *sbuffer;
|
GstBuffer *buffer = frame->buffer, *sbuffer;
|
||||||
GstMapInfo map;
|
GstMapInfo map;
|
||||||
GstFlowReturn res = GST_FLOW_ERROR;
|
GstFlowReturn res = GST_FLOW_ERROR;
|
||||||
|
guint64 relative_sample_number;
|
||||||
|
|
||||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
|
|
||||||
|
@ -1650,19 +1657,21 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* also cater for oggmux metadata */
|
/* also cater for oggmux metadata */
|
||||||
|
relative_sample_number =
|
||||||
|
flacparse->sample_number - flacparse->first_sample_number;
|
||||||
if (flacparse->blocking_strategy == 0) {
|
if (flacparse->blocking_strategy == 0) {
|
||||||
GST_BUFFER_PTS (buffer) =
|
GST_BUFFER_PTS (buffer) =
|
||||||
gst_util_uint64_scale (flacparse->sample_number,
|
gst_util_uint64_scale (relative_sample_number,
|
||||||
flacparse->block_size * GST_SECOND, flacparse->samplerate);
|
flacparse->block_size * GST_SECOND, flacparse->samplerate);
|
||||||
GST_BUFFER_OFFSET_END (buffer) =
|
GST_BUFFER_OFFSET_END (buffer) =
|
||||||
flacparse->sample_number * flacparse->block_size +
|
relative_sample_number * flacparse->block_size +
|
||||||
flacparse->block_size;
|
flacparse->block_size;
|
||||||
} else {
|
} else {
|
||||||
GST_BUFFER_PTS (buffer) =
|
GST_BUFFER_PTS (buffer) =
|
||||||
gst_util_uint64_scale (flacparse->sample_number, GST_SECOND,
|
gst_util_uint64_scale (relative_sample_number, GST_SECOND,
|
||||||
flacparse->samplerate);
|
flacparse->samplerate);
|
||||||
GST_BUFFER_OFFSET_END (buffer) =
|
GST_BUFFER_OFFSET_END (buffer) =
|
||||||
flacparse->sample_number + flacparse->block_size;
|
relative_sample_number + flacparse->block_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_BUFFER_DTS (buffer) = GST_BUFFER_PTS (buffer);
|
GST_BUFFER_DTS (buffer) = GST_BUFFER_PTS (buffer);
|
||||||
|
|
|
@ -74,6 +74,7 @@ struct _GstFlacParse {
|
||||||
guint8 blocking_strategy;
|
guint8 blocking_strategy;
|
||||||
guint16 block_size;
|
guint16 block_size;
|
||||||
guint64 sample_number;
|
guint64 sample_number;
|
||||||
|
guint64 first_sample_number;
|
||||||
gboolean strategy_checked;
|
gboolean strategy_checked;
|
||||||
|
|
||||||
gboolean sent_codec_tag;
|
gboolean sent_codec_tag;
|
||||||
|
|
Loading…
Reference in a new issue