[MPlayer-cvslog] r22158 - trunk/mp3lib/sr1.c

reimar subversion at mplayerhq.hu
Mon Feb 5 20:24:03 CET 2007


Author: reimar
Date: Mon Feb  5 20:24:03 2007
New Revision: 22158

Modified:
   trunk/mp3lib/sr1.c

Log:
Make sure buffer is aligned so no unaligned access happens.


Modified: trunk/mp3lib/sr1.c
==============================================================================
--- trunk/mp3lib/sr1.c	(original)
+++ trunk/mp3lib/sr1.c	Mon Feb  5 20:24:03 2007
@@ -315,7 +315,10 @@
  */
 LOCAL int read_frame(struct frame *fr){
   unsigned long newhead;
-  unsigned char hbuf[8];
+  union {
+    unsigned char buf[8];
+    unsigned long dummy; // for alignment
+  } hbuf;
   int skipped,resyncpos;
   int frames=0;
 
@@ -325,7 +328,7 @@
 
   set_pointer(512);
   fsizeold=fr->framesize;       /* for Layer3 */
-  if(!stream_head_read(hbuf,&newhead)) return 0;
+  if(!stream_head_read(hbuf.buf,&newhead)) return 0;
   if(!decode_header(fr,newhead)){
     // invalid header! try to resync stream!
 #ifdef DEBUG_RESYNC
@@ -333,7 +336,7 @@
 #endif
 retry1:
     while(!decode_header(fr,newhead)){
-      if(!stream_head_shift(hbuf,&newhead)) return 0;
+      if(!stream_head_shift(hbuf.buf,&newhead)) return 0;
     }
     resyncpos=MP3_fpos-4;
     // found valid header
@@ -343,14 +346,14 @@
     if(!stream_read_frame_body(fr->framesize)) return 0; // read body
     set_pointer(512);
     fsizeold=fr->framesize;       /* for Layer3 */
-    if(!stream_head_read(hbuf,&newhead)) return 0;
+    if(!stream_head_read(hbuf.buf,&newhead)) return 0;
     if(!decode_header(fr,newhead)){
       // invalid hdr! go back...
 #ifdef DEBUG_RESYNC
       printf("INVALID\n");
 #endif
 //      mp3_seek(resyncpos+1);
-      if(!stream_head_read(hbuf,&newhead)) return 0;
+      if(!stream_head_read(hbuf.buf,&newhead)) return 0;
       goto retry1;
     }
 #ifdef DEBUG_RESYNC



More information about the MPlayer-cvslog mailing list