mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 00:58:12 +00:00
mp3parse: be more conservative when changing layer/rate/etc.
Don't allow a change in sample rate/channels/layer/version unless we can see another frame at the correct offset. Prevents accidently flipping due to simple single-bit corruption.
This commit is contained in:
parent
b510f2ab6b
commit
777eb4d9cc
1 changed files with 10 additions and 5 deletions
|
@ -1225,15 +1225,22 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
|
||||||
if (head_check (mp3parse, header)) {
|
if (head_check (mp3parse, header)) {
|
||||||
guint bitrate = 0, layer = 0, rate = 0, channels = 0, version = 0, mode =
|
guint bitrate = 0, layer = 0, rate = 0, channels = 0, version = 0, mode =
|
||||||
0, crc = 0;
|
0, crc = 0;
|
||||||
|
gboolean caps_change = FALSE;
|
||||||
|
|
||||||
if (!(bpf = mp3_type_frame_length_from_header (mp3parse, header,
|
if (!(bpf = mp3_type_frame_length_from_header (mp3parse, header,
|
||||||
&version, &layer, &channels, &bitrate, &rate, &mode, &crc)))
|
&version, &layer, &channels, &bitrate, &rate, &mode, &crc)))
|
||||||
goto header_error;
|
goto header_error;
|
||||||
|
|
||||||
|
if (channels != mp3parse->channels ||
|
||||||
|
rate != mp3parse->rate || layer != mp3parse->layer ||
|
||||||
|
version != mp3parse->version)
|
||||||
|
caps_change = TRUE;
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* robust seek support
|
* robust seek support
|
||||||
* - This performs additional frame validation if the resyncing flag is set
|
* - This performs additional frame validation if the resyncing flag is set
|
||||||
* (indicating a discontinuous stream).
|
* (indicating a discontinuous stream), or if the caps are changing
|
||||||
|
* (different sample rate, channels, layer, version)
|
||||||
* - The current frame header is not accepted as valid unless the NEXT
|
* - The current frame header is not accepted as valid unless the NEXT
|
||||||
* frame header has the same values for most fields. This significantly
|
* frame header has the same values for most fields. This significantly
|
||||||
* increases the probability that we aren't processing random data.
|
* increases the probability that we aren't processing random data.
|
||||||
|
@ -1242,7 +1249,7 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
|
||||||
* bitrate from previous frames. In this case, seeking may be more
|
* bitrate from previous frames. In this case, seeking may be more
|
||||||
* complicated because the frames are not independently coded.
|
* complicated because the frames are not independently coded.
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
if (mp3parse->resyncing) {
|
if (mp3parse->resyncing || caps_change) {
|
||||||
guint32 header2;
|
guint32 header2;
|
||||||
const guint8 *data2;
|
const guint8 *data2;
|
||||||
|
|
||||||
|
@ -1284,9 +1291,7 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channels != mp3parse->channels ||
|
if (caps_change) {
|
||||||
rate != mp3parse->rate || layer != mp3parse->layer ||
|
|
||||||
version != mp3parse->version) {
|
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
caps = mp3_caps_create (version, layer, channels, rate);
|
caps = mp3_caps_create (version, layer, channels, rate);
|
||||||
|
|
Loading…
Reference in a new issue