summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjep <jep@2b0047a9-a6d8-0310-accf-f7200b2a168c>2014-10-29 17:03:38 +0000
committerjep <jep@2b0047a9-a6d8-0310-accf-f7200b2a168c>2014-10-29 17:03:38 +0000
commitec0baf0c3be0b144cc200d044374769f772bc616 (patch)
treed40d1ef50c9483543b22cb4fc57c674c23f6dd42
parentc0a303e9bf8224b72d9f0c39e47f243161e29057 (diff)
* src/mp3-c.c: (c_decode_mp3):
Perform same testing for Main data in both variants of decoder. git-svn-id: https://core.fluendo.com/gstreamer/svn/trunk/gst-fluendo-mp3@2641 2b0047a9-a6d8-0310-accf-f7200b2a168c
-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);