summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--src/mp3-c.c30
2 files changed, 24 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 3f3c585..19e83dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-10-29 Josep Torra <josep@fluendo.com>
+
+ * src/mp3-c.c: (c_decode_mp3):
+ Perform same testing for Main data in both variants of decoder.
+
2014-10-15 Release Maker <nomail@fluendo.com>
* configure.ac: Back to TRUNK.
diff --git a/src/mp3-c.c b/src/mp3-c.c
index b4dc6b6..1ac47bc 100644
--- a/src/mp3-c.c
+++ b/src/mp3-c.c
@@ -1632,6 +1632,7 @@ c_decode_mp3 (mp3tl * tl)
gint diff;
fr_header *hdr;
guint8 side_info[32]; /* At most 32 bytes side info for MPEG-1 stereo */
+ gboolean MainDataOK;
hdr = &tl->fr_ps.header;
bb = &tl->c_impl.bb;
@@ -1650,27 +1651,34 @@ c_decode_mp3 (mp3tl * tl)
if (bs_bits_avail (tl->bs) < hdr->main_slots * 8)
return MP3TL_ERR_NEED_DATA;
- /* Check that we have enough main_data between the bit reservoir
- * and the incoming data */
+ /* Verify that sufficient main_data was extracted from */
+ /* the previous sync interval */
diff = tl->c_impl.main_data_end - III_side_info.main_data_begin;
- if (diff < 0) {
- /* Usually happens after a seek. We can't decode this frame */
- GST_LOG ("Not enough main data available to decode frame");
- return MP3TL_ERR_NEED_DATA;
+ MainDataOK = (diff >= 0);
+ if (!MainDataOK) {
+ GST_DEBUG ("MainDataEnd: %d MainDataBegin: %d delta: %d",
+ tl->c_impl.main_data_end, III_side_info.main_data_begin, diff);
}
/* Copy the remaining main data in the bit reservoir to the start of the
* huffman bit buffer, and then append the incoming bytes */
- memmove (tl->c_impl.hb_buf, tl->c_impl.hb_buf +
- tl->c_impl.main_data_end - III_side_info.main_data_begin,
- III_side_info.main_data_begin);
- tl->c_impl.main_data_end = III_side_info.main_data_begin;
-
+ if (MainDataOK) {
+ if (diff > 0) {
+ memmove (tl->c_impl.hb_buf, tl->c_impl.hb_buf + diff,
+ III_side_info.main_data_begin);
+ tl->c_impl.main_data_end = III_side_info.main_data_begin;
+ }
+ }
/* And append the incoming bytes to the reservoir */
bs_getbytes (tl->bs, tl->c_impl.hb_buf + tl->c_impl.main_data_end,
hdr->main_slots);
tl->c_impl.main_data_end += hdr->main_slots;
+ if (!MainDataOK) {
+ GST_DEBUG ("Bad frame - not enough main data bits");
+ return MP3TL_ERR_BAD_FRAME;
+ }
+
/* And setup the huffman bitstream reader for this data */
h_setbuf (bb, tl->c_impl.hb_buf, tl->c_impl.main_data_end);