ref: 8890a518126adebba303763033fcd6de015a0305
parent: ce7117ae8702c3ab086d408ddd14df17cdeccdfd
author: menno <menno>
date: Mon Feb 11 06:34:18 EST 2002
Added recovery from synchronisation errors
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: specrec.c,v 1.1 2002/01/14 19:15:57 menno Exp $
+** $Id: specrec.c,v 1.2 2002/02/11 11:34:18 menno Exp $
**/
/*
@@ -177,8 +177,13 @@
{
tmp_spec_ptr = win_ptr + j;
- for (bin = 0; bin < width; bin++)
+ for (bin = 0; bin < width; bin += 4)
+ {
*tmp_spec_ptr++ = *spec_ptr++;
+ *tmp_spec_ptr++ = *spec_ptr++;
+ *tmp_spec_ptr++ = *spec_ptr++;
+ *tmp_spec_ptr++ = *spec_ptr++;
+ }
win_ptr += win_inc;
}
@@ -296,8 +301,14 @@
scale = get_scale_factor_gain(ics->scale_factors[g][sfb], pow2_table);
- for ( ; k < top; k++)
+ /* minimum size of a sf band is 4 and always a multiple of 4 */
+ for ( ; k < top; k+=4)
+ {
*fp++ *= scale;
+ *fp++ *= scale;
+ *fp++ *= scale;
+ *fp++ *= scale;
+ }
}
groups += ics->window_group_length[g];
}
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: syntax.c,v 1.5 2002/01/22 09:11:24 menno Exp $
+** $Id: syntax.c,v 1.6 2002/02/11 11:34:18 menno Exp $
**/
/*
@@ -23,7 +23,7 @@
Reads the AAC bitstream as defined in 14496-3 (MPEG-4 Audio)
(Note that there are some differences with 13818-7 (MPEG2), these
- are alse read correctly when the MPEG ID is known (can be found in
+ are also read correctly when the MPEG ID is known (can be found in
an ADTS header)).
*/
@@ -937,9 +937,24 @@
/* Table 1.A.6 */
static int adts_fixed_header(adts_header *adts, bitfile *ld)
{
- adts->syncword = faad_getbits(ld, 12
- DEBUGVAR(1,118,"adts_fixed_header(): syncword"));
- if (adts->syncword != 0xFFF)
+ int i, sync_err = 1;
+
+ /* try to recover from sync errors */
+ for (i = 0; i < 768; i++)
+ {
+ adts->syncword = faad_showbits(ld, 12);
+ if (adts->syncword != 0xFFF)
+ {
+ faad_getbits(ld, 8
+ DEBUGVAR(0,0,""));
+ } else {
+ sync_err = 0;
+ faad_getbits(ld, 12
+ DEBUGVAR(1,118,"adts_fixed_header(): syncword"));
+ break;
+ }
+ }
+ if (sync_err)
return 5;
adts->id = faad_get1bit(ld