[xiph-cvs] cvs commit: theora/win32/experimental/wincompat getopt.c getopt_long.c

Timothy Terriberry tterribe at xiph.org
Mon Jun 9 18:31:36 PDT 2003



tterribe    03/06/09 21:31:35

  Modified:    examples dump_video.c encoder_example.c player_example.c
               include/theora theora.h
               lib      block_inline.h blockmap.c comment.c compglobals.c
                        dct.c dct_decode.c dct_encode.c decode.c encode.c
                        encoder_internal.h encoder_lookup.h frarray.c
                        frinit.c huffman.c huffman.h hufftables.h idct.c
                        mcomp.c mcomp.h misc_common.c pb.c pp.c pp.h
                        quant.c quant_lookup.h reconstruct.c scan.c
                        toplevel.c toplevel_lookup.h
               win32/experimental/splayer splayer.c
               win32/experimental/wincompat getopt.c getopt_long.c
  Removed:     lib      toplevel.h
  Log:
  Cleaned up a great number of the warnings, C++ comments, dead code and whitespace.
  There are still some warnings to be checked, mostly type conversions.
  
  A note about the whitespace: All tabs have been removed. MSVC++ defaults to 4 space tab stops, and everything else in UNIX defaults to 8. While it is possible to change your editor to display things correctly no matter which convention is used (though of course not for other UNIX tools like diff), people were committing changes with mixtures of each convention in the same file. This made the indentation wrong no matter what settings you were using.
  
  This simple solution is just to never use tabs. If you must hit the tab key when editing, set your editor to insert spaces instead. This ensures that no matter what tab setting anyone reading the code is using, alignment and indentation will be correct.

Revision  Changes    Path
1.5       +57 -58    theora/examples/dump_video.c

Index: dump_video.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/dump_video.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- dump_video.c	9 Jun 2003 01:45:19 -0000	1.4
+++ dump_video.c	10 Jun 2003 01:31:32 -0000	1.5
@@ -10,8 +10,8 @@
  *                                                                  *
  ********************************************************************
 
-  function: example dumpvid application; dumps  Theora streams 
-  last mod: $Id: dump_video.c,v 1.4 2003/06/09 01:45:19 tterribe Exp $
+  function: example dumpvid application; dumps  Theora streams
+  last mod: $Id: dump_video.c,v 1.5 2003/06/10 01:31:32 tterribe Exp $
 
  ********************************************************************/
 
@@ -20,7 +20,7 @@
 
 #define _GNU_SOURCE
 #define _REENTRANT
-#define _LARGEFILE_SOURCE 
+#define _LARGEFILE_SOURCE
 #define _LARGEFILE64_SOURCE
 #define _FILE_OFFSET_BITS 64
 
@@ -49,7 +49,7 @@
 
 /* never forget that globals are a one-way ticket to Hell */
 /* Ogg and codec state for demux/decode */
-ogg_sync_state   oy; 
+ogg_sync_state   oy;
 ogg_page         og;
 ogg_stream_state vo;
 ogg_stream_state to;
@@ -58,7 +58,6 @@
 theora_state     td;
 
 int              theora_p=0;
-//int              vorbis_p=0;
 int              stateflag=0;
 
 /* single frame video buffering */
@@ -79,35 +78,35 @@
 
 static void video_write(void){
   int i;
-		
+
   yuv_buffer yuv;
   theora_decode_YUVout(&td,&yuv);
 
   for(i=0;i<yuv.y_height;i++)
     fwrite(yuv.y+yuv.y_stride*i, 1, yuv.y_width, outfile);
- for(i=0;i<yuv.uv_height;i++){
-	fwrite(yuv.v+yuv.uv_stride*i, 1, yuv.uv_width, outfile);
-	fwrite(yuv.u+yuv.uv_stride*i, 1, yuv.uv_width, outfile);
-	}
-  
+  for(i=0;i<yuv.uv_height;i++){
+    fwrite(yuv.v+yuv.uv_stride*i, 1, yuv.uv_width, outfile);
+  fwrite(yuv.u+yuv.uv_stride*i, 1, yuv.uv_width, outfile);
+  }
+
 }
 /* dump the theora (or vorbis) comment header */
 static int dump_comments(theora_comment *tc){
   int i, len;
   char *value;
   FILE *out=stdout;
-  
+
   fprintf(out,"Encoded by %s\n",tc->vendor);
   if(tc->comments){
     fprintf(out, "theora comment header:\n");
     for(i=0;i<tc->comments;i++){
       if(tc->user_comments[i]){
         len=tc->comment_lengths[i];
-      	value=malloc(len+1);
-      	memcpy(value,tc->user_comments[i],len);
-      	value[len]='\0';
-      	fprintf(out, "\t%s\n", value);
-      	free(value);
+        value=malloc(len+1);
+        memcpy(value,tc->user_comments[i],len);
+        value[len]='\0';
+        fprintf(out, "\t%s\n", value);
+        free(value);
       }
     }
   }
@@ -120,7 +119,7 @@
 static int queue_page(ogg_page *page){
   if(theora_p)ogg_stream_pagein(&to,&og);
   return 0;
-}                                   
+}
 
 static void usage(void){
   fprintf(stderr,
@@ -131,15 +130,15 @@
 }
 
 int main(int argc,char *argv[]){
-  
+
   int i,j;
   ogg_packet op;
-  
+
   FILE *infile = stdin;
   outfile = stdout;
 
 #ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
-  /* Beware the evil ifdef. We avoid these where we can, but this one we 
+  /* Beware the evil ifdef. We avoid these where we can, but this one we
      cannot. Don't add any more, you'll probably go to hell if you do. */
   _setmode( _fileno( stdin ), _O_BINARY );
   _setmode( _fileno( stdout ), _O_BINARY );
@@ -157,7 +156,7 @@
       usage();
       exit(1);
   }
-  
+
   /* start up Ogg stream synchronization layer */
   ogg_sync_init(&oy);
 
@@ -176,41 +175,41 @@
     if(ret==0)break;
     while(ogg_sync_pageout(&oy,&og)>0){
       ogg_stream_state test;
-      
+
       /* is this a mandated initial header? If not, stop parsing */
       if(!ogg_page_bos(&og)){
-	/* don't leak the page; get it into the appropriate stream */
-	queue_page(&og);
-	stateflag=1;
-	break;
+        /* don't leak the page; get it into the appropriate stream */
+        queue_page(&og);
+        stateflag=1;
+        break;
       }
-      
+
       ogg_stream_init(&test,ogg_page_serialno(&og));
       ogg_stream_pagein(&test,&og);
       ogg_stream_packetout(&test,&op);
-      
+
       /* identify the codec: try theora */
       if(!theora_p && theora_decode_header(&ti,&tc,&op)>=0){
-	/* it is theora */
-	memcpy(&to,&test,sizeof(test));
-	theora_p=1;
+        /* it is theora */
+        memcpy(&to,&test,sizeof(test));
+        theora_p=1;
       }else{
-	/* whatever it is, we don't care about it */
-	ogg_stream_clear(&test);
+        /* whatever it is, we don't care about it */
+        ogg_stream_clear(&test);
       }
     }
     /* fall through to non-bos page parsing */
   }
-  
+
   /* we're expecting more header packets. */
   while(theora_p && theora_p<3){
     int ret;
-    
+
     /* look for further theora headers */
     while(theora_p && (theora_p<3) && (ret=ogg_stream_packetout(&to,&op))){
       if(ret<0){
-      	fprintf(stderr,"Error parsing Theora stream headers; corrupt stream?\n");
-      	exit(1);
+        fprintf(stderr,"Error parsing Theora stream headers; corrupt stream?\n");
+        exit(1);
       }
       if(theora_decode_header(&ti,&tc,&op)){
         printf("Error parsing Theora stream headers; corrupt stream?\n");
@@ -220,17 +219,17 @@
       if(theora_p==3)break;
     }
 
-    
+
     /* The header pages/packets will arrive before anything else we
        care about, or the stream is not obeying spec */
-    
+
     if(ogg_sync_pageout(&oy,&og)>0){
       queue_page(&og); /* demux into the appropriate stream */
     }else{
       int ret=buffer_data(infile,&oy); /* someone needs more data */
       if(ret==0){
-	fprintf(stderr,"End of file while searching for codec headers.\n");
-	exit(1);
+        fprintf(stderr,"End of file while searching for codec headers.\n");
+        exit(1);
       }
     }
   }
@@ -239,8 +238,8 @@
   if(theora_p){
     theora_decode_init(&td,&ti);
     fprintf(stderr,"Ogg logical stream %x is Theora %dx%d %.02f fps video\nEncoded frame content is %dx%d with %dx%d offset\n",
-	    to.serialno,ti.width,ti.height, (double)ti.fps_numerator/ti.fps_denominator,
-		ti.frame_width, ti.frame_height, ti.offset_x, ti.offset_y);
+            to.serialno,ti.width,ti.height, (double)ti.fps_numerator/ti.fps_denominator,
+            ti.frame_width, ti.frame_height, ti.offset_x, ti.offset_y);
   }else{
     /* tear down the partial theora setup */
     theora_info_clear(&ti);
@@ -257,27 +256,27 @@
 
   stateflag=0; /* playback has not begun */
   while(!got_sigint){
-      
+
     while(theora_p && !videobuf_ready){
       /* theora is one in, one out... */
       if(ogg_stream_packetout(&to,&op)>0){
-   
-	theora_decode_packetin(&td,&op);
-	videobuf_granulepos=td.granulepos;
-	videobuf_time=theora_granule_time(&td,videobuf_granulepos);
-	videobuf_ready=1;
-		
+
+        theora_decode_packetin(&td,&op);
+        videobuf_granulepos=td.granulepos;
+        videobuf_time=theora_granule_time(&td,videobuf_granulepos);
+        videobuf_ready=1;
+
       }else
-	break;
+        break;
     }
-    
+
     if(!videobuf_ready  && feof(infile))break;
-    
+
     if(!videobuf_ready ){
       /* no data yet for somebody.  Grab another page */
       int ret=buffer_data(infile,&oy);
       while(ogg_sync_pageout(&oy,&og)>0){
-      	queue_page(&og);
+        queue_page(&og);
       }
     }
 
@@ -297,10 +296,10 @@
   ogg_sync_clear(&oy);
 
   if(infile && infile!=stdin)fclose(infile);
-  
+
   fprintf(stderr,
-	  "\r                                                              "
-	  "\nDone.\n");
+          "\r                                                              "
+          "\nDone.\n");
   return(0);
 
 }

<p><p>1.21      +258 -258  theora/examples/encoder_example.c

Index: encoder_example.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/encoder_example.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- encoder_example.c	9 Jun 2003 01:45:19 -0000	1.20
+++ encoder_example.c	10 Jun 2003 01:31:32 -0000	1.21
@@ -10,15 +10,15 @@
  *                                                                  *
  ********************************************************************
 
-  function: example encoder application; makes an Ogg Theora/Vorbis 
+  function: example encoder application; makes an Ogg Theora/Vorbis
             file from YUV4MPEG2 and WAV input
-  last mod: $Id: encoder_example.c,v 1.20 2003/06/09 01:45:19 tterribe Exp $
+  last mod: $Id: encoder_example.c,v 1.21 2003/06/10 01:31:32 tterribe Exp $
 
  ********************************************************************/
 
 #define _GNU_SOURCE
 #define _REENTRANT
-#define _LARGEFILE_SOURCE 
+#define _LARGEFILE_SOURCE
 #define _LARGEFILE64_SOURCE
 #define _FILE_OFFSET_BITS 64
 
@@ -38,10 +38,10 @@
 
 static double rint(double x)
 {
-    if (x < 0.0)
-        return (double)(int)(x - 0.5);
-    else
-        return (double)(int)(x + 0.5);
+  if (x < 0.0)
+    return (double)(int)(x - 0.5);
+  else
+    return (double)(int)(x + 0.5);
 }
 #endif
 
@@ -60,8 +60,8 @@
 FILE *audio=NULL;
 FILE *video=NULL;
 
-int audio_ch=0; 
-int audio_hz=0; 
+int audio_ch=0;
+int audio_hz=0;
 
 float audio_q=.1;
 int audio_r=-1;
@@ -82,27 +82,27 @@
 
 static void usage(void){
   fprintf(stderr,
-	  "Usage: encoder_example [options] [audio_file] video_file\n\n"
-	  "Options: \n\n"
-	  "  -o --output <filename.ogg>  file name for encoded output;\n"
-	  "                              If this option is not given, the\n"
-	  "                              compressed data is sent to stdout.\n\n"
-	  "  -A --audio-rate-target <n>  bitrate target for Vorbis audio;\n"
-	  "                              use -a and not -A if at all possible,\n"
-	  "                              as -a gives higher quality for a given\n"
-	  "                              bitrate.\n\n"
+          "Usage: encoder_example [options] [audio_file] video_file\n\n"
+          "Options: \n\n"
+          "  -o --output <filename.ogg>  file name for encoded output;\n"
+          "                              If this option is not given, the\n"
+          "                              compressed data is sent to stdout.\n\n"
+          "  -A --audio-rate-target <n>  bitrate target for Vorbis audio;\n"
+          "                              use -a and not -A if at all possible,\n"
+          "                              as -a gives higher quality for a given\n"
+          "                              bitrate.\n\n"
           "  -V --video-rate-target <n>  bitrate target for Theora video\n\n"
-	  "  -a --audio-quality <n>      Vorbis quality selector from -1 to 10\n"
-	  "                              (-1 yields smallest files but lowest\n"
-	  "                              fidelity; 10 yields highest fidelity\n"
-	  "                              but large files. '2' is a reasonable\n"
-	  "                              default).\n\n"
-	  "   -v --video-quality <n>     Theora quality selector fro 0 to 10\n"
-	  "                              (0 yields smallest files but lowest\n"
-	  "                              video quality. 10 yields highest\n"
-	  "                              fidelity but large files).\n\n"
-	  "encoder_example accepts only uncompressed RIFF WAV format audio and\n"
-	  "YUV4MPEG2 uncompressed video.\n\n");
+          "  -a --audio-quality <n>      Vorbis quality selector from -1 to 10\n"
+          "                              (-1 yields smallest files but lowest\n"
+          "                              fidelity; 10 yields highest fidelity\n"
+          "                              but large files. '2' is a reasonable\n"
+          "                              default).\n\n"
+          "   -v --video-quality <n>     Theora quality selector fro 0 to 10\n"
+          "                              (0 yields smallest files but lowest\n"
+          "                              video quality. 10 yields highest\n"
+          "                              fidelity but large files).\n\n"
+          "encoder_example accepts only uncompressed RIFF WAV format audio and\n"
+          "YUV4MPEG2 uncompressed video.\n\n");
   exit(1);
 }
 
@@ -145,53 +145,53 @@
     ret=fread(buffer,1,4,test);
     if(ret<4)goto riff_err;
     if(!memcmp(buffer,"WAVE",4)){
-      
+
       while(!feof(test)){
-	ret=fread(buffer,1,4,test);
-	if(ret<4)goto riff_err;
-	if(!memcmp("fmt",buffer,3)){
-
-	  /* OK, this is our audio specs chunk.  Slurp it up. */
-
-	  ret=fread(buffer,1,20,test);
-	  if(ret<20)goto riff_err;
-
-	  if(memcmp(buffer+4,"\001\000",2)){
-	    fprintf(stderr,"The WAV file %s is in a compressed format; "
-		    "can't read it.\n",f);
-	    exit(1);
-	  }
-
-	  audio=test;
-	  audio_ch=buffer[6]+(buffer[7]<<8);
-	  audio_hz=buffer[8]+(buffer[9]<<8)+
-	    (buffer[10]<<16)+(buffer[11]<<24);
-
-	  if(buffer[18]+(buffer[19]<<8)!=16){
-	    fprintf(stderr,"Can only read 16 bit WAV files for now.\n",f);
-	    exit(1);
-	  }
-	  
-	  /* Now, align things to the beginning of the data */
-	  /* Look for 'dataxxxx' */
-	  while(!feof(test)){
-	    ret=fread(buffer,1,4,test);
-	    if(ret<4)goto riff_err;
-	    if(!memcmp("data",buffer,4)){
-	      /* We're there.  Ignore the declared size for now. */
-	      ret=fread(buffer,1,4,test);
-	      if(ret<4)goto riff_err;
-
-	      fprintf(stderr,"File %s is 16 bit %d channel %d Hz RIFF WAV audio.\n",
-		      f,audio_ch,audio_hz);
-
-	      return;
-	    }
-	  }
-	}
+        ret=fread(buffer,1,4,test);
+        if(ret<4)goto riff_err;
+        if(!memcmp("fmt",buffer,3)){
+
+          /* OK, this is our audio specs chunk.  Slurp it up. */
+
+          ret=fread(buffer,1,20,test);
+          if(ret<20)goto riff_err;
+
+          if(memcmp(buffer+4,"\001\000",2)){
+            fprintf(stderr,"The WAV file %s is in a compressed format; "
+                    "can't read it.\n",f);
+            exit(1);
+          }
+
+          audio=test;
+          audio_ch=buffer[6]+(buffer[7]<<8);
+          audio_hz=buffer[8]+(buffer[9]<<8)+
+            (buffer[10]<<16)+(buffer[11]<<24);
+
+          if(buffer[18]+(buffer[19]<<8)!=16){
+            fprintf(stderr,"Can only read 16 bit WAV files for now.\n",f);
+            exit(1);
+          }
+
+          /* Now, align things to the beginning of the data */
+          /* Look for 'dataxxxx' */
+          while(!feof(test)){
+            ret=fread(buffer,1,4,test);
+            if(ret<4)goto riff_err;
+            if(!memcmp("data",buffer,4)){
+              /* We're there.  Ignore the declared size for now. */
+              ret=fread(buffer,1,4,test);
+              if(ret<4)goto riff_err;
+
+              fprintf(stderr,"File %s is 16 bit %d channel %d Hz RIFF WAV audio.\n",
+                      f,audio_ch,audio_hz);
+
+              return;
+            }
+          }
+        }
       }
     }
-    
+
     fprintf(stderr,"Couldn't find WAVE data in RIFF file %s.\n",f);
     exit(1);
 
@@ -216,33 +216,33 @@
       int aspectd;
 
       if(video){
-	/* umm, we already have one */
-	fprintf(stderr,"Multiple video files specified on command line.\n");
-	exit(1);
+        /* umm, we already have one */
+        fprintf(stderr,"Multiple video files specified on command line.\n");
+        exit(1);
       }
 
       if(buffer[4]!='2'){
-	fprintf(stderr,"Incorrect YUV input file version; YUV4MPEG2 required.\n");
+        fprintf(stderr,"Incorrect YUV input file version; YUV4MPEG2 required.\n");
       }
-      
+
       ret=sscanf(buffer,"MPEG2 W%d H%d F%d:%d I%c A%d:%d",
-		 &frame_x,&frame_y,&video_hzn,&video_hzd,&interlace,
-		 &video_an,&video_ad);
+                 &frame_x,&frame_y,&video_hzn,&video_hzd,&interlace,
+                 &video_an,&video_ad);
       if(ret<7){
-	fprintf(stderr,"Error parsing YUV4MPEG2 header in file %s.\n",f);
-	exit(1);
+        fprintf(stderr,"Error parsing YUV4MPEG2 header in file %s.\n",f);
+        exit(1);
       }
 
       if(interlace!='p'){
-	fprintf(stderr,"Input video is interlaced; Theora handles only progressive scan\n",f);
-	exit(1);
+        fprintf(stderr,"Input video is interlaced; Theora handles only progressive scan\n",f);
+        exit(1);
       }
 
       video=test;
-      
+
       fprintf(stderr,"File %s is %dx%d %.02f fps YUV12 video.\n",
-	      f,frame_x,frame_y,(double)video_hzn/video_hzd);
-      
+              f,frame_x,frame_y,(double)video_hzn/video_hzd);
+
       return;
     }
   }
@@ -255,7 +255,7 @@
  yuv_err:
   fprintf(stderr,"EOF parsing YUV4MPEG2 file %s.\n",f);
   exit(1);
-  
+
 }
 
 int spinner=0;
@@ -267,10 +267,10 @@
 }
 
 int fetch_and_process_audio(FILE *audio,ogg_page *audiopage,
-			    ogg_stream_state *vo,
-			    vorbis_dsp_state *vd,
-			    vorbis_block *vb,
-			    int audioflag){
+                            ogg_stream_state *vo,
+                            vorbis_dsp_state *vd,
+                            vorbis_block *vb,
+                            int audioflag){
   ogg_packet op;
   int i,j;
 
@@ -288,49 +288,49 @@
       int sampread=bytesread/2/audio_ch;
       float **vorbis_buffer;
       int count=0;
-      
+
       if(bytesread<=0){
-	/* end of file.  this can be done implicitly, but it's
-	   easier to see here in non-clever fashion.  Tell the
-	   library we're at end of stream so that it can handle the
-	   last frame and mark end of stream in the output properly */
-	vorbis_analysis_wrote(vd,0);
+        /* end of file.  this can be done implicitly, but it's
+           easier to see here in non-clever fashion.  Tell the
+           library we're at end of stream so that it can handle the
+           last frame and mark end of stream in the output properly */
+        vorbis_analysis_wrote(vd,0);
       }else{
-	vorbis_buffer=vorbis_analysis_buffer(vd,sampread);
-	/* uninterleave samples */
-	for(i=0;i<sampread;i++){
-	  for(j=0;j<audio_ch;j++){
-	    vorbis_buffer[j][i]=((readbuffer[count+1]<<8)|
-				 (0x00ff&(int)readbuffer[count]))/32768.f;
-	    count+=2;
-	  }
-	}
-	
-	vorbis_analysis_wrote(vd,sampread);
-	
+        vorbis_buffer=vorbis_analysis_buffer(vd,sampread);
+        /* uninterleave samples */
+        for(i=0;i<sampread;i++){
+          for(j=0;j<audio_ch;j++){
+            vorbis_buffer[j][i]=((readbuffer[count+1]<<8)|
+                                 (0x00ff&(int)readbuffer[count]))/32768.f;
+            count+=2;
+          }
+        }
+        
+        vorbis_analysis_wrote(vd,sampread);
+        
       }
-      
+
       while(vorbis_analysis_blockout(vd,vb)==1){
-	
-	/* analysis, assume we want to use bitrate management */
-	vorbis_analysis(vb,NULL);
-	vorbis_bitrate_addblock(vb);
-	
-	/* weld packets into the bitstream */
-	while(vorbis_bitrate_flushpacket(vd,&op))
-	  ogg_stream_packetin(vo,&op);
-	
+        
+        /* analysis, assume we want to use bitrate management */
+        vorbis_analysis(vb,NULL);
+        vorbis_bitrate_addblock(vb);
+        
+        /* weld packets into the bitstream */
+        while(vorbis_bitrate_flushpacket(vd,&op))
+          ogg_stream_packetin(vo,&op);
+        
       }
     }
   }
-  
+
   return audioflag;
 }
 
 int fetch_and_process_video(FILE *video,ogg_page *videopage,
-			    ogg_stream_state *to,
-			    theora_state *td,
-			    int videoflag){
+                            ogg_stream_state *to,
+                            theora_state *td,
+                            int videoflag){
   /* You'll go to Hell for using static variables */
   static int          state=-1;
   static signed char *yuvframe[2];
@@ -340,12 +340,12 @@
   int i, e;
 
   if(state==-1){
-	/* initialize the double frame buffer */
+        /* initialize the double frame buffer */
     yuvframe[0]=malloc(video_x*video_y*3/2);
     yuvframe[1]=malloc(video_x*video_y*3/2);
 
-	/* clear initial frame as it may be larger than actual video data */
-	/* fill Y plane with 0x10 and UV planes with 0X80, for black data */
+        /* clear initial frame as it may be larger than actual video data */
+        /* fill Y plane with 0x10 and UV planes with 0X80, for black data */
     memset(yuvframe[0],0x10,video_x*video_y);
     memset(yuvframe[0]+video_x*video_y,0x80,video_x*video_y/2);
     memset(yuvframe[1],0x10,video_x*video_y);
@@ -357,97 +357,97 @@
   /* is there a video page flushed?  If not, work until there is. */
   while(!videoflag){
     spinnit();
-    
+
     if(ogg_stream_pageout(to,videopage)>0) return 1;
     if(ogg_stream_eos(to)) return 0;
 
     {
       /* read and process more video */
       /* video strategy reads one frame ahead so we know when we're
-	 at end of stream and can mark last video frame as such
-	 (vorbis audio has to flush one frame past last video frame
-	 due to overlap and thus doesn't need this extra work */
-      
+         at end of stream and can mark last video frame as such
+         (vorbis audio has to flush one frame past last video frame
+         due to overlap and thus doesn't need this extra work */
+
       /* have two frame buffers full (if possible) before
-	 proceeding.  after first pass and until eos, one will
-	 always be full when we get here */
+         proceeding.  after first pass and until eos, one will
+         always be full when we get here */
 
       for(i=state;i<2;i++){
-	char frame[6];
-	int ret=fread(frame,1,6,video);
-	
-	if(ret<6)break;
-	if(memcmp(frame,"FRAME\n",6)){
-	  fprintf(stderr,"Loss of framing in YUV input data\n");
-	  exit(1);
-	}
-
-	/* read the Y plane into our frame buffer with centering */
-	line=yuvframe[i]+video_x*frame_y_offset+frame_x_offset;
-	for(e=0;e<frame_y;e++){
-	  ret=fread(line,1,frame_x,video);
-	    if(ret!=frame_x) break;
-	  line+=video_x; 
-	}
-	/* now get U plane*/
-	line=yuvframe[i]+(video_x*video_y)
-	  +(video_x/2)*(frame_y_offset/2)+frame_x_offset/2;
-	for(e=0;e<frame_y/2;e++){
-	  ret=fread(line,1,frame_x/2,video);
-	    if(ret!=frame_x/2) break;
-	  line+=video_x/2;
-	}
-	/* and the V plane*/
-	line=yuvframe[i]+(video_x*video_y*5/4)
-		  +(video_x/2)*(frame_y_offset/2)+frame_x_offset/2;
-	for(e=0;e<frame_y/2;e++){
-	  ret=fread(line,1,frame_x/2,video);
-	    if(ret!=frame_x/2) break;
-	  line+=video_x/2;
-	}
-	state++;
+        char frame[6];
+        int ret=fread(frame,1,6,video);
+        
+        if(ret<6)break;
+        if(memcmp(frame,"FRAME\n",6)){
+          fprintf(stderr,"Loss of framing in YUV input data\n");
+          exit(1);
+        }
+
+        /* read the Y plane into our frame buffer with centering */
+        line=yuvframe[i]+video_x*frame_y_offset+frame_x_offset;
+        for(e=0;e<frame_y;e++){
+          ret=fread(line,1,frame_x,video);
+            if(ret!=frame_x) break;
+          line+=video_x;
+        }
+        /* now get U plane*/
+        line=yuvframe[i]+(video_x*video_y)
+          +(video_x/2)*(frame_y_offset/2)+frame_x_offset/2;
+        for(e=0;e<frame_y/2;e++){
+          ret=fread(line,1,frame_x/2,video);
+            if(ret!=frame_x/2) break;
+          line+=video_x/2;
+        }
+        /* and the V plane*/
+        line=yuvframe[i]+(video_x*video_y*5/4)
+                  +(video_x/2)*(frame_y_offset/2)+frame_x_offset/2;
+        for(e=0;e<frame_y/2;e++){
+          ret=fread(line,1,frame_x/2,video);
+            if(ret!=frame_x/2) break;
+          line+=video_x/2;
+        }
+        state++;
       }
 
       if(state<1){
-	/* can't get here unless YUV4MPEG stream has no video */
-	fprintf(stderr,"Video input contains no frames.\n");
-	exit(1);
+        /* can't get here unless YUV4MPEG stream has no video */
+        fprintf(stderr,"Video input contains no frames.\n");
+        exit(1);
       }
-      
+
       /* Theora is a one-frame-in,one-frame-out system; submit a frame
          for compression and pull out the packet */
-      
+
       {
-	yuv.y_width=video_x;
-	yuv.y_height=video_y;
-	yuv.y_stride=video_x;
-
-	yuv.uv_width=video_x/2;
-	yuv.uv_height=video_y/2;
-	yuv.uv_stride=video_x/2;
-
-	yuv.y= yuvframe[0];
-	yuv.u= yuvframe[0]+ video_x*video_y;
-	yuv.v= yuvframe[0]+ video_x*video_y*5/4 ;
+        yuv.y_width=video_x;
+        yuv.y_height=video_y;
+        yuv.y_stride=video_x;
+
+        yuv.uv_width=video_x/2;
+        yuv.uv_height=video_y/2;
+        yuv.uv_stride=video_x/2;
+
+        yuv.y= yuvframe[0];
+        yuv.u= yuvframe[0]+ video_x*video_y;
+        yuv.v= yuvframe[0]+ video_x*video_y*5/4 ;
       }
-      
+
       theora_encode_YUVin(td,&yuv);
 
       /* if there's only one frame, it's the last in the stream */
       if(state<2)
-	theora_encode_packetout(td,1,&op);
+        theora_encode_packetout(td,1,&op);
       else
-	theora_encode_packetout(td,0,&op);
-      
+        theora_encode_packetout(td,0,&op);
+
       ogg_stream_packetin(to,&op);
-      
+
       {
-	signed char *temp=yuvframe[0];
-	yuvframe[0]=yuvframe[1];
-	yuvframe[1]=temp;
-	state--;
+        signed char *temp=yuvframe[0];
+        yuvframe[0]=yuvframe[1];
+        yuvframe[1]=temp;
+        state--;
       }
-      
+
     }
   }
   return videoflag;
@@ -484,11 +484,11 @@
   double timebase;
 
   FILE* outfile = stdout;
-  
+
 #ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
   /* if we were reading/writing a file, it would also need to in
      binary mode, eg, fopen("file.wav","wb"); */
-  /* Beware the evil ifdef. We avoid these where we can, but this one we 
+  /* Beware the evil ifdef. We avoid these where we can, but this one we
      cannot. Don't add any more, you'll probably go to hell if you do. */
   _setmode( _fileno( stdin ), _O_BINARY );
   _setmode( _fileno( stdout ), _O_BINARY );
@@ -503,39 +503,39 @@
         exit(1);
       }
       break;;
-      
+
     case 'a':
       audio_q=atof(optarg)*.099;
       if(audio_q<-.1 || audio_q>1){
-	fprintf(stderr,"Illegal audio quality (choose -1 through 10)\n");
-	exit(1);
+        fprintf(stderr,"Illegal audio quality (choose -1 through 10)\n");
+        exit(1);
       }
       audio_r=-1;
-      break; 
-      
+      break;
+
     case 'v':
       video_q=rint(atof(optarg)*6.3);
       if(video_q<0 || video_q>63){
-	fprintf(stderr,"Illegal video quality (choose 0 through 10)\n");
-	exit(1);
+        fprintf(stderr,"Illegal video quality (choose 0 through 10)\n");
+        exit(1);
       }
       video_r=0;
       break;
-     
+
     case 'A':
       audio_r=atof(optarg)*1000;
       if(audio_q<0){
-	fprintf(stderr,"Illegal audio quality (choose > 0 please)\n");
-	exit(1);
+        fprintf(stderr,"Illegal audio quality (choose > 0 please)\n");
+        exit(1);
       }
       audio_q=-99;
-      break; 
+      break;
 
     case 'V':
       video_r=rint(atof(optarg)*1000);
       if(video_r<45000 || video_r>2000000){
-	fprintf(stderr,"Illegal video bitrate (choose 45kbps through 2000kbps)\n");
-	exit(1);
+        fprintf(stderr,"Illegal video bitrate (choose 45kbps through 2000kbps)\n");
+        exit(1);
       }
       video_q=0;
      break;
@@ -566,7 +566,7 @@
   video_y=((frame_y + 15) >>4)<<4;
   frame_x_offset=(video_x-frame_x)/2;
   frame_y_offset=(video_y-frame_y)/2;
-  
+
   theora_info_init(&ti);
   ti.width=video_x;
   ti.height=video_y;
@@ -581,7 +581,7 @@
   ti.colorspace=not_specified;
   ti.target_bitrate=video_r;
   ti.quality=video_q;
-  
+
   ti.dropframes_p=0;
   ti.quick_p=1;
   ti.keyframe_auto_p=1;
@@ -604,10 +604,10 @@
       ret = vorbis_encode_init(&vi,audio_ch,audio_hz,-1,audio_r,-1);
     if(ret){
       fprintf(stderr,"The Vorbis encoder could not set up a mode according to\n"
-	      "the requested quality or bitrate.\n\n");
+              "the requested quality or bitrate.\n\n");
       exit(1);
     }
-    
+
     vorbis_comment_init(&vc);
     vorbis_analysis_init(&vd,&vi);
     vorbis_block_init(&vd,&vb);
@@ -621,7 +621,7 @@
   if(ogg_stream_pageout(&to,&og)!=1){
     fprintf(stderr,"Internal Ogg library error.\n");
     exit(1);
-  }  
+  }
   fwrite(og.header,1,og.header_len,outfile);
   fwrite(og.body,1,og.body_len,outfile);
 
@@ -630,13 +630,13 @@
   theora_encode_comment(&tc,&op);
   ogg_stream_packetin(&to,&op);
   theora_encode_tables(&td,&op);
-  ogg_stream_packetin(&to,&op); 
-  
+  ogg_stream_packetin(&to,&op);
+
   if(audio){
     ogg_packet header;
     ogg_packet header_comm;
     ogg_packet header_code;
-    
+
     vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code);
     ogg_stream_packetin(&vo,&header); /* automatically placed in its own
                                          page */
@@ -646,14 +646,14 @@
     }
     fwrite(og.header,1,og.header_len,outfile);
     fwrite(og.body,1,og.body_len,outfile);
-    
+
     /* remaining vorbis header packets */
     ogg_stream_packetin(&vo,&header_comm);
     ogg_stream_packetin(&vo,&header_code);
   }
-  
+
   /* Flush the rest of our headers. This ensures
-     the actual data in each stream will start 
+     the actual data in each stream will start
      on a new page, as per spec. */
   while(1){
     int result = ogg_stream_flush(&to,&og);
@@ -670,9 +670,9 @@
     while(1){
       int result=ogg_stream_flush(&vo,&og);
       if(result<0){
-	/* can't get here */
-	fprintf(stderr,"Internal Ogg library error.\n");
-	exit(1);
+        /* can't get here */
+        fprintf(stderr,"Internal Ogg library error.\n");
+        exit(1);
       }
       if(result==0)break;
       fwrite(og.header,1,og.header_len,outfile);
@@ -691,61 +691,61 @@
 
     /* is there a video page flushed?  If not, fetch one if possible */
     videoflag=fetch_and_process_video(video,&videopage,&to,&td,videoflag);
-    
+
     /* no pages of either?  Must be end of stream. */
-    if(!audioflag && !videoflag)break; 
+    if(!audioflag && !videoflag)break;
 
     /* which is earlier; the end of the audio page or the end of the
        video page? Flush the earlier to stream */
     {
       int audio_or_video=-1;
       double audiotime=
-	audioflag?vorbis_granule_time(&vd,ogg_page_granulepos(&audiopage)):-1;
+        audioflag?vorbis_granule_time(&vd,ogg_page_granulepos(&audiopage)):-1;
       double videotime=
-	videoflag?theora_granule_time(&td,ogg_page_granulepos(&videopage)):-1;
+        videoflag?theora_granule_time(&td,ogg_page_granulepos(&videopage)):-1;
 
       if(!audioflag){
-	audio_or_video=1;
+        audio_or_video=1;
       } else if(!videoflag) {
-	audio_or_video=0;
+        audio_or_video=0;
       } else {
-	if(audiotime<videotime)
-	  audio_or_video=0;
-	else
-	  audio_or_video=1;
+        if(audiotime<videotime)
+          audio_or_video=0;
+        else
+          audio_or_video=1;
       }
 
       if(audio_or_video==1){
-	/* flush a video page */
-	video_bytesout+=fwrite(videopage.header,1,videopage.header_len,outfile);
-	video_bytesout+=fwrite(videopage.body,1,videopage.body_len,outfile);
-	videoflag=0;
-	timebase=videotime;
-	
+        /* flush a video page */
+        video_bytesout+=fwrite(videopage.header,1,videopage.header_len,outfile);
+        video_bytesout+=fwrite(videopage.body,1,videopage.body_len,outfile);
+        videoflag=0;
+        timebase=videotime;
+        
       }else{
-	/* flush an audio page */
-	audio_bytesout+=fwrite(audiopage.header,1,audiopage.header_len,outfile);
-	audio_bytesout+=fwrite(audiopage.body,1,audiopage.body_len,outfile);
-	audioflag=0;
-	timebase=audiotime;
+        /* flush an audio page */
+        audio_bytesout+=fwrite(audiopage.header,1,audiopage.header_len,outfile);
+        audio_bytesout+=fwrite(audiopage.body,1,audiopage.body_len,outfile);
+        audioflag=0;
+        timebase=audiotime;
       }
       {
-	int hundredths=timebase*100-(long)timebase*100;
-	int seconds=(long)timebase%60;
-	int minutes=((long)timebase/60)%60;
-	int hours=(long)timebase/3600;
-	
-	if(audio_or_video)
-	  vkbps=rint(video_bytesout*8./timebase*.001);
-	else
-	  akbps=rint(audio_bytesout*8./timebase*.001);
-	
-	fprintf(stderr,
-		"\r      %d:%02d:%02d.%02d audio: %dkbps video: %dkbps                 ",
-		hours,minutes,seconds,hundredths,akbps,vkbps);
+        int hundredths=timebase*100-(long)timebase*100;
+        int seconds=(long)timebase%60;
+        int minutes=((long)timebase/60)%60;
+        int hours=(long)timebase/3600;
+        
+        if(audio_or_video)
+          vkbps=rint(video_bytesout*8./timebase*.001);
+        else
+          akbps=rint(audio_bytesout*8./timebase*.001);
+        
+        fprintf(stderr,
+                "\r      %d:%02d:%02d.%02d audio: %dkbps video: %dkbps                 ",
+                hours,minutes,seconds,hundredths,akbps,vkbps);
       }
     }
-	    
+
   }
 
   /* clear out state */
@@ -761,7 +761,7 @@
     ogg_stream_clear(&to);
     theora_clear(&td);
   }
-  
+
   if(outfile && outfile!=stdout)fclose(outfile);
 
   fprintf(stderr,"\r   \ndone.\n\n");

<p><p>1.23      +160 -160  theora/examples/player_example.c

Index: player_example.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/player_example.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- player_example.c	9 Jun 2003 12:21:21 -0000	1.22
+++ player_example.c	10 Jun 2003 01:31:32 -0000	1.23
@@ -12,7 +12,7 @@
 
   function: example SDL player application; plays Ogg Theora files (with
             optional Vorbis audio second stream)
-  last mod: $Id: player_example.c,v 1.22 2003/06/09 12:21:21 giles Exp $
+  last mod: $Id: player_example.c,v 1.23 2003/06/10 01:31:32 tterribe Exp $
 
  ********************************************************************/
 
@@ -27,7 +27,7 @@
 
 #define _GNU_SOURCE
 #define _REENTRANT
-#define _LARGEFILE_SOURCE 
+#define _LARGEFILE_SOURCE
 #define _LARGEFILE64_SOURCE
 #define _FILE_OFFSET_BITS 64
 
@@ -72,7 +72,7 @@
 
 /* never forget that globals are a one-way ticket to Hell */
 /* Ogg and codec state for demux/decode */
-ogg_sync_state   oy; 
+ogg_sync_state   oy;
 ogg_page         og;
 ogg_stream_state vo;
 ogg_stream_state to;
@@ -111,9 +111,9 @@
 strategy under Linux [the UNIX where Everything Is Hard].  Naturally,
 this works on other platforms using OSS for sound as well.
 
-In OSS, we don't have reliable access to any precise information on 
+In OSS, we don't have reliable access to any precise information on
 the exact current playback position (that, of course would have been
-too easy; the kernel folks like to keep us app people working hard 
+too easy; the kernel folks like to keep us app people working hard
 doing simple things that should have been solved once and abstracted
 long ago).  Hopefully ALSA solves this a little better; we'll probably
 use that once ALSA is the standard in the stable kernel.
@@ -122,7 +122,7 @@
 synced to its own clock, and both the system and audio clocks suffer
 from wobble, drift, and a lack of accuracy that can be guaranteed to
 add a reliable percent or so of error.  After ten seconds, that's
-100ms.  We can't drift by half a second every minute. 
+100ms.  We can't drift by half a second every minute.
 
 Although OSS can't generally tell us where the audio playback pointer
 is, we do know that if we work in complete audio fragments and keep
@@ -136,9 +136,9 @@
 
 long         audiofd_totalsize=-1;
 int          audiofd_fragsize;      /* read and write only complete fragments
-				       so that SNDCTL_DSP_GETOSPACE is 
-				       accurate immediately after a bank
-				       switch */
+                                       so that SNDCTL_DSP_GETOSPACE is
+                                       accurate immediately after a bank
+                                       switch */
 int          audiofd=-1;
 ogg_int64_t  audiofd_timer_calibrate=-1;
 
@@ -148,35 +148,35 @@
   int channels=vi.channels;
   int rate=vi.rate;
   int ret;
-  
+
   audiofd=open(AUDIO_DEVICE,O_RDWR);
   if(audiofd<0){
     fprintf(stderr,"Could not open audio device " AUDIO_DEVICE ".\n");
     exit(1);
   }
-  
+
   ret=ioctl(audiofd,SNDCTL_DSP_SETFMT,&format);
   if(ret){
     fprintf(stderr,"Could not set 16 bit host-endian playback\n");
     exit(1);
   }
-  
+
   ret=ioctl(audiofd,SNDCTL_DSP_CHANNELS,&channels);
   if(ret){
     fprintf(stderr,"Could not set %d channel playback\n",channels);
     exit(1);
   }
-  
+
   ret=ioctl(audiofd,SNDCTL_DSP_SPEED,&rate);
   if(ret){
     fprintf(stderr,"Could not set %d Hz playback\n",rate);
     exit(1);
   }
-  
+
   ioctl(audiofd,SNDCTL_DSP_GETOSPACE,&info);
   audiofd_fragsize=info.fragsize;
   audiofd_totalsize=info.fragstotal*info.fragsize;
-  
+
   audiobuf=malloc(audiofd_fragsize);
 }
 
@@ -203,7 +203,7 @@
   }else
     current_sample=audiobuf_granulepos-
       (audiobuf_fill+audiofd_totalsize-audiofd_fragsize)/2/vi.channels;
-  
+
   new_time-=1000*current_sample/vi.rate;
 
   audiofd_timer_calibrate=new_time;
@@ -237,9 +237,9 @@
     int seconds=(long)timebase%60;
     int minutes=((long)timebase/60)%60;
     int hours=(long)timebase/3600;
-    
+
     fprintf(stderr,"   Playing: %d:%02d:%02d.%02d                       \r",
-	    hours,minutes,seconds,hundredths);
+            hours,minutes,seconds,hundredths);
     up=now;
   }
 
@@ -250,7 +250,7 @@
 /* write a fragment to the OSS kernel audio API, but only if we can
    stuff in a whole fragment without blocking */
 void audio_write_nonblocking(void){
-  
+
   if(audiobuf_ready){
     audio_buf_info info;
     long bytes;
@@ -259,26 +259,26 @@
     bytes=info.bytes;
     if(bytes>=audiofd_fragsize){
       if(bytes==audiofd_totalsize)audio_calibrate_timer(1);
-   
+
       while(1){
-	bytes=write(audiofd,audiobuf+(audiofd_fragsize-audiobuf_fill),
-		    audiofd_fragsize);
-	
-	if(bytes>0){
-	
-	  if(bytes!=audiobuf_fill){
-	    /* shouldn't actually be possible... but eh */
-	    audiobuf_fill-=bytes;
-	  }else
-	    break;
-	}
+        bytes=write(audiofd,audiobuf+(audiofd_fragsize-audiobuf_fill),
+                    audiofd_fragsize);
+        
+        if(bytes>0){
+        
+          if(bytes!=audiobuf_fill){
+            /* shouldn't actually be possible... but eh */
+            audiobuf_fill-=bytes;
+          }else
+            break;
+        }
       }
 
       audiobuf_fill=0;
       audiobuf_ready=0;
 
     }
-  } 
+  }
 }
 
 /* clean quit on Ctrl-C for SDL and thread shutdown as per SDL example
@@ -293,20 +293,20 @@
     fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
     exit(1);
   }
-  
+
   screen = SDL_SetVideoMode(ti.frame_width, ti.frame_height, 0, SDL_SWSURFACE);
   if ( screen == NULL ) {
-    fprintf(stderr, "Unable to set %dx%d video: %s\n", 
-	    ti.frame_width,ti.frame_height,SDL_GetError());
+    fprintf(stderr, "Unable to set %dx%d video: %s\n",
+            ti.frame_width,ti.frame_height,SDL_GetError());
     exit(1);
   }
-  
+
   yuv_overlay = SDL_CreateYUVOverlay(ti.frame_width, ti.frame_height,
-				     SDL_YV12_OVERLAY,
-				     screen);
+                                     SDL_YV12_OVERLAY,
+                                     screen);
   if ( yuv_overlay == NULL ) {
-    fprintf(stderr, "SDL: Couldn't create SDL_yuv_overlay: %s\n", 
-	    SDL_GetError());
+    fprintf(stderr, "SDL: Couldn't create SDL_yuv_overlay: %s\n",
+            SDL_GetError());
     exit(1);
   }
   rect.x = 0;
@@ -322,30 +322,30 @@
   yuv_buffer yuv;
   int crop_offset;
   theora_decode_YUVout(&td,&yuv);
-  
+
   /* Lock SDL_yuv_overlay */
   if ( SDL_MUSTLOCK(screen) ) {
     if ( SDL_LockSurface(screen) < 0 ) return;
   }
   if (SDL_LockYUVOverlay(yuv_overlay) < 0) return;
-  
+
   /* let's draw the data (*yuv[3]) on a SDL screen (*screen) */
   /* deal with border stride */
   /* reverse u and v for SDL */
   /* and crop input properly, respecting the encoded frame rect */
   crop_offset=ti.offset_x+yuv.y_stride*ti.offset_y;
   for(i=0;i<yuv_overlay->h;i++)
-    memcpy(yuv_overlay->pixels[0]+yuv_overlay->pitches[0]*i, 
-	   yuv.y+crop_offset+yuv.y_stride*i, 
-	   yuv_overlay->w);
+    memcpy(yuv_overlay->pixels[0]+yuv_overlay->pitches[0]*i,
+           yuv.y+crop_offset+yuv.y_stride*i,
+           yuv_overlay->w);
   crop_offset=(ti.offset_x/2)+(yuv.uv_stride)*(ti.offset_y/2);
   for(i=0;i<yuv_overlay->h/2;i++){
-    memcpy(yuv_overlay->pixels[1]+yuv_overlay->pitches[1]*i, 
-	   yuv.v+crop_offset+yuv.uv_stride*i, 
-	   yuv_overlay->w/2);
-    memcpy(yuv_overlay->pixels[2]+yuv_overlay->pitches[2]*i, 
-	   yuv.u+crop_offset+yuv.uv_stride*i, 
-	   yuv_overlay->w/2);
+    memcpy(yuv_overlay->pixels[1]+yuv_overlay->pitches[1]*i,
+           yuv.v+crop_offset+yuv.uv_stride*i,
+           yuv_overlay->w/2);
+    memcpy(yuv_overlay->pixels[2]+yuv_overlay->pitches[2]*i,
+           yuv.u+crop_offset+yuv.uv_stride*i,
+           yuv_overlay->w/2);
   }
 
   /* Unlock SDL_yuv_overlay */
@@ -357,25 +357,25 @@
 
   /* Show, baby, show! */
   SDL_DisplayYUVOverlay(yuv_overlay, &rect);
-  
+
 }
 /* dump the theora (or vorbis) comment header */
 static int dump_comments(theora_comment *tc){
   int i, len;
   char *value;
   FILE *out=stdout;
-  
+
   fprintf(out,"Encoded by %s\n",tc->vendor);
   if(tc->comments){
     fprintf(out, "theora comment header:\n");
     for(i=0;i<tc->comments;i++){
       if(tc->user_comments[i]){
         len=tc->comment_lengths[i];
-      	value=malloc(len+1);
-      	memcpy(value,tc->user_comments[i],len);
-      	value[len]='\0';
-      	fprintf(out, "\t%s\n", value);
-      	free(value);
+        value=malloc(len+1);
+        memcpy(value,tc->user_comments[i],len);
+        value[len]='\0';
+        fprintf(out, "\t%s\n", value);
+        free(value);
       }
     }
   }
@@ -412,7 +412,7 @@
   if(theora_p)ogg_stream_pagein(&to,&og);
   if(vorbis_p)ogg_stream_pagein(&vo,&og);
   return 0;
-}                                   
+}
 
 static void usage(void){
   fprintf(stderr,
@@ -423,14 +423,14 @@
 }
 
 int main(int argc,char *argv[]){
-  
+
   int i,j;
   ogg_packet op;
-  
+
   FILE *infile = stdin;
 
 #ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
-  /* Beware the evil ifdef. We avoid these where we can, but this one we 
+  /* Beware the evil ifdef. We avoid these where we can, but this one we
      cannot. Don't add any more, you'll probably go to hell if you do. */
   _setmode( _fileno( stdin ), _O_BINARY );
 #endif
@@ -447,7 +447,7 @@
       usage();
       exit(1);
   }
-  
+
   /* start up Ogg stream synchronization layer */
   ogg_sync_init(&oy);
 
@@ -466,45 +466,45 @@
     if(ret==0)break;
     while(ogg_sync_pageout(&oy,&og)>0){
       ogg_stream_state test;
-      
+
       /* is this a mandated initial header? If not, stop parsing */
       if(!ogg_page_bos(&og)){
-	/* don't leak the page; get it into the appropriate stream */
-	queue_page(&og);
-	stateflag=1;
-	break;
+        /* don't leak the page; get it into the appropriate stream */
+        queue_page(&og);
+        stateflag=1;
+        break;
       }
-      
+
       ogg_stream_init(&test,ogg_page_serialno(&og));
       ogg_stream_pagein(&test,&og);
       ogg_stream_packetout(&test,&op);
-      
+
       /* identify the codec: try theora */
       if(!theora_p && theora_decode_header(&ti,&tc,&op)>=0){
-	/* it is theora */
-	memcpy(&to,&test,sizeof(test));
-	theora_p=1;
+        /* it is theora */
+        memcpy(&to,&test,sizeof(test));
+        theora_p=1;
       }else if(!vorbis_p && vorbis_synthesis_headerin(&vi,&vc,&op)>=0){
-	/* it is vorbis */
-	memcpy(&vo,&test,sizeof(test));
-	vorbis_p=1;
+        /* it is vorbis */
+        memcpy(&vo,&test,sizeof(test));
+        vorbis_p=1;
       }else{
-	/* whatever it is, we don't care about it */
-	ogg_stream_clear(&test);
+        /* whatever it is, we don't care about it */
+        ogg_stream_clear(&test);
       }
     }
     /* fall through to non-bos page parsing */
   }
-  
+
   /* we're expecting more header packets. */
   while((theora_p && theora_p<3) || (vorbis_p && vorbis_p<3)){
     int ret;
-    
+
     /* look for further theora headers */
     while(theora_p && (theora_p<3) && (ret=ogg_stream_packetout(&to,&op))){
       if(ret<0){
-      	fprintf(stderr,"Error parsing Theora stream headers; corrupt stream?\n");
-      	exit(1);
+        fprintf(stderr,"Error parsing Theora stream headers; corrupt stream?\n");
+        exit(1);
       }
       if(theora_decode_header(&ti,&tc,&op)){
         printf("Error parsing Theora stream headers; corrupt stream?\n");
@@ -514,30 +514,30 @@
       if(theora_p==3)break;
     }
 
-    /* look for more vorbis header packets */  
+    /* look for more vorbis header packets */
     while(vorbis_p && (vorbis_p<3) && (ret=ogg_stream_packetout(&vo,&op))){
       if(ret<0){
-	fprintf(stderr,"Error parsing Vorbis stream headers; corrupt stream?\n");
-	exit(1);
+        fprintf(stderr,"Error parsing Vorbis stream headers; corrupt stream?\n");
+        exit(1);
       }
       if(vorbis_synthesis_headerin(&vi,&vc,&op)){
-	fprintf(stderr,"Error parsing Vorbis stream headers; corrupt stream?\n");
-	exit(1);
+        fprintf(stderr,"Error parsing Vorbis stream headers; corrupt stream?\n");
+        exit(1);
       }
       vorbis_p++;
       if(vorbis_p==3)break;
     }
-    
+
     /* The header pages/packets will arrive before anything else we
        care about, or the stream is not obeying spec */
-    
+
     if(ogg_sync_pageout(&oy,&og)>0){
       queue_page(&og); /* demux into the appropriate stream */
     }else{
       int ret=buffer_data(infile,&oy); /* someone needs more data */
       if(ret==0){
-	fprintf(stderr,"End of file while searching for codec headers.\n");
-	exit(1);
+        fprintf(stderr,"End of file while searching for codec headers.\n");
+        exit(1);
       }
     }
   }
@@ -547,8 +547,8 @@
     theora_decode_init(&td,&ti);
     printf("Ogg logical stream %x is Theora %dx%d %.02f fps video\n"
            "  Frame content is %dx%d with offset (%d,%d).\n",
-	    to.serialno,ti.width,ti.height, (double)ti.fps_numerator/ti.fps_denominator,
-		ti.frame_width, ti.frame_height, ti.offset_x, ti.offset_y);
+           to.serialno,ti.width,ti.height, (double)ti.fps_numerator/ti.fps_denominator,
+           ti.frame_width, ti.frame_height, ti.offset_x, ti.offset_y);
     report_colorspace(&ti);
     dump_comments(&tc);
   }else{
@@ -558,15 +558,15 @@
   }
   if(vorbis_p){
     vorbis_synthesis_init(&vd,&vi);
-    vorbis_block_init(&vd,&vb);  
+    vorbis_block_init(&vd,&vb);
     fprintf(stderr,"Ogg logical stream %x is Vorbis %d channel %d Hz audio.\n",
-	    vo.serialno,vi.channels,vi.rate);
+            vo.serialno,vi.channels,vi.rate);
   }else{
     /* tear down the partial vorbis setup */
     vorbis_info_clear(&vi);
     vorbis_comment_clear(&vc);
   }
-  
+
   /* open audio */
   if(vorbis_p)open_audio();
 
@@ -584,93 +584,93 @@
 
   stateflag=0; /* playback has not begun */
   while(!got_sigint){
-    
+
     /* we want a video and audio frame ready to go at all times.  If
        we have to buffer incoming, buffer the compressed data (ie, let
        ogg do the buffering) */
     while(vorbis_p && !audiobuf_ready){
       int ret;
       float **pcm;
-      
+
       /* if there's pending, decoded audio, grab it */
       if((ret=vorbis_synthesis_pcmout(&vd,&pcm))>0){
-	int count=audiobuf_fill/2;
-	int maxsamples=(audiofd_fragsize-audiobuf_fill)/2/vi.channels;
-	for(i=0;i<ret && i<maxsamples;i++)
-	  for(j=0;j<vi.channels;j++){
-	    int val=rint(pcm[j][i]*32767.f);
-	    if(val>32767)val=32767;
-	    if(val<-32768)val=-32768;
-	    audiobuf[count++]=val;
-	  }
-	vorbis_synthesis_read(&vd,i);
-	audiobuf_fill+=i*vi.channels*2;
-	if(audiobuf_fill==audiofd_fragsize)audiobuf_ready=1;
-	if(vd.granulepos>=0)
-	  audiobuf_granulepos=vd.granulepos-ret+i;
-	else
-	  audiobuf_granulepos+=i;
-	
+        int count=audiobuf_fill/2;
+        int maxsamples=(audiofd_fragsize-audiobuf_fill)/2/vi.channels;
+        for(i=0;i<ret && i<maxsamples;i++)
+          for(j=0;j<vi.channels;j++){
+            int val=rint(pcm[j][i]*32767.f);
+            if(val>32767)val=32767;
+            if(val<-32768)val=-32768;
+            audiobuf[count++]=val;
+          }
+        vorbis_synthesis_read(&vd,i);
+        audiobuf_fill+=i*vi.channels*2;
+        if(audiobuf_fill==audiofd_fragsize)audiobuf_ready=1;
+        if(vd.granulepos>=0)
+          audiobuf_granulepos=vd.granulepos-ret+i;
+        else
+          audiobuf_granulepos+=i;
+        
       }else{
-	
-	/* no pending audio; is there a pending packet to decode? */
-	if(ogg_stream_packetout(&vo,&op)>0){
-	  if(vorbis_synthesis(&vb,&op)==0) /* test for success! */
-	    vorbis_synthesis_blockin(&vd,&vb);
-	}else	/* we need more data; break out to suck in another page */
-	  break;
+        
+        /* no pending audio; is there a pending packet to decode? */
+        if(ogg_stream_packetout(&vo,&op)>0){
+          if(vorbis_synthesis(&vb,&op)==0) /* test for success! */
+            vorbis_synthesis_blockin(&vd,&vb);
+        }else   /* we need more data; break out to suck in another page */
+          break;
       }
     }
-      
+
     while(theora_p && !videobuf_ready){
       /* theora is one in, one out... */
       if(ogg_stream_packetout(&to,&op)>0){
-   
-	theora_decode_packetin(&td,&op);
-	videobuf_granulepos=td.granulepos;
-	
-	videobuf_time=theora_granule_time(&td,videobuf_granulepos);
 
-	/* is it already too old to be useful?  This is only actually
+        theora_decode_packetin(&td,&op);
+        videobuf_granulepos=td.granulepos;
+        
+        videobuf_time=theora_granule_time(&td,videobuf_granulepos);
+
+        /* is it already too old to be useful?  This is only actually
            useful cosmetically after a SIGSTOP.  Note that we have to
            decode the frame even if we don't show it (for now) due to
            keyframing.  Soon enough libtheora will be able to deal
            with non-keyframe seeks.  */
 
-	if(videobuf_time>=get_time())
-	videobuf_ready=1;
-		
+        if(videobuf_time>=get_time())
+        videobuf_ready=1;
+                
       }else
-	break;
+        break;
     }
-    
+
     if(!videobuf_ready && !audiobuf_ready && feof(infile))break;
-    
+
     if(!videobuf_ready || !audiobuf_ready){
       /* no data yet for somebody.  Grab another page */
       int ret=buffer_data(infile,&oy);
       while(ogg_sync_pageout(&oy,&og)>0){
-      	queue_page(&og);
+        queue_page(&og);
       }
     }
 
     /* If playback has begun, top audio buffer off immediately. */
     if(stateflag) audio_write_nonblocking();
-      
+
     /* are we at or past time for this video frame? */
     if(stateflag && videobuf_ready && videobuf_time<=get_time()){
       video_write();
       videobuf_ready=0;
     }
-      
-    if(stateflag && 
-       (audiobuf_ready || !vorbis_p) && 
-       (videobuf_ready || !theora_p) && 
+
+    if(stateflag &&
+       (audiobuf_ready || !vorbis_p) &&
+       (videobuf_ready || !theora_p) &&
        !got_sigint){
       /* we have an audio frame ready (which means the audio buffer is
          full), it's not time to play video, so wait until one of the
          audio buffer is ready or it's near time to play video */
-	
+        
       /* set up select wait on the audiobuffer and a timeout for video */
       struct timeval timeout;
       fd_set writefs;
@@ -680,31 +680,31 @@
       FD_ZERO(&writefs);
       FD_ZERO(&empty);
       if(audiofd>=0){
-	FD_SET(audiofd,&writefs);
-	n=audiofd+1;
+        FD_SET(audiofd,&writefs);
+        n=audiofd+1;
       }
 
       if(theora_p){
-	long milliseconds=(videobuf_time-get_time())*1000-5;
-	if(milliseconds>500)milliseconds=500;
-	if(milliseconds>0){
-	  timeout.tv_sec=milliseconds/1000;
-	  timeout.tv_usec=(milliseconds%1000)*1000;
-
-	  n=select(n,&empty,&writefs,&empty,&timeout);
-	  if(n)audio_calibrate_timer(0);
-	}
+        long milliseconds=(videobuf_time-get_time())*1000-5;
+        if(milliseconds>500)milliseconds=500;
+        if(milliseconds>0){
+          timeout.tv_sec=milliseconds/1000;
+          timeout.tv_usec=(milliseconds%1000)*1000;
+
+          n=select(n,&empty,&writefs,&empty,&timeout);
+          if(n)audio_calibrate_timer(0);
+        }
       }else{
-	select(n,&empty,&writefs,&empty,NULL);
+        select(n,&empty,&writefs,&empty,NULL);
       }
     }
 
     /* if our buffers either don't exist or are ready to go,
        we can begin playback */
-    if((!theora_p || videobuf_ready) && 
+    if((!theora_p || videobuf_ready) &&
        (!vorbis_p || audiobuf_ready))stateflag=1;
     /* same if we've run out of input */
-    if(feof(infile))stateflag=1; 
+    if(feof(infile))stateflag=1;
 
   }
 
@@ -718,7 +718,7 @@
     vorbis_block_clear(&vb);
     vorbis_dsp_clear(&vd);
     vorbis_comment_clear(&vc);
-    vorbis_info_clear(&vi); 
+    vorbis_info_clear(&vi);
   }
   if(theora_p){
     ogg_stream_clear(&to);
@@ -729,10 +729,10 @@
   ogg_sync_clear(&oy);
 
   if(infile && infile!=stdin)fclose(infile);
-  
+
   fprintf(stderr,
-	  "\r                                                              "
-	  "\nDone.\n");
+          "\r                                                              "
+          "\nDone.\n");
   return(0);
 
 }

<p><p>1.12      +8 -8      theora/include/theora/theora.h

Index: theora.h
===================================================================
RCS file: /usr/local/cvsroot/theora/include/theora/theora.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- theora.h	9 Jun 2003 01:45:19 -0000	1.11
+++ theora.h	10 Jun 2003 01:31:33 -0000	1.12
@@ -10,8 +10,8 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: theora.h,v 1.11 2003/06/09 01:45:19 tterribe Exp $
+  function:
+  last mod: $Id: theora.h,v 1.12 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
@@ -68,7 +68,7 @@
   int           keyframe_auto_p;
   ogg_uint32_t  keyframe_frequency;
   ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to
-					      get granpos shift correct */
+                                              get granpos shift correct */
   ogg_uint32_t  keyframe_data_target_bitrate;
   ogg_int32_t   keyframe_auto_threshold;
   ogg_uint32_t  keyframe_mindistance;
@@ -90,7 +90,7 @@
   char **user_comments;
   int   *comment_lengths;
   int    comments;
-  char  *vendor;                                                          
+  char  *vendor;
 
 } theora_comment;
 
@@ -106,11 +106,12 @@
 extern ogg_uint32_t theora_version_number(void);
 extern int theora_encode_init(theora_state *th, theora_info *c);
 extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
-extern int theora_encode_packetout( theora_state *t, int last_p, 
-				    ogg_packet *op);
+extern int theora_encode_packetout( theora_state *t, int last_p,
+                                    ogg_packet *op);
 extern int theora_encode_header(theora_state *t, ogg_packet *op);
 extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
-extern int theora_decode_header(theora_info *ci, theora_comment *cc, ogg_packet *op);
+extern int theora_decode_header(theora_info *ci, theora_comment *cc,
+                                ogg_packet *op);
 extern int theora_decode_init(theora_state *th, theora_info *c);
 extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
 extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
@@ -130,4 +131,3 @@
 
 
 #endif /* _O_THEORA_H_ */
-

<p><p>1.5       +9 -10     theora/lib/block_inline.h

Index: block_inline.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/block_inline.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- block_inline.h	8 Jun 2003 00:08:38 -0000	1.4
+++ block_inline.h	10 Jun 2003 01:31:33 -0000	1.5
@@ -10,28 +10,27 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: block_inline.h,v 1.4 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: block_inline.h,v 1.5 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
 static ogg_int32_t MBOrderMap[4] = { 0, 2, 3, 1 };
-static ogg_int32_t BlockOrderMap1[4][4] = { 
+static ogg_int32_t BlockOrderMap1[4][4] = {
   { 0, 1, 3, 2 },
-  { 0, 2, 3, 1 },       
+  { 0, 2, 3, 1 },
   { 0, 2, 3, 1 },
   { 3, 2, 0, 1 }
 };
 
-static ogg_int32_t QuadMapToIndex1( ogg_int32_t	(*BlockMap)[4][4], 
-				    ogg_uint32_t SB, ogg_uint32_t MB, 
-				    ogg_uint32_t B ){
+static ogg_int32_t QuadMapToIndex1( ogg_int32_t (*BlockMap)[4][4],
+                                    ogg_uint32_t SB, ogg_uint32_t MB,
+                                    ogg_uint32_t B ){
   return BlockMap[SB][MBOrderMap[MB]][BlockOrderMap1[MB][B]];
 }
 
 
-static ogg_int32_t QuadMapToMBTopLeft( ogg_int32_t (*BlockMap)[4][4], 
-				       ogg_uint32_t SB, ogg_uint32_t MB ){
+static ogg_int32_t QuadMapToMBTopLeft( ogg_int32_t (*BlockMap)[4][4],
+                                       ogg_uint32_t SB, ogg_uint32_t MB ){
   return BlockMap[SB][MBOrderMap[MB]][0];
 }
-

<p><p>1.4       +41 -41    theora/lib/blockmap.c

Index: blockmap.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/blockmap.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- blockmap.c	8 Jun 2003 00:08:38 -0000	1.3
+++ blockmap.c	10 Jun 2003 01:31:33 -0000	1.4
@@ -10,80 +10,80 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: blockmap.c,v 1.3 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: blockmap.c,v 1.4 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 
-static void CreateMapping ( ogg_int32_t (*BlockMap)[4][4], 
-			    ogg_uint32_t FirstSB, 
-			    ogg_uint32_t FirstFrag, ogg_uint32_t HFrags, 
-			    ogg_uint32_t VFrags ){
+static void CreateMapping ( ogg_int32_t (*BlockMap)[4][4],
+                            ogg_uint32_t FirstSB,
+                            ogg_uint32_t FirstFrag, ogg_uint32_t HFrags,
+                            ogg_uint32_t VFrags ){
   ogg_uint32_t i, j;
   ogg_uint32_t xpos;
   ogg_uint32_t ypos;
   ogg_uint32_t SBrow, SBcol;
   ogg_uint32_t SBRows, SBCols;
-  ogg_uint32_t MB, B;	
-  
+  ogg_uint32_t MB, B;
+
   ogg_uint32_t SB=FirstSB;
   ogg_uint32_t FragIndex=FirstFrag;
-  
+
   /* Set Super-Block dimensions */
   SBRows = VFrags/4 + ( VFrags%4 ? 1 : 0 );
   SBCols = HFrags/4 + ( HFrags%4 ? 1 : 0 );
-  
+
   /* Map each Super-Block */
   for ( SBrow=0; SBrow<SBRows; SBrow++ ){
     for ( SBcol=0; SBcol<SBCols; SBcol++ ){
       /* Y co-ordinate of Super-Block in Block units */
       ypos = SBrow<<2;
-      
+
       /* Map Blocks within this Super-Block */
       for ( i=0; (i<4) && (ypos<VFrags); i++, ypos++ ){
-	/* X co-ordinate of Super-Block in Block units */
-	xpos = SBcol<<2;
-				
-	for ( j=0; (j<4) && (xpos<HFrags); j++, xpos++ ){
-	  if ( i<2 ){
-	    MB = ( j<2 ? 0 : 1 );
-	  }else{
-	    MB = ( j<2 ? 2 : 3 );
-	  }
-	  
-	  if ( i%2 ){
-	    B = ( j%2 ? 3 : 2 );
-	  }else{
-	    B = ( j%2 ? 1 : 0 );
-	  }
-	  
-	  /* Set mapping and move to next fragment */
-	  BlockMap[SB][MB][B] = FragIndex++;
-	}
+        /* X co-ordinate of Super-Block in Block units */
+        xpos = SBcol<<2;
+
+        for ( j=0; (j<4) && (xpos<HFrags); j++, xpos++ ){
+          if ( i<2 ){
+            MB = ( j<2 ? 0 : 1 );
+          }else{
+            MB = ( j<2 ? 2 : 3 );
+          }
+
+          if ( i%2 ){
+            B = ( j%2 ? 3 : 2 );
+          }else{
+            B = ( j%2 ? 1 : 0 );
+          }
 
-	/* Move to first fragment in next row in Super-Block */
-	FragIndex += HFrags-j;
+          /* Set mapping and move to next fragment */
+          BlockMap[SB][MB][B] = FragIndex++;
+        }
+
+        /* Move to first fragment in next row in Super-Block */
+        FragIndex += HFrags-j;
       }
-      
+
       /* Move on to next Super-Block */
       SB++;
       FragIndex -= i*HFrags-j;
     }
-    
+
     /* Move to first Super-Block in next row */
     FragIndex += 3*HFrags;
   }
 }
 
-void CreateBlockMapping ( ogg_int32_t  (*BlockMap)[4][4], 
-			  ogg_uint32_t YSuperBlocks, 
-			  ogg_uint32_t UVSuperBlocks, 
-			  ogg_uint32_t HFrags, ogg_uint32_t VFrags ) {
+void CreateBlockMapping ( ogg_int32_t  (*BlockMap)[4][4],
+                          ogg_uint32_t YSuperBlocks,
+                          ogg_uint32_t UVSuperBlocks,
+                          ogg_uint32_t HFrags, ogg_uint32_t VFrags ) {
   ogg_uint32_t i, j;
-  
+
   for ( i=0; i<YSuperBlocks + UVSuperBlocks * 2; i++ ){
     for ( j=0; j<4; j++ ) {
       BlockMap[i][j][0] = -1;
@@ -92,10 +92,10 @@
       BlockMap[i][j][3] = -1;
     }
   }
-  
+
   CreateMapping ( BlockMap, 0, 0, HFrags, VFrags );
   CreateMapping ( BlockMap, YSuperBlocks, HFrags*VFrags, HFrags/2, VFrags/2 );
   CreateMapping ( BlockMap, YSuperBlocks + UVSuperBlocks, (HFrags*VFrags*5)/4,
-		  HFrags/2, VFrags/2 );
+                  HFrags/2, VFrags/2 );
 }
 

<p><p>1.6       +9 -8      theora/lib/comment.c

Index: comment.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/comment.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- comment.c	8 Jun 2003 00:08:38 -0000	1.5
+++ comment.c	10 Jun 2003 01:31:33 -0000	1.6
@@ -11,11 +11,12 @@
  ********************************************************************
 
   function: read/write and client interface for comment header packet
-  last mod: $Id: comment.c,v 1.5 2003/06/08 00:08:38 giles Exp $
+  last mod: $Id: comment.c,v 1.6 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
 #include <stdlib.h>
+#include <string.h>
 #include <ogg/ogg.h>
 #include <theora/theora.h>
 #include "encoder_internal.h"
@@ -23,7 +24,7 @@
 void theora_comment_init(theora_comment *tc){
   memset(tc,0,sizeof(*tc));
 }
-                                                                                
+
 void theora_comment_add(theora_comment *tc,char *comment){
   tc->user_comments=_ogg_realloc(tc->user_comments,
                             (tc->comments+2)*sizeof(*tc->user_comments));
@@ -44,7 +45,7 @@
   theora_comment_add(tc, comment);
   _ogg_free(comment);
 }
-                                                                                
+
 /* This is more or less the same as strncasecmp - but that doesn't exist
  * everywhere, and this is a fairly trivial function, so we include it */
 static int tagcompare(const char *s1, const char *s2, int n){
@@ -62,10 +63,10 @@
   int found = 0;
   int taglen = strlen(tag)+1; /* +1 for the = we append */
   char *fulltag = _ogg_malloc(taglen+ 1);
-                                                                                
+
   strcpy(fulltag, tag);
   strcat(fulltag, "=");
-                                                                                
+
   for(i=0;i<tc->comments;i++){
     if(!tagcompare(tc->user_comments[i], fulltag, taglen)){
       if(count == found)
@@ -75,7 +76,7 @@
         found++;
     }
   }
-  _ogg_free(fulltag); 
+  _ogg_free(fulltag);
   return NULL; /* didn't find anything */
 }
 
@@ -85,12 +86,12 @@
   char *fulltag = _ogg_malloc(taglen+1);
   strcpy(fulltag,tag);
   strcat(fulltag, "=");
-                                                                                
+
   for(i=0;i<tc->comments;i++){
     if(!tagcompare(tc->user_comments[i], fulltag, taglen))
       count++;
   }
-  _ogg_free(fulltag);                                                                           
+  _ogg_free(fulltag);
   return count;
 }
 

<p><p>1.3       +49 -49    theora/lib/compglobals.c

Index: compglobals.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/compglobals.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- compglobals.c	8 Jun 2003 00:08:38 -0000	1.2
+++ compglobals.c	10 Jun 2003 01:31:33 -0000	1.3
@@ -10,8 +10,8 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: compglobals.c,v 1.2 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: compglobals.c,v 1.3 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
@@ -20,7 +20,7 @@
 
 /* the Roundup32 silliness is dangerous on non-Intel processors and
    will also choke some C compilers.  Find a non dangerous way later.
-   Disabled for now. 
+   Disabled for now.
 
    #define ROUNDUP32(X) ( ( ( (unsigned long) X ) + 31 )&( 0xFFFFFFE0 ) ) */
 
@@ -55,10 +55,10 @@
     _ogg_free(cpi->PartiallyCodedMbPatterns);
   if(cpi->UncodedMbFlags)
     _ogg_free(cpi->UncodedMbFlags);
-  
+
   if(cpi->BlockCodedFlagsAlloc)
     _ogg_free(cpi->BlockCodedFlagsAlloc);
-  
+
   cpi->extra_fragmentsAlloc = 0;
   cpi->FragmentLastQAlloc = 0;
   cpi->FragTokensAlloc = 0;
@@ -71,7 +71,7 @@
   cpi->DCTDataBufferAlloc = 0;
   cpi->quantized_listAlloc = 0;
   cpi->OriginalDCAlloc = 0;
-  
+
   cpi->extra_fragments = 0;
   cpi->FragmentLastQ = 0;
   cpi->FragTokens = 0;
@@ -85,20 +85,20 @@
   cpi->quantized_list = 0;
   cpi->OriginalDC = 0;
   cpi->FixedQ = 0;
-  
+
   cpi->BlockCodedFlagsAlloc = 0;
   cpi->BlockCodedFlags = 0;
 }
 
 void EAllocateFragmentInfo(CP_INSTANCE * cpi){
-  
+
   /* clear any existing info */
   EDeleteFragmentInfo(cpi);
-  
+
   /* Perform Fragment Allocations */
-  cpi->extra_fragments =  
+  cpi->extra_fragments =
     _ogg_malloc(32+cpi->pb.UnitFragments*sizeof(unsigned char));
-  
+
   /* A note to people reading and wondering why malloc returns aren't
      checked:
 
@@ -113,39 +113,39 @@
      strategy is only to allocate virtual pages, which are not mapped
      until the memory on that page is touched.  At *that* point, if
      the machine is out of heap, the page fails to be mapped and a
-     SEGV is generated.  
+     SEGV is generated.
 
      That means that is we want to deal with out of memory conditions,
      we *must* be prepared to process a SEGV.  If we implement the
      SEGV handler, there's no reason to to check malloc return; it is
      a waste of code. */
 
-  cpi->FragmentLastQ = 
+  cpi->FragmentLastQ =
     _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(*cpi->FragmentLastQAlloc));
-  cpi->FragTokens =  
+  cpi->FragTokens =
     _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(*cpi->FragTokensAlloc));
   cpi->OriginalDC =
     _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(*cpi->OriginalDCAlloc));
-  cpi->FragTokenCounts =  
-    _ogg_malloc(cpi->pb.UnitFragments* 
+  cpi->FragTokenCounts =
+    _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(*cpi->FragTokenCountsAlloc));
-  cpi->RunHuffIndices =  
+  cpi->RunHuffIndices =
     _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(*cpi->RunHuffIndicesAlloc));
-  cpi->LastCodedErrorScore =  
+  cpi->LastCodedErrorScore =
     _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(*cpi->LastCodedErrorScoreAlloc));
-  cpi->BlockCodedFlags =  
+  cpi->BlockCodedFlags =
     _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(*cpi->BlockCodedFlagsAlloc));
-  cpi->ModeList =  
+  cpi->ModeList =
     _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(*cpi->ModeListAlloc));
-  cpi->MVList =  
-    _ogg_malloc(cpi->pb.UnitFragments* 
+  cpi->MVList =
+    _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(cpi->MVListAlloc));
   cpi->DCT_codes =
     _ogg_malloc(64*
@@ -156,14 +156,14 @@
   cpi->quantized_list =
     _ogg_malloc(64*
                 sizeof(*cpi->quantized_listAlloc));
-  cpi->PartiallyCodedFlags = 
-    _ogg_malloc(cpi->pb.MacroBlocks* 
+  cpi->PartiallyCodedFlags =
+    _ogg_malloc(cpi->pb.MacroBlocks*
                 sizeof(*cpi->PartiallyCodedFlags));
-  cpi->PartiallyCodedMbPatterns = 
-    _ogg_malloc(cpi->pb.MacroBlocks* 
+  cpi->PartiallyCodedMbPatterns =
+    _ogg_malloc(cpi->pb.MacroBlocks*
                 sizeof(*cpi->PartiallyCodedMbPatterns));
-  cpi->UncodedMbFlags = 
-    _ogg_malloc(cpi->pb.MacroBlocks* 
+  cpi->UncodedMbFlags =
+    _ogg_malloc(cpi->pb.MacroBlocks*
                 sizeof(*cpi->UncodedMbFlags));
 
 }
@@ -173,7 +173,7 @@
     _ogg_free(cpi->ConvDestBufferAlloc );
   cpi->ConvDestBufferAlloc = 0;
   cpi->ConvDestBuffer = 0;
-  
+
   if(cpi->yuv0ptrAlloc)
     _ogg_free(cpi->yuv0ptrAlloc);
   cpi->yuv0ptrAlloc = 0;
@@ -188,7 +188,7 @@
     _ogg_free(cpi->OptimisedTokenListEbAlloc);
   cpi->OptimisedTokenListEbAlloc = 0;
   cpi->OptimisedTokenListEb = 0;
-  
+
   if(cpi->OptimisedTokenListAlloc )
     _ogg_free(cpi->OptimisedTokenListAlloc);
   cpi->OptimisedTokenListAlloc = 0;
@@ -203,7 +203,7 @@
     _ogg_free(cpi->OptimisedTokenListPlAlloc);
   cpi->OptimisedTokenListPlAlloc = 0;
   cpi->OptimisedTokenListPl = 0;
-  
+
 }
 
 void EAllocateFrameInfo(CP_INSTANCE * cpi){
@@ -213,25 +213,25 @@
   EDeleteFrameInfo(cpi);
 
   /* allocate frames */
-  cpi->ConvDestBuffer = 
+  cpi->ConvDestBuffer =
     _ogg_malloc(FrameSize*
                 sizeof(*cpi->ConvDestBuffer));
-  cpi->yuv0ptr = 
+  cpi->yuv0ptr =
     _ogg_malloc(FrameSize*
                 sizeof(*cpi->yuv0ptr));
-  cpi->yuv1ptr = 
+  cpi->yuv1ptr =
     _ogg_malloc(FrameSize*
                 sizeof(*cpi->yuv1ptr));
-  cpi->OptimisedTokenListEb = 
+  cpi->OptimisedTokenListEb =
     _ogg_malloc(FrameSize*
                 sizeof(*cpi->OptimisedTokenListEb));
-  cpi->OptimisedTokenList = 
+  cpi->OptimisedTokenList =
     _ogg_malloc(FrameSize*
                 sizeof(*cpi->OptimisedTokenList));
-  cpi->OptimisedTokenListHi = 
+  cpi->OptimisedTokenListHi =
     _ogg_malloc(FrameSize*
                 sizeof(*cpi->OptimisedTokenListHi));
-  cpi->OptimisedTokenListPl = 
+  cpi->OptimisedTokenListPl =
     _ogg_malloc(FrameSize*
                 sizeof(*cpi->OptimisedTokenListPl));
 }
@@ -252,7 +252,7 @@
 
 void InitCPInstance(CP_INSTANCE *cpi){
   ogg_uint32_t  i;
-  
+
   memset((unsigned char *) cpi, 0, sizeof(*cpi));
   AllocateTmpBuffers(&cpi->pb);
   cpi->pp = CreatePPInstance();
@@ -264,14 +264,14 @@
   cpi->Configuration.ActiveMaxQ = 32;
   cpi->Configuration.OutputFrameRate = 30;
   cpi->Configuration.TargetBandwidth = 3000;
-  
-  cpi->MVChangeFactor    =    14;     
-  cpi->FourMvChangeFactor =   8;           
-  cpi->MinImprovementForNewMV = 25;   
+
+  cpi->MVChangeFactor    =    14;
+  cpi->FourMvChangeFactor =   8;
+  cpi->MinImprovementForNewMV = 25;
   cpi->ExhaustiveSearchThresh = 2500;
-  cpi->MinImprovementForFourMV = 100;   
+  cpi->MinImprovementForFourMV = 100;
   cpi->FourMVThreshold = 10000;
-  cpi->BitRateCapFactor = 1.50;    
+  cpi->BitRateCapFactor = 1.50;
   cpi->InterTripOutThresh = 5000;
   cpi->MVEnabled = TRUE;
   cpi->InterCodeCount = 127;
@@ -283,11 +283,11 @@
   cpi->QuickCompress = TRUE;
   cpi->MaxConsDroppedFrames = 1;
   cpi->Sharpness = 2;
-  
+
   cpi->PreProcFilterLevel = 2;
-  
+
   /* Set up default values for QTargetModifier[Q_TABLE_SIZE] table */
-  for ( i = 0; i < Q_TABLE_SIZE; i++ ) 
+  for ( i = 0; i < Q_TABLE_SIZE; i++ )
     cpi->QTargetModifier[Q_TABLE_SIZE] = 1.0;
- 
+
 }

<p><p>1.4       +41 -41    theora/lib/dct.c

Index: dct.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/dct.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- dct.c	8 Jun 2003 00:08:38 -0000	1.3
+++ dct.c	10 Jun 2003 01:31:33 -0000	1.4
@@ -10,8 +10,8 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: dct.c,v 1.3 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: dct.c,v 1.4 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
@@ -31,17 +31,17 @@
 
 void fdct_short ( ogg_int16_t * InputData, ogg_int16_t * OutputData ){
   int loop;
-  
+
   ogg_int32_t  is07, is12, is34, is56;
   ogg_int32_t  is0734, is1256;
-  ogg_int32_t  id07, id12, id34, id56; 
-  
+  ogg_int32_t  id07, id12, id34, id56;
+
   ogg_int32_t  irot_input_x, irot_input_y;
   ogg_int32_t  icommon_product1;   /* Re-used product  (c4s4 * (s12 - s56)). */
   ogg_int32_t  icommon_product2;   /* Re-used product  (c4s4 * (d12 + d56)). */
-  
-  ogg_int32_t  temp1, temp2;	     /* intermediate variable for computation */
-  
+
+  ogg_int32_t  temp1, temp2;         /* intermediate variable for computation */
+
   ogg_int32_t  InterData[64];
   ogg_int32_t *ip = InterData;
   ogg_int16_t * op = OutputData;
@@ -51,37 +51,37 @@
     is12 = InputData[1] + InputData[2];
     is34 = InputData[3] + InputData[4];
     is56 = InputData[5] + InputData[6];
-    
+
     id07 = InputData[0] - InputData[7];
     id12 = InputData[1] - InputData[2];
     id34 = InputData[3] - InputData[4];
     id56 = InputData[5] - InputData[6];
-    
+
     is0734 = is07 + is34;
     is1256 = is12 + is56;
-    
+
     /* Pre-Calculate some common product terms. */
-    icommon_product1 = xC4S4*(is12 - is56); 
+    icommon_product1 = xC4S4*(is12 - is56);
     icommon_product1 = DOROUND(icommon_product1);
     icommon_product1>>=16;
-    
+
     icommon_product2 = xC4S4*(id12 + id56);
     icommon_product2 = DOROUND(icommon_product2);
     icommon_product2>>=16;
-    
-    
+
+
     ip[0] = (xC4S4*(is0734 + is1256));
     ip[0] = DOROUND(ip[0]);
     ip[0] >>= 16;
-    
+
     ip[4] = (xC4S4*(is0734 - is1256));
     ip[4] = DOROUND(ip[4]);
     ip[4] >>= 16;
-    
+
     /* Define inputs to rotation for outputs 2 and 6 */
     irot_input_x = id12 - id56;
     irot_input_y = is07 - is34;
-    
+
     /* Apply rotation for outputs 2 and 6.  */
     temp1=xC6S2*irot_input_x;
     temp1=DOROUND(temp1);
@@ -90,7 +90,7 @@
     temp2=DOROUND(temp2);
     temp2>>=16;
     ip[2] = temp1 + temp2;
-    
+
     temp1=xC6S2*irot_input_y;
     temp1=DOROUND(temp1);
     temp1>>=16;
@@ -102,9 +102,9 @@
     /* Define inputs to rotation for outputs 1 and 7  */
     irot_input_x = icommon_product1 + id07;
     irot_input_y = -( id34 + icommon_product2 );
-    
+
     /* Apply rotation for outputs 1 and 7.  */
-    
+
     temp1=xC1S7*irot_input_x;
     temp1=DOROUND(temp1);
     temp1>>=16;
@@ -112,7 +112,7 @@
     temp2=DOROUND(temp2);
     temp2>>=16;
     ip[1] = temp1 - temp2;
-    
+
     temp1=xC7S1*irot_input_x;
     temp1=DOROUND(temp1);
     temp1>>=16;
@@ -120,11 +120,11 @@
     temp2=DOROUND(temp2);
     temp2>>=16;
     ip[7] = temp1 + temp2 ;
-    
+
     /* Define inputs to rotation for outputs 3 and 5 */
     irot_input_x = id07 - icommon_product1;
     irot_input_y = id34 - icommon_product2;
-    
+
     /* Apply rotation for outputs 3 and 5. */
     temp1=xC3S5*irot_input_x;
     temp1=DOROUND(temp1);
@@ -141,11 +141,11 @@
     temp2=DOROUND(temp2);
     temp2>>=16;
     ip[5] = temp1 + temp2;
-    
+
     /* Increment data pointer for next row. */
     InputData += 8 ;
     ip += 8; /* advance pointer to next row */
-		
+
   }
 
 
@@ -157,24 +157,24 @@
     is12 = ip[1 * 8] + ip[2 * 8];
     is34 = ip[3 * 8] + ip[4 * 8];
     is56 = ip[5 * 8] + ip[6 * 8];
-    
+
     id07 = ip[0 * 8] - ip[7 * 8];
     id12 = ip[1 * 8] - ip[2 * 8];
     id34 = ip[3 * 8] - ip[4 * 8];
     id56 = ip[5 * 8] - ip[6 * 8];
-    
+
     is0734 = is07 + is34;
     is1256 = is12 + is56;
-    
+
     /* Pre-Calculate some common product terms. */
-    icommon_product1 = xC4S4*(is12 - is56) ; 
+    icommon_product1 = xC4S4*(is12 - is56) ;
     icommon_product2 = xC4S4*(id12 + id56) ;
     icommon_product1 = DOROUND(icommon_product1);
     icommon_product2 = DOROUND(icommon_product2);
     icommon_product1>>=16;
     icommon_product2>>=16;
-    
-    
+
+
     temp1 = xC4S4*(is0734 + is1256) ;
     temp2 = xC4S4*(is0734 - is1256) ;
     temp1 = DOROUND(temp1);
@@ -183,11 +183,11 @@
     temp2>>=16;
     op[0*8] = (ogg_int16_t) temp1;
     op[4*8] = (ogg_int16_t) temp2;
-    
+
     /* Define inputs to rotation for outputs 2 and 6 */
     irot_input_x = id12 - id56;
     irot_input_y = is07 - is34;
-    
+
     /* Apply rotation for outputs 2 and 6.  */
     temp1=xC6S2*irot_input_x;
     temp1=DOROUND(temp1);
@@ -196,7 +196,7 @@
     temp2=DOROUND(temp2);
     temp2>>=16;
     op[2*8] = (ogg_int16_t) (temp1 + temp2);
-    
+
     temp1=xC6S2*irot_input_y;
     temp1=DOROUND(temp1);
     temp1>>=16;
@@ -204,11 +204,11 @@
     temp2=DOROUND(temp2);
     temp2>>=16;
     op[6*8] = (ogg_int16_t) (temp1 -temp2) ;
-    
+
     /* Define inputs to rotation for outputs 1 and 7 */
     irot_input_x = icommon_product1 + id07;
     irot_input_y = -( id34 + icommon_product2 );
-    
+
     /* Apply rotation for outputs 1 and 7. */
     temp1=xC1S7*irot_input_x;
     temp1=DOROUND(temp1);
@@ -217,7 +217,7 @@
     temp2=DOROUND(temp2);
     temp2>>=16;
     op[1*8] = (ogg_int16_t) (temp1 - temp2);
-    
+
     temp1=xC7S1*irot_input_x;
     temp1=DOROUND(temp1);
     temp1>>=16;
@@ -225,11 +225,11 @@
     temp2=DOROUND(temp2);
     temp2>>=16;
     op[7*8] = (ogg_int16_t) (temp1 + temp2);
-    
+
     /* Define inputs to rotation for outputs 3 and 5 */
     irot_input_x = id07 - icommon_product1;
     irot_input_y = id34 - icommon_product2;
-    
+
     /* Apply rotation for outputs 3 and 5. */
     temp1=xC3S5*irot_input_x;
     temp1=DOROUND(temp1);
@@ -246,7 +246,7 @@
     temp2=DOROUND(temp2);
     temp2>>=16;
     op[5*8] = (ogg_int16_t) (temp1 + temp2);
-    
+
     /* Increment data pointer for next column.  */
     ip ++;
     op ++;

<p><p>1.6       +545 -547  theora/lib/dct_decode.c

Index: dct_decode.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/dct_decode.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- dct_decode.c	8 Jun 2003 00:08:38 -0000	1.5
+++ dct_decode.c	10 Jun 2003 01:31:33 -0000	1.6
@@ -10,11 +10,13 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: dct_decode.c,v 1.5 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: dct_decode.c,v 1.6 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
+#include <stdlib.h>
+#include <string.h>
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 
@@ -26,36 +28,36 @@
 #define PL 1
 #define HIGHBITDUPPED(X) (((signed short) X)  >> 15)
 
-ogg_uint32_t LoopFilterLimitValuesV1[Q_TABLE_SIZE] = {  
+ogg_uint32_t LoopFilterLimitValuesV1[Q_TABLE_SIZE] = {
   30, 25, 20, 20, 15, 15, 14, 14,
-  13, 13, 12, 12, 11, 11, 10, 10, 
+  13, 13, 12, 12, 11, 11, 10, 10,
   9,  9,  8,  8,  7,  7,  7,  7,
   6,  6,  6,  6,  5,  5,  5,  5,
-  4,  4,  4,  4,  3,  3,  3,  3,  
-  2,  2,  2,  2,  2,  2,  2,  2,  
-  0,  0,  0,  0,  0,  0,  0,  0,  
-  0,  0,  0,  0,  0,  0,  0,  0 
+  4,  4,  4,  4,  3,  3,  3,  3,
+  2,  2,  2,  2,  2,  2,  2,  2,
+  0,  0,  0,  0,  0,  0,  0,  0,
+  0,  0,  0,  0,  0,  0,  0,  0
 };
 
-ogg_uint32_t LoopFilterLimitValuesV2[Q_TABLE_SIZE] = {  
+ogg_uint32_t LoopFilterLimitValuesV2[Q_TABLE_SIZE] = {
   30, 25, 20, 20, 15, 15, 14, 14,
-  13, 13, 12, 12, 11, 11, 10, 10, 
+  13, 13, 12, 12, 11, 11, 10, 10,
   9,  9,  8,  8,  7,  7,  7,  7,
   6,  6,  6,  6,  5,  5,  5,  5,
-  4,  4,  4,  4,  3,  3,  3,  3,  
-  2,  2,  2,  2,  2,  2,  2,  2,  
-  2,  2,  2,  2,  2,  2,  2,  2,  
-  1,  1,  1,  1,  1,  1,  1,  1 
+  4,  4,  4,  4,  3,  3,  3,  3,
+  2,  2,  2,  2,  2,  2,  2,  2,
+  2,  2,  2,  2,  2,  2,  2,  2,
+  1,  1,  1,  1,  1,  1,  1,  1
 };
 
 static int ModeUsesMC[MAX_MODES] = { 0, 0, 1, 1, 1, 0, 1, 1 };
 
-static void SetupBoundingValueArray_Generic(PB_INSTANCE *pbi, 
-					    ogg_int32_t FLimit){
+static void SetupBoundingValueArray_Generic(PB_INSTANCE *pbi,
+                                            ogg_int32_t FLimit){
 
   ogg_int32_t * BoundingValuePtr = pbi->FiltBoundingValue+256;
   ogg_int32_t i;
-  
+
   /* Set up the bounding value array. */
   memset ( pbi->FiltBoundingValue, 0, (512*sizeof(*pbi->FiltBoundingValue)) );
   for ( i = 0; i < FLimit; i++ ){
@@ -67,19 +69,19 @@
 }
 
 void SetupLoopFilter(PB_INSTANCE *pbi){
-  ogg_int32_t FLimit; 
-  
+  ogg_int32_t FLimit;
+
   FLimit = LoopFilterLimitValuesV2[pbi->FrameQIndex];
   SetupBoundingValueArray_Generic(pbi, FLimit);
 }
 
-void CopyBlock(unsigned char *src, 
-	       unsigned char *dest, 
-	       unsigned int srcstride){
+void CopyBlock(unsigned char *src,
+               unsigned char *dest,
+               unsigned int srcstride){
   unsigned char *s = src;
   unsigned char *d = dest;
   unsigned int stride = srcstride;
-  
+
   int j;
   for ( j = 0; j < 8; j++ ){
     ((ogg_uint32_t*)d)[0] = ((ogg_uint32_t*)s)[0];
@@ -91,7 +93,7 @@
 
 static void ExpandKFBlock ( PB_INSTANCE *pbi, ogg_int32_t FragmentNumber ){
   ogg_uint32_t ReconPixelsPerLine;
-  ogg_int32_t     ReconPixelIndex;  
+  ogg_int32_t     ReconPixelIndex;
 
   /* Select the appropriate inverse Q matrix and line stride */
   if ( FragmentNumber<(ogg_int32_t)pbi->YPlaneFragments ){
@@ -101,10 +103,10 @@
     ReconPixelsPerLine = pbi->UVStride;
     pbi->dequant_coeffs = pbi->dequant_UV_coeffs;
   }
-    
+
   /* Set up pointer into the quantisation buffer. */
   pbi->quantized_list = &pbi->QFragData[FragmentNumber][0];
-  
+
   /* Invert quantisation and DCT to get pixel data. */
   switch(pbi->FragCoefEOB[FragmentNumber]){
   case 0:case 1:
@@ -119,19 +121,19 @@
 
   /* Convert fragment number to a pixel offset in a reconstruction buffer. */
   ReconPixelIndex = pbi->recon_pixel_index_table[FragmentNumber];
-  
+
   /* Get the pixel index for the first pixel in the fragment. */
-  ReconIntra( pbi, (unsigned char *)(&pbi->ThisFrameRecon[ReconPixelIndex]), 
-	      (ogg_uint16_t *)pbi->ReconDataBuffer, ReconPixelsPerLine );
-  
+  ReconIntra( pbi, (unsigned char *)(&pbi->ThisFrameRecon[ReconPixelIndex]),
+              (ogg_uint16_t *)pbi->ReconDataBuffer, ReconPixelsPerLine );
+
 }
 
 static void ExpandBlock ( PB_INSTANCE *pbi, ogg_int32_t FragmentNumber ){
   unsigned char *LastFrameRecPtr;   /* Pointer into previous frame
-				       reconstruction. */
+                                       reconstruction. */
   unsigned char *LastFrameRecPtr2;  /* Pointer into previous frame
-				       reconstruction for 1/2 pixel MC. */
-  
+                                       reconstruction for 1/2 pixel MC. */
+
   ogg_uint32_t   ReconPixelsPerLine; /* Pixels per line */
   ogg_int32_t    ReconPixelIndex;    /* Offset for block into a
                                         reconstruction buffer */
@@ -142,7 +144,7 @@
   ogg_int32_t    MvShift  ;          /* Shift to correct to 1/2 or 1/4 pixel */
   ogg_int32_t    MvModMask;          /* Mask to determine whether 1/2
                                         pixel is used */
-  
+
   /* Get coding mode for this block */
   if ( GetFrameType(pbi) == BASE_FRAME ){
     pbi->CodingMode = CODE_INTRA;
@@ -156,7 +158,7 @@
     ReconPixelsPerLine = pbi->YStride;
     MvShift = 1;
     MvModMask = 0x00000001;
-    
+
     /* Select appropriate dequantiser matrix. */
     if ( pbi->CodingMode == CODE_INTRA )
       pbi->dequant_coeffs = pbi->dequant_Y_coeffs;
@@ -173,10 +175,10 @@
     else
       pbi->dequant_coeffs = pbi->dequant_Inter_coeffs;
   }
-    
+
   /* Set up pointer into the quantisation buffer. */
   pbi->quantized_list = &pbi->QFragData[FragmentNumber][0];
-  
+
   /* Invert quantisation and DCT to get pixel data. */
   switch(pbi->FragCoefEOB[FragmentNumber]){
   case 0:case 1:
@@ -198,16 +200,16 @@
     /* Reconstruct the pixel data using the last frame reconstruction
        and change data when the motion vector is (0,0), the recon is
        based on the lastframe without loop filtering---- for testing */
-    ReconInter( pbi, &pbi->ThisFrameRecon[ReconPixelIndex], 
-		&pbi->LastFrameRecon[ReconPixelIndex], 
-		pbi->ReconDataBuffer, ReconPixelsPerLine );
-    
+    ReconInter( pbi, &pbi->ThisFrameRecon[ReconPixelIndex],
+                &pbi->LastFrameRecon[ReconPixelIndex],
+                pbi->ReconDataBuffer, ReconPixelsPerLine );
+
   }else if ( ModeUsesMC[pbi->CodingMode] ) {
     /* The mode uses a motion vector. */
     /* Get vector from list */
     pbi->MVector.x = pbi->FragMVect[FragmentNumber].x;
     pbi->MVector.y = pbi->FragMVect[FragmentNumber].y;
-    
+
     /* Work out the base motion vector offset and the 1/2 pixel offset
        if any.  For the U and V planes the MV specifies 1/4 pixel
        accuracy. This is adjusted to 1/2 pixel as follows ( 0->0,
@@ -217,93 +219,93 @@
     if ( pbi->MVector.x > 0 ){
       MVOffset = pbi->MVector.x >> MvShift;
       if ( pbi->MVector.x & MvModMask )
-	ReconPtr2Offset += 1;
+        ReconPtr2Offset += 1;
     } else if ( pbi->MVector.x < 0 ) {
       MVOffset -= (-pbi->MVector.x) >> MvShift;
       if ( (-pbi->MVector.x) & MvModMask )
-	ReconPtr2Offset -= 1;
+        ReconPtr2Offset -= 1;
     }
 
     if ( pbi->MVector.y > 0 ){
       MVOffset += (pbi->MVector.y >>  MvShift) * ReconPixelsPerLine;
       if ( pbi->MVector.y & MvModMask )
-	ReconPtr2Offset += ReconPixelsPerLine;
+        ReconPtr2Offset += ReconPixelsPerLine;
     } else if ( pbi->MVector.y < 0 ){
       MVOffset -= ((-pbi->MVector.y) >> MvShift) * ReconPixelsPerLine;
       if ( (-pbi->MVector.y) & MvModMask )
-	ReconPtr2Offset -= ReconPixelsPerLine;
+        ReconPtr2Offset -= ReconPixelsPerLine;
     }
-            
+
     /* Set up the first of the two reconstruction buffer pointers. */
     if ( pbi->CodingMode==CODE_GOLDEN_MV ) {
       LastFrameRecPtr = &pbi->GoldenFrame[ReconPixelIndex] + MVOffset;
     }else{
       LastFrameRecPtr = &pbi->LastFrameRecon[ReconPixelIndex] + MVOffset;
     }
-            
+
     /* Set up the second of the two reconstruction pointers. */
     LastFrameRecPtr2 = LastFrameRecPtr + ReconPtr2Offset;
-    
+
     /* Select the appropriate reconstruction function */
     if ( (int)(LastFrameRecPtr - LastFrameRecPtr2) == 0 ) {
       /* Reconstruct the pixel dats from the reference frame and change data
-	 (no half pixel in this case as the two references were the same. */
-      ReconInter( pbi, &pbi->ThisFrameRecon[ReconPixelIndex], 
-		  LastFrameRecPtr, pbi->ReconDataBuffer, 
-		  ReconPixelsPerLine );
+         (no half pixel in this case as the two references were the same. */
+      ReconInter( pbi, &pbi->ThisFrameRecon[ReconPixelIndex],
+                  LastFrameRecPtr, pbi->ReconDataBuffer,
+                  ReconPixelsPerLine );
     }else{
       /* Fractional pixel reconstruction. */
       /* Note that we only use two pixels per reconstruction even for
          the diagonal. */
-      ReconInterHalfPixel2( pbi,&pbi->ThisFrameRecon[ReconPixelIndex], 
-			    LastFrameRecPtr, LastFrameRecPtr2, 
-			    pbi->ReconDataBuffer, ReconPixelsPerLine );
+      ReconInterHalfPixel2( pbi,&pbi->ThisFrameRecon[ReconPixelIndex],
+                            LastFrameRecPtr, LastFrameRecPtr2,
+                            pbi->ReconDataBuffer, ReconPixelsPerLine );
     }
   } else if ( pbi->CodingMode == CODE_USING_GOLDEN ){
     /* Golden frame with motion vector */
     /* Reconstruct the pixel data using the golden frame
        reconstruction and change data */
-    ReconInter( pbi, &pbi->ThisFrameRecon[ReconPixelIndex], 
-		&pbi->GoldenFrame[ ReconPixelIndex ], 
-		pbi->ReconDataBuffer, ReconPixelsPerLine );
+    ReconInter( pbi, &pbi->ThisFrameRecon[ReconPixelIndex],
+                &pbi->GoldenFrame[ ReconPixelIndex ],
+                pbi->ReconDataBuffer, ReconPixelsPerLine );
   } else {
     /* Simple Intra coding */
     /* Get the pixel index for the first pixel in the fragment. */
-    ReconIntra( pbi, &pbi->ThisFrameRecon[ReconPixelIndex], 
-		pbi->ReconDataBuffer, ReconPixelsPerLine );
+    ReconIntra( pbi, &pbi->ThisFrameRecon[ReconPixelIndex],
+                pbi->ReconDataBuffer, ReconPixelsPerLine );
   }
 }
 
-static void UpdateUMV_HBorders( PB_INSTANCE *pbi, 
-				unsigned char * DestReconPtr, 
-				ogg_uint32_t  PlaneFragOffset ) {
+static void UpdateUMV_HBorders( PB_INSTANCE *pbi,
+                                unsigned char * DestReconPtr,
+                                ogg_uint32_t  PlaneFragOffset ) {
   ogg_uint32_t  i;
   ogg_uint32_t  PixelIndex;
-  
+
   ogg_uint32_t  PlaneStride;
   ogg_uint32_t  BlockVStep;
   ogg_uint32_t  PlaneFragments;
   ogg_uint32_t  LineFragments;
   ogg_uint32_t  PlaneBorderWidth;
-  
-  unsigned char   *SrcPtr1;  
-  unsigned char   *SrcPtr2;  
-  unsigned char   *DestPtr1; 
-  unsigned char   *DestPtr2; 
-  
+
+  unsigned char   *SrcPtr1;
+  unsigned char   *SrcPtr2;
+  unsigned char   *DestPtr1;
+  unsigned char   *DestPtr2;
+
   /* Work out various plane specific values */
   if ( PlaneFragOffset == 0 ) {
     /* Y Plane */
-    BlockVStep = (pbi->YStride * 
-		  (VFRAGPIXELS - 1));
+    BlockVStep = (pbi->YStride *
+                  (VFRAGPIXELS - 1));
     PlaneStride = pbi->YStride;
     PlaneBorderWidth = UMV_BORDER;
     PlaneFragments = pbi->YPlaneFragments;
     LineFragments = pbi->HFragments;
   }else{
     /* U or V plane. */
-    BlockVStep = (pbi->UVStride * 
-		  (VFRAGPIXELS - 1));
+    BlockVStep = (pbi->UVStride *
+                  (VFRAGPIXELS - 1));
     PlaneStride = pbi->UVStride;
     PlaneBorderWidth = UMV_BORDER / 2;
     PlaneFragments = pbi->UVPlaneFragments;
@@ -315,9 +317,9 @@
   PixelIndex = pbi->recon_pixel_index_table[PlaneFragOffset];
   SrcPtr1 = &DestReconPtr[ PixelIndex - PlaneBorderWidth ];
   DestPtr1 = SrcPtr1 - (PlaneBorderWidth * PlaneStride);
-  
-  PixelIndex = pbi->recon_pixel_index_table[PlaneFragOffset + 
-					   PlaneFragments - LineFragments] + 
+
+  PixelIndex = pbi->recon_pixel_index_table[PlaneFragOffset +
+                                           PlaneFragments - LineFragments] +
     BlockVStep;
   SrcPtr2 = &DestReconPtr[ PixelIndex - PlaneBorderWidth];
   DestPtr2 = SrcPtr2 + PlaneStride;
@@ -332,19 +334,19 @@
   }
 }
 
-static void UpdateUMV_VBorders( PB_INSTANCE *pbi, 
-				unsigned char * DestReconPtr, 
-				ogg_uint32_t  PlaneFragOffset ){
+static void UpdateUMV_VBorders( PB_INSTANCE *pbi,
+                                unsigned char * DestReconPtr,
+                                ogg_uint32_t  PlaneFragOffset ){
   ogg_uint32_t  i;
   ogg_uint32_t  PixelIndex;
-  
+
   ogg_uint32_t  PlaneStride;
   ogg_uint32_t  LineFragments;
   ogg_uint32_t  PlaneBorderWidth;
   ogg_uint32_t   PlaneHeight;
-  
-  unsigned char   *SrcPtr1; 
-  unsigned char   *SrcPtr2; 
+
+  unsigned char   *SrcPtr1;
+  unsigned char   *SrcPtr2;
   unsigned char   *DestPtr1;
   unsigned char   *DestPtr2;
 
@@ -362,15 +364,15 @@
     LineFragments = pbi->HFragments / 2;
     PlaneHeight = pbi->info.height / 2;
   }
-  
+
   /* Setup the source data values and destination pointers for the
      left and right edge borders */
   PixelIndex = pbi->recon_pixel_index_table[PlaneFragOffset];
   SrcPtr1 = &DestReconPtr[ PixelIndex ];
   DestPtr1 = &DestReconPtr[ PixelIndex - PlaneBorderWidth ];
-  
-  PixelIndex = pbi->recon_pixel_index_table[PlaneFragOffset + 
-					   LineFragments - 1] + 
+
+  PixelIndex = pbi->recon_pixel_index_table[PlaneFragOffset +
+                                           LineFragments - 1] +
     (HFRAGPIXELS - 1);
   SrcPtr2 = &DestReconPtr[ PixelIndex ];
   DestPtr2 = &DestReconPtr[ PixelIndex + 1 ];
@@ -387,36 +389,36 @@
   }
 }
 
-void UpdateUMVBorder( PB_INSTANCE *pbi, 
-		      unsigned char * DestReconPtr ) {
+void UpdateUMVBorder( PB_INSTANCE *pbi,
+                      unsigned char * DestReconPtr ) {
   ogg_uint32_t  PlaneFragOffset;
-  
+
   /* Y plane */
   PlaneFragOffset = 0;
   UpdateUMV_VBorders( pbi, DestReconPtr, PlaneFragOffset );
   UpdateUMV_HBorders( pbi, DestReconPtr, PlaneFragOffset );
-  
+
   /* Then the U and V Planes */
   PlaneFragOffset = pbi->YPlaneFragments;
   UpdateUMV_VBorders( pbi, DestReconPtr, PlaneFragOffset );
   UpdateUMV_HBorders( pbi, DestReconPtr, PlaneFragOffset );
-  
-  PlaneFragOffset = pbi->YPlaneFragments + pbi->UVPlaneFragments;   
+
+  PlaneFragOffset = pbi->YPlaneFragments + pbi->UVPlaneFragments;
   UpdateUMV_VBorders( pbi, DestReconPtr, PlaneFragOffset );
   UpdateUMV_HBorders( pbi, DestReconPtr, PlaneFragOffset );
 }
 
-static void CopyRecon( PB_INSTANCE *pbi, unsigned char * DestReconPtr, 
-		unsigned char * SrcReconPtr ) {
+static void CopyRecon( PB_INSTANCE *pbi, unsigned char * DestReconPtr,
+                unsigned char * SrcReconPtr ) {
   ogg_uint32_t  i;
-  ogg_uint32_t	PlaneLineStep; /* Pixels per line */
+  ogg_uint32_t  PlaneLineStep; /* Pixels per line */
   ogg_uint32_t  PixelIndex;
-  
+
   unsigned char  *SrcPtr;      /* Pointer to line of source image data */
   unsigned char  *DestPtr;     /* Pointer to line of destination image data */
-  
+
   /* Copy over only updated blocks.*/
-  
+
   /* First Y plane */
   PlaneLineStep = pbi->YStride;
   for ( i = 0; i < pbi->YPlaneFragments; i++ ) {
@@ -424,11 +426,11 @@
       PixelIndex = pbi->recon_pixel_index_table[i];
       SrcPtr = &SrcReconPtr[ PixelIndex ];
       DestPtr = &DestReconPtr[ PixelIndex ];
-      
+
       CopyBlock(SrcPtr, DestPtr, PlaneLineStep);
     }
   }
-  
+
   /* Then U and V */
   PlaneLineStep = pbi->UVStride;
   for ( i = pbi->YPlaneFragments; i < pbi->UnitFragments; i++ ) {
@@ -436,23 +438,23 @@
       PixelIndex = pbi->recon_pixel_index_table[i];
       SrcPtr = &SrcReconPtr[ PixelIndex ];
       DestPtr = &DestReconPtr[ PixelIndex ];
-      
+
       CopyBlock(SrcPtr, DestPtr, PlaneLineStep);
-      
+
     }
   }
 
   /* We may need to update the UMV border */
   UpdateUMVBorder(pbi, DestReconPtr);
-  
+
 }
 
-static void CopyNotRecon( PB_INSTANCE *pbi, unsigned char * DestReconPtr, 
-		   unsigned char * SrcReconPtr ) {
+static void CopyNotRecon( PB_INSTANCE *pbi, unsigned char * DestReconPtr,
+                   unsigned char * SrcReconPtr ) {
   ogg_uint32_t  i;
-  ogg_uint32_t	PlaneLineStep; /* Pixels per line */
+  ogg_uint32_t  PlaneLineStep; /* Pixels per line */
   ogg_uint32_t  PixelIndex;
-  
+
   unsigned char  *SrcPtr;      /* Pointer to line of source image data */
   unsigned char  *DestPtr;     /* Pointer to line of destination image data*/
 
@@ -465,11 +467,11 @@
       PixelIndex = pbi->recon_pixel_index_table[i];
       SrcPtr = &SrcReconPtr[ PixelIndex ];
       DestPtr = &DestReconPtr[ PixelIndex ];
-      
+
       CopyBlock(SrcPtr, DestPtr, PlaneLineStep);
     }
   }
-  
+
   /* Then U and V */
   PlaneLineStep = pbi->UVStride;
   for ( i = pbi->YPlaneFragments; i < pbi->UnitFragments; i++ ) {
@@ -477,82 +479,82 @@
       PixelIndex = pbi->recon_pixel_index_table[i];
       SrcPtr = &SrcReconPtr[ PixelIndex ];
       DestPtr = &DestReconPtr[ PixelIndex ];
-      
+
       CopyBlock(SrcPtr, DestPtr, PlaneLineStep);
-      
+
     }
   }
-  
+
   /*  We may need to update the UMV border */
   UpdateUMVBorder(pbi, DestReconPtr);
-  
+
 }
 
-void ExpandToken( Q_LIST_ENTRY * ExpandedBlock, 
-		  unsigned char * CoeffIndex, ogg_uint32_t Token, 
-		  ogg_int32_t ExtraBits ){
+void ExpandToken( Q_LIST_ENTRY * ExpandedBlock,
+                  unsigned char * CoeffIndex, ogg_uint32_t Token,
+                  ogg_int32_t ExtraBits ){
   /* Is the token is a combination run and value token. */
   if ( Token >= DCT_RUN_CATEGORY1 ){
     /* Expand the token and additional bits to a zero run length and
        data value.  */
-    if ( Token < DCT_RUN_CATEGORY2 ) {   
+    if ( Token < DCT_RUN_CATEGORY2 ) {
       /* Decoding method depends on token */
       if ( Token < DCT_RUN_CATEGORY1B ) {
-	/* Step on by the zero run length */
-	*CoeffIndex += (unsigned char)((Token - DCT_RUN_CATEGORY1) + 1);
+        /* Step on by the zero run length */
+        *CoeffIndex += (unsigned char)((Token - DCT_RUN_CATEGORY1) + 1);
 
-	/* The extra bit determines the sign. */
-	if ( ExtraBits & 0x01 )
-	  ExpandedBlock[*CoeffIndex] = -1;
-	else
-	  ExpandedBlock[*CoeffIndex] = 1;
+        /* The extra bit determines the sign. */
+        if ( ExtraBits & 0x01 )
+          ExpandedBlock[*CoeffIndex] = -1;
+        else
+          ExpandedBlock[*CoeffIndex] = 1;
       } else if ( Token == DCT_RUN_CATEGORY1B ) {
-	/* Bits 0-1 determines the zero run length */
-	*CoeffIndex += (6 + (ExtraBits & 0x03));
-	
-	/* Bit 2 determines the sign */
-	if ( ExtraBits & 0x04 )
-	  ExpandedBlock[*CoeffIndex] = -1;
-	else
-	  ExpandedBlock[*CoeffIndex] = 1;
+        /* Bits 0-1 determines the zero run length */
+        *CoeffIndex += (6 + (ExtraBits & 0x03));
+
+        /* Bit 2 determines the sign */
+        if ( ExtraBits & 0x04 )
+          ExpandedBlock[*CoeffIndex] = -1;
+        else
+          ExpandedBlock[*CoeffIndex] = 1;
       }else{
-	/* Bits 0-2 determines the zero run length */
-	*CoeffIndex += (10 + (ExtraBits & 0x07));
-	
-	/* Bit 3 determines the sign */
-	if ( ExtraBits & 0x08 )
-	  ExpandedBlock[*CoeffIndex] = -1;
-	else
-	  ExpandedBlock[*CoeffIndex] = 1;
+        /* Bits 0-2 determines the zero run length */
+        *CoeffIndex += (10 + (ExtraBits & 0x07));
+
+        /* Bit 3 determines the sign */
+        if ( ExtraBits & 0x08 )
+          ExpandedBlock[*CoeffIndex] = -1;
+        else
+          ExpandedBlock[*CoeffIndex] = 1;
       }
-    }else{   
+    }else{
       /* If token == DCT_RUN_CATEGORY2 we have a single 0 followed by
          a value */
       if ( Token == DCT_RUN_CATEGORY2 ){
-	/* Step on by the zero run length */
-	*CoeffIndex += 1;
-	
-	/* Bit 1 determines sign, bit 0 the value */
-	if ( ExtraBits & 0x02 )
-	  ExpandedBlock[*CoeffIndex] = -(2 + (ExtraBits & 0x01));
-	else
-	  ExpandedBlock[*CoeffIndex] = 2 + (ExtraBits & 0x01);
+        /* Step on by the zero run length */
+        *CoeffIndex += 1;
+
+        /* Bit 1 determines sign, bit 0 the value */
+        if ( ExtraBits & 0x02 )
+          ExpandedBlock[*CoeffIndex] = -(2 + (ExtraBits & 0x01));
+        else
+          ExpandedBlock[*CoeffIndex] = 2 + (ExtraBits & 0x01);
       }else{
-	/* else we have 2->3 zeros followed by a value */
-	/* Bit 0 determines the zero run length */
-	*CoeffIndex += 2 + (ExtraBits & 0x01);
-	
-	/* Bit 2 determines the sign, bit 1 the value */
-	if ( ExtraBits & 0x04 )
-	  ExpandedBlock[*CoeffIndex] = -(2 + ((ExtraBits & 0x02) >> 1));
-	else
-	  ExpandedBlock[*CoeffIndex] = 2 + ((ExtraBits & 0x02) >> 1);
+        /* else we have 2->3 zeros followed by a value */
+        /* Bit 0 determines the zero run length */
+        *CoeffIndex += 2 + (ExtraBits & 0x01);
+
+        /* Bit 2 determines the sign, bit 1 the value */
+        if ( ExtraBits & 0x04 )
+          ExpandedBlock[*CoeffIndex] = -(2 + ((ExtraBits & 0x02) >> 1));
+        else
+          ExpandedBlock[*CoeffIndex] = 2 + ((ExtraBits & 0x02) >> 1);
       }
     }
-    
+
     /* Step on over value */
     *CoeffIndex += 1;
-    
+
   } else if ( Token == DCT_SHORT_ZRL_TOKEN ) {
     /* Token is a ZRL token so step on by the appropriate number of zeros */
     *CoeffIndex += ExtraBits + 1;
@@ -575,61 +577,61 @@
       ExpandedBlock[*CoeffIndex] = -2;
       break;
     }
-    
+
     /* Step on the coefficient index. */
     *CoeffIndex += 1;
   }else{
     /* Token is a larger single value token */
     /* Expand the token and additional bits to a data value. */
-    if ( Token < DCT_VAL_CATEGORY3 ) {   
+    if ( Token < DCT_VAL_CATEGORY3 ) {
       /* Offset from LOW_VAL_TOKENS determines value */
       Token = Token - LOW_VAL_TOKENS;
-      
+
       /* Extra bit determines sign */
       if ( ExtraBits )
-	ExpandedBlock[*CoeffIndex] = 
-	  -((Q_LIST_ENTRY)(Token + DCT_VAL_CAT2_MIN));
+        ExpandedBlock[*CoeffIndex] =
+          -((Q_LIST_ENTRY)(Token + DCT_VAL_CAT2_MIN));
       else
-	ExpandedBlock[*CoeffIndex] = 
-	  (Q_LIST_ENTRY)(Token + DCT_VAL_CAT2_MIN);
-    } else if ( Token == DCT_VAL_CATEGORY3 ) {   
+        ExpandedBlock[*CoeffIndex] =
+          (Q_LIST_ENTRY)(Token + DCT_VAL_CAT2_MIN);
+    } else if ( Token == DCT_VAL_CATEGORY3 ) {
       /* Bit 1 determines sign, Bit 0 the value */
       if ( ExtraBits & 0x02 )
-	ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT3_MIN + (ExtraBits & 0x01));
+        ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT3_MIN + (ExtraBits & 0x01));
       else
-	ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT3_MIN + (ExtraBits & 0x01);
-    } else if ( Token == DCT_VAL_CATEGORY4 ) {   
+        ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT3_MIN + (ExtraBits & 0x01);
+    } else if ( Token == DCT_VAL_CATEGORY4 ) {
       /* Bit 2 determines sign, Bit 0-1 the value */
       if ( ExtraBits & 0x04 )
-	ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT4_MIN + (ExtraBits & 0x03));
+        ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT4_MIN + (ExtraBits & 0x03));
       else
-	ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT4_MIN + (ExtraBits & 0x03);
+        ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT4_MIN + (ExtraBits & 0x03);
     } else if ( Token == DCT_VAL_CATEGORY5 ) {
       /* Bit 3 determines sign, Bit 0-2 the value */
       if ( ExtraBits & 0x08 )
-	ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT5_MIN + (ExtraBits & 0x07));
+        ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT5_MIN + (ExtraBits & 0x07));
       else
-	ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT5_MIN + (ExtraBits & 0x07);
+        ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT5_MIN + (ExtraBits & 0x07);
     } else if ( Token == DCT_VAL_CATEGORY6 ) {
       /* Bit 4 determines sign, Bit 0-3 the value */
       if ( ExtraBits & 0x10 )
-	ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT6_MIN + (ExtraBits & 0x0F));
+        ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT6_MIN + (ExtraBits & 0x0F));
       else
-	ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT6_MIN + (ExtraBits & 0x0F);
+        ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT6_MIN + (ExtraBits & 0x0F);
     } else if ( Token == DCT_VAL_CATEGORY7 ) {
       /* Bit 5 determines sign, Bit 0-4 the value */
       if ( ExtraBits & 0x20 )
-	ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT7_MIN + (ExtraBits & 0x1F));
+        ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT7_MIN + (ExtraBits & 0x1F));
       else
-	ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT7_MIN + (ExtraBits & 0x1F);
+        ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT7_MIN + (ExtraBits & 0x1F);
     } else if ( Token == DCT_VAL_CATEGORY8 ) {
       /* Bit 9 determines sign, Bit 0-8 the value */
       if ( ExtraBits & 0x200 )
-	ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT8_MIN + (ExtraBits & 0x1FF));
+        ExpandedBlock[*CoeffIndex] = -(DCT_VAL_CAT8_MIN + (ExtraBits & 0x1FF));
       else
-	ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT8_MIN + (ExtraBits & 0x1FF);
+        ExpandedBlock[*CoeffIndex] = DCT_VAL_CAT8_MIN + (ExtraBits & 0x1FF);
     }
-    
+
     /* Step on the coefficient index. */
     *CoeffIndex += 1;
   }
@@ -638,7 +640,7 @@
 void ClearDownQFragData(PB_INSTANCE *pbi){
   ogg_int32_t       i,j;
   Q_LIST_ENTRY *    QFragPtr;
-  
+
   for ( i = 0; i < pbi->CodedBlockIndex; i++ ) {
     /* Get the linear index for the current fragment. */
     QFragPtr = pbi->QFragData[pbi->CodedBlockList[i]];
@@ -646,86 +648,86 @@
   }
 }
 
-static void FilterHoriz(unsigned char * PixelPtr, 
-			ogg_int32_t LineLength, 
-			ogg_int32_t *BoundingValuePtr){
+static void FilterHoriz(unsigned char * PixelPtr,
+                        ogg_int32_t LineLength,
+                        ogg_int32_t *BoundingValuePtr){
   ogg_int32_t j;
   ogg_int32_t FiltVal;
-  
-  for ( j = 0; j < 8; j++ ){            
-    FiltVal =  
-      ( PixelPtr[0] ) - 
+
+  for ( j = 0; j < 8; j++ ){
+    FiltVal =
+      ( PixelPtr[0] ) -
       ( PixelPtr[1] * 3 ) +
-      ( PixelPtr[2] * 3 ) - 
+      ( PixelPtr[2] * 3 ) -
       ( PixelPtr[3] );
-    
+
     FiltVal = *(BoundingValuePtr+((FiltVal + 4) >> 3));
-    
+
     PixelPtr[1] = clamp255(PixelPtr[1] + FiltVal);
     PixelPtr[2] = clamp255(PixelPtr[2] - FiltVal);
-    
+
     PixelPtr += LineLength;
   }
 }
 
-static void FilterVert(unsigned char * PixelPtr, 
-		ogg_int32_t LineLength, 
-		ogg_int32_t *BoundingValuePtr){
+static void FilterVert(unsigned char * PixelPtr,
+                ogg_int32_t LineLength,
+                ogg_int32_t *BoundingValuePtr){
   ogg_int32_t j;
   ogg_int32_t FiltVal;
-  
+
   /* the math was correct, but negative array indicies are forbidden
      by ANSI/C99 and will break optimization on several modern
      compilers */
 
   PixelPtr -= 2*LineLength;
 
-  for ( j = 0; j < 8; j++ ) {            
-    FiltVal = ( (ogg_int32_t)PixelPtr[0] ) - 
-      ( (ogg_int32_t)PixelPtr[LineLength] * 3 ) + 
-      ( (ogg_int32_t)PixelPtr[2 * LineLength] * 3 ) - 
+  for ( j = 0; j < 8; j++ ) {
+    FiltVal = ( (ogg_int32_t)PixelPtr[0] ) -
+      ( (ogg_int32_t)PixelPtr[LineLength] * 3 ) +
+      ( (ogg_int32_t)PixelPtr[2 * LineLength] * 3 ) -
       ( (ogg_int32_t)PixelPtr[3 * LineLength] );
-    
+
     FiltVal = *(BoundingValuePtr+((FiltVal + 4) >> 3));
-    
+
     PixelPtr[LineLength] = clamp255(PixelPtr[LineLength] + FiltVal);
     PixelPtr[2 * LineLength] = clamp255(PixelPtr[2*LineLength] - FiltVal);
-    
+
     PixelPtr ++;
   }
 }
 
 void LoopFilter(PB_INSTANCE *pbi){
   ogg_int32_t i;
-  
+
   ogg_int32_t * BoundingValuePtr=pbi->FiltBoundingValue+256;
-  int FragsAcross=pbi->HFragments;	
+  int FragsAcross=pbi->HFragments;
   int FromFragment,ToFragment;
   int FragsDown = pbi->VFragments;
   ogg_int32_t LineFragments;
   ogg_int32_t LineLength;
-  ogg_int32_t FLimit; 
+  ogg_int32_t FLimit;
   int QIndex;
   int j,m,n;
-  
+
   /* Set the limit value for the loop filter based upon the current
      quantizer. */
   QIndex = Q_TABLE_SIZE - 1;
   while ( QIndex >= 0 ) {
-    if ( (QIndex == 0) || 
-	 ( pbi->QThreshTable[QIndex] >= pbi->ThisFrameQualityValue) )
+    if ( (QIndex == 0) ||
+         ( pbi->QThreshTable[QIndex] >= pbi->ThisFrameQualityValue) )
       break;
     QIndex --;
   }
-  
+
   /* Encoder version specific clause */
   FLimit = LoopFilterLimitValuesV1[QIndex];
-  
+
   if ( FLimit == 0 ) return;
-  
+
   SetupBoundingValueArray_Generic(pbi, FLimit);
- 
-  
+
+
   for ( j = 0; j < 3 ; j++){
     switch(j) {
     case 0: /* y */
@@ -753,11 +755,11 @@
       LineFragments = pbi->HFragments / 2;
       break;
     }
-    
+
     i=FromFragment;
-    
+
     /**************************************************************
-     First Row 
+     First Row
     **************************************************************/
     /* first column conditions */
     /* only do 2 prediction if fragment coded and on non intra or if
@@ -766,62 +768,62 @@
       /* Filter right hand border only if the block to the right is
          not coded */
       if ( !pbi->display_fragments[ i + 1 ] ){
-	FilterHoriz(pbi->LastFrameRecon+
-		    pbi->recon_pixel_index_table[i]+6, 
-		    LineLength,BoundingValuePtr);
+        FilterHoriz(pbi->LastFrameRecon+
+                    pbi->recon_pixel_index_table[i]+6,
+                    LineLength,BoundingValuePtr);
       }
-      
+
       /* Bottom done if next row set */
       if( !pbi->display_fragments[ i + LineFragments] ){
-	FilterVert(pbi->LastFrameRecon+
-		   pbi->recon_pixel_index_table[i+LineFragments], 
-		   LineLength, BoundingValuePtr);
-      }		
-    }	
+        FilterVert(pbi->LastFrameRecon+
+                   pbi->recon_pixel_index_table[i+LineFragments],
+                   LineLength, BoundingValuePtr);
+      }
+    }
     i++;
-    
+
     /***************************************************************/
     /* middle columns  */
     for ( n = 1 ; n < FragsAcross - 1 ; n++, i++) {
       if( pbi->display_fragments[i]){
-	/* Filter Left edge always */
-	FilterHoriz(pbi->LastFrameRecon+
-		    pbi->recon_pixel_index_table[i]-2, 
-		    LineLength, BoundingValuePtr);
-	
-	/* Filter right hand border only if the block to the right is
+        /* Filter Left edge always */
+        FilterHoriz(pbi->LastFrameRecon+
+                    pbi->recon_pixel_index_table[i]-2,
+                    LineLength, BoundingValuePtr);
+
+        /* Filter right hand border only if the block to the right is
            not coded */
-	if ( !pbi->display_fragments[ i + 1 ] ){
-	  FilterHoriz(pbi->LastFrameRecon+
-		      pbi->recon_pixel_index_table[i]+6, 
-		      LineLength, BoundingValuePtr);
-	}
-	
-	/* Bottom done if next row set */
-	if( !pbi->display_fragments[ i + LineFragments] ){
-	  FilterVert(pbi->LastFrameRecon+
-		     pbi->recon_pixel_index_table[i + LineFragments],
-		     LineLength, BoundingValuePtr);
-	}
-							
-      } 			
+        if ( !pbi->display_fragments[ i + 1 ] ){
+          FilterHoriz(pbi->LastFrameRecon+
+                      pbi->recon_pixel_index_table[i]+6,
+                      LineLength, BoundingValuePtr);
+        }
+
+        /* Bottom done if next row set */
+        if( !pbi->display_fragments[ i + LineFragments] ){
+          FilterVert(pbi->LastFrameRecon+
+                     pbi->recon_pixel_index_table[i + LineFragments],
+                     LineLength, BoundingValuePtr);
+        }
+
+      }
     }
-		
+
     /***************************************************************/
     /* Last Column */
     if( pbi->display_fragments[i]){
       /* Filter Left edge always */
       FilterHoriz(pbi->LastFrameRecon+
-		  pbi->recon_pixel_index_table[i] - 2 , 
-		  LineLength, BoundingValuePtr);
-      
+                  pbi->recon_pixel_index_table[i] - 2 ,
+                  LineLength, BoundingValuePtr);
+
       /* Bottom done if next row set */
       if( !pbi->display_fragments[ i + LineFragments] ){
-	FilterVert(pbi->LastFrameRecon+
-		   pbi->recon_pixel_index_table[i + LineFragments], 
-		   LineLength, BoundingValuePtr);
-      }		
-    }	
+        FilterVert(pbi->LastFrameRecon+
+                   pbi->recon_pixel_index_table[i + LineFragments],
+                   LineLength, BoundingValuePtr);
+      }
+    }
     i++;
 
     /***************************************************************/
@@ -834,83 +836,83 @@
       /* only do 2 prediction if fragment coded and on non intra or if
          all fragments are intra */
       if( pbi->display_fragments[i]){
-	/* TopRow is always done */
-	FilterVert(pbi->LastFrameRecon+
-		   pbi->recon_pixel_index_table[i], 
-		   LineLength, BoundingValuePtr);
-	
-	/* Filter right hand border only if the block to the right is
+        /* TopRow is always done */
+        FilterVert(pbi->LastFrameRecon+
+                   pbi->recon_pixel_index_table[i],
+                   LineLength, BoundingValuePtr);
+
+        /* Filter right hand border only if the block to the right is
            not coded */
-	if ( !pbi->display_fragments[ i + 1 ] ){
-	  FilterHoriz(pbi->LastFrameRecon+
-		      pbi->recon_pixel_index_table[i] + 6, 
-		      LineLength, BoundingValuePtr);
-	}
-
-	/* Bottom done if next row set */
-	if( !pbi->display_fragments[ i + LineFragments] ){
-	  FilterVert(pbi->LastFrameRecon+
-		     pbi->recon_pixel_index_table[i + LineFragments], 
-		     LineLength, BoundingValuePtr);
-	}
+        if ( !pbi->display_fragments[ i + 1 ] ){
+          FilterHoriz(pbi->LastFrameRecon+
+                      pbi->recon_pixel_index_table[i] + 6,
+                      LineLength, BoundingValuePtr);
+        }
+
+        /* Bottom done if next row set */
+        if( !pbi->display_fragments[ i + LineFragments] ){
+          FilterVert(pbi->LastFrameRecon+
+                     pbi->recon_pixel_index_table[i + LineFragments],
+                     LineLength, BoundingValuePtr);
+        }
       }
       i++;
 
       /*****************************************************************/
       /* middle columns  */
       for ( n = 1 ; n < FragsAcross - 1 ; n++, i++){
-	if( pbi->display_fragments[i]){
-	  /* Filter Left edge always */
-	  FilterHoriz(pbi->LastFrameRecon+
-		      pbi->recon_pixel_index_table[i] - 2, 
-		      LineLength, BoundingValuePtr);
-	  
-	  /* TopRow is always done */
-	  FilterVert(pbi->LastFrameRecon+
-		     pbi->recon_pixel_index_table[i], 
-		     LineLength, BoundingValuePtr);
+        if( pbi->display_fragments[i]){
+          /* Filter Left edge always */
+          FilterHoriz(pbi->LastFrameRecon+
+                      pbi->recon_pixel_index_table[i] - 2,
+                      LineLength, BoundingValuePtr);
+
+          /* TopRow is always done */
+          FilterVert(pbi->LastFrameRecon+
+                     pbi->recon_pixel_index_table[i],
+                     LineLength, BoundingValuePtr);
 
-	  /* Filter right hand border only if the block to the right
+          /* Filter right hand border only if the block to the right
              is not coded */
-	  if ( !pbi->display_fragments[ i + 1 ] ){
-	    FilterHoriz(pbi->LastFrameRecon+
-			pbi->recon_pixel_index_table[i] + 6,
-			LineLength, BoundingValuePtr);
-	  }
-	  
-	  /* Bottom done if next row set */
-	  if( !pbi->display_fragments[ i + LineFragments] ){
-	    FilterVert(pbi->LastFrameRecon+
-		       pbi->recon_pixel_index_table[i + LineFragments],
-		       LineLength, BoundingValuePtr);
-	  }
-	}
+          if ( !pbi->display_fragments[ i + 1 ] ){
+            FilterHoriz(pbi->LastFrameRecon+
+                        pbi->recon_pixel_index_table[i] + 6,
+                        LineLength, BoundingValuePtr);
+          }
+
+          /* Bottom done if next row set */
+          if( !pbi->display_fragments[ i + LineFragments] ){
+            FilterVert(pbi->LastFrameRecon+
+                       pbi->recon_pixel_index_table[i + LineFragments],
+                       LineLength, BoundingValuePtr);
+          }
+        }
       }
 
       /******************************************************************/
       /* Last Column */
       if( pbi->display_fragments[i]){
-	/* Filter Left edge always*/
-	FilterHoriz(pbi->LastFrameRecon+
-		    pbi->recon_pixel_index_table[i] - 2,
-		    LineLength, BoundingValuePtr);
-	
-	/* TopRow is always done */
-	FilterVert(pbi->LastFrameRecon+
-		   pbi->recon_pixel_index_table[i], 
-		   LineLength, BoundingValuePtr);
-	
-	/* Bottom done if next row set */
-	if( !pbi->display_fragments[ i + LineFragments] ){
-	  FilterVert(pbi->LastFrameRecon+
-		     pbi->recon_pixel_index_table[i + LineFragments],
-		     LineLength, BoundingValuePtr);
-	}
+        /* Filter Left edge always*/
+        FilterHoriz(pbi->LastFrameRecon+
+                    pbi->recon_pixel_index_table[i] - 2,
+                    LineLength, BoundingValuePtr);
+
+        /* TopRow is always done */
+        FilterVert(pbi->LastFrameRecon+
+                   pbi->recon_pixel_index_table[i],
+                   LineLength, BoundingValuePtr);
+
+        /* Bottom done if next row set */
+        if( !pbi->display_fragments[ i + LineFragments] ){
+          FilterVert(pbi->LastFrameRecon+
+                     pbi->recon_pixel_index_table[i + LineFragments],
+                     LineLength, BoundingValuePtr);
+        }
       }
       i++;
 
     }
-		
+
     /*******************************************************************/
     /* Last Row  */
 
@@ -918,60 +920,60 @@
     /* only do 2 prediction if fragment coded and on non intra or if
        all fragments are intra */
     if( pbi->display_fragments[i]){
-			
+
       /* TopRow is always done */
       FilterVert(pbi->LastFrameRecon+
-		 pbi->recon_pixel_index_table[i], 
-		 LineLength, BoundingValuePtr);
-      
+                 pbi->recon_pixel_index_table[i],
+                 LineLength, BoundingValuePtr);
+
       /* Filter right hand border only if the block to the right is
          not coded */
       if ( !pbi->display_fragments[ i + 1 ] ){
-	FilterHoriz(pbi->LastFrameRecon+
-		    pbi->recon_pixel_index_table[i] + 6,
-		    LineLength, BoundingValuePtr);
-      }		
-    }		
+        FilterHoriz(pbi->LastFrameRecon+
+                    pbi->recon_pixel_index_table[i] + 6,
+                    LineLength, BoundingValuePtr);
+      }
+    }
     i++;
-		
+
     /******************************************************************/
     /* middle columns  */
     for ( n = 1 ; n < FragsAcross - 1 ; n++, i++){
       if( pbi->display_fragments[i]){
-	/* Filter Left edge always */
-	FilterHoriz(pbi->LastFrameRecon+
-		    pbi->recon_pixel_index_table[i] - 2, 
-		    LineLength, BoundingValuePtr);
-	
-	/* TopRow is always done */
-	FilterVert(pbi->LastFrameRecon+
-		   pbi->recon_pixel_index_table[i],
-		   LineLength, BoundingValuePtr);
-				
-	/* Filter right hand border only if the block to the right is
+        /* Filter Left edge always */
+        FilterHoriz(pbi->LastFrameRecon+
+                    pbi->recon_pixel_index_table[i] - 2,
+                    LineLength, BoundingValuePtr);
+
+        /* TopRow is always done */
+        FilterVert(pbi->LastFrameRecon+
+                   pbi->recon_pixel_index_table[i],
+                   LineLength, BoundingValuePtr);
+
+        /* Filter right hand border only if the block to the right is
            not coded */
-	if ( !pbi->display_fragments[ i + 1 ] ){
-	  FilterHoriz(pbi->LastFrameRecon+
-		      pbi->recon_pixel_index_table[i] + 6, 
-		      LineLength, BoundingValuePtr);
-	}			
-      }		
+        if ( !pbi->display_fragments[ i + 1 ] ){
+          FilterHoriz(pbi->LastFrameRecon+
+                      pbi->recon_pixel_index_table[i] + 6,
+                      LineLength, BoundingValuePtr);
+        }
+      }
     }
-		
+
     /******************************************************************/
     /* Last Column */
     if( pbi->display_fragments[i]){
       /* Filter Left edge always */
       FilterHoriz(pbi->LastFrameRecon+
-		  pbi->recon_pixel_index_table[i] - 2,
-		  LineLength, BoundingValuePtr);
-      
+                  pbi->recon_pixel_index_table[i] - 2,
+                  LineLength, BoundingValuePtr);
+
       /* TopRow is always done */
       FilterVert(pbi->LastFrameRecon+
-		 pbi->recon_pixel_index_table[i],
-		 LineLength, BoundingValuePtr);
-      
-    } 	
+                 pbi->recon_pixel_index_table[i],
+                 LineLength, BoundingValuePtr);
+
+    }
     i++;
   }
 }
@@ -980,9 +982,9 @@
   ogg_int32_t i;
   ogg_int32_t FragIndex;
   unsigned char *SwapReconBuffersTemp;
-  
+
   short pc[16][6]={
-    {0,0,0,0,0,0},	
+    {0,0,0,0,0,0},
     {0,0,0,1,0,0},
     {0,0,1,0,0,0},
     {0,0,53,75,7,127},
@@ -1006,7 +1008,7 @@
   short Mode2Frame[] = { 1,0,1,1,1,2,2,1 };
   short Last[3];
   short PredictedDC;
-  int FragsAcross=pbi->HFragments;	
+  int FragsAcross=pbi->HFragments;
   int FromFragment,ToFragment;
   int FragsDown = pbi->VFragments;
 
@@ -1022,17 +1024,17 @@
     {-3,0},{-1,-3},{-3,-1},{-3,1},{-1,3},{-2,-3},{-3,-2},{-3,2},{-2,3},
     {0,-4},{-4,0},{-1,-4},{-4,-1},{-4,1},{-1,4},{-3,-3},{-3,3}
   };
-	
+
   int DCSearchPointCount = 0;
   void (*ExpandBlockA) ( PB_INSTANCE *pbi, ogg_int32_t FragmentNumber );
-  
+
   if ( GetFrameType(pbi) == BASE_FRAME )
     ExpandBlockA=ExpandKFBlock;
   else
     ExpandBlockA=ExpandBlock;
 
   SetupLoopFilter(pbi);
-  
+
   /* for y,u,v */
   for ( j = 0; j < 3 ; j++) {
     /* pick which fragments based on Y, U, V */
@@ -1062,194 +1064,194 @@
       Last[k]=0;
 
     i=FromFragment;
-    
+
     /* do prediction on all of Y, U or V */
     for ( m = 0 ; m < FragsDown ; m++) {
       for ( n = 0 ; n < FragsAcross ; n++, i++){
-	
-	/* only do 2 prediction if fragment coded and on non intra or
+
+        /* only do 2 prediction if fragment coded and on non intra or
            if all fragments are intra */
-	if( pbi->display_fragments[i] || (GetFrameType(pbi) == BASE_FRAME) ){
-	  /* Type of Fragment */	  
-	  WhichFrame = Mode2Frame[pbi->FragCodingMethod[i]];
-	  
-	  /* Check Borderline Cases */
-	  WhichCase = (n==0) + ((m==0) << 1) + ((n+1 == FragsAcross) << 2);
-
-	  switch(WhichCase){
-	  case 0: /* normal case no border condition */
-	    
-	    /* calculate values left, up, up-right and up-left */
-	    l = i-1;
-	    u = i - FragsAcross;
-	    ur = i - FragsAcross + 1;
-	    ul = i - FragsAcross - 1;
-	    
-	    /* calculate values */
-	    vl = pbi->QFragData[l][0];
-	    vu = pbi->QFragData[u][0];
-	    vur = pbi->QFragData[ur][0];
-	    vul = pbi->QFragData[ul][0];
-	    
-	    /* fragment valid for prediction use if coded and it comes
+        if( pbi->display_fragments[i] || (GetFrameType(pbi) == BASE_FRAME) ){
+          /* Type of Fragment */
+          WhichFrame = Mode2Frame[pbi->FragCodingMethod[i]];
+
+          /* Check Borderline Cases */
+          WhichCase = (n==0) + ((m==0) << 1) + ((n+1 == FragsAcross) << 2);
+
+          switch(WhichCase){
+          case 0: /* normal case no border condition */
+
+            /* calculate values left, up, up-right and up-left */
+            l = i-1;
+            u = i - FragsAcross;
+            ur = i - FragsAcross + 1;
+            ul = i - FragsAcross - 1;
+
+            /* calculate values */
+            vl = pbi->QFragData[l][0];
+            vu = pbi->QFragData[u][0];
+            vur = pbi->QFragData[ur][0];
+            vul = pbi->QFragData[ul][0];
+
+            /* fragment valid for prediction use if coded and it comes
                from same frame as the one we are predicting */
-	    fl = pbi->display_fragments[l] && 
-	      (Mode2Frame[pbi->FragCodingMethod[l]] == WhichFrame);
-	    fu = pbi->display_fragments[u] && 
-	      (Mode2Frame[pbi->FragCodingMethod[u]] == WhichFrame);
-	    fur = pbi->display_fragments[ur] && 
-	      (Mode2Frame[pbi->FragCodingMethod[ur]] == WhichFrame);
-	    ful = pbi->display_fragments[ul] && 
-	      (Mode2Frame[pbi->FragCodingMethod[ul]] == WhichFrame);
-
-	    /* calculate which predictor to use */
-	    wpc = (fl*PL) | (fu*PU) | (ful*PUL) | (fur*PUR);
-	    
-	    break;
-	    
-	  case 1: /* n == 0 Left Column */
-	    
-	    /* calculate values left, up, up-right and up-left */
-	    u = i - FragsAcross;
-	    ur = i - FragsAcross + 1;
-	    
-	    /* calculate values */
-	    vu = pbi->QFragData[u][0];
-	    vur = pbi->QFragData[ur][0];
+            fl = pbi->display_fragments[l] &&
+              (Mode2Frame[pbi->FragCodingMethod[l]] == WhichFrame);
+            fu = pbi->display_fragments[u] &&
+              (Mode2Frame[pbi->FragCodingMethod[u]] == WhichFrame);
+            fur = pbi->display_fragments[ur] &&
+              (Mode2Frame[pbi->FragCodingMethod[ur]] == WhichFrame);
+            ful = pbi->display_fragments[ul] &&
+              (Mode2Frame[pbi->FragCodingMethod[ul]] == WhichFrame);
+
+            /* calculate which predictor to use */
+            wpc = (fl*PL) | (fu*PU) | (ful*PUL) | (fur*PUR);
+
+            break;
+
+          case 1: /* n == 0 Left Column */
+
+            /* calculate values left, up, up-right and up-left */
+            u = i - FragsAcross;
+            ur = i - FragsAcross + 1;
+
+            /* calculate values */
+            vu = pbi->QFragData[u][0];
+            vur = pbi->QFragData[ur][0];
 
-	    /* fragment valid for prediction if coded and it comes
+            /* fragment valid for prediction if coded and it comes
                from same frame as the one we are predicting */
-	    fu = pbi->display_fragments[u] && 
-	      (Mode2Frame[pbi->FragCodingMethod[u]] == WhichFrame);
-	    fur = pbi->display_fragments[ur] && 
-	      (Mode2Frame[pbi->FragCodingMethod[ur]] == WhichFrame);
-
-	    /* calculate which predictor to use */
-	    wpc = (fu*PU) | (fur*PUR);
-	    
-	    break;
-	    
-	  case 2: /* m == 0 Top Row */
-	  case 6: /* m == 0 and n+1 == FragsAcross or Top Row Right Column */
-	    
-	    /* calculate values left, up, up-right and up-left */
-	    l = i-1;
-	    
-	    /* calculate values */
-	    vl = pbi->QFragData[l][0];
-	    
-	    /* fragment valid for prediction if coded and it comes
+            fu = pbi->display_fragments[u] &&
+              (Mode2Frame[pbi->FragCodingMethod[u]] == WhichFrame);
+            fur = pbi->display_fragments[ur] &&
+              (Mode2Frame[pbi->FragCodingMethod[ur]] == WhichFrame);
+
+            /* calculate which predictor to use */
+            wpc = (fu*PU) | (fur*PUR);
+
+            break;
+
+          case 2: /* m == 0 Top Row */
+          case 6: /* m == 0 and n+1 == FragsAcross or Top Row Right Column */
+
+            /* calculate values left, up, up-right and up-left */
+            l = i-1;
+
+            /* calculate values */
+            vl = pbi->QFragData[l][0];
+
+            /* fragment valid for prediction if coded and it comes
                from same frame as the one we are predicting */
-	    fl = pbi->display_fragments[l] && 
-	      (Mode2Frame[pbi->FragCodingMethod[l]] == WhichFrame);
-	    
-	    /* calculate which predictor to use */
-	    wpc = (fl*PL) ;
-	    
-	    break;
-	    
-	  case 3: /* n == 0 & m == 0 Top Row Left Column */
-	    
-	    wpc = 0;
-	    
-	    break;
-	    
-	  case 4: /* n+1 == FragsAcross : Right Column */
-	    
-	    /* calculate values left, up, up-right and up-left */
-	    l = i-1;
-	    u = i - FragsAcross;
-	    ul = i - FragsAcross - 1;
-	    
-	    /* calculate values */
-	    vl = pbi->QFragData[l][0];
-	    vu = pbi->QFragData[u][0];
-	    vul = pbi->QFragData[ul][0];
-	    
-	    /* fragment valid for prediction if coded and it comes
+            fl = pbi->display_fragments[l] &&
+              (Mode2Frame[pbi->FragCodingMethod[l]] == WhichFrame);
+
+            /* calculate which predictor to use */
+            wpc = (fl*PL) ;
+
+            break;
+
+          case 3: /* n == 0 & m == 0 Top Row Left Column */
+
+            wpc = 0;
+
+            break;
+
+          case 4: /* n+1 == FragsAcross : Right Column */
+
+            /* calculate values left, up, up-right and up-left */
+            l = i-1;
+            u = i - FragsAcross;
+            ul = i - FragsAcross - 1;
+
+            /* calculate values */
+            vl = pbi->QFragData[l][0];
+            vu = pbi->QFragData[u][0];
+            vul = pbi->QFragData[ul][0];
+
+            /* fragment valid for prediction if coded and it comes
                from same frame as the one we are predicting */
-	    fl = pbi->display_fragments[l] && 
-	      (Mode2Frame[pbi->FragCodingMethod[l]] == WhichFrame);
-	    fu = pbi->display_fragments[u] && 
-	      (Mode2Frame[pbi->FragCodingMethod[u]] == WhichFrame);
-	    ful = pbi->display_fragments[ul] && 
-	      (Mode2Frame[pbi->FragCodingMethod[ul]] == WhichFrame);
-	    
-	    /* calculate which predictor to use */
-	    wpc = (fl*PL) | (fu*PU) | (ful*PUL) ;
-	    
-	    break;
-	    
-	  }
-	  					
-	  if(wpc==0){
-	    FragIndex = 1;
-	    
-	    /* find the nearest one that is coded */
-	    for( k = 0; k < DCSearchPointCount ; k++){
-	      FragIndex = i + DCSearchPoints[k].RowOffset * FragsAcross + 
-		DCSearchPoints[k].ColOffset;
-	      
-	      if( FragIndex - FromFragment > 0 ) {
-		if(pbi->display_fragments[FragIndex] && 
-		   (Mode2Frame[pbi->FragCodingMethod[FragIndex]] == 
-		    WhichFrame)){
-		  pbi->QFragData[i][0] += pbi->QFragData[FragIndex][0];
-		  FragIndex = 0;
-		  break;
-		}
-	      }
-	    }
-	    
-	    
-	    /* if none matched fall back to the last one ever */
-	    if(FragIndex){
-	      pbi->QFragData[i][0] += Last[WhichFrame];
-	    }
-	    
-	  }else{
-	    
-	    /* don't do divide if divisor is 1 or 0 */
-	    PredictedDC = (pc[wpc][0]*vul + pc[wpc][1] * vu + 
-			   pc[wpc][2] * vur + pc[wpc][3] * vl );
-	    
-	    /* if we need to do a shift */
-	    if(pc[wpc][4] != 0 ){
-	      
-	      /* If negative add in the negative correction factor */
-	      PredictedDC += (HIGHBITDUPPED(PredictedDC) & pc[wpc][5]);
-	      
-	      /* Shift in lieu of a divide */
-	      PredictedDC >>= pc[wpc][4];
-	    }
-	    
-	    /* check for outranging on the two predictors that can outrange */
-	    switch(wpc){
-	    case 13: /* pul pu pl */
-	    case 15: /* pul pu pur pl */
-	      if( abs(PredictedDC - vu) > 128)
-		PredictedDC = vu;
-	      else if( abs(PredictedDC - vl) > 128)
-		PredictedDC = vl;
-	      else if( abs(PredictedDC - vul) > 128)
-		PredictedDC = vul;
-	      
-	      break;
-	    }
-	    
-	    pbi->QFragData[i][0] += PredictedDC;
-	    
-	  }
-	  
-	  /* Save the last fragment coded for whatever frame we are
+            fl = pbi->display_fragments[l] &&
+              (Mode2Frame[pbi->FragCodingMethod[l]] == WhichFrame);
+            fu = pbi->display_fragments[u] &&
+              (Mode2Frame[pbi->FragCodingMethod[u]] == WhichFrame);
+            ful = pbi->display_fragments[ul] &&
+              (Mode2Frame[pbi->FragCodingMethod[ul]] == WhichFrame);
+
+            /* calculate which predictor to use */
+            wpc = (fl*PL) | (fu*PU) | (ful*PUL) ;
+
+            break;
+
+          }
+
+          if(wpc==0){
+            FragIndex = 1;
+
+            /* find the nearest one that is coded */
+            for( k = 0; k < DCSearchPointCount ; k++){
+              FragIndex = i + DCSearchPoints[k].RowOffset * FragsAcross +
+                DCSearchPoints[k].ColOffset;
+
+              if( FragIndex - FromFragment > 0 ) {
+                if(pbi->display_fragments[FragIndex] &&
+                   (Mode2Frame[pbi->FragCodingMethod[FragIndex]] ==
+                    WhichFrame)){
+                  pbi->QFragData[i][0] += pbi->QFragData[FragIndex][0];
+                  FragIndex = 0;
+                  break;
+                }
+              }
+            }
+
+
+            /* if none matched fall back to the last one ever */
+            if(FragIndex){
+              pbi->QFragData[i][0] += Last[WhichFrame];
+            }
+
+          }else{
+
+            /* don't do divide if divisor is 1 or 0 */
+            PredictedDC = (pc[wpc][0]*vul + pc[wpc][1] * vu +
+                           pc[wpc][2] * vur + pc[wpc][3] * vl );
+
+            /* if we need to do a shift */
+            if(pc[wpc][4] != 0 ){
+
+              /* If negative add in the negative correction factor */
+              PredictedDC += (HIGHBITDUPPED(PredictedDC) & pc[wpc][5]);
+
+              /* Shift in lieu of a divide */
+              PredictedDC >>= pc[wpc][4];
+            }
+
+            /* check for outranging on the two predictors that can outrange */
+            switch(wpc){
+            case 13: /* pul pu pl */
+            case 15: /* pul pu pur pl */
+              if( abs(PredictedDC - vu) > 128)
+                PredictedDC = vu;
+              else if( abs(PredictedDC - vl) > 128)
+                PredictedDC = vl;
+              else if( abs(PredictedDC - vul) > 128)
+                PredictedDC = vul;
+
+              break;
+            }
+
+            pbi->QFragData[i][0] += PredictedDC;
+
+          }
+
+          /* Save the last fragment coded for whatever frame we are
              predicting from */
-	  Last[WhichFrame] = pbi->QFragData[i][0];
-	  
-	  /* Inverse DCT and reconstitute buffer in thisframe */
-	  ExpandBlockA( pbi, i );
-	  
-	}
-      } 
+          Last[WhichFrame] = pbi->QFragData[i][0];
+
+          /* Inverse DCT and reconstitute buffer in thisframe */
+          ExpandBlockA( pbi, i );
+
+        }
+      }
     }
   }
 
@@ -1262,18 +1264,14 @@
   }else{
     CopyRecon( pbi, pbi->LastFrameRecon, pbi->ThisFrameRecon );
   }
-         
+
   /* Apply a loop filter to edge pixels of updated blocks */
   LoopFilter(pbi);
-	
-  
-  /* Reconstruct the golden frame if necessary. 
+
+
+  /* Reconstruct the golden frame if necessary.
      For VFW codec only on key frames */
   if ( GetFrameType(pbi) == BASE_FRAME )
     CopyRecon( pbi, pbi->GoldenFrame, pbi->LastFrameRecon );
 
 }
-
-
-
-

<p><p>1.8       +167 -166  theora/lib/dct_encode.c

Index: dct_encode.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/dct_encode.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- dct_encode.c	8 Jun 2003 00:08:38 -0000	1.7
+++ dct_encode.c	10 Jun 2003 01:31:33 -0000	1.8
@@ -10,21 +10,22 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: dct_encode.c,v 1.7 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: dct_encode.c,v 1.8 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
+#include <stdlib.h>
 #include "encoder_internal.h"
 
 static int ModeUsesMC[MAX_MODES] = { 0, 0, 1, 1, 1, 0, 1, 1 };
 
-static void Sub8 (unsigned char *FiltPtr, unsigned char *ReconPtr, 
-		  ogg_int16_t *DctInputPtr, unsigned char *old_ptr1, 
-		  unsigned char *new_ptr1, ogg_uint32_t PixelsPerLine, 
-		  ogg_uint32_t ReconPixelsPerLine ) {
+static void Sub8 (unsigned char *FiltPtr, unsigned char *ReconPtr,
+                  ogg_int16_t *DctInputPtr, unsigned char *old_ptr1,
+                  unsigned char *new_ptr1, ogg_uint32_t PixelsPerLine,
+                  ogg_uint32_t ReconPixelsPerLine ) {
   int i;
-  
+
   /* For each block row */
   for ( i=0; i<BLOCK_HEIGHT_WIDTH; i++ ){
     DctInputPtr[0] = (ogg_int16_t)((int)(FiltPtr[0]) - ((int)ReconPtr[0]) );
@@ -35,11 +36,11 @@
     DctInputPtr[5] = (ogg_int16_t)((int)(FiltPtr[5]) - ((int)ReconPtr[5]) );
     DctInputPtr[6] = (ogg_int16_t)((int)(FiltPtr[6]) - ((int)ReconPtr[6]) );
     DctInputPtr[7] = (ogg_int16_t)((int)(FiltPtr[7]) - ((int)ReconPtr[7]) );
-        
+
     /* Update the screen canvas in one step*/
     ((ogg_uint32_t*)old_ptr1)[0] = ((ogg_uint32_t*)new_ptr1)[0];
     ((ogg_uint32_t*)old_ptr1)[1] = ((ogg_uint32_t*)new_ptr1)[1];
-    
+
     /* Start next row */
     new_ptr1 += PixelsPerLine;
     old_ptr1 += PixelsPerLine;
@@ -49,9 +50,9 @@
   }
 }
 
-static void Sub8_128 (unsigned char *FiltPtr, ogg_int16_t *DctInputPtr, 
-		      unsigned char *old_ptr1, unsigned char *new_ptr1, 
-		      ogg_uint32_t PixelsPerLine ) {
+static void Sub8_128 (unsigned char *FiltPtr, ogg_int16_t *DctInputPtr,
+                      unsigned char *old_ptr1, unsigned char *new_ptr1,
+                      ogg_uint32_t PixelsPerLine ) {
   int i;
   /* For each block row */
   for ( i=0; i<BLOCK_HEIGHT_WIDTH; i++ ){
@@ -67,11 +68,11 @@
     DctInputPtr[5] = (ogg_int16_t)((int)(FiltPtr[5]) - 128);
     DctInputPtr[6] = (ogg_int16_t)((int)(FiltPtr[6]) - 128);
     DctInputPtr[7] = (ogg_int16_t)((int)(FiltPtr[7]) - 128);
-    
+
     /* Update the screen canvas in one step */
     ((ogg_uint32_t*)old_ptr1)[0] = ((ogg_uint32_t*)new_ptr1)[0];
     ((ogg_uint32_t*)old_ptr1)[1] = ((ogg_uint32_t*)new_ptr1)[1];
-    
+
     /* Start next row */
     new_ptr1 += PixelsPerLine;
     old_ptr1 += PixelsPerLine;
@@ -80,13 +81,13 @@
   }
 }
 
-static void Sub8Av2 (unsigned char *FiltPtr, unsigned char *ReconPtr1, 
-		     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr, 
-		     unsigned char *old_ptr1, unsigned char *new_ptr1, 
-		     ogg_uint32_t PixelsPerLine, 
-		     ogg_uint32_t ReconPixelsPerLine ) {
+static void Sub8Av2 (unsigned char *FiltPtr, unsigned char *ReconPtr1,
+                     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
+                     unsigned char *old_ptr1, unsigned char *new_ptr1,
+                     ogg_uint32_t PixelsPerLine,
+                     ogg_uint32_t ReconPixelsPerLine ) {
   int i;
-  
+
   /* For each block row */
   for ( i=0; i<BLOCK_HEIGHT_WIDTH; i++ ) {
     DctInputPtr[0] = (ogg_int16_t)
@@ -105,11 +106,11 @@
       ((int)(FiltPtr[6]) - (((int)ReconPtr1[6] + (int)ReconPtr2[6]) / 2) );
     DctInputPtr[7] = (ogg_int16_t)
       ((int)(FiltPtr[7]) - (((int)ReconPtr1[7] + (int)ReconPtr2[7]) / 2) );
-    
+
     /* Update the screen canvas in one step */
     ((ogg_uint32_t*)old_ptr1)[0] = ((ogg_uint32_t*)new_ptr1)[0];
     ((ogg_uint32_t*)old_ptr1)[1] = ((ogg_uint32_t*)new_ptr1)[1];
-    
+
     /* Start next row */
     new_ptr1 += PixelsPerLine;
     old_ptr1 += PixelsPerLine;
@@ -120,30 +121,30 @@
   }
 }
 
-static unsigned char TokenizeDctValue (ogg_int16_t DataValue, 
-				       ogg_uint32_t * TokenListPtr ){
+static unsigned char TokenizeDctValue (ogg_int16_t DataValue,
+                                       ogg_uint32_t * TokenListPtr ){
   unsigned char tokens_added = 0;
   ogg_uint32_t AbsDataVal = abs( (ogg_int32_t)DataValue );
-  
+
   /* Values are tokenised as category value and a number of additional
      bits that define the position within the category.  */
-  
+
   if ( DataValue == 0 ) return 0;
-  
+
   if ( AbsDataVal == 1 ){
     if ( DataValue == 1 )
-      TokenListPtr[0] = ONE_TOKEN; 
+      TokenListPtr[0] = ONE_TOKEN;
     else
-      TokenListPtr[0] = MINUS_ONE_TOKEN; 
+      TokenListPtr[0] = MINUS_ONE_TOKEN;
     tokens_added = 1;
   } else if ( AbsDataVal == 2 ) {
     if ( DataValue == 2 )
-      TokenListPtr[0] = TWO_TOKEN; 
+      TokenListPtr[0] = TWO_TOKEN;
     else
-      TokenListPtr[0] = MINUS_TWO_TOKEN; 
+      TokenListPtr[0] = MINUS_TWO_TOKEN;
     tokens_added = 1;
-  } else if ( AbsDataVal <= MAX_SINGLE_TOKEN_VALUE ) {   
-    TokenListPtr[0] = LOW_VAL_TOKENS + (AbsDataVal - DCT_VAL_CAT2_MIN); 
+  } else if ( AbsDataVal <= MAX_SINGLE_TOKEN_VALUE ) {
+    TokenListPtr[0] = LOW_VAL_TOKENS + (AbsDataVal - DCT_VAL_CAT2_MIN);
     if ( DataValue > 0 )
       TokenListPtr[1] = 0;
     else
@@ -151,7 +152,7 @@
     tokens_added = 2;
   } else if ( AbsDataVal <= 8 ) {
     /* Bit 1 determines sign, Bit 0 the value */
-    TokenListPtr[0] = DCT_VAL_CATEGORY3; 
+    TokenListPtr[0] = DCT_VAL_CATEGORY3;
     if ( DataValue > 0 )
       TokenListPtr[1] = (AbsDataVal - DCT_VAL_CAT3_MIN);
     else
@@ -159,7 +160,7 @@
     tokens_added = 2;
   } else if ( AbsDataVal <= 12 ) {
     /* Bit 2 determines sign, Bit 0-2 the value */
-    TokenListPtr[0] = DCT_VAL_CATEGORY4; 
+    TokenListPtr[0] = DCT_VAL_CATEGORY4;
     if ( DataValue > 0 )
       TokenListPtr[1] = (AbsDataVal - DCT_VAL_CAT4_MIN);
     else
@@ -167,7 +168,7 @@
     tokens_added = 2;
   } else if ( AbsDataVal <= 20 ) {
     /* Bit 3 determines sign, Bit 0-2 the value */
-    TokenListPtr[0] = DCT_VAL_CATEGORY5;    
+    TokenListPtr[0] = DCT_VAL_CATEGORY5;
     if ( DataValue > 0 )
       TokenListPtr[1] = (AbsDataVal - DCT_VAL_CAT5_MIN);
     else
@@ -175,7 +176,7 @@
     tokens_added = 2;
   } else if ( AbsDataVal <= 36 ) {
     /* Bit 4 determines sign, Bit 0-3 the value */
-    TokenListPtr[0] = DCT_VAL_CATEGORY6;    
+    TokenListPtr[0] = DCT_VAL_CATEGORY6;
     if ( DataValue > 0 )
       TokenListPtr[1] = (AbsDataVal - DCT_VAL_CAT6_MIN);
     else
@@ -183,7 +184,7 @@
     tokens_added = 2;
   } else if ( AbsDataVal <= 68 ) {
     /* Bit 5 determines sign, Bit 0-4 the value */
-    TokenListPtr[0] = DCT_VAL_CATEGORY7;    
+    TokenListPtr[0] = DCT_VAL_CATEGORY7;
     if ( DataValue > 0 )
       TokenListPtr[1] = (AbsDataVal - DCT_VAL_CAT7_MIN);
     else
@@ -191,149 +192,149 @@
     tokens_added = 2;
   } else if ( AbsDataVal <= 511 ) {
     /* Bit 9 determines sign, Bit 0-8 the value */
-    TokenListPtr[0] = DCT_VAL_CATEGORY8;    
+    TokenListPtr[0] = DCT_VAL_CATEGORY8;
     if ( DataValue > 0 )
       TokenListPtr[1] = (AbsDataVal - DCT_VAL_CAT8_MIN);
     else
       TokenListPtr[1] = (0x200) + (AbsDataVal - DCT_VAL_CAT8_MIN);
     tokens_added = 2;
   } else {
-    TokenListPtr[0] = DCT_VAL_CATEGORY8;    
+    TokenListPtr[0] = DCT_VAL_CATEGORY8;
     if ( DataValue > 0 )
       TokenListPtr[1] = (511 - DCT_VAL_CAT8_MIN);
     else
       TokenListPtr[1] = (0x200) + (511 - DCT_VAL_CAT8_MIN);
     tokens_added = 2;
   }
-  
+
   /* Return the total number of tokens added */
   return tokens_added;
 }
 
-static unsigned char TokenizeDctRunValue (unsigned char RunLength, 
-					  ogg_int16_t DataValue, 
-					  ogg_uint32_t * TokenListPtr ){
+static unsigned char TokenizeDctRunValue (unsigned char RunLength,
+                                          ogg_int16_t DataValue,
+                                          ogg_uint32_t * TokenListPtr ){
   unsigned char tokens_added = 0;
   ogg_uint32_t AbsDataVal = abs( (ogg_int32_t)DataValue );
-  
+
   /* Values are tokenised as category value and a number of additional
      bits  that define the category.  */
   if ( DataValue == 0 ) return 0;
-  if ( AbsDataVal == 1 ) {   
+  if ( AbsDataVal == 1 ) {
     /* Zero runs of 1-5 */
     if ( RunLength <= 5 ) {
-      TokenListPtr[0] = DCT_RUN_CATEGORY1 + (RunLength - 1);  
+      TokenListPtr[0] = DCT_RUN_CATEGORY1 + (RunLength - 1);
       if ( DataValue > 0 )
-	TokenListPtr[1] = 0;
+        TokenListPtr[1] = 0;
       else
-	TokenListPtr[1] = 1;
+        TokenListPtr[1] = 1;
     } else if ( RunLength <= 9 ) {
       /* Zero runs of 6-9 */
-      TokenListPtr[0] = DCT_RUN_CATEGORY1B;  
+      TokenListPtr[0] = DCT_RUN_CATEGORY1B;
       if ( DataValue > 0 )
-	TokenListPtr[1] = (RunLength - 6);
+        TokenListPtr[1] = (RunLength - 6);
       else
-	TokenListPtr[1] = 0x04 + (RunLength - 6);
+        TokenListPtr[1] = 0x04 + (RunLength - 6);
     } else {
       /* Zero runs of 10-17 */
-      TokenListPtr[0] = DCT_RUN_CATEGORY1C;  
+      TokenListPtr[0] = DCT_RUN_CATEGORY1C;
       if ( DataValue > 0 )
-	TokenListPtr[1] = (RunLength - 10);
+        TokenListPtr[1] = (RunLength - 10);
       else
-	TokenListPtr[1] = 0x08 + (RunLength - 10);
+        TokenListPtr[1] = 0x08 + (RunLength - 10);
     }
     tokens_added = 2;
   } else if ( AbsDataVal <= 3 ) {
     if ( RunLength == 1 ) {
-      TokenListPtr[0] = DCT_RUN_CATEGORY2; 
-      
+      TokenListPtr[0] = DCT_RUN_CATEGORY2;
+
       /* Extra bits token bit 1 indicates sign, bit 0 indicates value */
       if ( DataValue > 0 )
-	TokenListPtr[1] = (AbsDataVal - 2);
+        TokenListPtr[1] = (AbsDataVal - 2);
       else
-	TokenListPtr[1] = (0x02) + (AbsDataVal - 2);
+        TokenListPtr[1] = (0x02) + (AbsDataVal - 2);
       tokens_added = 2;
     }else{
-      TokenListPtr[0] = DCT_RUN_CATEGORY2 + 1; 
-      
+      TokenListPtr[0] = DCT_RUN_CATEGORY2 + 1;
+
       /* Extra bits token. */
       /* bit 2 indicates sign, bit 1 indicates value, bit 0 indicates
          run length */
       if ( DataValue > 0 )
-	TokenListPtr[1] = ((AbsDataVal - 2) << 1) + (RunLength - 2);
+        TokenListPtr[1] = ((AbsDataVal - 2) << 1) + (RunLength - 2);
       else
-	TokenListPtr[1] = (0x04) + ((AbsDataVal - 2) << 1) + (RunLength - 2);
+        TokenListPtr[1] = (0x04) + ((AbsDataVal - 2) << 1) + (RunLength - 2);
       tokens_added = 2;
     }
   } else  {
     tokens_added = 2;  /* ERROR */
     /*IssueWarning( "Bad Input to TokenizeDctRunValue" );*/
   }
-  
+
   /* Return the total number of tokens added */
   return tokens_added;
 }
 
-static unsigned char TokenizeDctBlock (ogg_int16_t * RawData, 
-				       ogg_uint32_t * TokenListPtr ) {
-  ogg_uint32_t i;  
-  unsigned char  run_count;    
+static unsigned char TokenizeDctBlock (ogg_int16_t * RawData,
+                                       ogg_uint32_t * TokenListPtr ) {
+  ogg_uint32_t i;
+  unsigned char  run_count;
   unsigned char  token_count = 0;     /* Number of tokens crated. */
   ogg_uint32_t AbsData;
-  
-  
+
+
   /* Tokenize the block */
-  for( i = 0; i < BLOCK_SIZE; i++ ){   
-    run_count = 0;  
-    
+  for( i = 0; i < BLOCK_SIZE; i++ ){
+    run_count = 0;
+
     /* Look for a zero run.  */
     /* NOTE the use of & instead of && which is faster (and
        equivalent) in this instance. */
     /* NO, NO IT ISN'T --Monty */
     while( (i < BLOCK_SIZE) && (!RawData[i]) ){
-      run_count++; 
+      run_count++;
       i++;
     }
-    
+
     /* If we have reached the end of the block then code EOB */
     if ( i == BLOCK_SIZE ){
-      TokenListPtr[token_count] = DCT_EOB_TOKEN;    
+      TokenListPtr[token_count] = DCT_EOB_TOKEN;
       token_count++;
     }else{
       /* If we have a short zero run followed by a low data value code
          the two as a composite token. */
       if ( run_count ){
-	AbsData = abs(RawData[i]);
-	
-	if ( ((AbsData == 1) && (run_count <= 17)) || 
-	     ((AbsData <= 3) && (run_count <= 3)) ) {
-	  /* Tokenise the run and subsequent value combination value */
-	  token_count += TokenizeDctRunValue( run_count, 
-					      RawData[i], 
-					      &TokenListPtr[token_count] );
-	}else{
-
-	/* Else if we have a long non-EOB run or a run followed by a
-	   value token > MAX_RUN_VAL then code the run and token
-	   seperately */
-	  if ( run_count <= 8 )
-	    TokenListPtr[token_count] = DCT_SHORT_ZRL_TOKEN;
-	  else
-	    TokenListPtr[token_count] = DCT_ZRL_TOKEN;
-	  
-	  token_count++;
-	  TokenListPtr[token_count] = run_count - 1;    
-	  token_count++;
-	  
-	  /* Now tokenize the value */
-	  token_count += TokenizeDctValue( RawData[i], 
-					   &TokenListPtr[token_count] );
-	}
+        AbsData = abs(RawData[i]);
+
+        if ( ((AbsData == 1) && (run_count <= 17)) ||
+             ((AbsData <= 3) && (run_count <= 3)) ) {
+          /* Tokenise the run and subsequent value combination value */
+          token_count += TokenizeDctRunValue( run_count,
+                                              RawData[i],
+                                              &TokenListPtr[token_count] );
+        }else{
+
+        /* Else if we have a long non-EOB run or a run followed by a
+           value token > MAX_RUN_VAL then code the run and token
+           seperately */
+          if ( run_count <= 8 )
+            TokenListPtr[token_count] = DCT_SHORT_ZRL_TOKEN;
+          else
+            TokenListPtr[token_count] = DCT_ZRL_TOKEN;
+
+          token_count++;
+          TokenListPtr[token_count] = run_count - 1;
+          token_count++;
+
+          /* Now tokenize the value */
+          token_count += TokenizeDctValue( RawData[i],
+                                           &TokenListPtr[token_count] );
+        }
       }else{
-	/* Else there was NO zero run. */
-	/* Tokenise the value  */
-	token_count += TokenizeDctValue( RawData[i], 
-					 &TokenListPtr[token_count] );
+        /* Else there was NO zero run. */
+        /* Tokenise the value  */
+        token_count += TokenizeDctValue( RawData[i],
+                                         &TokenListPtr[token_count] );
       }
     }
   }
@@ -343,10 +344,10 @@
   return token_count;
 }
 
-ogg_uint32_t DPCMTokenizeBlock (CP_INSTANCE *cpi, 
-				ogg_int32_t FragIndex){
+ogg_uint32_t DPCMTokenizeBlock (CP_INSTANCE *cpi,
+                                ogg_int32_t FragIndex){
   ogg_uint32_t  token_count;
-  
+
   if ( GetFrameType(&cpi->pb) == BASE_FRAME ){
     /* Key frame so code block in INTRA mode. */
     cpi->pb.CodingMode = CODE_INTRA;
@@ -354,14 +355,14 @@
     /* Get Motion vector and mode for this block. */
     cpi->pb.CodingMode = cpi->pb.FragCodingMethod[FragIndex];
   }
-  
+
   /* Tokenise the dct data. */
-  token_count = TokenizeDctBlock( cpi->pb.QFragData[FragIndex], 
-				  cpi->pb.TokenList[FragIndex] );
-    
+  token_count = TokenizeDctBlock( cpi->pb.QFragData[FragIndex],
+                                  cpi->pb.TokenList[FragIndex] );
+
   cpi->FragTokenCounts[FragIndex] = token_count;
   cpi->TotTokenCount += token_count;
-  
+
   /* Return number of pixels coded (i.e. 8x8). */
   return BLOCK_SIZE;
 }
@@ -372,28 +373,28 @@
   for ( i = 0; i < 64; i ++ )
     if ( QuantList[i] != 0 )
       return 0;
-  
+
   return 1;
 }
 
-static void MotionBlockDifference (CP_INSTANCE * cpi, unsigned char * FiltPtr, 
-			    ogg_int16_t *DctInputPtr, ogg_int32_t MvDevisor, 
-			    unsigned char* old_ptr1, unsigned char* new_ptr1, 
-			    ogg_uint32_t FragIndex,ogg_uint32_t PixelsPerLine, 
-			    ogg_uint32_t ReconPixelsPerLine) {
-  
+static void MotionBlockDifference (CP_INSTANCE * cpi, unsigned char * FiltPtr,
+                            ogg_int16_t *DctInputPtr, ogg_int32_t MvDevisor,
+                            unsigned char* old_ptr1, unsigned char* new_ptr1,
+                            ogg_uint32_t FragIndex,ogg_uint32_t PixelsPerLine,
+                            ogg_uint32_t ReconPixelsPerLine) {
+
   ogg_int32_t MvShift;
-  ogg_int32_t MvModMask; 
+  ogg_int32_t MvModMask;
   ogg_int32_t  AbsRefOffset;
-  ogg_int32_t  AbsXOffset;             
+  ogg_int32_t  AbsXOffset;
   ogg_int32_t  AbsYOffset;
   ogg_int32_t  MVOffset;        /* Baseline motion vector offset */
   ogg_int32_t  ReconPtr2Offset; /* Offset for second reconstruction in
                                    half pixel MC */
   unsigned char  *ReconPtr1;    /* DCT reconstructed image pointers */
   unsigned char  *ReconPtr2;    /* Pointer used in half pixel MC */
-  
-  
+
+
   switch(MvDevisor) {
   case 2:
     MvShift = 1;
@@ -406,14 +407,14 @@
   default:
     break;
   }
-  
+
   cpi->MVector.x = cpi->pb.FragMVect[FragIndex].x;
   cpi->MVector.y = cpi->pb.FragMVect[FragIndex].y;
-  
+
   /* Set up the baseline offset for the motion vector. */
-  MVOffset = ((cpi->MVector.y / MvDevisor) * ReconPixelsPerLine) + 
+  MVOffset = ((cpi->MVector.y / MvDevisor) * ReconPixelsPerLine) +
     (cpi->MVector.x / MvDevisor);
-        
+
   /* Work out the offset of the second reference position for 1/2
      pixel interpolation.  For the U and V planes the MV specifies 1/4
      pixel accuracy. This is adjusted to 1/2 pixel as follows ( 0->0,
@@ -421,21 +422,21 @@
   ReconPtr2Offset = 0;
   AbsXOffset = cpi->MVector.x % MvDevisor;
   AbsYOffset = cpi->MVector.y % MvDevisor;
-  
+
   if ( AbsXOffset ) {
     if ( cpi->MVector.x > 0 )
       ReconPtr2Offset += 1;
-    else 
+    else
       ReconPtr2Offset -= 1;
   }
-  
+
   if ( AbsYOffset ) {
     if ( cpi->MVector.y > 0 )
       ReconPtr2Offset += ReconPixelsPerLine;
     else
       ReconPtr2Offset -= ReconPixelsPerLine;
   }
-  
+
   if ( cpi->pb.CodingMode==CODE_GOLDEN_MV ) {
     ReconPtr1 = &cpi->
       pb.GoldenFrame[cpi->pb.recon_pixel_index_table[FragIndex]];
@@ -443,41 +444,41 @@
     ReconPtr1 = &cpi->
       pb.LastFrameRecon[cpi->pb.recon_pixel_index_table[FragIndex]];
   }
-  
+
   ReconPtr1 += MVOffset;
   ReconPtr2 =  ReconPtr1 + ReconPtr2Offset;
-  
+
   AbsRefOffset = abs((int)(ReconPtr1 - ReconPtr2));
-  
+
   /* Is the MV offset exactly pixel alligned */
   if ( AbsRefOffset == 0 ){
-    Sub8( FiltPtr, ReconPtr1, DctInputPtr, old_ptr1, new_ptr1, 
-	       PixelsPerLine, ReconPixelsPerLine );
+    Sub8( FiltPtr, ReconPtr1, DctInputPtr, old_ptr1, new_ptr1,
+               PixelsPerLine, ReconPixelsPerLine );
   } else {
     /* Fractional pixel MVs. */
     /* Note that we only use two pixel values even for the diagonal */
-    Sub8Av2(FiltPtr, ReconPtr1,ReconPtr2,DctInputPtr, old_ptr1, 
-		 new_ptr1, PixelsPerLine, ReconPixelsPerLine );
+    Sub8Av2(FiltPtr, ReconPtr1,ReconPtr2,DctInputPtr, old_ptr1,
+                 new_ptr1, PixelsPerLine, ReconPixelsPerLine );
   }
 }
 
-void TransformQuantizeBlock (CP_INSTANCE *cpi, ogg_int32_t FragIndex, 
-			     ogg_uint32_t PixelsPerLine ) {
-  unsigned char	*new_ptr1;    /* Pointers into current frame */
-  unsigned char	*old_ptr1;    /* Pointers into old frame */
-  unsigned char	*FiltPtr;     /* Pointers to srf filtered pixels */
+void TransformQuantizeBlock (CP_INSTANCE *cpi, ogg_int32_t FragIndex,
+                             ogg_uint32_t PixelsPerLine ) {
+  unsigned char *new_ptr1;    /* Pointers into current frame */
+  unsigned char *old_ptr1;    /* Pointers into old frame */
+  unsigned char *FiltPtr;     /* Pointers to srf filtered pixels */
   ogg_int16_t   *DctInputPtr; /* Pointer into buffer containing input to DCT */
-  int LeftEdge;		      /* Flag if block at left edge of component */
+  int LeftEdge;               /* Flag if block at left edge of component */
   ogg_uint32_t  ReconPixelsPerLine; /* Line length for recon buffers. */
-  
+
   unsigned char   *ReconPtr1;   /* DCT reconstructed image pointers */
   ogg_int32_t   MvDevisor;      /* Defines MV resolution (2 = 1/2
                                    pixel for Y or 4 = 1/4 for UV) */
 
-  new_ptr1 = &cpi->yuv1ptr[cpi->pb.pixel_index_table[FragIndex]]; 
+  new_ptr1 = &cpi->yuv1ptr[cpi->pb.pixel_index_table[FragIndex]];
   old_ptr1 = &cpi->yuv0ptr[cpi->pb.pixel_index_table[FragIndex]];
-  DctInputPtr	= cpi->DCTDataBuffer;
-  
+  DctInputPtr   = cpi->DCTDataBuffer;
+
   /* Set plane specific values */
   if (FragIndex < (ogg_int32_t)cpi->pb.YPlaneFragments){
     ReconPixelsPerLine = cpi->pb.YStride;
@@ -509,36 +510,36 @@
       select_Inter_quantiser(&cpi->pb);
   }else{
     LeftEdge = !((FragIndex-cpi->pb.YPlaneFragments)%(cpi->pb.HFragments>>1));
-    
+
     /* Select the approrpriate UV quantiser matrix */
     if ( cpi->pb.CodingMode == CODE_INTRA )
       select_UV_quantiser(&cpi->pb);
     else
       select_Inter_quantiser(&cpi->pb);
   }
-  
+
   if ( ModeUsesMC[cpi->pb.CodingMode] ){
-    
+
     MotionBlockDifference(cpi, FiltPtr, DctInputPtr, MvDevisor,
-			  old_ptr1, new_ptr1, FragIndex, PixelsPerLine, 
-			  ReconPixelsPerLine);
-    
-  } else if ( (cpi->pb.CodingMode==CODE_INTER_NO_MV ) || 
-	      ( cpi->pb.CodingMode==CODE_USING_GOLDEN ) ) {
+                          old_ptr1, new_ptr1, FragIndex, PixelsPerLine,
+                          ReconPixelsPerLine);
+
+  } else if ( (cpi->pb.CodingMode==CODE_INTER_NO_MV ) ||
+              ( cpi->pb.CodingMode==CODE_USING_GOLDEN ) ) {
     if ( cpi->pb.CodingMode==CODE_INTER_NO_MV ) {
       ReconPtr1 = &cpi->
-	pb.LastFrameRecon[cpi->pb.recon_pixel_index_table[FragIndex]];
+        pb.LastFrameRecon[cpi->pb.recon_pixel_index_table[FragIndex]];
     } else {
       ReconPtr1 = &cpi->
-	pb.GoldenFrame[cpi->pb.recon_pixel_index_table[FragIndex]];
+        pb.GoldenFrame[cpi->pb.recon_pixel_index_table[FragIndex]];
     }
 
-    Sub8( FiltPtr, ReconPtr1, DctInputPtr, old_ptr1, new_ptr1, 
-	       PixelsPerLine, ReconPixelsPerLine );
+    Sub8( FiltPtr, ReconPtr1, DctInputPtr, old_ptr1, new_ptr1,
+               PixelsPerLine, ReconPixelsPerLine );
   } else if ( cpi->pb.CodingMode==CODE_INTRA ) {
     Sub8_128(FiltPtr, DctInputPtr, old_ptr1, new_ptr1, PixelsPerLine);
-    
-  } 
+
+  }
 
   /* Proceed to encode the data into the encode buffer if the encoder
      is enabled. */
@@ -546,9 +547,9 @@
   fdct_short( cpi->DCTDataBuffer, cpi->DCT_codes );
 
   /* Quantize that transform data. */
-  quantize ( &cpi->pb, cpi->DCT_codes, cpi->pb.QFragData[FragIndex] );   
+  quantize ( &cpi->pb, cpi->DCT_codes, cpi->pb.QFragData[FragIndex] );
 
-  if ( (cpi->pb.CodingMode == CODE_INTER_NO_MV) && 
+  if ( (cpi->pb.CodingMode == CODE_INTER_NO_MV) &&
        ( AllZeroDctData(cpi->pb.QFragData[FragIndex]) ) ) {
     cpi->pb.display_fragments[FragIndex] = 0;
   }

<p><p>1.5       +330 -330  theora/lib/decode.c

Index: decode.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/decode.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- decode.c	8 Jun 2003 00:08:38 -0000	1.4
+++ decode.c	10 Jun 2003 01:31:33 -0000	1.5
@@ -10,131 +10,132 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: decode.c,v 1.4 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: decode.c,v 1.5 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
+#include <string.h>
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 #include "block_inline.h"
 
-CODING_MODE  ModeAlphabet[MODE_METHODS-1][MAX_MODES] = {   
+CODING_MODE  ModeAlphabet[MODE_METHODS-1][MAX_MODES] = {
 
   /* Reserved for custom alphabet. */
   {    (CODING_MODE)0,        (CODING_MODE)0,
        (CODING_MODE)0,        (CODING_MODE)0,
        (CODING_MODE)0,        (CODING_MODE)0,
-       (CODING_MODE)0,        (CODING_MODE)0 },     
-    
+       (CODING_MODE)0,        (CODING_MODE)0 },
+
   /* Last motion vector dominates */
-  {    CODE_INTER_LAST_MV,    CODE_INTER_PRIOR_LAST,  
-       CODE_INTER_PLUS_MV,    CODE_INTER_NO_MV,     
+  {    CODE_INTER_LAST_MV,    CODE_INTER_PRIOR_LAST,
+       CODE_INTER_PLUS_MV,    CODE_INTER_NO_MV,
        CODE_INTRA,            CODE_USING_GOLDEN,
        CODE_GOLDEN_MV,        CODE_INTER_FOURMV },
-  
-  {    CODE_INTER_LAST_MV,    CODE_INTER_PRIOR_LAST,  
-       CODE_INTER_NO_MV,      CODE_INTER_PLUS_MV,     
+
+  {    CODE_INTER_LAST_MV,    CODE_INTER_PRIOR_LAST,
+       CODE_INTER_NO_MV,      CODE_INTER_PLUS_MV,
        CODE_INTRA,            CODE_USING_GOLDEN,
        CODE_GOLDEN_MV,        CODE_INTER_FOURMV },
-         
+
   {    CODE_INTER_LAST_MV,    CODE_INTER_PLUS_MV,
-       CODE_INTER_PRIOR_LAST, CODE_INTER_NO_MV,     
+       CODE_INTER_PRIOR_LAST, CODE_INTER_NO_MV,
        CODE_INTRA,            CODE_USING_GOLDEN,
        CODE_GOLDEN_MV,        CODE_INTER_FOURMV },
 
   {    CODE_INTER_LAST_MV,    CODE_INTER_PLUS_MV,
-       CODE_INTER_NO_MV,      CODE_INTER_PRIOR_LAST,     
+       CODE_INTER_NO_MV,      CODE_INTER_PRIOR_LAST,
        CODE_INTRA,            CODE_USING_GOLDEN,
        CODE_GOLDEN_MV,        CODE_INTER_FOURMV },
-  
+
   /* No motion vector dominates */
   {    CODE_INTER_NO_MV,      CODE_INTER_LAST_MV,
-       CODE_INTER_PRIOR_LAST, CODE_INTER_PLUS_MV,     
+       CODE_INTER_PRIOR_LAST, CODE_INTER_PLUS_MV,
        CODE_INTRA,            CODE_USING_GOLDEN,
        CODE_GOLDEN_MV,        CODE_INTER_FOURMV },
-    
+
   {    CODE_INTER_NO_MV,      CODE_USING_GOLDEN,
-       CODE_INTER_LAST_MV,    CODE_INTER_PRIOR_LAST,       
-       CODE_INTER_PLUS_MV,    CODE_INTRA, 
+       CODE_INTER_LAST_MV,    CODE_INTER_PRIOR_LAST,
+       CODE_INTER_PLUS_MV,    CODE_INTRA,
        CODE_GOLDEN_MV,        CODE_INTER_FOURMV },
-  
+
 };
 
 int GetFrameType(PB_INSTANCE *pbi){
-  return pbi->FrameType; 
+  return pbi->FrameType;
 }
 
 static int LoadFrameHeader(PB_INSTANCE *pbi){
   unsigned char  DctQMask;
   unsigned char  SpareBits;       /* Spare cfg bits */
-  
+
   /* Is the frame and inter frame or a key frame */
-  pbi->FrameType = oggpackB_read(&pbi->opb,1);
-    
+  pbi->FrameType = (unsigned char)oggpackB_read(&pbi->opb,1);
+
   /* Quality (Q) index */
-  DctQMask = oggpackB_read( &pbi->opb,   6 );
+  DctQMask = (unsigned char)oggpackB_read( &pbi->opb, 6 );
 
   /* If the frame was a base frame then read the frame dimensions and
      build a bitmap structure. */
   if ( (pbi->FrameType == BASE_FRAME) ){
     /* Read the type / coding method for the key frame. */
-    pbi->KeyFrameType = oggpackB_read( &pbi->opb,   1 );
-    
-    SpareBits = oggpackB_read( &pbi->opb,   2 );
-    
+    pbi->KeyFrameType = (unsigned char)oggpackB_read( &pbi->opb, 1 );
+
+    SpareBits = (unsigned char)oggpackB_read( &pbi->opb, 2 );
+
   }
-	
+
   /* Set this frame quality value from Q Index */
   pbi->ThisFrameQualityValue = pbi->QThreshTable[DctQMask];
-  
+
   return 1;
 }
 
-void SetFrameType( PB_INSTANCE *pbi,unsigned char FrType ){ 
+void SetFrameType( PB_INSTANCE *pbi,unsigned char FrType ){
   /* Set the appropriate frame type according to the request. */
-  switch ( FrType ){  
-    
+  switch ( FrType ){
+
   case BASE_FRAME:
     pbi->FrameType = FrType;
     break;
-    
+
   default:
     pbi->FrameType = FrType;
     break;
   }
 }
 
-static int LoadFrame(PB_INSTANCE *pbi){ 
-  
+static int LoadFrame(PB_INSTANCE *pbi){
+
   /* Load the frame header (including the frame size). */
   if ( LoadFrameHeader(pbi) ){
     /* Read in the updated block map */
     QuadDecodeDisplayFragments( pbi );
     return 1;
   }
-  
+
   return 0;
 }
 
-static void DecodeModes (PB_INSTANCE *pbi, 
-			 ogg_uint32_t SBRows, 
-			 ogg_uint32_t SBCols){
+static void DecodeModes (PB_INSTANCE *pbi,
+                         ogg_uint32_t SBRows,
+                         ogg_uint32_t SBCols){
   ogg_int32_t   FragIndex;
-  ogg_uint32_t  MB;       
-  ogg_uint32_t  SBrow;    
-  ogg_uint32_t  SBcol;    
-  ogg_uint32_t  SB=0;     
+  ogg_uint32_t  MB;
+  ogg_uint32_t  SBrow;
+  ogg_uint32_t  SBcol;
+  ogg_uint32_t  SB=0;
   CODING_MODE  CodingMethod;
 
   ogg_uint32_t  UVRow;
   ogg_uint32_t  UVColumn;
   ogg_uint32_t  UVFragOffset;
-  
-  ogg_uint32_t  CodingScheme; 
-    
+
+  ogg_uint32_t  CodingScheme;
+
   ogg_uint32_t  MBListIndex = 0;
-  
+
   ogg_uint32_t  i;
 
   /* If the frame is an intra frame then all blocks have mode intra. */
@@ -144,67 +145,67 @@
     }
   }else{
     ogg_uint32_t  ModeEntry; /* Mode bits read */
-    
+
     /* Read the coding method */
-    CodingScheme = oggpackB_read( &pbi->opb,  MODE_METHOD_BITS );  
+    CodingScheme = oggpackB_read( &pbi->opb,  MODE_METHOD_BITS );
 
     /* If the coding method is method 0 then we have to read in a
        custom coding scheme */
     if ( CodingScheme == 0 ){
       /* Read the coding scheme. */
       for ( i = 0; i < MAX_MODES; i++ ){
-	ModeAlphabet[0][ oggpackB_read( &pbi->opb,  MODE_BITS) ] = i;
+        ModeAlphabet[0][ oggpackB_read( &pbi->opb,  MODE_BITS) ] = i;
       }
     }
 
     /* Unravel the quad-tree */
     for ( SBrow=0; SBrow<SBRows; SBrow++ ){
       for ( SBcol=0; SBcol<SBCols; SBcol++ ){
-	for ( MB=0; MB<4; MB++ ){
-	  /* There may be MB's lying out of frame which must be
-	     ignored. For these MB's top left block will have a negative
-	     Fragment Index. */
-	  if ( QuadMapToMBTopLeft(pbi->BlockMap, SB,MB) >= 0){
-	    /* Is the Macro-Block coded: */
-	    if ( pbi->MBCodedFlags[MBListIndex++] ){
-	      /* Upack the block level modes and motion vectors */
-	      FragIndex = QuadMapToMBTopLeft( pbi->BlockMap, SB, MB );
-                        
-	      /* Unpack the mode. */
-	      if ( CodingScheme == (MODE_METHODS-1) ){
-		/* This is the fall back coding scheme. */
-		/* Simply MODE_BITS bits per mode entry. */
-		CodingMethod = (CODING_MODE)oggpackB_read( &pbi->opb,  
-							   MODE_BITS );
-	      }else{
-		ModeEntry = FrArrayUnpackMode(pbi);
-		CodingMethod =  ModeAlphabet[CodingScheme][ ModeEntry ];
-	      }
-	      
-	      /* Note the coding mode for each block in macro block. */
-	      pbi->FragCodingMethod[FragIndex] = CodingMethod;
-	      pbi->FragCodingMethod[FragIndex + 1] = CodingMethod;
-	      pbi->FragCodingMethod[FragIndex + pbi->HFragments] = 
-		CodingMethod;
-	      pbi->FragCodingMethod[FragIndex + pbi->HFragments + 1] = 
-		CodingMethod;
-	      
-	      /* Matching fragments in the U and V planes */
-	      UVRow = (FragIndex / (pbi->HFragments * 2));
-	      UVColumn = (FragIndex % pbi->HFragments) / 2;
-	      UVFragOffset = (UVRow * (pbi->HFragments / 2)) + UVColumn;
-	      pbi->FragCodingMethod[pbi->YPlaneFragments + UVFragOffset] = 
-		CodingMethod;
-	      pbi->FragCodingMethod[pbi->YPlaneFragments + 
-				   pbi->UVPlaneFragments + UVFragOffset] = 
-		CodingMethod;
-	      
-	    }
-	  }
-	}
-	
-	/* Next Super-Block */
-	SB++;
+        for ( MB=0; MB<4; MB++ ){
+          /* There may be MB's lying out of frame which must be
+             ignored. For these MB's top left block will have a negative
+             Fragment Index. */
+          if ( QuadMapToMBTopLeft(pbi->BlockMap, SB,MB) >= 0){
+            /* Is the Macro-Block coded: */
+            if ( pbi->MBCodedFlags[MBListIndex++] ){
+              /* Upack the block level modes and motion vectors */
+              FragIndex = QuadMapToMBTopLeft( pbi->BlockMap, SB, MB );
+
+              /* Unpack the mode. */
+              if ( CodingScheme == (MODE_METHODS-1) ){
+                /* This is the fall back coding scheme. */
+                /* Simply MODE_BITS bits per mode entry. */
+                CodingMethod = (CODING_MODE)oggpackB_read( &pbi->opb,
+                                                           MODE_BITS );
+              }else{
+                ModeEntry = FrArrayUnpackMode(pbi);
+                CodingMethod =  ModeAlphabet[CodingScheme][ ModeEntry ];
+              }
+
+              /* Note the coding mode for each block in macro block. */
+              pbi->FragCodingMethod[FragIndex] = CodingMethod;
+              pbi->FragCodingMethod[FragIndex + 1] = CodingMethod;
+              pbi->FragCodingMethod[FragIndex + pbi->HFragments] =
+                CodingMethod;
+              pbi->FragCodingMethod[FragIndex + pbi->HFragments + 1] =
+                CodingMethod;
+
+              /* Matching fragments in the U and V planes */
+              UVRow = (FragIndex / (pbi->HFragments * 2));
+              UVColumn = (FragIndex % pbi->HFragments) / 2;
+              UVFragOffset = (UVRow * (pbi->HFragments / 2)) + UVColumn;
+              pbi->FragCodingMethod[pbi->YPlaneFragments + UVFragOffset] =
+                CodingMethod;
+              pbi->FragCodingMethod[pbi->YPlaneFragments +
+                                   pbi->UVPlaneFragments + UVFragOffset] =
+                CodingMethod;
+
+            }
+          }
+        }
+
+        /* Next Super-Block */
+        SB++;
       }
     }
   }
@@ -214,9 +215,9 @@
   ogg_int32_t   MVectComponent;
   ogg_uint32_t  MVCode = 0;
   ogg_uint32_t  ExtraBits = 0;
-  
+
   /* Get group to which coded component belongs */
-  MVCode = oggpackB_read( &pbi->opb,  3 ); 
+  MVCode = oggpackB_read( &pbi->opb,  3 );
 
   /*  Now extract the appropriate number of bits to identify the component */
   switch ( MVCode ){
@@ -232,57 +233,57 @@
   case 3:
     if ( oggpackB_read( &pbi->opb, 1 ))
       MVectComponent = -2;
-    else 
+    else
       MVectComponent = 2;
     break;
   case 4:
     if ( oggpackB_read( &pbi->opb, 1 ) )
       MVectComponent = -3;
-    else 
+    else
       MVectComponent = 3;
     break;
   case 5:
-    ExtraBits = oggpackB_read( &pbi->opb,  2 ); 
+    ExtraBits = oggpackB_read( &pbi->opb,  2 );
     MVectComponent = 4 + ExtraBits;
     if ( oggpackB_read( &pbi->opb, 1 ) )
       MVectComponent = -MVectComponent;
     break;
   case 6:
-    ExtraBits = oggpackB_read( &pbi->opb,  3 ); 
+    ExtraBits = oggpackB_read( &pbi->opb,  3 );
     MVectComponent = 8 + ExtraBits;
     if ( oggpackB_read( &pbi->opb, 1 ))
       MVectComponent = -MVectComponent;
     break;
   case 7:
-    ExtraBits = oggpackB_read( &pbi->opb,  4 ); 
+    ExtraBits = oggpackB_read( &pbi->opb,  4 );
     MVectComponent = 16 + ExtraBits;
     if ( oggpackB_read( &pbi->opb, 1 ) )
       MVectComponent = -MVectComponent;
     break;
   }
-  
+
   return MVectComponent;
 }
 
 static ogg_int32_t ExtractMVectorComponentB(PB_INSTANCE *pbi){
-  ogg_int32_t   MVectComponent; 
+  ogg_int32_t   MVectComponent;
 
   /* Get group to which coded component belongs */
-  MVectComponent = oggpackB_read( &pbi->opb,  5 ); 
+  MVectComponent = oggpackB_read( &pbi->opb,  5 );
   if ( oggpackB_read( &pbi->opb, 1 ) )
     MVectComponent = -MVectComponent;
-  
+
   return MVectComponent;
 }
 
-static void DecodeMVectors ( PB_INSTANCE *pbi, 
-			     ogg_uint32_t SBRows, 
-			     ogg_uint32_t SBCols ){
+static void DecodeMVectors ( PB_INSTANCE *pbi,
+                             ogg_uint32_t SBRows,
+                             ogg_uint32_t SBCols ){
   ogg_int32_t   FragIndex;
-  ogg_uint32_t  MB;       
-  ogg_uint32_t  SBrow;    
-  ogg_uint32_t  SBcol;    
-  ogg_uint32_t  SB=0;     
+  ogg_uint32_t  MB;
+  ogg_uint32_t  SBrow;
+  ogg_uint32_t  SBcol;
+  ogg_uint32_t  SB=0;
   ogg_uint32_t  CodingMethod;
 
   MOTION_VECTOR MVect[6];
@@ -290,18 +291,18 @@
   MOTION_VECTOR LastInterMV;
   MOTION_VECTOR PriorLastInterMV;
   ogg_int32_t (*ExtractMVectorComponent)(PB_INSTANCE *pbi);
-  
+
   ogg_uint32_t  UVRow;
   ogg_uint32_t  UVColumn;
   ogg_uint32_t  UVFragOffset;
-  
+
   ogg_uint32_t  MBListIndex = 0;
-    
+
   /* Should not be decoding motion vectors if in INTRA only mode. */
   if ( GetFrameType(pbi) == BASE_FRAME ){
     return;
   }
-  
+
   /* set the default motion vector to 0,0 */
   MVect[0].x = 0;
   MVect[0].y = 0;
@@ -318,194 +319,194 @@
 
   /* Unravel the quad-tree */
   for ( SBrow=0; SBrow<SBRows; SBrow++ ){
-    
+
     for ( SBcol=0; SBcol<SBCols; SBcol++ ){
       for ( MB=0; MB<4; MB++ ){
-	/* There may be MB's lying out of frame which must be
-	   ignored. For these MB's the top left block will have a
-	   negative Fragment. */
-	if ( QuadMapToMBTopLeft(pbi->BlockMap, SB,MB) >= 0 ) {
-	  /* Is the Macro-Block further coded: */
-	  if ( pbi->MBCodedFlags[MBListIndex++] ){
-	    /* Upack the block level modes and motion vectors */
-	    FragIndex = QuadMapToMBTopLeft( pbi->BlockMap, SB, MB );
-	    
-	    /* Clear the motion vector before we start. */
-	    MVect[0].x = 0;
-	    MVect[0].y = 0;
-	    
-	    /* Unpack the mode (and motion vectors if necessary). */
-	    CodingMethod = pbi->FragCodingMethod[FragIndex];
-
-	    /* Read the motion vector or vectors if present. */
-	    if ( (CodingMethod == CODE_INTER_PLUS_MV) || 
-		 (CodingMethod == CODE_GOLDEN_MV) ){
-	      MVect[0].x = ExtractMVectorComponent(pbi); 
-	      MVect[1].x = MVect[0].x;
-	      MVect[2].x = MVect[0].x;
-	      MVect[3].x = MVect[0].x;
-	      MVect[4].x = MVect[0].x;
-	      MVect[5].x = MVect[0].x;
-	      MVect[0].y = ExtractMVectorComponent(pbi); 
-	      MVect[1].y = MVect[0].y;
-	      MVect[2].y = MVect[0].y;
-	      MVect[3].y = MVect[0].y;
-	      MVect[4].y = MVect[0].y;
-	      MVect[5].y = MVect[0].y;
-	    }else if ( CodingMethod == CODE_INTER_FOURMV ){
-	      /* Extrac the 4 Y MVs */
-	      MVect[0].x = ExtractMVectorComponent(pbi);
-	      MVect[0].y = ExtractMVectorComponent(pbi);
-	      
-	      MVect[1].x = ExtractMVectorComponent(pbi);
-	      MVect[1].y = ExtractMVectorComponent(pbi);
-	      
-	      MVect[2].x = ExtractMVectorComponent(pbi);
-	      MVect[2].y = ExtractMVectorComponent(pbi);
-	      
-	      MVect[3].x = ExtractMVectorComponent(pbi);
-	      MVect[3].y = ExtractMVectorComponent(pbi);
+        /* There may be MB's lying out of frame which must be
+           ignored. For these MB's the top left block will have a
+           negative Fragment. */
+        if ( QuadMapToMBTopLeft(pbi->BlockMap, SB,MB) >= 0 ) {
+          /* Is the Macro-Block further coded: */
+          if ( pbi->MBCodedFlags[MBListIndex++] ){
+            /* Upack the block level modes and motion vectors */
+            FragIndex = QuadMapToMBTopLeft( pbi->BlockMap, SB, MB );
+
+            /* Clear the motion vector before we start. */
+            MVect[0].x = 0;
+            MVect[0].y = 0;
+
+            /* Unpack the mode (and motion vectors if necessary). */
+            CodingMethod = pbi->FragCodingMethod[FragIndex];
+
+            /* Read the motion vector or vectors if present. */
+            if ( (CodingMethod == CODE_INTER_PLUS_MV) ||
+                 (CodingMethod == CODE_GOLDEN_MV) ){
+              MVect[0].x = ExtractMVectorComponent(pbi);
+              MVect[1].x = MVect[0].x;
+              MVect[2].x = MVect[0].x;
+              MVect[3].x = MVect[0].x;
+              MVect[4].x = MVect[0].x;
+              MVect[5].x = MVect[0].x;
+              MVect[0].y = ExtractMVectorComponent(pbi);
+              MVect[1].y = MVect[0].y;
+              MVect[2].y = MVect[0].y;
+              MVect[3].y = MVect[0].y;
+              MVect[4].y = MVect[0].y;
+              MVect[5].y = MVect[0].y;
+            }else if ( CodingMethod == CODE_INTER_FOURMV ){
+              /* Extrac the 4 Y MVs */
+              MVect[0].x = ExtractMVectorComponent(pbi);
+              MVect[0].y = ExtractMVectorComponent(pbi);
+
+              MVect[1].x = ExtractMVectorComponent(pbi);
+              MVect[1].y = ExtractMVectorComponent(pbi);
 
-	      /* Calculate the U and V plane MVs as the average of the
+              MVect[2].x = ExtractMVectorComponent(pbi);
+              MVect[2].y = ExtractMVectorComponent(pbi);
+
+              MVect[3].x = ExtractMVectorComponent(pbi);
+              MVect[3].y = ExtractMVectorComponent(pbi);
+
+              /* Calculate the U and V plane MVs as the average of the
                  Y plane MVs. */
-	      /* First .x component */
-	      MVect[4].x = MVect[0].x + MVect[1].x + MVect[2].x + MVect[3].x;
-	      if ( MVect[4].x >= 0 )
-		MVect[4].x = (MVect[4].x + 2) / 4;
-	      else
-		MVect[4].x = (MVect[4].x - 2) / 4;
-	      MVect[5].x = MVect[4].x;
-	      /* Then .y component */
-	      MVect[4].y = MVect[0].y + MVect[1].y + MVect[2].y + MVect[3].y;
-	      if ( MVect[4].y >= 0 )
-		MVect[4].y = (MVect[4].y + 2) / 4;
-	      else
-		MVect[4].y = (MVect[4].y - 2) / 4;
-	      MVect[5].y = MVect[4].y;
-	    }
-
-	    /* Keep track of last and prior last inter motion vectors. */
-	    if ( CodingMethod == CODE_INTER_PLUS_MV ){
-	      PriorLastInterMV.x = LastInterMV.x;
-	      PriorLastInterMV.y = LastInterMV.y;
-	      LastInterMV.x = MVect[0].x;
-	      LastInterMV.y = MVect[0].y;
-	    }else if ( CodingMethod == CODE_INTER_LAST_MV ){
-	      /* Use the last coded Inter motion vector. */
-	      MVect[0].x = LastInterMV.x;
-	      MVect[1].x = MVect[0].x;
-	      MVect[2].x = MVect[0].x;
-	      MVect[3].x = MVect[0].x;
-	      MVect[4].x = MVect[0].x;
-	      MVect[5].x = MVect[0].x;
-	      MVect[0].y = LastInterMV.y;
-	      MVect[1].y = MVect[0].y;
-	      MVect[2].y = MVect[0].y;
-	      MVect[3].y = MVect[0].y;
-	      MVect[4].y = MVect[0].y;
-	      MVect[5].y = MVect[0].y;
-	    }else if ( CodingMethod == CODE_INTER_PRIOR_LAST ){
-	      /* Use the last coded Inter motion vector. */
-	      MVect[0].x = PriorLastInterMV.x;
-	      MVect[1].x = MVect[0].x;
-	      MVect[2].x = MVect[0].x;
-	      MVect[3].x = MVect[0].x;
-	      MVect[4].x = MVect[0].x;
-	      MVect[5].x = MVect[0].x;
-	      MVect[0].y = PriorLastInterMV.y;
-	      MVect[1].y = MVect[0].y;
-	      MVect[2].y = MVect[0].y;
-	      MVect[3].y = MVect[0].y;
-	      MVect[4].y = MVect[0].y;
-	      MVect[5].y = MVect[0].y;
-	      
-	      /* Swap the prior and last MV cases over */
-	      TmpMVect.x = PriorLastInterMV.x;
-	      TmpMVect.y = PriorLastInterMV.y;
-	      PriorLastInterMV.x = LastInterMV.x;
-	      PriorLastInterMV.y = LastInterMV.y;
-	      LastInterMV.x = TmpMVect.x;
-	      LastInterMV.y = TmpMVect.y;
-	    }else if ( CodingMethod == CODE_INTER_FOURMV ){
-	      /* Update last MV and prior last mv */
-	      PriorLastInterMV.x = LastInterMV.x;
-	      PriorLastInterMV.y = LastInterMV.y;
-	      LastInterMV.x = MVect[3].x;
-	      LastInterMV.y = MVect[3].y;
-	    }
-	    
-	    /* Note the coding mode and vector for each block in the
+              /* First .x component */
+              MVect[4].x = MVect[0].x + MVect[1].x + MVect[2].x + MVect[3].x;
+              if ( MVect[4].x >= 0 )
+                MVect[4].x = (MVect[4].x + 2) / 4;
+              else
+                MVect[4].x = (MVect[4].x - 2) / 4;
+              MVect[5].x = MVect[4].x;
+              /* Then .y component */
+              MVect[4].y = MVect[0].y + MVect[1].y + MVect[2].y + MVect[3].y;
+              if ( MVect[4].y >= 0 )
+                MVect[4].y = (MVect[4].y + 2) / 4;
+              else
+                MVect[4].y = (MVect[4].y - 2) / 4;
+              MVect[5].y = MVect[4].y;
+            }
+
+            /* Keep track of last and prior last inter motion vectors. */
+            if ( CodingMethod == CODE_INTER_PLUS_MV ){
+              PriorLastInterMV.x = LastInterMV.x;
+              PriorLastInterMV.y = LastInterMV.y;
+              LastInterMV.x = MVect[0].x;
+              LastInterMV.y = MVect[0].y;
+            }else if ( CodingMethod == CODE_INTER_LAST_MV ){
+              /* Use the last coded Inter motion vector. */
+              MVect[0].x = LastInterMV.x;
+              MVect[1].x = MVect[0].x;
+              MVect[2].x = MVect[0].x;
+              MVect[3].x = MVect[0].x;
+              MVect[4].x = MVect[0].x;
+              MVect[5].x = MVect[0].x;
+              MVect[0].y = LastInterMV.y;
+              MVect[1].y = MVect[0].y;
+              MVect[2].y = MVect[0].y;
+              MVect[3].y = MVect[0].y;
+              MVect[4].y = MVect[0].y;
+              MVect[5].y = MVect[0].y;
+            }else if ( CodingMethod == CODE_INTER_PRIOR_LAST ){
+              /* Use the last coded Inter motion vector. */
+              MVect[0].x = PriorLastInterMV.x;
+              MVect[1].x = MVect[0].x;
+              MVect[2].x = MVect[0].x;
+              MVect[3].x = MVect[0].x;
+              MVect[4].x = MVect[0].x;
+              MVect[5].x = MVect[0].x;
+              MVect[0].y = PriorLastInterMV.y;
+              MVect[1].y = MVect[0].y;
+              MVect[2].y = MVect[0].y;
+              MVect[3].y = MVect[0].y;
+              MVect[4].y = MVect[0].y;
+              MVect[5].y = MVect[0].y;
+
+              /* Swap the prior and last MV cases over */
+              TmpMVect.x = PriorLastInterMV.x;
+              TmpMVect.y = PriorLastInterMV.y;
+              PriorLastInterMV.x = LastInterMV.x;
+              PriorLastInterMV.y = LastInterMV.y;
+              LastInterMV.x = TmpMVect.x;
+              LastInterMV.y = TmpMVect.y;
+            }else if ( CodingMethod == CODE_INTER_FOURMV ){
+              /* Update last MV and prior last mv */
+              PriorLastInterMV.x = LastInterMV.x;
+              PriorLastInterMV.y = LastInterMV.y;
+              LastInterMV.x = MVect[3].x;
+              LastInterMV.y = MVect[3].y;
+            }
+
+            /* Note the coding mode and vector for each block in the
                current macro block. */
-	    pbi->FragMVect[FragIndex].x = MVect[0].x;
-	    pbi->FragMVect[FragIndex].y = MVect[0].y;
-	    
-	    pbi->FragMVect[FragIndex + 1].x = MVect[1].x;
-	    pbi->FragMVect[FragIndex + 1].y = MVect[1].y;
-	    
-	    pbi->FragMVect[FragIndex + pbi->HFragments].x = MVect[2].x;
-	    pbi->FragMVect[FragIndex + pbi->HFragments].y = MVect[2].y;
-	    
-	    pbi->FragMVect[FragIndex + pbi->HFragments + 1].x = MVect[3].x;
-	    pbi->FragMVect[FragIndex + pbi->HFragments + 1].y = MVect[3].y;
-
-	    /* Matching fragments in the U and V planes */
-	    UVRow = (FragIndex / (pbi->HFragments * 2));
-	    UVColumn = (FragIndex % pbi->HFragments) / 2;
-	    UVFragOffset = (UVRow * (pbi->HFragments / 2)) + UVColumn;
-	    
-	    pbi->FragMVect[pbi->YPlaneFragments + UVFragOffset].x = MVect[4].x;
-	    pbi->FragMVect[pbi->YPlaneFragments + UVFragOffset].y = MVect[4].y;
-
-	    pbi->FragMVect[pbi->YPlaneFragments + pbi->UVPlaneFragments + 
-			  UVFragOffset].x = MVect[5].x;
-	    pbi->FragMVect[pbi->YPlaneFragments + pbi->UVPlaneFragments + 
-			  UVFragOffset].y = MVect[5].y;
-	  }
-	}
+            pbi->FragMVect[FragIndex].x = MVect[0].x;
+            pbi->FragMVect[FragIndex].y = MVect[0].y;
+
+            pbi->FragMVect[FragIndex + 1].x = MVect[1].x;
+            pbi->FragMVect[FragIndex + 1].y = MVect[1].y;
+
+            pbi->FragMVect[FragIndex + pbi->HFragments].x = MVect[2].x;
+            pbi->FragMVect[FragIndex + pbi->HFragments].y = MVect[2].y;
+
+            pbi->FragMVect[FragIndex + pbi->HFragments + 1].x = MVect[3].x;
+            pbi->FragMVect[FragIndex + pbi->HFragments + 1].y = MVect[3].y;
+
+            /* Matching fragments in the U and V planes */
+            UVRow = (FragIndex / (pbi->HFragments * 2));
+            UVColumn = (FragIndex % pbi->HFragments) / 2;
+            UVFragOffset = (UVRow * (pbi->HFragments / 2)) + UVColumn;
+
+            pbi->FragMVect[pbi->YPlaneFragments + UVFragOffset].x = MVect[4].x;
+            pbi->FragMVect[pbi->YPlaneFragments + UVFragOffset].y = MVect[4].y;
+
+            pbi->FragMVect[pbi->YPlaneFragments + pbi->UVPlaneFragments +
+                          UVFragOffset].x = MVect[5].x;
+            pbi->FragMVect[pbi->YPlaneFragments + pbi->UVPlaneFragments +
+                          UVFragOffset].y = MVect[5].y;
+          }
+        }
       }
-      
+
       /* Next Super-Block */
       SB++;
     }
   }
 }
 
-static ogg_uint32_t ExtractToken(oggpack_buffer *opb, 
-				 HUFF_ENTRY * CurrentRoot){
+static ogg_uint32_t ExtractToken(oggpack_buffer *opb,
+                                 HUFF_ENTRY * CurrentRoot){
   ogg_uint32_t Token;
   /* Loop searches down through tree based upon bits read from the
      bitstream */
   /* until it hits a leaf at which point we have decoded a token */
   while ( CurrentRoot->Value < 0 ){
-    
+
     if ( oggpackB_read(opb,1) )
       CurrentRoot = CurrentRoot->OneChild;
     else
       CurrentRoot = CurrentRoot->ZeroChild;
-		     
+
   }
-  Token = CurrentRoot->Value; 
+  Token = CurrentRoot->Value;
   return Token;
 }
 
-static void UnpackAndExpandDcToken( PB_INSTANCE *pbi, 
-				    Q_LIST_ENTRY *ExpandedBlock, 
-				    unsigned char * CoeffIndex ){
+static void UnpackAndExpandDcToken( PB_INSTANCE *pbi,
+                                    Q_LIST_ENTRY *ExpandedBlock,
+                                    unsigned char * CoeffIndex ){
   ogg_int32_t           ExtraBits;
   ogg_uint32_t          Token;
-  
+
   Token = ExtractToken(&pbi->opb, pbi->HuffRoot_VP3x[pbi->DcHuffChoice]);
 
-  
+
   /* Now.. if we are using the DCT optimised coding system, extract any
-   *  assosciated additional bits token. 
+   *  assosciated additional bits token.
    */
   if ( pbi->ExtraBitLengths_VP3x[Token] > 0 ){
     /* Extract the appropriate number of extra bits. */
     ExtraBits = oggpackB_read(&pbi->opb, pbi->ExtraBitLengths_VP3x[Token]);
-    
+
   }
-  
+
   /* Take token dependant action */
   if ( Token >= DCT_SHORT_ZRL_TOKEN ) {
     /* "Value", "zero run" and "zero run value" tokens */
@@ -552,20 +553,20 @@
   }
 }
 
-static void UnpackAndExpandAcToken( PB_INSTANCE *pbi, 
-				    Q_LIST_ENTRY * ExpandedBlock, 
-				    unsigned char * CoeffIndex  ) {
+static void UnpackAndExpandAcToken( PB_INSTANCE *pbi,
+                                    Q_LIST_ENTRY * ExpandedBlock,
+                                    unsigned char * CoeffIndex  ) {
   ogg_int32_t           ExtraBits;
   ogg_uint32_t          Token;
-  
+
   Token = ExtractToken(&pbi->opb, pbi->HuffRoot_VP3x[pbi->ACHuffChoice]);
 
   /* Now.. if we are using the DCT optimised coding system, extract any
-   *  assosciated additional bits token. 
+   *  assosciated additional bits token.
    */
   if ( pbi->ExtraBitLengths_VP3x[Token] > 0 ){
     /* Extract the appropriate number of extra bits. */
-    ExtraBits = oggpackB_read(&pbi->opb,pbi->ExtraBitLengths_VP3x[Token]); 
+    ExtraBits = oggpackB_read(&pbi->opb,pbi->ExtraBitLengths_VP3x[Token]);
   }
 
   /* Take token dependant action */
@@ -619,16 +620,16 @@
   ogg_int32_t       FragIndex;
   ogg_int32_t *     CodedBlockListPtr;
   ogg_int32_t *     CodedBlockListEnd;
-  
+
   unsigned char     AcHuffIndex1;
   unsigned char     AcHuffIndex2;
   unsigned char     AcHuffChoice1;
   unsigned char     AcHuffChoice2;
-  
+
   unsigned char     DcHuffChoice1;
   unsigned char     DcHuffChoice2;
-  
-  
+
+
   /* Bail out immediately if a decode error has already been reported. */
   if ( pbi->DecoderErrorCode ) return;
 
@@ -636,17 +637,17 @@
      for each block. */
   memset(pbi->FragCoeffs, 0, pbi->UnitFragments);
   memset(pbi->FragCoefEOB, 0, pbi->UnitFragments);
-  
+
   /* Clear down the pbi->QFragData structure for all coded blocks. */
   ClearDownQFragData(pbi);
 
   /* Note the number of blocks to decode */
   pbi->BlocksToDecode = pbi->CodedBlockIndex;
-  
+
   /* Get the DC huffman table choice for Y and then UV */
   DcHuffChoice1 = oggpackB_read( &pbi->opb,  DC_HUFF_CHOICE_BITS ) + DC_HUFF_OFFSET;
   DcHuffChoice2 = oggpackB_read( &pbi->opb,  DC_HUFF_CHOICE_BITS ) + DC_HUFF_OFFSET;
-  
+
   /* UnPack DC coefficients / tokens */
   CodedBlockListPtr = pbi->CodedBlockList;
   CodedBlockListEnd = &pbi->CodedBlockList[pbi->CodedBlockIndex];
@@ -654,7 +655,7 @@
     /* Get the block data index */
     FragIndex = *CodedBlockListPtr;
     pbi->FragCoefEOB[FragIndex] = pbi->FragCoeffs[FragIndex];
-    
+
     /* Select the appropriate huffman table offset according to
        whether the token is fro am Y or UV block */
     if ( FragIndex < (ogg_int32_t)pbi->YPlaneFragments )
@@ -671,23 +672,23 @@
       pbi->BlocksToDecode --;
     }else{
       /* Else unpack a DC token */
-      UnpackAndExpandDcToken( pbi, 
-			      pbi->QFragData[FragIndex], 
-			      &pbi->FragCoeffs[FragIndex] );
+      UnpackAndExpandDcToken( pbi,
+                              pbi->QFragData[FragIndex],
+                              &pbi->FragCoeffs[FragIndex] );
     }
     CodedBlockListPtr++;
   }
-  
+
   /* Get the AC huffman table choice for Y and then for UV. */
   AcHuffIndex1 = oggpackB_read( &pbi->opb,  AC_HUFF_CHOICE_BITS ) + AC_HUFF_OFFSET;
   AcHuffIndex2 = oggpackB_read( &pbi->opb,  AC_HUFF_CHOICE_BITS ) + AC_HUFF_OFFSET;
-  
+
   /* Unpack Lower AC coefficients. */
   while ( EncodedCoeffs < 64 ) {
     /* Repeatedly scan through the list of blocks. */
     CodedBlockListPtr = pbi->CodedBlockList;
     CodedBlockListEnd = &pbi->CodedBlockList[pbi->CodedBlockIndex];
-    
+
     /* Huffman table selection based upon which AC coefficient we are on */
     if ( EncodedCoeffs <= AC_TABLE_2_THRESH ){
       AcHuffChoice1 = AcHuffIndex1;
@@ -706,42 +707,42 @@
     while( CodedBlockListPtr < CodedBlockListEnd ) {
       /* Get the linear index for the current fragment. */
       FragIndex = *CodedBlockListPtr;
-      
+
       /* Should we decode a token for this block on this pass. */
       if ( pbi->FragCoeffs[FragIndex] <= EncodedCoeffs ) {
-	pbi->FragCoefEOB[FragIndex] = pbi->FragCoeffs[FragIndex];
-	/* If we are in the middle of an EOB run */
-	if ( pbi->EOB_Run ) {
-	  /* Mark the current block as fully expanded and decrement
+        pbi->FragCoefEOB[FragIndex] = pbi->FragCoeffs[FragIndex];
+        /* If we are in the middle of an EOB run */
+        if ( pbi->EOB_Run ) {
+          /* Mark the current block as fully expanded and decrement
              EOB_RUN count */
-	  pbi->FragCoeffs[FragIndex] = BLOCK_SIZE;
-	  pbi->EOB_Run --;
-	  pbi->BlocksToDecode --;
-	}else{
-	  /* Else unpack an AC token */
-	  /* Work out which huffman table to use, then decode a token */
-	  if ( FragIndex < (ogg_int32_t)pbi->YPlaneFragments )
-	    pbi->ACHuffChoice = AcHuffChoice1;
-	  else
-	    pbi->ACHuffChoice = AcHuffChoice2;
-	  
-	  UnpackAndExpandAcToken( pbi, pbi->QFragData[FragIndex], 
-				  &pbi->FragCoeffs[FragIndex] );
-	}
+          pbi->FragCoeffs[FragIndex] = BLOCK_SIZE;
+          pbi->EOB_Run --;
+          pbi->BlocksToDecode --;
+        }else{
+          /* Else unpack an AC token */
+          /* Work out which huffman table to use, then decode a token */
+          if ( FragIndex < (ogg_int32_t)pbi->YPlaneFragments )
+            pbi->ACHuffChoice = AcHuffChoice1;
+          else
+            pbi->ACHuffChoice = AcHuffChoice2;
+
+          UnpackAndExpandAcToken( pbi, pbi->QFragData[FragIndex],
+                                  &pbi->FragCoeffs[FragIndex] );
+        }
       }
       CodedBlockListPtr++;
     }
-    
+
     /* Test for condition where there are no blocks left with any
        tokesn to decode */
     if ( !pbi->BlocksToDecode )
       break;
-    
+
     EncodedCoeffs ++;
   }
 }
 
-static void DecodeData(PB_INSTANCE *pbi){   
+static void DecodeData(PB_INSTANCE *pbi){
   ogg_uint32_t i;
 
   /* Bail out immediately if a decode error has already been reported. */
@@ -753,51 +754,50 @@
     pbi->FragMVect[i].x = 0;
     pbi->FragMVect[i].y = 0;
   }
-  
+
   /* Zero Decoder EOB run count */
   pbi->EOB_Run = 0;
-  
+
   /* Make a not of the number of coded blocks this frame */
   pbi->CodedBlocksThisFrame = pbi->CodedBlockIndex;
-  
+
   /* Decode the modes data */
   DecodeModes( pbi, pbi->YSBRows, pbi->YSBCols);
 
   /* Unpack and decode the motion vectors. */
   DecodeMVectors ( pbi, pbi->YSBRows, pbi->YSBCols);
-  
+
   /* Unpack and decode the actual video data. */
   UnPackVideo(pbi);
-  
+
   /* Reconstruct and display the frame */
   ReconRefFrames(pbi);
 
 }
 
 
-int LoadAndDecode(PB_INSTANCE *pbi){    
+int LoadAndDecode(PB_INSTANCE *pbi){
   int    LoadFrameOK;
-  
+
   /* Reset the DC predictors. */
   pbi->InvLastIntraDC = 0;
   pbi->InvLastInterDC = 0;
 
   /* Load the next frame. */
-  LoadFrameOK = LoadFrame(pbi); 
-            
+  LoadFrameOK = LoadFrame(pbi);
+
   if ( LoadFrameOK ){
     if ( (pbi->ThisFrameQualityValue != pbi->LastFrameQualityValue) ){
       /* Initialise DCT tables. */
-      UpdateQ( pbi, pbi->ThisFrameQualityValue );  
-      pbi->LastFrameQualityValue = pbi->ThisFrameQualityValue;    
-    }   
-        
-    
+      UpdateQ( pbi, pbi->ThisFrameQualityValue );
+      pbi->LastFrameQualityValue = pbi->ThisFrameQualityValue;
+    }
+
+
     /* Decode the data into the fragment buffer. */
-    DecodeData(pbi);                    
+    DecodeData(pbi);
     return(0);
   }
 
   return(OC_BADPACKET);
-}                          
-
+}

<p><p>1.10      +806 -797  theora/lib/encode.c

Index: encode.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/encode.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- encode.c	8 Jun 2003 00:08:38 -0000	1.9
+++ encode.c	10 Jun 2003 01:31:33 -0000	1.10
@@ -10,12 +10,14 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: encode.c,v 1.9 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: encode.c,v 1.10 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
-#include "ogg/ogg.h"
+#include <stdlib.h>
+#include <string.h>
+#include <ogg/ogg.h>
 #include "encoder_internal.h"
 #include "encoder_lookup.h"
 #include "block_inline.h"
@@ -26,19 +28,19 @@
 #define PL 1
 #define HIGHBITDUPPED(X) (((ogg_int16_t) X)  >> 15)
 
-static ogg_uint32_t QuadCodeComponent ( CP_INSTANCE *cpi, 
-				 ogg_uint32_t FirstSB, 
-				 ogg_uint32_t SBRows, 
-				 ogg_uint32_t SBCols, 
-				 ogg_uint32_t PixelsPerLine ){
-
-  ogg_int32_t	FragIndex;      /* Fragment number */
-  ogg_uint32_t	MB, B;	        /* Macro-Block, Block indices */
-  ogg_uint32_t	SBrow;          /* Super-Block row number */
-  ogg_uint32_t	SBcol;          /* Super-Block row number */
-  ogg_uint32_t	SB=FirstSB;     /* Super-Block index, initialised to first 
-			           of this component */
-  ogg_uint32_t	coded_pixels=0;	/* Number of pixels coded */
+static ogg_uint32_t QuadCodeComponent ( CP_INSTANCE *cpi,
+                                 ogg_uint32_t FirstSB,
+                                 ogg_uint32_t SBRows,
+                                 ogg_uint32_t SBCols,
+                                 ogg_uint32_t PixelsPerLine ){
+
+  ogg_int32_t   FragIndex;      /* Fragment number */
+  ogg_uint32_t  MB, B;          /* Macro-Block, Block indices */
+  ogg_uint32_t  SBrow;          /* Super-Block row number */
+  ogg_uint32_t  SBcol;          /* Super-Block row number */
+  ogg_uint32_t  SB=FirstSB;     /* Super-Block index, initialised to first
+                                   of this component */
+  ogg_uint32_t  coded_pixels=0; /* Number of pixels coded */
   int           MBCodedFlag;
 
   /* actually transform and quantize the image now that we've decided
@@ -49,52 +51,52 @@
     for ( SBcol=0; SBcol<SBCols; SBcol++ ) {
       /* Check its four Macro-Blocks  */
       for ( MB=0; MB<4; MB++ ) {
-                
-	if ( QuadMapToMBTopLeft(cpi->pb.BlockMap,SB,MB) >= 0 ) {
-                    
-	  MBCodedFlag = 0;
-	  
-	  /*  Now actually code the blocks */
-	  for ( B=0; B<4; B++ ) {
-	    FragIndex = QuadMapToIndex1( cpi->pb.BlockMap, SB, MB, B );
-                        
-	    /* Does Block lie in frame: */
-	    if ( FragIndex >= 0 ) {
-	      /* In Frame: Is it coded: */
-	      if ( cpi->pb.display_fragments[FragIndex] ) {
+
+        if ( QuadMapToMBTopLeft(cpi->pb.BlockMap,SB,MB) >= 0 ) {
+
+          MBCodedFlag = 0;
+
+          /*  Now actually code the blocks */
+          for ( B=0; B<4; B++ ) {
+            FragIndex = QuadMapToIndex1( cpi->pb.BlockMap, SB, MB, B );
+
+            /* Does Block lie in frame: */
+            if ( FragIndex >= 0 ) {
+              /* In Frame: Is it coded: */
+              if ( cpi->pb.display_fragments[FragIndex] ) {
 
                 /* transform and quantize block */
-		TransformQuantizeBlock( cpi, FragIndex, PixelsPerLine );
-		
+                TransformQuantizeBlock( cpi, FragIndex, PixelsPerLine );
+
                 /* Has the block got struck off (no MV and no data
-		   generated after DCT) If not then mark it and the
-		   assosciated MB as coded. */
-		if ( cpi->pb.display_fragments[FragIndex] ) {
-		  /* Create linear list of coded block indices */
-		  cpi->pb.CodedBlockList[cpi->pb.CodedBlockIndex] = FragIndex;
-		  cpi->pb.CodedBlockIndex++;
-                                    
-		  /* MB is still coded */
-		  MBCodedFlag = 1;
-		  cpi->MBCodingMode = cpi->pb.FragCodingMethod[FragIndex];
-		  
-		}
-	      }
-	    }				
-	  }
-	  /* If the MB is marked as coded and we are in the Y plane then */
-	  // the mode list needs to be updated.
-	  if ( MBCodedFlag && (FirstSB == 0) ){
-	    /* Make a note of the selected mode in the mode list */
-	    cpi->ModeList[cpi->ModeListCount] = cpi->MBCodingMode;
-	    cpi->ModeListCount++;
-	  } 
-	}
+                   generated after DCT) If not then mark it and the
+                   assosciated MB as coded. */
+                if ( cpi->pb.display_fragments[FragIndex] ) {
+                  /* Create linear list of coded block indices */
+                  cpi->pb.CodedBlockList[cpi->pb.CodedBlockIndex] = FragIndex;
+                  cpi->pb.CodedBlockIndex++;
+
+                  /* MB is still coded */
+                  MBCodedFlag = 1;
+                  cpi->MBCodingMode = cpi->pb.FragCodingMethod[FragIndex];
+
+                }
+              }
+            }
+          }
+          /* If the MB is marked as coded and we are in the Y plane then */
+          /* the mode list needs to be updated. */
+          if ( MBCodedFlag && (FirstSB == 0) ){
+            /* Make a note of the selected mode in the mode list */
+            cpi->ModeList[cpi->ModeListCount] = cpi->MBCodingMode;
+            cpi->ModeListCount++;
+          }
+        }
       }
 
       SB++;
 
-    } 
+    }
   }
 
   /* Return number of pixels coded */
@@ -106,11 +108,11 @@
   ogg_uint32_t  Token;
   ogg_uint32_t  ExtraBitsToken;
   ogg_uint32_t  HuffIndex;
-  
+
   ogg_uint32_t  BestDcBits;
   ogg_uint32_t  DcHuffChoice[2];
   ogg_uint32_t  EntropyTableBits[2][DC_HUFF_CHOICES];
-  
+
   oggpack_buffer *opb=&cpi->oggbuffer;
 
   /* Clear table data structure */
@@ -121,11 +123,11 @@
     /* Count number of bits for each table option */
     Token = (ogg_uint32_t)cpi->OptimisedTokenList[i];
     for ( j = 0; j < DC_HUFF_CHOICES; j++ ){
-      EntropyTableBits[cpi->OptimisedTokenListPl[i]][j] += 
-	cpi->pb.HuffCodeLengthArray_VP3x[DC_HUFF_OFFSET + j][Token];
+      EntropyTableBits[cpi->OptimisedTokenListPl[i]][j] +=
+        cpi->pb.HuffCodeLengthArray_VP3x[DC_HUFF_OFFSET + j][Token];
     }
   }
-  
+
   /* Work out which table option is best for Y */
   BestDcBits = EntropyTableBits[0][0];
   DcHuffChoice[0] = 0;
@@ -138,7 +140,7 @@
 
   /* Add the DC huffman table choice to the bitstream */
   oggpackB_write( opb, DcHuffChoice[0], DC_HUFF_CHOICE_BITS );
-  
+
   /* Work out which table option is best for UV */
   BestDcBits = EntropyTableBits[1][0];
   DcHuffChoice[1] = 0;
@@ -148,7 +150,7 @@
       DcHuffChoice[1] = j;
     }
   }
-  
+
   /* Add the DC huffman table choice to the bitstream */
   oggpackB_write( opb, DcHuffChoice[1], DC_HUFF_CHOICE_BITS );
 
@@ -158,28 +160,28 @@
     /* Get the token and extra bits */
     Token = (ogg_uint32_t)cpi->OptimisedTokenList[i];
     ExtraBitsToken = (ogg_uint32_t)cpi->OptimisedTokenListEb[i];
-    
+
     /* Select the huffman table */
     if ( cpi->OptimisedTokenListPl[i] == 0)
       HuffIndex = (ogg_uint32_t)DC_HUFF_OFFSET + (ogg_uint32_t)DcHuffChoice[0];
     else
       HuffIndex = (ogg_uint32_t)DC_HUFF_OFFSET + (ogg_uint32_t)DcHuffChoice[1];
-    
+
     /* Add the bits to the encode holding buffer. */
     cpi->FrameBitCount += cpi->pb.HuffCodeLengthArray_VP3x[HuffIndex][Token];
-    oggpackB_write( opb, cpi->pb.HuffCodeArray_VP3x[HuffIndex][Token], 
-		     (ogg_uint32_t)cpi->
-		     pb.HuffCodeLengthArray_VP3x[HuffIndex][Token] );
+    oggpackB_write( opb, cpi->pb.HuffCodeArray_VP3x[HuffIndex][Token],
+                     (ogg_uint32_t)cpi->
+                     pb.HuffCodeLengthArray_VP3x[HuffIndex][Token] );
 
     /* If the token is followed by an extra bits token then code it */
     if ( cpi->pb.ExtraBitLengths_VP3x[Token] > 0 ) {
       /* Add the bits to the encode holding buffer.  */
       cpi->FrameBitCount += cpi->pb.ExtraBitLengths_VP3x[Token];
-      oggpackB_write( opb, ExtraBitsToken, 
-		       (ogg_uint32_t)cpi->pb.ExtraBitLengths_VP3x[Token] );
+      oggpackB_write( opb, ExtraBitsToken,
+                       (ogg_uint32_t)cpi->pb.ExtraBitLengths_VP3x[Token] );
     }
   }
-  
+
   /* Reset the count of second order optimised tokens */
   cpi->OptimisedTokenCount = 0;
 }
@@ -189,7 +191,7 @@
   ogg_uint32_t  Token;
   ogg_uint32_t  ExtraBitsToken;
   ogg_uint32_t  HuffIndex;
-  
+
   ogg_uint32_t  BestAcBits;
   ogg_uint32_t  AcHuffChoice[2];
   ogg_uint32_t  EntropyTableBits[2][AC_HUFF_CHOICES];
@@ -197,15 +199,15 @@
   oggpack_buffer *opb=&cpi->oggbuffer;
 
   memset ( EntropyTableBits, 0, sizeof(ogg_uint32_t)*AC_HUFF_CHOICES*2 );
-  
+
   /* Analyse token list to see which is the best entropy table to use */
   for ( i = 0; i < cpi->OptimisedTokenCount; i++ ) {
     /* Count number of bits for each table option */
     Token = (ogg_uint32_t)cpi->OptimisedTokenList[i];
     HuffIndex = cpi->OptimisedTokenListHi[i];
     for ( j = 0; j < AC_HUFF_CHOICES; j++ ) {
-      EntropyTableBits[cpi->OptimisedTokenListPl[i]][j] += 
-	cpi->pb.HuffCodeLengthArray_VP3x[HuffIndex + j][Token];
+      EntropyTableBits[cpi->OptimisedTokenListPl[i]][j] +=
+        cpi->pb.HuffCodeLengthArray_VP3x[HuffIndex + j][Token];
     }
   }
 
@@ -221,7 +223,7 @@
 
   /* Add the AC-Y huffman table choice to the bitstream */
   oggpackB_write( opb, AcHuffChoice[0], AC_HUFF_CHOICE_BITS );
-  
+
   /* Select the best set of AC tables for UV */
   BestAcBits = EntropyTableBits[1][0];
   AcHuffChoice[1] = 0;
@@ -231,48 +233,49 @@
       AcHuffChoice[1] = j;
     }
   }
-  
+
   /* Add the AC-UV huffman table choice to the bitstream */
   oggpackB_write( opb, AcHuffChoice[1], AC_HUFF_CHOICE_BITS );
-  
+
   /* Encode the token list */
   for ( i = 0; i < cpi->OptimisedTokenCount; i++ ) {
     /* Get the token and extra bits */
     Token = (ogg_uint32_t)cpi->OptimisedTokenList[i];
     ExtraBitsToken = (ogg_uint32_t)cpi->OptimisedTokenListEb[i];
-    
+
     /* Select the huffman table */
-    HuffIndex = (ogg_uint32_t)cpi->OptimisedTokenListHi[i] + 
+    HuffIndex = (ogg_uint32_t)cpi->OptimisedTokenListHi[i] +
       AcHuffChoice[cpi->OptimisedTokenListPl[i]];
 
     /* Add the bits to the encode holding buffer. */
     cpi->FrameBitCount += cpi->pb.HuffCodeLengthArray_VP3x[HuffIndex][Token];
-    oggpackB_write( opb, cpi->pb.HuffCodeArray_VP3x[HuffIndex][Token], 
-		     (ogg_uint32_t)cpi->
-		     pb.HuffCodeLengthArray_VP3x[HuffIndex][Token] );
+    oggpackB_write( opb, cpi->pb.HuffCodeArray_VP3x[HuffIndex][Token],
+                     (ogg_uint32_t)cpi->
+                     pb.HuffCodeLengthArray_VP3x[HuffIndex][Token] );
 
     /* If the token is followed by an extra bits token then code it */
     if ( cpi->pb.ExtraBitLengths_VP3x[Token] > 0 ) {
       /* Add the bits to the encode holding buffer. */
       cpi->FrameBitCount += cpi->pb.ExtraBitLengths_VP3x[Token];
-      oggpackB_write( opb, ExtraBitsToken, 
-		       (ogg_uint32_t)cpi->pb.ExtraBitLengths_VP3x[Token] );
+      oggpackB_write( opb, ExtraBitsToken,
+                       (ogg_uint32_t)cpi->pb.ExtraBitLengths_VP3x[Token] );
     }
   }
-  
+
   /* Reset the count of second order optimised tokens */
   cpi->OptimisedTokenCount = 0;
 }
 
 static void PackModes (CP_INSTANCE *cpi) {
   ogg_uint32_t  i,j;
-  unsigned char   ModeIndex;
-  
+  unsigned char ModeIndex;
+
+  unsigned char BestModeSchemes[MAX_MODES];
   ogg_int32_t   ModeCount[MAX_MODES];
   ogg_int32_t   TmpFreq;
   ogg_int32_t   TmpIndex;
-  
-  unsigned char   BestScheme;
+
+  ogg_uint32_t  BestScheme;
   ogg_uint32_t  BestSchemeScore;
   ogg_uint32_t  SchemeScore;
 
@@ -280,7 +283,7 @@
 
   /* Build a frequency map for the modes in this frame */
   memset( ModeCount, 0, MAX_MODES*sizeof(ogg_int32_t) );
-  for ( i = 0; i < cpi->ModeListCount; i++ ) 
+  for ( i = 0; i < cpi->ModeListCount; i++ )
     ModeCount[cpi->ModeList[i]] ++;
 
   /* Order the modes from most to least frequent.  Store result as
@@ -291,12 +294,12 @@
     for ( i = 0; i < MAX_MODES; i++ ) {
       /* Is this the best scheme so far ??? */
       if ( ModeCount[i] > TmpFreq ) {
-	TmpFreq = ModeCount[i];
-	TmpIndex = i;
+        TmpFreq = ModeCount[i];
+        TmpIndex = i;
       }
     }
     ModeCount[TmpIndex] = -1;
-    ModeSchemes[0][TmpIndex] = j;
+    BestModeSchemes[TmpIndex] = (unsigned char)j;
   }
 
   /* Default/ fallback scheme uses MODE_BITS bits per mode entry */
@@ -304,16 +307,21 @@
   BestSchemeScore = cpi->ModeListCount * 3;
   /* Get a bit score for the available schemes. */
   for (  j = 0; j < (MODE_METHODS - 1); j++ ) {
+    unsigned char *SchemeList;
+
     /* Reset the scheme score */
-    if ( j == 0 )
-      SchemeScore = 24; /* Scheme 0 additional cost of sending
-                           frequency order */
-    else
+    if ( j == 0 ){
+      /* Scheme 0 additional cost of sending frequency order */
+      SchemeScore = 24;
+      SchemeList = BestModeSchemes;
+    } else {
       SchemeScore = 0;
-    
+      SchemeList = ModeSchemes[j-1];
+    }
+
     /* Find the total bits to code using each avaialable scheme */
-    for ( i = 0; i < cpi->ModeListCount; i++ ) 
-      SchemeScore += ModeBitLengths[ModeSchemes[j][cpi->ModeList[i]]];
+    for ( i = 0; i < cpi->ModeListCount; i++ )
+      SchemeScore += ModeBitLengths[SchemeList[cpi->ModeList[i]]];
 
     /* Is this the best scheme so far ??? */
     if ( SchemeScore < BestSchemeScore ) {
@@ -330,7 +338,7 @@
   if ( BestScheme == 0 ) {
     for ( j = 0; j < MAX_MODES; j++ )
       /* Note that the last two entries are implicit */
-      oggpackB_write( opb, ModeSchemes[0][j], (ogg_uint32_t)MODE_BITS );
+      oggpackB_write( opb, BestModeSchemes[j], (ogg_uint32_t)MODE_BITS );
   }
 
   /* Are we using one of the alphabet based schemes or the fallback scheme */
@@ -338,9 +346,9 @@
     /* Pack and encode the Mode list */
     for ( i = 0; i < cpi->ModeListCount; i++ ) {
       /* Add the appropriate mode entropy token. */
-      ModeIndex = ModeSchemes[BestScheme][cpi->ModeList[i]];
-      oggpackB_write( opb, ModeBitPatterns[ModeIndex], 
-		       (ogg_uint32_t)ModeBitLengths[ModeIndex] );
+      ModeIndex = ModeSchemes[BestScheme-1][cpi->ModeList[i]];
+      oggpackB_write( opb, ModeBitPatterns[ModeIndex],
+                       (ogg_uint32_t)ModeBitLengths[ModeIndex] );
     }
   }else{
     /* Fall back to MODE_BITS per entry */
@@ -353,16 +361,16 @@
 
 static void PackMotionVectors (CP_INSTANCE *cpi) {
   ogg_int32_t  i;
-  ogg_uint32_t MethodBits[2] = {0,0};  
+  ogg_uint32_t MethodBits[2] = {0,0};
   ogg_uint32_t * MvBitsPtr;
-  ogg_uint32_t * MvPatternPtr;  
+  ogg_uint32_t * MvPatternPtr;
 
   oggpack_buffer *opb=&cpi->oggbuffer;
 
   /* Choose the coding method */
   MvBitsPtr = &MvBits[MAX_MV_EXTENT];
   for ( i = 0; i < (ogg_int32_t)cpi->MvListCount; i++ ) {
-    MethodBits[0] += MvBitsPtr[cpi->MVList[i].x]; 
+    MethodBits[0] += MvBitsPtr[cpi->MVList[i].x];
     MethodBits[0] += MvBitsPtr[cpi->MVList[i].y];
     MethodBits[1] += 12; /* Simple six bits per mv component fallback
                              mechanism */
@@ -381,10 +389,10 @@
 
   /* Pack and encode the motion vectors */
   for ( i = 0; i < (ogg_int32_t)cpi->MvListCount; i++ ) {
-    oggpackB_write( opb, MvPatternPtr[cpi->MVList[i].x], 
-		     (ogg_uint32_t)MvBitsPtr[cpi->MVList[i].x] );
-    oggpackB_write( opb, MvPatternPtr[cpi->MVList[i].y], 
-		     (ogg_uint32_t)MvBitsPtr[cpi->MVList[i].y] );
+    oggpackB_write( opb, MvPatternPtr[cpi->MVList[i].x],
+                     (ogg_uint32_t)MvBitsPtr[cpi->MVList[i].x] );
+    oggpackB_write( opb, MvPatternPtr[cpi->MVList[i].y],
+                     (ogg_uint32_t)MvBitsPtr[cpi->MVList[i].y] );
   }
 }
 
@@ -397,13 +405,13 @@
      the first token in the run */
 
   /* Mark out which plane the block belonged to */
-  cpi->OptimisedTokenListPl[cpi->OptimisedTokenCount] = 
-    cpi->RunPlaneIndex;
-    
+  cpi->OptimisedTokenListPl[cpi->OptimisedTokenCount] =
+    (unsigned char)cpi->RunPlaneIndex;
+
   /* Note the huffman index to be used */
-  cpi->OptimisedTokenListHi[cpi->OptimisedTokenCount] = 
-    cpi->RunHuffIndex;
-    
+  cpi->OptimisedTokenListHi[cpi->OptimisedTokenCount] =
+    (unsigned char)cpi->RunHuffIndex;
+
   if ( cpi->RunLength <= 3 ) {
     if ( cpi->RunLength == 1 ) {
       cpi->OptimisedTokenList[cpi->OptimisedTokenCount] = DCT_EOB_TOKEN;
@@ -412,50 +420,50 @@
     } else {
       cpi->OptimisedTokenList[cpi->OptimisedTokenCount] = DCT_EOB_TRIPLE_TOKEN;
     }
-    
+
     cpi->RunLength = 0;
 
   } else {
 
     /* Choose a token appropriate to the run length. */
     if ( cpi->RunLength < 8 ) {
-      cpi->OptimisedTokenList[cpi->OptimisedTokenCount] = 
-	DCT_REPEAT_RUN_TOKEN;
-      cpi->OptimisedTokenListEb[cpi->OptimisedTokenCount] = 
-	cpi->RunLength - 4;
+      cpi->OptimisedTokenList[cpi->OptimisedTokenCount] =
+        DCT_REPEAT_RUN_TOKEN;
+      cpi->OptimisedTokenListEb[cpi->OptimisedTokenCount] =
+        cpi->RunLength - 4;
       cpi->RunLength = 0;
     } else if ( cpi->RunLength < 16 ) {
-      cpi->OptimisedTokenList[cpi->OptimisedTokenCount] = 
-	DCT_REPEAT_RUN2_TOKEN;
-      cpi->OptimisedTokenListEb[cpi->OptimisedTokenCount] = 
-	cpi->RunLength - 8;
+      cpi->OptimisedTokenList[cpi->OptimisedTokenCount] =
+        DCT_REPEAT_RUN2_TOKEN;
+      cpi->OptimisedTokenListEb[cpi->OptimisedTokenCount] =
+        cpi->RunLength - 8;
       cpi->RunLength = 0;
     } else if ( cpi->RunLength < 32 ) {
-      cpi->OptimisedTokenList[cpi->OptimisedTokenCount] = 
-	DCT_REPEAT_RUN3_TOKEN;
-      cpi->OptimisedTokenListEb[cpi->OptimisedTokenCount] = 
-	cpi->RunLength - 16;
+      cpi->OptimisedTokenList[cpi->OptimisedTokenCount] =
+        DCT_REPEAT_RUN3_TOKEN;
+      cpi->OptimisedTokenListEb[cpi->OptimisedTokenCount] =
+        cpi->RunLength - 16;
       cpi->RunLength = 0;
     } else if ( cpi->RunLength < 4096) {
-      cpi->OptimisedTokenList[cpi->OptimisedTokenCount] = 
-	DCT_REPEAT_RUN4_TOKEN;
-      cpi->OptimisedTokenListEb[cpi->OptimisedTokenCount] = 
-	cpi->RunLength;
+      cpi->OptimisedTokenList[cpi->OptimisedTokenCount] =
+        DCT_REPEAT_RUN4_TOKEN;
+      cpi->OptimisedTokenListEb[cpi->OptimisedTokenCount] =
+        cpi->RunLength;
       cpi->RunLength = 0;
-    } 
-    
+    }
+
   }
-  
+
   cpi->OptimisedTokenCount++;
   /* Reset run EOB length */
   cpi->RunLength = 0;
 }
 
-static void PackToken ( CP_INSTANCE *cpi, ogg_int32_t FragmentNumber, 
-		 ogg_uint32_t HuffIndex ) {
-  ogg_uint32_t Token = 
+static void PackToken ( CP_INSTANCE *cpi, ogg_int32_t FragmentNumber,
+                 ogg_uint32_t HuffIndex ) {
+  ogg_uint32_t Token =
     cpi->pb.TokenList[FragmentNumber][cpi->FragTokens[FragmentNumber]];
-  ogg_uint32_t ExtraBitsToken = 
+  ogg_uint32_t ExtraBitsToken =
     cpi->pb.TokenList[FragmentNumber][cpi->FragTokens[FragmentNumber] + 1];
   ogg_uint32_t OneOrTwo;
   ogg_uint32_t OneOrZero;
@@ -466,65 +474,66 @@
   if ( Token == DCT_EOB_TOKEN )
     cpi->pb.FragCoeffs[FragmentNumber] = BLOCK_SIZE;
   else
-    ExpandToken( cpi->pb.QFragData[FragmentNumber], 
-		 &cpi->pb.FragCoeffs[FragmentNumber], 
-		 Token, ExtraBitsToken );
-  
+    ExpandToken( cpi->pb.QFragData[FragmentNumber],
+                 &cpi->pb.FragCoeffs[FragmentNumber],
+                 Token, ExtraBitsToken );
+
   /* Update record of tokens coded and where we are in this fragment. */
   /* Is there an extra bits token */
-  OneOrTwo= 1 + ( cpi->pb.ExtraBitLengths_VP3x[Token] > 0 ); 
+  OneOrTwo= 1 + ( cpi->pb.ExtraBitLengths_VP3x[Token] > 0 );
   /* Advance to the next real token. */
-  cpi->FragTokens[FragmentNumber] += OneOrTwo;
-	
+  cpi->FragTokens[FragmentNumber] += (unsigned char)OneOrTwo;
+
   /* Update the counts of tokens coded */
   cpi->TokensCoded += OneOrTwo;
   cpi->TokensToBeCoded -= OneOrTwo;
-  
+
   OneOrZero = ( FragmentNumber < (ogg_int32_t)cpi->pb.YPlaneFragments );
-  
+
   if ( Token == DCT_EOB_TOKEN ) {
     if ( cpi->RunLength == 0 ) {
       cpi->RunHuffIndex = HuffIndex;
       cpi->RunPlaneIndex = 1 -  OneOrZero;
     }
     cpi->RunLength++;
-    
+
     /* we have exceeded our longest run length  xmit an eob run token; */
     if ( cpi->RunLength == 4095 ) PackEOBRun(cpi);
-  
+
   }else{
 
     /* If we have an EOB run then code it up first */
     if ( cpi->RunLength > 0 ) PackEOBRun( cpi);
 
     /* Mark out which plane the block belonged to */
-    cpi->OptimisedTokenListPl[cpi->OptimisedTokenCount] = 1 - OneOrZero;
-    
+    cpi->OptimisedTokenListPl[cpi->OptimisedTokenCount] =
+      (unsigned char)(1 - OneOrZero);
+
     /* Note the token, extra bits and hufman table in the optimised
        token list */
-    cpi->OptimisedTokenList[cpi->OptimisedTokenCount] = 
-      Token;
-    cpi->OptimisedTokenListEb[cpi->OptimisedTokenCount] = 
+    cpi->OptimisedTokenList[cpi->OptimisedTokenCount] =
+      (unsigned char)Token;
+    cpi->OptimisedTokenListEb[cpi->OptimisedTokenCount] =
       ExtraBitsToken;
-    cpi->OptimisedTokenListHi[cpi->OptimisedTokenCount] = 
-      HuffIndex;
-    
+    cpi->OptimisedTokenListHi[cpi->OptimisedTokenCount] =
+      (unsigned char)HuffIndex;
+
     cpi->OptimisedTokenCount++;
   }
 }
 
-static ogg_uint32_t GetBlockReconErrorSlow( CP_INSTANCE *cpi, 
-				     ogg_int32_t BlockIndex ) {
-  ogg_uint32_t	i;
-  ogg_uint32_t	ErrorVal = 0;
-  
-  unsigned char * SrcDataPtr = 
+static ogg_uint32_t GetBlockReconErrorSlow( CP_INSTANCE *cpi,
+                                     ogg_int32_t BlockIndex ) {
+  ogg_uint32_t  i;
+  ogg_uint32_t  ErrorVal = 0;
+
+  unsigned char * SrcDataPtr =
     &cpi->ConvDestBuffer[cpi->pb.pixel_index_table[BlockIndex]];
-  unsigned char * RecDataPtr = 
+  unsigned char * RecDataPtr =
     &cpi->pb.LastFrameRecon[cpi->pb.recon_pixel_index_table[BlockIndex]];
   ogg_int32_t   SrcStride;
   ogg_int32_t   RecStride;
-  
+
   /* Is the block a Y block or a UV block. */
   if ( BlockIndex < (ogg_int32_t)cpi->pb.YPlaneFragments ) {
     SrcStride = cpi->pb.info.width;
@@ -533,8 +542,8 @@
     SrcStride = cpi->pb.info.width >> 1;
     RecStride = cpi->pb.UVStride;
   }
-    
-  
+
+
   /* Decide on standard or MMX implementation */
   for ( i=0; i < BLOCK_HEIGHT_WIDTH; i++ ) {
     ErrorVal += abs( ((int)SrcDataPtr[0]) - ((int)RecDataPtr[0]) );
@@ -560,27 +569,27 @@
 
   /* Reset the count of second order optimised tokens */
   cpi->OptimisedTokenCount = 0;
-  
+
   cpi->TokensToBeCoded = cpi->TotTokenCount;
   cpi->TokensCoded = 0;
-  
+
   /* Calculate the bit rate at which this frame should be capped. */
   cpi->MaxBitTarget = (ogg_uint32_t)((double)(cpi->ThisFrameTargetBytes * 8) *
-				     cpi->BitRateCapFactor);  
-  
+                                     cpi->BitRateCapFactor);
+
   /* Blank the various fragment data structures before we start. */
   memset(cpi->pb.FragCoeffs, 0, cpi->pb.UnitFragments);
   memset(cpi->FragTokens, 0, cpi->pb.UnitFragments);
 
   /* Clear down the QFragData structure for all coded blocks. */
   ClearDownQFragData(&cpi->pb);
-    
+
   /* The tree is not needed (implicit) for key frames */
   if ( GetFrameType(&cpi->pb) != BASE_FRAME ){
     /* Pack the quad tree fragment mapping. */
     PackAndWriteDFArray( cpi );
   }
-  
+
   /* Note the number of bits used to code the tree itself. */
   cpi->FrameBitCount = oggpackB_bytes(&cpi->oggbuffer) << 3;
 
@@ -591,28 +600,28 @@
     /* Pack the motion vectors */
     PackMotionVectors (cpi);
   }
-  
+
   cpi->FrameBitCount = oggpackB_bytes(&cpi->oggbuffer) << 3;
-  
+
   /* Optimise the DC tokens */
   for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) {
     /* Get the linear index for the current fragment. */
     FragIndex = cpi->pb.CodedBlockList[i];
-    
-    cpi->pb.FragCoefEOB[FragIndex]=EncodedCoeffs;
+
+    cpi->pb.FragCoefEOB[FragIndex]=(unsigned char)EncodedCoeffs;
     PackToken(cpi, FragIndex, DC_HUFF_OFFSET );
-    
+
   }
 
   /* Pack any outstanding EOB tokens */
   PackEOBRun(cpi);
-  
+
   /* Now output the optimised DC token list using the appropriate
      entropy tables. */
   EncodeDcTokenList(cpi);
 
   /* Work out the number of DC bits coded */
-  
+
   /* Optimise the AC tokens */
   while ( EncodedCoeffs < 64 ) {
     /* Huffman table adjustment based upon coefficient number. */
@@ -624,57 +633,57 @@
       HuffIndex = AC_HUFF_OFFSET + (AC_HUFF_CHOICES * 2);
     else
       HuffIndex = AC_HUFF_OFFSET + (AC_HUFF_CHOICES * 3);
-    
+
     /* Repeatedly scan through the list of blocks. */
     for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) {
       /* Get the linear index for the current fragment. */
       FragIndex = cpi->pb.CodedBlockList[i];
-      
+
       /* Should we code a token for this block on this pass. */
       if ( cpi->FragTokens[FragIndex] < cpi->FragTokenCounts[FragIndex]
-	   && cpi->pb.FragCoeffs[FragIndex] <= EncodedCoeffs ) {
-	/* Bit pack and a token for this block */
-	cpi->pb.FragCoefEOB[FragIndex]=EncodedCoeffs;
-	PackToken( cpi, FragIndex, HuffIndex );
+           && cpi->pb.FragCoeffs[FragIndex] <= EncodedCoeffs ) {
+        /* Bit pack and a token for this block */
+        cpi->pb.FragCoefEOB[FragIndex]=(unsigned char)EncodedCoeffs;
+        PackToken( cpi, FragIndex, HuffIndex );
       }
     }
-    
+
     EncodedCoeffs ++;
   }
-  
+
   /* Pack any outstanding EOB tokens */
   PackEOBRun(cpi);
-  
+
   /* Now output the optimised AC token list using the appropriate
      entropy tables. */
   EncodeAcTokenList(cpi);
-  
+
 }
 
 static ogg_uint32_t QuadCodeDisplayFragments (CP_INSTANCE *cpi) {
   ogg_int32_t   i,j;
-  ogg_uint32_t	coded_pixels=0;
+  ogg_uint32_t  coded_pixels=0;
   int           QIndex;
   int k,m,n;
 
   /* predictor multiplier up-left, up, up-right,left, shift */
   ogg_int16_t pc[16][6]={
-    {0,0,0,0,0,0},	
-    {0,0,0,1,0,0},	/* PL */
-    {0,0,1,0,0,0},	/* PUR */
-    {0,0,53,75,7,127},	/* PUR|PL */
-    {0,1,0,0,0,0},	/* PU */
-    {0,1,0,1,1,1},	/* PU|PL */
-    {0,1,0,0,0,0},	/* PU|PUR */
-    {0,0,53,75,7,127},	/* PU|PUR|PL */
-    {1,0,0,0,0,0},	/* PUL| */
-    {0,0,0,1,0,0},	/* PUL|PL */
-    {1,0,1,0,1,1},	/* PUL|PUR */
-    {0,0,53,75,7,127},	/* PUL|PUR|PL */
-    {0,1,0,0,0,0},	/* PUL|PU */
+    {0,0,0,0,0,0},
+    {0,0,0,1,0,0},      /* PL */
+    {0,0,1,0,0,0},      /* PUR */
+    {0,0,53,75,7,127},  /* PUR|PL */
+    {0,1,0,0,0,0},      /* PU */
+    {0,1,0,1,1,1},      /* PU|PL */
+    {0,1,0,0,0,0},      /* PU|PUR */
+    {0,0,53,75,7,127},  /* PU|PUR|PL */
+    {1,0,0,0,0,0},      /* PUL| */
+    {0,0,0,1,0,0},      /* PUL|PL */
+    {1,0,1,0,1,1},      /* PUL|PUR */
+    {0,0,53,75,7,127},  /* PUL|PUR|PL */
+    {0,1,0,0,0,0},      /* PUL|PU */
     {-26,29,0,29,5,31}, /* PUL|PU|PL */
-    {3,10,3,0,4,15},	/* PUL|PU|PUR */
-    {-26,29,0,29,5,31}	/* PUL|PU|PUR|PL */
+    {3,10,3,0,4,15},    /* PUL|PU|PUR */
+    {-26,29,0,29,5,31}  /* PUL|PU|PUR|PL */
   };
 
   struct SearchPoints {
@@ -687,38 +696,38 @@
   };
 
   int DCSearchPointCount = 0;
-  
+
   /* fragment left fragment up-left, fragment up, fragment up-right */
   int fl,ful,fu,fur;
-  
+
   /* value left value up-left, value up, value up-right */
   int vl,vul,vu,vur;
-  
+
   /* fragment number left, up-left, up, up-right */
   int l,ul,u,ur;
-  
+
   /*which predictor constants to use */
   ogg_int16_t wpc;
-  
+
   /* last used inter predictor (Raster Order) */
-  ogg_int16_t Last[3];	/* last value used for given frame */
-  
-  int FragsAcross=cpi->pb.HFragments;	
+  ogg_int16_t Last[3];  /* last value used for given frame */
+
+  int FragsAcross=cpi->pb.HFragments;
   int FragsDown = cpi->pb.VFragments;
   int FromFragment,ToFragment;
-  ogg_int32_t	FragIndex;
+  ogg_int32_t   FragIndex;
   int WhichFrame;
   int WhichCase;
-  
+
   ogg_int16_t Mode2Frame[] = {
-    1,	/* CODE_INTER_NO_MV	0 => Encoded diff from same MB last frame  */
-    0,	/* CODE_INTRA		1 => DCT Encoded Block */
-    1,	/* CODE_INTER_PLUS_MV	2 => Encoded diff from included MV MB last frame */
-    1,	/* CODE_INTER_LAST_MV	3 => Encoded diff from MRU MV MB last frame */
-    1,	/* CODE_INTER_PRIOR_MV	4 => Encoded diff from included 4 separate MV blocks */
-    2,	/* CODE_USING_GOLDEN	5 => Encoded diff from same MB golden frame */
-    2,	/* CODE_GOLDEN_MV	6 => Encoded diff from included MV MB golden frame */
-    1	/* CODE_INTER_FOUR_MV	7 => Encoded diff from included 4 separate MV blocks */
+    1,  /* CODE_INTER_NO_MV     0 => Encoded diff from same MB last frame  */
+    0,  /* CODE_INTRA           1 => DCT Encoded Block */
+    1,  /* CODE_INTER_PLUS_MV   2 => Encoded diff from included MV MB last frame */
+    1,  /* CODE_INTER_LAST_MV   3 => Encoded diff from MRU MV MB last frame */
+    1,  /* CODE_INTER_PRIOR_MV  4 => Encoded diff from included 4 separate MV blocks */
+    2,  /* CODE_USING_GOLDEN    5 => Encoded diff from same MB golden frame */
+    2,  /* CODE_GOLDEN_MV       6 => Encoded diff from included MV MB golden frame */
+    1   /* CODE_INTER_FOUR_MV   7 => Encoded diff from included 4 separate MV blocks */
   };
 
   ogg_int16_t PredictedDC;
@@ -727,29 +736,29 @@
      subsequent linear access to the quad tree ordered list of coded
      blocks */
   cpi->pb.CodedBlockIndex = 0;
-  
+
   /* Set the inter/intra descision control variables. */
   QIndex = Q_TABLE_SIZE - 1;
   while ( QIndex >= 0 ) {
-    if ( (QIndex == 0) || 
-	 ( cpi->pb.QThreshTable[QIndex] >= cpi->pb.ThisFrameQualityValue) )
+    if ( (QIndex == 0) ||
+         ( cpi->pb.QThreshTable[QIndex] >= cpi->pb.ThisFrameQualityValue) )
       break;
     QIndex --;
   }
-  
+
 
   /* Encode and tokenise the Y, U and V components */
-  coded_pixels = QuadCodeComponent(cpi, 0, cpi->pb.YSBRows, cpi->pb.YSBCols, 
-				   cpi->pb.info.width );
-  coded_pixels += QuadCodeComponent(cpi, cpi->pb.YSuperBlocks, 
-				    cpi->pb.UVSBRows, 
-				    cpi->pb.UVSBCols, 
-				    cpi->pb.info.width>>1 );
-  coded_pixels += QuadCodeComponent(cpi, 
-				    cpi->pb.YSuperBlocks+cpi->pb.UVSuperBlocks,
-				    cpi->pb.UVSBRows, cpi->pb.UVSBCols, 
-				    cpi->pb.info.width>>1 );
-    
+  coded_pixels = QuadCodeComponent(cpi, 0, cpi->pb.YSBRows, cpi->pb.YSBCols,
+                                   cpi->pb.info.width );
+  coded_pixels += QuadCodeComponent(cpi, cpi->pb.YSuperBlocks,
+                                    cpi->pb.UVSBRows,
+                                    cpi->pb.UVSBCols,
+                                    cpi->pb.info.width>>1 );
+  coded_pixels += QuadCodeComponent(cpi,
+                                    cpi->pb.YSuperBlocks+cpi->pb.UVSuperBlocks,
+                                    cpi->pb.UVSBRows, cpi->pb.UVSBCols,
+                                    cpi->pb.info.width>>1 );
+
   /* for y,u,v */
   for ( j = 0; j < 3 ; j++) {
     /* pick which fragments based on Y, U, V */
@@ -781,184 +790,184 @@
     /* do prediction on all of Y, U or V */
     for ( m = 0 ; m < FragsDown ; m++) {
       for ( n = 0 ; n < FragsAcross ; n++, i++) {
-	cpi->OriginalDC[i] = cpi->pb.QFragData[i][0];
+        cpi->OriginalDC[i] = cpi->pb.QFragData[i][0];
 
-	/* only do 2 prediction if fragment coded and on non intra or
+        /* only do 2 prediction if fragment coded and on non intra or
            if all fragments are intra */
-	if( cpi->pb.display_fragments[i] || 
-	    (GetFrameType(&cpi->pb) == BASE_FRAME) ) {
-	  /* Type of Fragment */
-	  WhichFrame = Mode2Frame[cpi->pb.FragCodingMethod[i]];
-
-	  /* Check Borderline Cases */
-	  WhichCase = (n==0) + ((m==0) << 1) + ((n+1 == FragsAcross) << 2);
-	  
-	  switch(WhichCase) {
-	  case 0: /* normal case no border condition */
-	    
-	    /* calculate values left, up, up-right and up-left */
-	    l = i-1;
-	    u = i - FragsAcross;
-	    ur = i - FragsAcross + 1;
-	    ul = i - FragsAcross - 1;
-
-	    /* calculate values */
-	    vl = cpi->OriginalDC[l];
-	    vu = cpi->OriginalDC[u];
-	    vur = cpi->OriginalDC[ur];
-	    vul = cpi->OriginalDC[ul];
-	    
-	    /* fragment valid for prediction use if coded and it comes
+        if( cpi->pb.display_fragments[i] ||
+            (GetFrameType(&cpi->pb) == BASE_FRAME) ) {
+          /* Type of Fragment */
+          WhichFrame = Mode2Frame[cpi->pb.FragCodingMethod[i]];
+
+          /* Check Borderline Cases */
+          WhichCase = (n==0) + ((m==0) << 1) + ((n+1 == FragsAcross) << 2);
+
+          switch(WhichCase) {
+          case 0: /* normal case no border condition */
+
+            /* calculate values left, up, up-right and up-left */
+            l = i-1;
+            u = i - FragsAcross;
+            ur = i - FragsAcross + 1;
+            ul = i - FragsAcross - 1;
+
+            /* calculate values */
+            vl = cpi->OriginalDC[l];
+            vu = cpi->OriginalDC[u];
+            vur = cpi->OriginalDC[ur];
+            vul = cpi->OriginalDC[ul];
+
+            /* fragment valid for prediction use if coded and it comes
                from same frame as the one we are predicting */
-	    fl = cpi->pb.display_fragments[l] && 
-	      (Mode2Frame[cpi->pb.FragCodingMethod[l]] == WhichFrame);
-	    fu = cpi->pb.display_fragments[u] && 
-	      (Mode2Frame[cpi->pb.FragCodingMethod[u]] == WhichFrame);
-	    fur = cpi->pb.display_fragments[ur] && 
-	      (Mode2Frame[cpi->pb.FragCodingMethod[ur]] == WhichFrame);
-	    ful = cpi->pb.display_fragments[ul] && 
-	      (Mode2Frame[cpi->pb.FragCodingMethod[ul]] == WhichFrame);
-	    
-	    /* calculate which predictor to use */
-	    wpc = (fl*PL) | (fu*PU) | (ful*PUL) | (fur*PUR);
-
-	    break;
-
-	  case 1: /* n == 0 Left Column */
-	    
-	    /* calculate values left, up, up-right and up-left */
-	    u = i - FragsAcross;
-	    ur = i - FragsAcross + 1;
-	    
-	    /* calculate values */
-	    vu = cpi->OriginalDC[u];
-	    vur = cpi->OriginalDC[ur];
-	    
-	    /* fragment valid for prediction if coded and it comes
+            fl = cpi->pb.display_fragments[l] &&
+              (Mode2Frame[cpi->pb.FragCodingMethod[l]] == WhichFrame);
+            fu = cpi->pb.display_fragments[u] &&
+              (Mode2Frame[cpi->pb.FragCodingMethod[u]] == WhichFrame);
+            fur = cpi->pb.display_fragments[ur] &&
+              (Mode2Frame[cpi->pb.FragCodingMethod[ur]] == WhichFrame);
+            ful = cpi->pb.display_fragments[ul] &&
+              (Mode2Frame[cpi->pb.FragCodingMethod[ul]] == WhichFrame);
+
+            /* calculate which predictor to use */
+            wpc = (fl*PL) | (fu*PU) | (ful*PUL) | (fur*PUR);
+
+            break;
+
+          case 1: /* n == 0 Left Column */
+
+            /* calculate values left, up, up-right and up-left */
+            u = i - FragsAcross;
+            ur = i - FragsAcross + 1;
+
+            /* calculate values */
+            vu = cpi->OriginalDC[u];
+            vur = cpi->OriginalDC[ur];
+
+            /* fragment valid for prediction if coded and it comes
                from same frame as the one we are predicting */
-	    fu = cpi->pb.display_fragments[u] && 
-	      (Mode2Frame[cpi->pb.FragCodingMethod[u]] == WhichFrame);
-	    fur = cpi->pb.display_fragments[ur] && 
-	      (Mode2Frame[cpi->pb.FragCodingMethod[ur]] == WhichFrame);
-
-	    /* calculate which predictor to use  */
-	    wpc = (fu*PU) | (fur*PUR);
-	    
-	    break;
-
-	  case 2: /* m == 0 Top Row */
-	  case 6: /* m == 0 and n+1 == FragsAcross or Top Row Right Column */
-
-	    /* calculate values left, up, up-right and up-left */
-	    l = i-1;
-	    
-	    /* calculate values */
-	    vl = cpi->OriginalDC[l];
-	    
-	    /* fragment valid for prediction if coded and it comes
+            fu = cpi->pb.display_fragments[u] &&
+              (Mode2Frame[cpi->pb.FragCodingMethod[u]] == WhichFrame);
+            fur = cpi->pb.display_fragments[ur] &&
+              (Mode2Frame[cpi->pb.FragCodingMethod[ur]] == WhichFrame);
+
+            /* calculate which predictor to use  */
+            wpc = (fu*PU) | (fur*PUR);
+
+            break;
+
+          case 2: /* m == 0 Top Row */
+          case 6: /* m == 0 and n+1 == FragsAcross or Top Row Right Column */
+
+            /* calculate values left, up, up-right and up-left */
+            l = i-1;
+
+            /* calculate values */
+            vl = cpi->OriginalDC[l];
+
+            /* fragment valid for prediction if coded and it comes
                from same frame as the one we are predicting */
-	    fl = cpi->pb.display_fragments[l] && 
-	      (Mode2Frame[cpi->pb.FragCodingMethod[l]] == WhichFrame);
-	    
-	    /* calculate which predictor to use */
-	    wpc = (fl*PL) ;
-	    
-	    break;
-	    
-	  case 3: /* n == 0 & m == 0 Top Row Left Column */
-
-	    wpc = 0;
-	    break;
-
-	  case 4: /* n+1 == FragsAcross : Right Column */
-
-	    /* calculate values left, up, up-right and up-left */
-	    l = i-1;
-	    u = i - FragsAcross;
-	    ul = i - FragsAcross - 1;
-	    
-	    /*  calculate values */
-	    vl = cpi->OriginalDC[l];
-	    vu = cpi->OriginalDC[u];
-	    vul = cpi->OriginalDC[ul];
-	    
-	    /* fragment valid for prediction if coded and it comes
+            fl = cpi->pb.display_fragments[l] &&
+              (Mode2Frame[cpi->pb.FragCodingMethod[l]] == WhichFrame);
+
+            /* calculate which predictor to use */
+            wpc = (fl*PL) ;
+
+            break;
+
+          case 3: /* n == 0 & m == 0 Top Row Left Column */
+
+            wpc = 0;
+            break;
+
+          case 4: /* n+1 == FragsAcross : Right Column */
+
+            /* calculate values left, up, up-right and up-left */
+            l = i-1;
+            u = i - FragsAcross;
+            ul = i - FragsAcross - 1;
+
+            /*  calculate values */
+            vl = cpi->OriginalDC[l];
+            vu = cpi->OriginalDC[u];
+            vul = cpi->OriginalDC[ul];
+
+            /* fragment valid for prediction if coded and it comes
                 from same frame as the one we are predicting */
-	    fl = cpi->pb.display_fragments[l] && 
-	      (Mode2Frame[cpi->pb.FragCodingMethod[l]] == WhichFrame);
-	    fu = cpi->pb.display_fragments[u] && 
-	      (Mode2Frame[cpi->pb.FragCodingMethod[u]] == WhichFrame);
-	    ful = cpi->pb.display_fragments[ul] && 
-	      (Mode2Frame[cpi->pb.FragCodingMethod[ul]] == WhichFrame);
-	    
-	    /* calculate which predictor to use */
-	    wpc = (fl*PL) | (fu*PU) | (ful*PUL) ;
-	    break;
-
-	  }
-	  
-	  if(wpc==0) {
-	    FragIndex = 1;
-						
-	    /* find the nearest one that is coded  */
-	    for( k = 0; k < DCSearchPointCount ; k++) {
-	      FragIndex = i + DCSearchPoints[k].RowOffset * 
-		FragsAcross + DCSearchPoints[k].ColOffset;
-							
-	      if( FragIndex - FromFragment > 0 ) {
-		if(cpi->pb.display_fragments[FragIndex] && 
-		   (Mode2Frame[cpi->pb.FragCodingMethod[FragIndex]] == 
-		    WhichFrame)) {
-		  cpi->pb.QFragData[i][0] -= cpi->OriginalDC[FragIndex];
-		  FragIndex = 0;
-		  break;
-		}
-	      }
-	    }
-	    
-	    /* if none matched fall back to the last one ever */
-	    if(FragIndex) cpi->pb.QFragData[i][0] -= Last[WhichFrame];
-	   
-	  } else {						
-	    
-	    /* don't do divide if divisor is 1 or 0 */
-	    PredictedDC = (pc[wpc][0]*vul + pc[wpc][1] * vu + 
-			   pc[wpc][2] * vur + pc[wpc][3] * vl );
-	    
-	    /* if we need to do a shift */
-	    if(pc[wpc][4] != 0 ) {
-
-	      /* If negative add in the negative correction factor */
-	      PredictedDC += (HIGHBITDUPPED(PredictedDC) & pc[wpc][5]);
-	      /* Shift in lieu of a divide */
-	      PredictedDC >>= pc[wpc][4];
-
-	    }
-						
-	    /* check for outranging on the two predictors that can outrange */
-	    switch(wpc) {
-	    case 13: /*  pul pu pl */
-	    case 15: /* pul pu pur pl */
-	      if( abs(PredictedDC - vu) > 128)
-		PredictedDC = vu;
-	      else if( abs(PredictedDC - vl) > 128)
-		PredictedDC = vl;
-	      else if( abs(PredictedDC - vul) > 128)
-		PredictedDC = vul;
-	      break;
-	    }
-	    
-	    cpi->pb.QFragData[i][0] -= PredictedDC;
-	  }
-	  
-	  /* Save the last fragment coded for whatever frame we are
+            fl = cpi->pb.display_fragments[l] &&
+              (Mode2Frame[cpi->pb.FragCodingMethod[l]] == WhichFrame);
+            fu = cpi->pb.display_fragments[u] &&
+              (Mode2Frame[cpi->pb.FragCodingMethod[u]] == WhichFrame);
+            ful = cpi->pb.display_fragments[ul] &&
+              (Mode2Frame[cpi->pb.FragCodingMethod[ul]] == WhichFrame);
+
+            /* calculate which predictor to use */
+            wpc = (fl*PL) | (fu*PU) | (ful*PUL) ;
+            break;
+
+          }
+
+          if(wpc==0) {
+            FragIndex = 1;
+
+            /* find the nearest one that is coded  */
+            for( k = 0; k < DCSearchPointCount ; k++) {
+              FragIndex = i + DCSearchPoints[k].RowOffset *
+                FragsAcross + DCSearchPoints[k].ColOffset;
+
+              if( FragIndex - FromFragment > 0 ) {
+                if(cpi->pb.display_fragments[FragIndex] &&
+                   (Mode2Frame[cpi->pb.FragCodingMethod[FragIndex]] ==
+                    WhichFrame)) {
+                  cpi->pb.QFragData[i][0] -= cpi->OriginalDC[FragIndex];
+                  FragIndex = 0;
+                  break;
+                }
+              }
+            }
+
+            /* if none matched fall back to the last one ever */
+            if(FragIndex) cpi->pb.QFragData[i][0] -= Last[WhichFrame];
+
+          } else {
+
+            /* don't do divide if divisor is 1 or 0 */
+            PredictedDC = (pc[wpc][0]*vul + pc[wpc][1] * vu +
+                           pc[wpc][2] * vur + pc[wpc][3] * vl );
+
+            /* if we need to do a shift */
+            if(pc[wpc][4] != 0 ) {
+
+              /* If negative add in the negative correction factor */
+              PredictedDC += (HIGHBITDUPPED(PredictedDC) & pc[wpc][5]);
+              /* Shift in lieu of a divide */
+              PredictedDC >>= pc[wpc][4];
+
+            }
+
+            /* check for outranging on the two predictors that can outrange */
+            switch(wpc) {
+            case 13: /*  pul pu pl */
+            case 15: /* pul pu pur pl */
+              if( abs(PredictedDC - vu) > 128)
+                PredictedDC = vu;
+              else if( abs(PredictedDC - vl) > 128)
+                PredictedDC = vl;
+              else if( abs(PredictedDC - vul) > 128)
+                PredictedDC = vul;
+              break;
+            }
+
+            cpi->pb.QFragData[i][0] -= PredictedDC;
+          }
+
+          /* Save the last fragment coded for whatever frame we are
              predicting from */
-	  
-	  Last[WhichFrame] = cpi->OriginalDC[i];
-	  
-	}
-      } 
-    } 
+
+          Last[WhichFrame] = cpi->OriginalDC[i];
+
+        }
+      }
+    }
   }
 
   /* Pack DC tokens and adjust the ones we couldn't predict 2d */
@@ -966,7 +975,7 @@
     /* Get the linear index for the current coded fragment. */
     FragIndex = cpi->pb.CodedBlockList[i];
     coded_pixels += DPCMTokenizeBlock ( cpi, FragIndex);
-    
+
   }
 
 
@@ -980,16 +989,16 @@
   ReconRefFrames(&cpi->pb);
 
   UpdateFragQIndex(&cpi->pb);
-  
+
   /* Measure the inter reconstruction error for all the blocks that
      were coded */
-    // for use as part of the recovery monitoring process in subsequent frames.
+  /* for use as part of the recovery monitoring process in subsequent frames. */
   for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) {
-    cpi->LastCodedErrorScore[ cpi->pb.CodedBlockList[i] ] = 
+    cpi->LastCodedErrorScore[ cpi->pb.CodedBlockList[i] ] =
       GetBlockReconErrorSlow( cpi, cpi->pb.CodedBlockList[i] );
-    
+
   }
-	
+
   /* Return total number of coded pixels */
   return coded_pixels;
 }
@@ -1007,22 +1016,22 @@
     cpi->pb.EOB_Run = 0;
 
     /* Encode any fragments coded using DCT. */
-    coded_pixels += QuadCodeDisplayFragments (cpi);           
+    coded_pixels += QuadCodeDisplayFragments (cpi);
 
     return coded_pixels;
 
 }
 
-ogg_uint32_t PickIntra( CP_INSTANCE *cpi, 
-			ogg_uint32_t SBRows, 
-			ogg_uint32_t SBCols){
-
-  ogg_int32_t	FragIndex;  /* Fragment number */
-  ogg_uint32_t	MB, B;	    /* Macro-Block, Block indices */
-  ogg_uint32_t	SBrow;	    /* Super-Block row number */
-  ogg_uint32_t	SBcol;	    /* Super-Block row number */
-  ogg_uint32_t	SB=0;	    /* Super-Block index, initialised to first of 
-			       this component */
+ogg_uint32_t PickIntra( CP_INSTANCE *cpi,
+                        ogg_uint32_t SBRows,
+                        ogg_uint32_t SBCols){
+
+  ogg_int32_t   FragIndex;  /* Fragment number */
+  ogg_uint32_t  MB, B;      /* Macro-Block, Block indices */
+  ogg_uint32_t  SBrow;      /* Super-Block row number */
+  ogg_uint32_t  SBcol;      /* Super-Block row number */
+  ogg_uint32_t  SB=0;       /* Super-Block index, initialised to first of
+                               this component */
 
   ogg_uint32_t UVRow;
   ogg_uint32_t UVColumn;
@@ -1033,33 +1042,33 @@
     for ( SBcol=0; SBcol<SBCols; SBcol++ ) {
       /* Check its four Macro-Blocks */
       for ( MB=0; MB<4; MB++ ) {
-	/* There may be MB's lying out of frame which must be
-	   ignored. For these MB's Top left block will have a negative
-	   Fragment Index. */
-	if ( QuadMapToMBTopLeft(cpi->pb.BlockMap,SB,MB) >= 0 ) {
-
-	  cpi->MBCodingMode = CODE_INTRA;
-	  
-	  /* Now actually code the blocks. */
-	  for ( B=0; B<4; B++ ) {
-	    FragIndex = QuadMapToIndex1( cpi->pb.BlockMap, SB, MB, B );
-	    cpi->pb.FragCodingMethod[FragIndex] = cpi->MBCodingMode;
-	  }
-                    
-	  /* Matching fragments in the U and V planes */
-	  UVRow = (FragIndex / (cpi->pb.HFragments * 2));
-	  UVColumn = (FragIndex % cpi->pb.HFragments) / 2;
-	  UVFragOffset = (UVRow * (cpi->pb.HFragments / 2)) + UVColumn;
-                    
-	  cpi->pb.FragCodingMethod[cpi->pb.YPlaneFragments + UVFragOffset] = 
-	    cpi->MBCodingMode;
-	  cpi->pb.FragCodingMethod[cpi->pb.YPlaneFragments + 
-				  cpi->pb.UVPlaneFragments + UVFragOffset] = 
-	    cpi->MBCodingMode;
-                            
-	}
+        /* There may be MB's lying out of frame which must be
+           ignored. For these MB's Top left block will have a negative
+           Fragment Index. */
+        if ( QuadMapToMBTopLeft(cpi->pb.BlockMap,SB,MB) >= 0 ) {
+
+          cpi->MBCodingMode = CODE_INTRA;
+
+          /* Now actually code the blocks. */
+          for ( B=0; B<4; B++ ) {
+            FragIndex = QuadMapToIndex1( cpi->pb.BlockMap, SB, MB, B );
+            cpi->pb.FragCodingMethod[FragIndex] = cpi->MBCodingMode;
+          }
+
+          /* Matching fragments in the U and V planes */
+          UVRow = (FragIndex / (cpi->pb.HFragments * 2));
+          UVColumn = (FragIndex % cpi->pb.HFragments) / 2;
+          UVFragOffset = (UVRow * (cpi->pb.HFragments / 2)) + UVColumn;
+
+          cpi->pb.FragCodingMethod[cpi->pb.YPlaneFragments + UVFragOffset] =
+            cpi->MBCodingMode;
+          cpi->pb.FragCodingMethod[cpi->pb.YPlaneFragments +
+                                  cpi->pb.UVPlaneFragments + UVFragOffset] =
+            cpi->MBCodingMode;
+
+        }
       }
-            
+
       /* Next Super-Block */
       SB++;
     }
@@ -1067,48 +1076,48 @@
   return 0;
 }
 
-static void AddMotionVector(CP_INSTANCE *cpi,     
-		     MOTION_VECTOR *ThisMotionVector) {
+static void AddMotionVector(CP_INSTANCE *cpi,
+                     MOTION_VECTOR *ThisMotionVector) {
   cpi->MVList[cpi->MvListCount].x = ThisMotionVector->x;
   cpi->MVList[cpi->MvListCount].y = ThisMotionVector->y;
   cpi->MvListCount++;
 }
 
-static void SetFragMotionVectorAndMode(CP_INSTANCE *cpi,     
-				ogg_int32_t FragIndex,
-				MOTION_VECTOR *ThisMotionVector){
+static void SetFragMotionVectorAndMode(CP_INSTANCE *cpi,
+                                ogg_int32_t FragIndex,
+                                MOTION_VECTOR *ThisMotionVector){
   /* Note the coding mode and vector for each block */
   cpi->pb.FragMVect[FragIndex].x = ThisMotionVector->x;
   cpi->pb.FragMVect[FragIndex].y = ThisMotionVector->y;
-  cpi->pb.FragCodingMethod[FragIndex] = cpi->MBCodingMode; 
+  cpi->pb.FragCodingMethod[FragIndex] = cpi->MBCodingMode;
 }
 
-static void SetMBMotionVectorsAndMode(CP_INSTANCE *cpi,     
-			       ogg_int32_t YFragIndex,
-			       ogg_int32_t UFragIndex,
-			       ogg_int32_t VFragIndex,
-			       MOTION_VECTOR *ThisMotionVector){
+static void SetMBMotionVectorsAndMode(CP_INSTANCE *cpi,
+                               ogg_int32_t YFragIndex,
+                               ogg_int32_t UFragIndex,
+                               ogg_int32_t VFragIndex,
+                               MOTION_VECTOR *ThisMotionVector){
   SetFragMotionVectorAndMode(cpi, YFragIndex, ThisMotionVector);
   SetFragMotionVectorAndMode(cpi, YFragIndex + 1, ThisMotionVector);
   SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments,
-			     ThisMotionVector);
-  SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments + 1, 
-			     ThisMotionVector);
+                             ThisMotionVector);
+  SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments + 1,
+                             ThisMotionVector);
   SetFragMotionVectorAndMode(cpi, UFragIndex, ThisMotionVector);
   SetFragMotionVectorAndMode(cpi, VFragIndex, ThisMotionVector);
 }
 
-ogg_uint32_t PickModes(CP_INSTANCE *cpi, 
-		       ogg_uint32_t SBRows, ogg_uint32_t SBCols, 
-		       ogg_uint32_t PixelsPerLine, 
-		       ogg_uint32_t *InterError, ogg_uint32_t *IntraError) {
-  ogg_int32_t	YFragIndex;
-  ogg_int32_t	UFragIndex;
-  ogg_int32_t	VFragIndex;
-  ogg_uint32_t	MB, B;	    /* Macro-Block, Block indices */
-  ogg_uint32_t	SBrow;	    /* Super-Block row number */
-  ogg_uint32_t	SBcol;	    /* Super-Block row number */
-  ogg_uint32_t	SB=0;	    /* Super-Block index, initialised to first
+ogg_uint32_t PickModes(CP_INSTANCE *cpi,
+                       ogg_uint32_t SBRows, ogg_uint32_t SBCols,
+                       ogg_uint32_t PixelsPerLine,
+                       ogg_uint32_t *InterError, ogg_uint32_t *IntraError) {
+  ogg_int32_t   YFragIndex;
+  ogg_int32_t   UFragIndex;
+  ogg_int32_t   VFragIndex;
+  ogg_uint32_t  MB, B;      /* Macro-Block, Block indices */
+  ogg_uint32_t  SBrow;      /* Super-Block row number */
+  ogg_uint32_t  SBcol;      /* Super-Block row number */
+  ogg_uint32_t  SB=0;       /* Super-Block index, initialised to first
                                of this component */
 
   ogg_uint32_t  MBIntraError;           /* Intra error for macro block */
@@ -1127,9 +1136,9 @@
                                            motion vectors per macro
                                            block */
   ogg_uint32_t  BestError;              /* Best error so far. */
-  
+
   MOTION_VECTOR FourMVect[6];     /* storage for last used vectors (one
-				     entry for each block in MB) */
+                                     entry for each block in MB) */
   MOTION_VECTOR LastInterMVect;   /* storage for last used Inter frame
                                      MB motion vector */
   MOTION_VECTOR PriorLastInterMVect;  /* storage for prior last used
@@ -1142,18 +1151,18 @@
                                      from exhaustive search */
   MOTION_VECTOR GFMVect;          /* storage for motion vector */
   MOTION_VECTOR ZeroVect;
-  
+
   ogg_uint32_t UVRow;
   ogg_uint32_t UVColumn;
   ogg_uint32_t UVFragOffset;
-  
+
   int          MBCodedFlag;
   unsigned char QIndex;
-  
+
   /* initialize error scores */
   *InterError = 0;
   *IntraError = 0;
-  
+
   /* clear down the default motion vector. */
   cpi->MvListCount = 0;
   FourMVect[0].x = 0;
@@ -1178,20 +1187,20 @@
   InterMVect.y = 0;
   GFMVect.x = 0;
   GFMVect.y = 0;
-  
+
   ZeroVect.x = 0;
   ZeroVect.y = 0;
-  
-  QIndex = cpi->pb.FrameQIndex;
+
+  QIndex = (unsigned char)cpi->pb.FrameQIndex;
 
 
 
   /* change the quatization matrix to the one at best Q to compute the
      new error score */
-  cpi->MinImprovementForNewMV = (MvThreshTable[QIndex] << 12); 
+  cpi->MinImprovementForNewMV = (MvThreshTable[QIndex] << 12);
   cpi->InterTripOutThresh = (5000<<12);
   cpi->MVChangeFactor = MVChangeFactorTable[QIndex]; /* 0.9 */
-  
+
   if ( cpi->pb.info.quick_p ) {
     cpi->ExhaustiveSearchThresh = (1000<<12);
     cpi->FourMVThreshold = (2500<<12);
@@ -1199,329 +1208,329 @@
     cpi->ExhaustiveSearchThresh = (250<<12);
     cpi->FourMVThreshold = (500<<12);
   }
-  cpi->MinImprovementForFourMV = cpi->MinImprovementForNewMV * 4;     
-  
+  cpi->MinImprovementForFourMV = cpi->MinImprovementForNewMV * 4;
+
   if(cpi->MinImprovementForFourMV < (40<<12))
     cpi->MinImprovementForFourMV = (40<<12);
-  
+
   cpi->FourMvChangeFactor = 8; /* cpi->MVChangeFactor - 0.05;  */
-  
+
   /* decide what block type and motion vectors to use on all of the frames */
   for ( SBrow=0; SBrow<SBRows; SBrow++ ) {
     for ( SBcol=0; SBcol<SBCols; SBcol++ ) {
       /* Check its four Macro-Blocks */
       for ( MB=0; MB<4; MB++ ) {
-	/* There may be MB's lying out of frame which must be
-	   ignored. For these MB's Top left block will have a negative
-	   Fragment Index. */
-	if ( QuadMapToMBTopLeft(cpi->pb.BlockMap,SB,MB) < 0 ) continue;
-                
-	/* Is the current macro block coded (in part or in whole) */
-	MBCodedFlag = 0;
-	for ( B=0; B<4; B++ ) {
-	  YFragIndex = QuadMapToIndex1( cpi->pb.BlockMap, SB, MB, B );
-                   
-	  /* Does Block lie in frame: */
-	  if ( YFragIndex >= 0 ) {
-	    /* In Frame: Is it coded: */
-	    if ( cpi->pb.display_fragments[YFragIndex] ) {
-	      MBCodedFlag = 1;
-	      break;
-	    }
-	  } else
-	    MBCodedFlag = 0;
-	}
-                
-	/* This one isn't coded go to the next one */
-	if(!MBCodedFlag) continue;
-
-	/* Calculate U and V FragIndex from YFragIndex */
-	YFragIndex = QuadMapToMBTopLeft(cpi->pb.BlockMap, SB,MB);
-	UVRow = (YFragIndex / (cpi->pb.HFragments * 2));
-	UVColumn = (YFragIndex % cpi->pb.HFragments) / 2;
-	UVFragOffset = (UVRow * (cpi->pb.HFragments / 2)) + UVColumn;
-	UFragIndex = cpi->pb.YPlaneFragments + UVFragOffset;
-	VFragIndex = cpi->pb.YPlaneFragments + cpi->pb.UVPlaneFragments + 
-	  UVFragOffset;
-	
-	
-	/**************************************************************
-	 Find the block choice with the lowest error 
-
-	 NOTE THAT if U or V is coded but no Y from a macro block then
-	 the mode will be CODE_INTER_NO_MV as this is the default
-	 state to which the mode data structure is initialised in
-	 encoder and decoder at the start of each frame. */
-
-	BestError = HUGE_ERROR;
-	
-
-	/* Look at the intra coding error. */
-	MBIntraError = GetMBIntraError( cpi, YFragIndex, PixelsPerLine );
-	BestError = (BestError > MBIntraError) ? MBIntraError : BestError;
-                
-	/* Get the golden frame error */
-	MBGFError = GetMBInterError( cpi, cpi->ConvDestBuffer, 
-				     cpi->pb.GoldenFrame, YFragIndex, 
-				     0, 0, PixelsPerLine );
-	BestError = (BestError > MBGFError) ? MBGFError : BestError;
-	
-	/* Calculate the 0,0 case. */
-	MBInterError = GetMBInterError( cpi, cpi->ConvDestBuffer, 
-					cpi->pb.LastFrameRecon, 
-					YFragIndex, 0, 0, PixelsPerLine );
-	BestError = (BestError > MBInterError) ? MBInterError : BestError;
-                
-	/* Measure error for last MV */
-	MBLastInterError =  GetMBInterError( cpi, cpi->ConvDestBuffer, 
-					     cpi->pb.LastFrameRecon, 
-					     YFragIndex, LastInterMVect.x, 
-					     LastInterMVect.y, PixelsPerLine );
-	BestError = (BestError > MBLastInterError) ? 
-	  MBLastInterError : BestError;
-                
-	/* Measure error for prior last MV */
-	MBPriorLastInterError =  GetMBInterError( cpi, cpi->ConvDestBuffer, 
-						  cpi->pb.LastFrameRecon, 
-						  YFragIndex, 
-						  PriorLastInterMVect.x, 
-						  PriorLastInterMVect.y, 
-						  PixelsPerLine );
-	BestError = (BestError > MBPriorLastInterError) ? 
-	  MBPriorLastInterError : BestError;
-
-	/* Temporarily force usage of no motionvector blocks */
-	MBInterMVError = HUGE_ERROR;
-	InterMVect.x = 0;  /* Set 0,0 motion vector */
-	InterMVect.y = 0;
-                
-	/* If the best error is above the required threshold search
+        /* There may be MB's lying out of frame which must be
+           ignored. For these MB's Top left block will have a negative
+           Fragment Index. */
+        if ( QuadMapToMBTopLeft(cpi->pb.BlockMap,SB,MB) < 0 ) continue;
+
+        /* Is the current macro block coded (in part or in whole) */
+        MBCodedFlag = 0;
+        for ( B=0; B<4; B++ ) {
+          YFragIndex = QuadMapToIndex1( cpi->pb.BlockMap, SB, MB, B );
+
+          /* Does Block lie in frame: */
+          if ( YFragIndex >= 0 ) {
+            /* In Frame: Is it coded: */
+            if ( cpi->pb.display_fragments[YFragIndex] ) {
+              MBCodedFlag = 1;
+              break;
+            }
+          } else
+            MBCodedFlag = 0;
+        }
+
+        /* This one isn't coded go to the next one */
+        if(!MBCodedFlag) continue;
+
+        /* Calculate U and V FragIndex from YFragIndex */
+        YFragIndex = QuadMapToMBTopLeft(cpi->pb.BlockMap, SB,MB);
+        UVRow = (YFragIndex / (cpi->pb.HFragments * 2));
+        UVColumn = (YFragIndex % cpi->pb.HFragments) / 2;
+        UVFragOffset = (UVRow * (cpi->pb.HFragments / 2)) + UVColumn;
+        UFragIndex = cpi->pb.YPlaneFragments + UVFragOffset;
+        VFragIndex = cpi->pb.YPlaneFragments + cpi->pb.UVPlaneFragments +
+          UVFragOffset;
+
+
+        /**************************************************************
+         Find the block choice with the lowest error
+
+         NOTE THAT if U or V is coded but no Y from a macro block then
+         the mode will be CODE_INTER_NO_MV as this is the default
+         state to which the mode data structure is initialised in
+         encoder and decoder at the start of each frame. */
+
+        BestError = HUGE_ERROR;
+
+
+        /* Look at the intra coding error. */
+        MBIntraError = GetMBIntraError( cpi, YFragIndex, PixelsPerLine );
+        BestError = (BestError > MBIntraError) ? MBIntraError : BestError;
+
+        /* Get the golden frame error */
+        MBGFError = GetMBInterError( cpi, cpi->ConvDestBuffer,
+                                     cpi->pb.GoldenFrame, YFragIndex,
+                                     0, 0, PixelsPerLine );
+        BestError = (BestError > MBGFError) ? MBGFError : BestError;
+
+        /* Calculate the 0,0 case. */
+        MBInterError = GetMBInterError( cpi, cpi->ConvDestBuffer,
+                                        cpi->pb.LastFrameRecon,
+                                        YFragIndex, 0, 0, PixelsPerLine );
+        BestError = (BestError > MBInterError) ? MBInterError : BestError;
+
+        /* Measure error for last MV */
+        MBLastInterError =  GetMBInterError( cpi, cpi->ConvDestBuffer,
+                                             cpi->pb.LastFrameRecon,
+                                             YFragIndex, LastInterMVect.x,
+                                             LastInterMVect.y, PixelsPerLine );
+        BestError = (BestError > MBLastInterError) ?
+          MBLastInterError : BestError;
+
+        /* Measure error for prior last MV */
+        MBPriorLastInterError =  GetMBInterError( cpi, cpi->ConvDestBuffer,
+                                                  cpi->pb.LastFrameRecon,
+                                                  YFragIndex,
+                                                  PriorLastInterMVect.x,
+                                                  PriorLastInterMVect.y,
+                                                  PixelsPerLine );
+        BestError = (BestError > MBPriorLastInterError) ?
+          MBPriorLastInterError : BestError;
+
+        /* Temporarily force usage of no motionvector blocks */
+        MBInterMVError = HUGE_ERROR;
+        InterMVect.x = 0;  /* Set 0,0 motion vector */
+        InterMVect.y = 0;
+
+        /* If the best error is above the required threshold search
            for a new inter MV */
-	if ( BestError > cpi->MinImprovementForNewMV ) {
-	  /* Use a mix of heirachical and exhaustive searches for
+        if ( BestError > cpi->MinImprovementForNewMV ) {
+          /* Use a mix of heirachical and exhaustive searches for
              quick mode. */
-	  if ( cpi->pb.info.quick_p ) {
-	    MBInterMVError = GetMBMVInterError( cpi, cpi->pb.LastFrameRecon, 
-						YFragIndex, PixelsPerLine, 
-						cpi->MVPixelOffsetY, 
-						&InterMVect );
-	    
-	    /* If we still do not have a good match try an exhaustive
+          if ( cpi->pb.info.quick_p ) {
+            MBInterMVError = GetMBMVInterError( cpi, cpi->pb.LastFrameRecon,
+                                                YFragIndex, PixelsPerLine,
+                                                cpi->MVPixelOffsetY,
+                                                &InterMVect );
+
+            /* If we still do not have a good match try an exhaustive
                MBMV search */
-	    if ( (MBInterMVError > cpi->ExhaustiveSearchThresh) && 
-		 (BestError > cpi->ExhaustiveSearchThresh) ) {
+            if ( (MBInterMVError > cpi->ExhaustiveSearchThresh) &&
+                 (BestError > cpi->ExhaustiveSearchThresh) ) {
+
+              MBInterMVExError =
+                GetMBMVExhaustiveSearch( cpi, cpi->pb.LastFrameRecon,
+                                         YFragIndex, PixelsPerLine,
+                                         &InterMVectEx );
 
-	      MBInterMVExError = 
-		GetMBMVExhaustiveSearch( cpi, cpi->pb.LastFrameRecon, 
-					 YFragIndex, PixelsPerLine, 
-					 &InterMVectEx );
-                            
-	      /* Is the Variance measure for the EX search
+              /* Is the Variance measure for the EX search
                  better... If so then use it. */
-	      if ( MBInterMVExError < MBInterMVError ) {
-		MBInterMVError = MBInterMVExError;   
-		InterMVect.x = InterMVectEx.x;
-		InterMVect.y = InterMVectEx.y;
-	      }
-	    }
-	  }else{
-	    /* Use an exhaustive search */
-	    MBInterMVError = 
-	      GetMBMVExhaustiveSearch( cpi, cpi->pb.LastFrameRecon, 
-				       YFragIndex, PixelsPerLine, 
-				       &InterMVect );
-	  }
-                    
-	  
-	  /* Is the improvement, if any, good enough to justify a new MV */
-	  if ( (16 * MBInterMVError < (BestError * cpi->MVChangeFactor)) && 
-	       ((MBInterMVError + cpi->MinImprovementForNewMV) < BestError) ){
-	    BestError = MBInterMVError;
-	  }
-	  
-	}
-                
-	/* If the best error is still above the required threshold
+              if ( MBInterMVExError < MBInterMVError ) {
+                MBInterMVError = MBInterMVExError;
+                InterMVect.x = InterMVectEx.x;
+                InterMVect.y = InterMVectEx.y;
+              }
+            }
+          }else{
+            /* Use an exhaustive search */
+            MBInterMVError =
+              GetMBMVExhaustiveSearch( cpi, cpi->pb.LastFrameRecon,
+                                       YFragIndex, PixelsPerLine,
+                                       &InterMVect );
+          }
+
+
+          /* Is the improvement, if any, good enough to justify a new MV */
+          if ( (16 * MBInterMVError < (BestError * cpi->MVChangeFactor)) &&
+               ((MBInterMVError + cpi->MinImprovementForNewMV) < BestError) ){
+            BestError = MBInterMVError;
+          }
+
+        }
+
+        /* If the best error is still above the required threshold
            search for a golden frame MV */
-	MBGF_MVError = HUGE_ERROR;
-	GFMVect.x = 0; /* Set 0,0 motion vector */
-	GFMVect.y = 0;
-	if ( BestError > cpi->MinImprovementForNewMV ) {
-	  /* Do an MV search in the golden reference frame */
-	  MBGF_MVError = GetMBMVInterError( cpi, cpi->pb.GoldenFrame, 
-					    YFragIndex, PixelsPerLine, 
-					    cpi->MVPixelOffsetY, &GFMVect );
-                    
-	  /* Measure error for last GFMV */
-	  LastMBGF_MVError =  GetMBInterError( cpi, cpi->ConvDestBuffer, 
-					       cpi->pb.GoldenFrame, 
-					       YFragIndex, LastGFMVect.x, 
-					       LastGFMVect.y, PixelsPerLine );
-                    
-	  /* Check against last GF motion vector and reset if the
+        MBGF_MVError = HUGE_ERROR;
+        GFMVect.x = 0; /* Set 0,0 motion vector */
+        GFMVect.y = 0;
+        if ( BestError > cpi->MinImprovementForNewMV ) {
+          /* Do an MV search in the golden reference frame */
+          MBGF_MVError = GetMBMVInterError( cpi, cpi->pb.GoldenFrame,
+                                            YFragIndex, PixelsPerLine,
+                                            cpi->MVPixelOffsetY, &GFMVect );
+
+          /* Measure error for last GFMV */
+          LastMBGF_MVError =  GetMBInterError( cpi, cpi->ConvDestBuffer,
+                                               cpi->pb.GoldenFrame,
+                                               YFragIndex, LastGFMVect.x,
+                                               LastGFMVect.y, PixelsPerLine );
+
+          /* Check against last GF motion vector and reset if the
              search has thrown a worse result. */
-	  if ( LastMBGF_MVError < MBGF_MVError ) {
-	    GFMVect.x = LastGFMVect.x;
-	    GFMVect.y = LastGFMVect.y;
-	    MBGF_MVError = LastMBGF_MVError;
-	  }else{
-	    LastGFMVect.x = GFMVect.x;
-	    LastGFMVect.y = GFMVect.y;
-	  }
-	  
-	  /* Is the improvement, if any, good enough to justify a new MV */
-	  if ( (16 * MBGF_MVError < (BestError * cpi->MVChangeFactor)) && 
-	       ((MBGF_MVError + cpi->MinImprovementForNewMV) < BestError) ) {
-	    BestError = MBGF_MVError;
-	  }
-	}
+          if ( LastMBGF_MVError < MBGF_MVError ) {
+            GFMVect.x = LastGFMVect.x;
+            GFMVect.y = LastGFMVect.y;
+            MBGF_MVError = LastMBGF_MVError;
+          }else{
+            LastGFMVect.x = GFMVect.x;
+            LastGFMVect.y = GFMVect.y;
+          }
+
+          /* Is the improvement, if any, good enough to justify a new MV */
+          if ( (16 * MBGF_MVError < (BestError * cpi->MVChangeFactor)) &&
+               ((MBGF_MVError + cpi->MinImprovementForNewMV) < BestError) ) {
+            BestError = MBGF_MVError;
+          }
+        }
 
-	/* Finally... If the best error is still to high then consider
+        /* Finally... If the best error is still to high then consider
            the 4MV mode */
-	MBInterFOURMVError = HUGE_ERROR;
-	if ( BestError > cpi->FourMVThreshold ) {
-	  /* Get the 4MV error. */
-	  MBInterFOURMVError =
-	    GetFOURMVExhaustiveSearch( cpi, cpi->pb.LastFrameRecon, 
-				       YFragIndex, PixelsPerLine, FourMVect );
-                    
-	  /* If the improvement is great enough then use the four MV mode */
-	  if ( ((MBInterFOURMVError + cpi->MinImprovementForFourMV) < 
-		BestError) && (16 * MBInterFOURMVError < 
-			       (BestError * cpi->FourMvChangeFactor))) {
-	    BestError = MBInterFOURMVError;
-	  }
-	}
-        
+        MBInterFOURMVError = HUGE_ERROR;
+        if ( BestError > cpi->FourMVThreshold ) {
+          /* Get the 4MV error. */
+          MBInterFOURMVError =
+            GetFOURMVExhaustiveSearch( cpi, cpi->pb.LastFrameRecon,
+                                       YFragIndex, PixelsPerLine, FourMVect );
+
+          /* If the improvement is great enough then use the four MV mode */
+          if ( ((MBInterFOURMVError + cpi->MinImprovementForFourMV) <
+                BestError) && (16 * MBInterFOURMVError <
+                               (BestError * cpi->FourMvChangeFactor))) {
+            BestError = MBInterFOURMVError;
+          }
+        }
+
         /********************************************************
-	 end finding the best error 
-	 *******************************************************
-	
+         end finding the best error
+         *******************************************************
+
          Figure out what to do with the block we chose
-	
-	 Over-ride and force intra if error high and Intra error similar
-	 Now choose a mode based on lowest error (with bias towards no MV) */
-
-	if ( (BestError > cpi->InterTripOutThresh) && 
-	     (10 * BestError > MBIntraError * 7 ) ) {
-	  cpi->MBCodingMode = CODE_INTRA;
-	  SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&ZeroVect);
-	} else if ( BestError == MBInterError ) {
-	  cpi->MBCodingMode = CODE_INTER_NO_MV;
-	  SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&ZeroVect);
-	} else if ( BestError == MBGFError ) {
-	  cpi->MBCodingMode = CODE_USING_GOLDEN;
-	  SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&ZeroVect);
-	} else if ( BestError == MBLastInterError ) {
-	  cpi->MBCodingMode = CODE_INTER_LAST_MV;
-	  SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&LastInterMVect);
-	} else if ( BestError == MBPriorLastInterError ) {
-	  cpi->MBCodingMode = CODE_INTER_PRIOR_LAST;
-	  SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&PriorLastInterMVect);
-	  
-	  /* Swap the prior and last MV cases over */
-	  TmpMVect.x = PriorLastInterMVect.x;
-	  TmpMVect.y = PriorLastInterMVect.y;
-	  PriorLastInterMVect.x = LastInterMVect.x;
-	  PriorLastInterMVect.y = LastInterMVect.y;
-	  LastInterMVect.x = TmpMVect.x;
-	  LastInterMVect.y = TmpMVect.y;
-
-	} else if ( BestError == MBInterMVError ) {
-
-	  cpi->MBCodingMode = CODE_INTER_PLUS_MV;
-	  SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&InterMVect);
-	  
-	  /* Update Prior last mv with last mv */
-	  PriorLastInterMVect.x = LastInterMVect.x;
-	  PriorLastInterMVect.y = LastInterMVect.y;
-	  
-	  /* Note last inter MV for future use */
-	  LastInterMVect.x = InterMVect.x;
-	  LastInterMVect.y = InterMVect.y;
-	  
-	  AddMotionVector( cpi, &InterMVect);
-
-	} else if ( BestError == MBGF_MVError ) {
-
-	  cpi->MBCodingMode = CODE_GOLDEN_MV;
-	  SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&GFMVect);
-	  
-	  /* Note last inter GF MV for future use */
-	  LastGFMVect.x = GFMVect.x;
-	  LastGFMVect.y = GFMVect.y;
-                    
-	  AddMotionVector( cpi, &GFMVect);
-	} else if ( BestError == MBInterFOURMVError ) {
-	  cpi->MBCodingMode = CODE_INTER_FOURMV;
-	  
-	  /* Calculate the UV vectors as the average of the Y plane ones. */
-	  /* First .x component */
-	  FourMVect[4].x = FourMVect[0].x + FourMVect[1].x + 
-	    FourMVect[2].x + FourMVect[3].x;
-	  if ( FourMVect[4].x >= 0 )
-	    FourMVect[4].x = (FourMVect[4].x + 2) / 4;
-	  else
-	    FourMVect[4].x = (FourMVect[4].x - 2) / 4;
-	  FourMVect[5].x = FourMVect[4].x;
-	  
-	  /* Then .y component */
-	  FourMVect[4].y = FourMVect[0].y + FourMVect[1].y + 
-	    FourMVect[2].y + FourMVect[3].y;
-	  if ( FourMVect[4].y >= 0 )
-	    FourMVect[4].y = (FourMVect[4].y + 2) / 4;
-	  else
-	    FourMVect[4].y = (FourMVect[4].y - 2) / 4;
-	  FourMVect[5].y = FourMVect[4].y;
-	  
-	  SetFragMotionVectorAndMode(cpi, YFragIndex, &FourMVect[0]);
-	  SetFragMotionVectorAndMode(cpi, YFragIndex + 1, &FourMVect[1]);
-	  SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments, 
-				     &FourMVect[2]);
-	  SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments + 1,
-				     &FourMVect[3]);
-	  SetFragMotionVectorAndMode(cpi, UFragIndex, &FourMVect[4]);
-	  SetFragMotionVectorAndMode(cpi, VFragIndex, &FourMVect[5]);
-	  
-	  /* Note the four MVs values for current macro-block. */
-	  AddMotionVector( cpi, &FourMVect[0]);
-	  AddMotionVector( cpi, &FourMVect[1]);
-	  AddMotionVector( cpi, &FourMVect[2]);
-	  AddMotionVector( cpi, &FourMVect[3]);
-	  
-	  /* Update Prior last mv with last mv */
-	  PriorLastInterMVect.x = LastInterMVect.x;
-	  PriorLastInterMVect.y = LastInterMVect.y;
-	  
-	  /* Note last inter MV for future use */
-	  LastInterMVect.x = FourMVect[3].x;
-	  LastInterMVect.y = FourMVect[3].y;
-	  
-	} else {
-
-	  cpi->MBCodingMode = CODE_INTRA;
-	  SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&ZeroVect);
-	}
-	
 
-	/* setting up mode specific block types
+         Over-ride and force intra if error high and Intra error similar
+         Now choose a mode based on lowest error (with bias towards no MV) */
+
+        if ( (BestError > cpi->InterTripOutThresh) &&
+             (10 * BestError > MBIntraError * 7 ) ) {
+          cpi->MBCodingMode = CODE_INTRA;
+          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
+                                    VFragIndex,&ZeroVect);
+        } else if ( BestError == MBInterError ) {
+          cpi->MBCodingMode = CODE_INTER_NO_MV;
+          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
+                                    VFragIndex,&ZeroVect);
+        } else if ( BestError == MBGFError ) {
+          cpi->MBCodingMode = CODE_USING_GOLDEN;
+          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
+                                    VFragIndex,&ZeroVect);
+        } else if ( BestError == MBLastInterError ) {
+          cpi->MBCodingMode = CODE_INTER_LAST_MV;
+          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
+                                    VFragIndex,&LastInterMVect);
+        } else if ( BestError == MBPriorLastInterError ) {
+          cpi->MBCodingMode = CODE_INTER_PRIOR_LAST;
+          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
+                                    VFragIndex,&PriorLastInterMVect);
+
+          /* Swap the prior and last MV cases over */
+          TmpMVect.x = PriorLastInterMVect.x;
+          TmpMVect.y = PriorLastInterMVect.y;
+          PriorLastInterMVect.x = LastInterMVect.x;
+          PriorLastInterMVect.y = LastInterMVect.y;
+          LastInterMVect.x = TmpMVect.x;
+          LastInterMVect.y = TmpMVect.y;
+
+        } else if ( BestError == MBInterMVError ) {
+
+          cpi->MBCodingMode = CODE_INTER_PLUS_MV;
+          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
+                                    VFragIndex,&InterMVect);
+
+          /* Update Prior last mv with last mv */
+          PriorLastInterMVect.x = LastInterMVect.x;
+          PriorLastInterMVect.y = LastInterMVect.y;
+
+          /* Note last inter MV for future use */
+          LastInterMVect.x = InterMVect.x;
+          LastInterMVect.y = InterMVect.y;
+
+          AddMotionVector( cpi, &InterMVect);
+
+        } else if ( BestError == MBGF_MVError ) {
+
+          cpi->MBCodingMode = CODE_GOLDEN_MV;
+          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
+                                    VFragIndex,&GFMVect);
+
+          /* Note last inter GF MV for future use */
+          LastGFMVect.x = GFMVect.x;
+          LastGFMVect.y = GFMVect.y;
+
+          AddMotionVector( cpi, &GFMVect);
+        } else if ( BestError == MBInterFOURMVError ) {
+          cpi->MBCodingMode = CODE_INTER_FOURMV;
+
+          /* Calculate the UV vectors as the average of the Y plane ones. */
+          /* First .x component */
+          FourMVect[4].x = FourMVect[0].x + FourMVect[1].x +
+            FourMVect[2].x + FourMVect[3].x;
+          if ( FourMVect[4].x >= 0 )
+            FourMVect[4].x = (FourMVect[4].x + 2) / 4;
+          else
+            FourMVect[4].x = (FourMVect[4].x - 2) / 4;
+          FourMVect[5].x = FourMVect[4].x;
+
+          /* Then .y component */
+          FourMVect[4].y = FourMVect[0].y + FourMVect[1].y +
+            FourMVect[2].y + FourMVect[3].y;
+          if ( FourMVect[4].y >= 0 )
+            FourMVect[4].y = (FourMVect[4].y + 2) / 4;
+          else
+            FourMVect[4].y = (FourMVect[4].y - 2) / 4;
+          FourMVect[5].y = FourMVect[4].y;
+
+          SetFragMotionVectorAndMode(cpi, YFragIndex, &FourMVect[0]);
+          SetFragMotionVectorAndMode(cpi, YFragIndex + 1, &FourMVect[1]);
+          SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments,
+                                     &FourMVect[2]);
+          SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments + 1,
+                                     &FourMVect[3]);
+          SetFragMotionVectorAndMode(cpi, UFragIndex, &FourMVect[4]);
+          SetFragMotionVectorAndMode(cpi, VFragIndex, &FourMVect[5]);
+
+          /* Note the four MVs values for current macro-block. */
+          AddMotionVector( cpi, &FourMVect[0]);
+          AddMotionVector( cpi, &FourMVect[1]);
+          AddMotionVector( cpi, &FourMVect[2]);
+          AddMotionVector( cpi, &FourMVect[3]);
+
+          /* Update Prior last mv with last mv */
+          PriorLastInterMVect.x = LastInterMVect.x;
+          PriorLastInterMVect.y = LastInterMVect.y;
+
+          /* Note last inter MV for future use */
+          LastInterMVect.x = FourMVect[3].x;
+          LastInterMVect.y = FourMVect[3].y;
+
+        } else {
+
+          cpi->MBCodingMode = CODE_INTRA;
+          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
+                                    VFragIndex,&ZeroVect);
+        }
+
+
+        /* setting up mode specific block types
            *******************************************************/
-                
-	*InterError += (BestError>>8);
-	*IntraError += (MBIntraError>>8);
-	
-	
+
+        *InterError += (BestError>>8);
+        *IntraError += (MBIntraError>>8);
+
+
       }
       SB++;
-      
+
     }
   }
 
@@ -1535,7 +1544,7 @@
 
   /* Output the frame type (base/key frame or inter frame) */
   oggpackB_write( opb, cpi->pb.FrameType, 1 );
-  
+
   /* Write out details of the current value of Q... variable resolution. */
   for ( i = 0; i < Q_TABLE_SIZE; i++ ) {
     if ( cpi->pb.ThisFrameQualityValue == cpi->pb.QThreshTable[i] ) {
@@ -1543,20 +1552,20 @@
       break;
     }
   }
-   
+
   if ( i == Q_TABLE_SIZE ) {
     /* An invalid DCT value was specified.  */
     /*IssueWarning( "Invalid Q Multiplier" );*/
     oggpackB_write( opb, 31, 6 );
   }
-  
+
   /* If the frame was a base frame then write out the frame dimensions. */
   if ( cpi->pb.FrameType == BASE_FRAME ) {
     /* Key frame type / method */
     oggpackB_write( opb, cpi->pb.KeyFrameType, 1 );
-    
+
     /* Spare configuration bits */
-    oggpackB_write( opb, 0, 2 );        
+    oggpackB_write( opb, 0, 2 );
   }
 }
 

<p><p>1.14      +228 -232  theora/lib/encoder_internal.h

Index: encoder_internal.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/encoder_internal.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- encoder_internal.h	9 Jun 2003 01:45:19 -0000	1.13
+++ encoder_internal.h	10 Jun 2003 01:31:33 -0000	1.14
@@ -10,8 +10,8 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: encoder_internal.h,v 1.13 2003/06/09 01:45:19 tterribe Exp $
+  function:
+  last mod: $Id: encoder_internal.h,v 1.14 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
@@ -38,7 +38,7 @@
 #define BASE_FRAME              0
 #define NORMAL_FRAME            1
 
-#define MAX_MODES               8 
+#define MAX_MODES               8
 #define MODE_BITS               3
 #define MODE_METHODS            8
 #define MODE_METHOD_BITS        3
@@ -52,7 +52,7 @@
 #define MAX_PREV_FRAMES        16
 
 /* Number of search sites for a 4-step search (at pixel accuracy) */
-#define MAX_SEARCH_SITES       33             
+#define MAX_SEARCH_SITES       33
 
 #define VERY_BEST_Q            10
 #define MIN_BPB_FACTOR        0.3
@@ -69,7 +69,7 @@
   ogg_uint32_t BaseQ;
   ogg_uint32_t MaxQ;            /* Absolute Max Q allowed. */
   ogg_uint32_t ActiveMaxQ;      /* Currently active Max Q */
-  
+
 } CONFIG_TYPE2;
 
 typedef struct coeffNode{
@@ -82,7 +82,7 @@
   unsigned char * Yuv1ptr;
   unsigned char * SrfWorkSpcPtr;
   unsigned char * disp_fragments;
-  
+
   ogg_uint32_t  * RegionIndex; /* Gives pixel index for top left of
                                  each block */
   ogg_uint32_t    VideoFrameHeight;
@@ -103,26 +103,26 @@
 
 typedef struct PP_INSTANCE {
   ogg_uint32_t  PrevFrameLimit;
-  
-  ogg_uint32_t   *ScanPixelIndexTable;               
+
+  ogg_uint32_t   *ScanPixelIndexTable;
   signed char    *ScanDisplayFragments;
-  
+
   signed char    *PrevFragments[MAX_PREV_FRAMES];
-  
+
   ogg_uint32_t   *FragScores; /* The individual frame difference ratings. */
   signed char    *SameGreyDirPixels;
   signed char    *BarBlockMap;
-  
+
   /* Number of pixels changed by diff threshold in row of a fragment. */
-  unsigned char  *FragDiffPixels;  
+  unsigned char  *FragDiffPixels;
 
-  unsigned char  *PixelScores;  
+  unsigned char  *PixelScores;
   unsigned char  *PixelChangedMap;
   unsigned char  *ChLocals;
-  ogg_int16_t    *yuv_differences;  
+  ogg_int16_t    *yuv_differences;
   ogg_int32_t    *RowChangedPixels;
   signed char    *TmpCodedMap;
-  
+
   /* Plane pointers and dimension variables */
   unsigned char  * YPlanePtr0;
   unsigned char  * YPlanePtr1;
@@ -130,88 +130,88 @@
   unsigned char  * UPlanePtr1;
   unsigned char  * VPlanePtr0;
   unsigned char  * VPlanePtr1;
-  
+
   ogg_uint32_t    VideoYPlaneWidth;
   ogg_uint32_t    VideoYPlaneHeight;
   ogg_uint32_t    VideoUVPlaneWidth;
   ogg_uint32_t    VideoUVPlaneHeight;
-  
+
   ogg_uint32_t    VideoYPlaneStride;
   ogg_uint32_t    VideoUPlaneStride;
   ogg_uint32_t    VideoVPlaneStride;
-  
+
   /* Scan control variables. */
   unsigned char   HFragPixels;
   unsigned char   VFragPixels;
-  
+
   ogg_uint32_t    ScanFrameFragments;
   ogg_uint32_t    ScanYPlaneFragments;
   ogg_uint32_t    ScanUVPlaneFragments;
   ogg_uint32_t    ScanHFragments;
   ogg_uint32_t    ScanVFragments;
-  
-  ogg_uint32_t    YFramePixels; 
-  ogg_uint32_t    UVFramePixels; 
-  
+
+  ogg_uint32_t    YFramePixels;
+  ogg_uint32_t    UVFramePixels;
+
   ogg_uint32_t    SgcThresh;
-  
+
   ogg_uint32_t    OutputBlocksUpdated;
   ogg_uint32_t    KFIndicator;
-  
+
   /* The pre-processor scan configuration. */
   SCAN_CONFIG_DATA ScanConfig;
-  
+
   ogg_int32_t   SRFGreyThresh;
   ogg_int32_t   SRFColThresh;
   ogg_int32_t   SgcLevelThresh;
   ogg_int32_t   SuvcLevelThresh;
-  
+
   ogg_uint32_t  NoiseSupLevel;
-  
+
   /* Block Thresholds. */
   ogg_uint32_t  PrimaryBlockThreshold;
   unsigned char LineSearchTripTresh;
 
   int   PAKEnabled;
-  
-  int   LevelThresh; 
-  int   NegLevelThresh; 
+
+  int   LevelThresh;
+  int   NegLevelThresh;
   int   SrfThresh;
   int   NegSrfThresh;
   int   HighChange;
-  int   NegHighChange;     
-  
+  int   NegHighChange;
+
   /* Threshold lookup tables */
   unsigned char SrfPakThreshTable[512];
   unsigned char SrfThreshTable[512];
   unsigned char SgcThreshTable[512];
-  
+
   /* Variables controlling S.A.D. break outs. */
   ogg_uint32_t GrpLowSadThresh;
   ogg_uint32_t GrpHighSadThresh;
   ogg_uint32_t ModifiedGrpLowSadThresh;
   ogg_uint32_t ModifiedGrpHighSadThresh;
-  
+
   ogg_int32_t  PlaneHFragments;
   ogg_int32_t  PlaneVFragments;
   ogg_int32_t  PlaneHeight;
   ogg_int32_t  PlaneWidth;
   ogg_int32_t  PlaneStride;
-  
+
   ogg_uint32_t BlockThreshold;
   ogg_uint32_t BlockSgcThresh;
   double UVBlockThreshCorrection;
   double UVSgcCorrection;
-  
-  double YUVPlaneCorrectionFactor;        
+
+  double YUVPlaneCorrectionFactor;
   double AbsDiff_ScoreMultiplierTable[256];
   unsigned char  NoiseScoreBoostTable[256];
   unsigned char  MaxLineSearchLen;
-  
+
   ogg_int32_t YuvDiffsCircularBufferSize;
   ogg_int32_t ChLocalsCircularBufferSize;
   ogg_int32_t PixelMapCircularBufferSize;
-  
+
 } PP_INSTANCE;
 
 
@@ -228,15 +228,15 @@
     CODE_INTER_FOURMV     = 0x7  /* Inter prediction 4MV per macro block. */
 } CODING_MODE;
 
-typedef struct HUFF_ENTRY {            
+typedef struct HUFF_ENTRY {
   struct HUFF_ENTRY *ZeroChild;
   struct HUFF_ENTRY *OneChild;
   struct HUFF_ENTRY *Previous;
   struct HUFF_ENTRY *Next;
   ogg_int32_t        Value;
   ogg_uint32_t       Frequency;
-    
-} HUFF_ENTRY; 
+
+} HUFF_ENTRY;
 
 typedef struct codec_setup_info {
   ogg_uint32_t QThreshTable[Q_TABLE_SIZE];
@@ -257,16 +257,16 @@
 
   /***********************************************************************/
   /* Decoder and Frame Type Information */
-  
+
   int           DecoderErrorCode;
   int           FramesHaveBeenSkipped;
-  
-  int           PostProcessEnabled;  
+
+  int           PostProcessEnabled;
   ogg_uint32_t  PostProcessingLevel;    /* Perform post processing */
-  
+
   /* Frame Info */
   CODING_MODE   CodingMode;
-  unsigned char FrameType;       
+  unsigned char FrameType;
   unsigned char KeyFrameType;
   ogg_uint32_t  QualitySetting;
   ogg_uint32_t  FrameQIndex;            /* Quality specified as a
@@ -279,20 +279,20 @@
 
   /**********************************************************************/
   /* Frame Size & Index Information */
-  
-  ogg_uint32_t  YPlaneSize;  
-  ogg_uint32_t  UVPlaneSize;  
-  ogg_uint32_t  YStride;  
-  ogg_uint32_t  UVStride;  
+
+  ogg_uint32_t  YPlaneSize;
+  ogg_uint32_t  UVPlaneSize;
+  ogg_uint32_t  YStride;
+  ogg_uint32_t  UVStride;
   ogg_uint32_t  VFragments;
   ogg_uint32_t  HFragments;
   ogg_uint32_t  UnitFragments;
   ogg_uint32_t  YPlaneFragments;
   ogg_uint32_t  UVPlaneFragments;
-  
+
   ogg_uint32_t  ReconYPlaneSize;
   ogg_uint32_t  ReconUVPlaneSize;
-  
+
   ogg_uint32_t  YDataOffset;
   ogg_uint32_t  UDataOffset;
   ogg_uint32_t  VDataOffset;
@@ -303,7 +303,7 @@
   ogg_uint32_t  UVSuperBlocks;  /* Number of SuperBlocks in a U or V frame */
   ogg_uint32_t  SuperBlocks;    /* Total number of SuperBlocks in a
                                    Y,U,V frame */
-  
+
   ogg_uint32_t  YSBRows;        /* Number of rows of SuperBlocks in a
                                    Y frame */
   ogg_uint32_t  YSBCols;        /* Number of cols of SuperBlocks in a
@@ -312,7 +312,7 @@
                                    U or V frame */
   ogg_uint32_t  UVSBCols;       /* Number of cols of SuperBlocks in a
                                    U or V frame */
-  
+
   ogg_uint32_t  YMacroBlocks;   /* Number of Macro-Blocks in Y component */
   ogg_uint32_t  UVMacroBlocks;  /* Number of Macro-Blocks in U/V component */
   ogg_uint32_t  MacroBlocks;    /* Total number of Macro-Blocks */
@@ -320,26 +320,26 @@
   /**********************************************************************/
   /* Frames  */
   YUV_BUFFER_ENTRY *ThisFrameRecon;
-  YUV_BUFFER_ENTRY *GoldenFrame; 
+  YUV_BUFFER_ENTRY *GoldenFrame;
   YUV_BUFFER_ENTRY *LastFrameRecon;
   YUV_BUFFER_ENTRY *PostProcessBuffer;
-  
+
   /**********************************************************************/
   /* Fragment Information */
   ogg_uint32_t  *pixel_index_table;        /* start address of first
-					      pixel of fragment in
-					      source */
+                                              pixel of fragment in
+                                              source */
   ogg_uint32_t  *recon_pixel_index_table;  /* start address of first
-					      pixel in recon buffer */
+                                              pixel in recon buffer */
 
   unsigned char *display_fragments;        /* Fragment update map */
   unsigned char *skipped_display_fragments;/* whether fragment YUV
-					      Conversion and update is to be
-					      skipped */
+                                              Conversion and update is to be
+                                              skipped */
   ogg_int32_t   *CodedBlockList;           /* A list of fragment indices for
-					      coded blocks. */
+                                              coded blocks. */
   MOTION_VECTOR *FragMVect;                /* fragment motion vectors */
-  
+
   ogg_uint32_t  *FragTokenCounts;          /* Number of tokens per fragment */
   ogg_uint32_t  (*TokenList)[128];         /* Fragment Token Pointers */
 
@@ -350,29 +350,29 @@
                                               coefficients data */
 
   unsigned char *FragCoeffs;                /* # of coeffs decoded so far for
-					       fragment */
+                                               fragment */
   unsigned char *FragCoefEOB;               /* Position of last non 0 coef
-						within QFragData */
+                                                within QFragData */
   Q_LIST_ENTRY (*QFragData)[64];            /* Fragment Coefficients
                                                Array Pointers */
   CODING_MODE   *FragCodingMethod;          /* coding method for the
                                                fragment */
 
-  //**********************************************************************/
+  /***********************************************************************/
   /* pointers to addresses used for allocation and deallocation the
       others are rounded up to the nearest 32 bytes */
 
   COEFFNODE     *_Nodes;
   ogg_uint32_t  *transIndex;                    /* ptr to table of
-						   transposed indexes */
-  
-  /**********************************************************************/
+                                                   transposed indexes */
+
+  /***********************************************************************/
   ogg_int32_t    bumpLast;
-  
+
   /* Macro Block and SuperBlock Information */
   ogg_int32_t  (*BlockMap)[4][4];               /* super block + sub macro
-						   block + sub frag ->
-						   FragIndex */
+                                                   block + sub frag ->
+                                                   FragIndex */
 
   /* Coded flag arrays and counters for them */
   unsigned char *SBCodedFlags;
@@ -382,42 +382,42 @@
 
   /**********************************************************************/
   ogg_uint32_t   EOB_Run;
-  
+
   COORDINATE    *FragCoordinates;
   MOTION_VECTOR  MVector;
   ogg_int32_t    ReconPtr2Offset;       /* Offset for second reconstruction
-					   in half pixel MC */
-  Q_LIST_ENTRY  *quantized_list;  
+                                           in half pixel MC */
+  Q_LIST_ENTRY  *quantized_list;
   ogg_int16_t   *ReconDataBuffer;
   Q_LIST_ENTRY   InvLastIntraDC;
   Q_LIST_ENTRY   InvLastInterDC;
   Q_LIST_ENTRY   LastIntraDC;
   Q_LIST_ENTRY   LastInterDC;
-  
+
   ogg_uint32_t   BlocksToDecode;        /* Blocks to be decoded this frame */
   ogg_uint32_t   DcHuffChoice;          /* Huffman table selection variables */
-  unsigned char  ACHuffChoice; 
+  unsigned char  ACHuffChoice;
   ogg_uint32_t   QuadMBListIndex;
-  
+
   ogg_int32_t    ByteCount;
-  
+
   ogg_uint32_t   bit_pattern;
-  unsigned char  bits_so_far; 
+  unsigned char  bits_so_far;
   unsigned char  NextBit;
   ogg_int32_t    BitsLeft;
-  
+
   ogg_int16_t   *DequantBuffer;
-  
+
   ogg_int32_t    fp_quant_InterUV_coeffs[64];
   ogg_int32_t    fp_quant_InterUV_round[64];
   ogg_int32_t    fp_ZeroBinSize_InterUV[64];
-  
+
   ogg_int16_t   *TmpReconBuffer;
   ogg_int16_t   *TmpDataBuffer;
-  
+
   /* Loop filter bounding values */
   ogg_int32_t    FiltBoundingValue[512];
-  
+
   /* Dequantiser and rounding tables */
   ogg_uint32_t   QThreshTable[Q_TABLE_SIZE];
   Q_LIST_ENTRY   DcScaleFactorTable[Q_TABLE_SIZE];
@@ -429,12 +429,12 @@
   ogg_int32_t    quant_Y_coeffs[64];
   ogg_int32_t    quant_UV_coeffs[64];
   ogg_int32_t    fp_quant_Y_coeffs[64]; /* used in reiniting quantizers */
-  
+
   HUFF_ENTRY    *HuffRoot_VP3x[NUM_HUFF_TABLES];
   ogg_uint32_t  *HuffCodeArray_VP3x[NUM_HUFF_TABLES];
   unsigned char *HuffCodeLengthArray_VP3x[NUM_HUFF_TABLES];
   unsigned char *ExtraBitLengths_VP3x;
-  
+
   /* Quantiser and rounding tables */
   ogg_int32_t    fp_quant_UV_coeffs[64];
   ogg_int32_t    fp_quant_Inter_coeffs[64];
@@ -454,11 +454,11 @@
 
   /* Predictor used in choosing entropy table for decoding block patterns. */
   unsigned char  BlockPatternPredictor;
-  
+
   short          Modifier[4][512];
   short         *ModifierPointer[4];
-        
-  unsigned char *DataOutputInPtr;                 
+
+  unsigned char *DataOutputInPtr;
 
 
 } PB_INSTANCE;
@@ -491,51 +491,51 @@
   ogg_int32_t      TotalMotionScore;
   ogg_int64_t      TotalByteCount;
   ogg_int32_t      FixedQ;
-	
+
   /* Frame Statistics  */
   signed char      InterCodeCount;
-  ogg_int64_t      CurrentFrame;                                
+  ogg_int64_t      CurrentFrame;
   ogg_int64_t      CarryOver ;
   ogg_uint32_t     LastFrameSize;
   ogg_uint32_t     FrameBitCount;
   int              ThisIsFirstFrame;
   int              ThisIsKeyFrame;
-	
-  ogg_int32_t      MotionScore;   
+
+  ogg_int32_t      MotionScore;
   ogg_uint32_t     RegulationBlocks;
-  ogg_int32_t      RecoveryMotionScore;   
+  ogg_int32_t      RecoveryMotionScore;
   int              RecoveryBlocksAdded ;
   double           ProportionRecBlocks;
   double           MaxRecFactor ;
-  
+
   /* Rate Targeting variables. */
   ogg_uint32_t     ThisFrameTargetBytes;
   double           BpbCorrectionFactor;
-  
+
   /* Up regulation variables */
   ogg_uint32_t     FinalPassLastPos;  /* Used to regulate a final
-					 unrestricted high quality
-					 pass. */
-  ogg_uint32_t     LastEndSB;	      /* Where we were in the loop
+                                         unrestricted high quality
+                                         pass. */
+  ogg_uint32_t     LastEndSB;         /* Where we were in the loop
                                          last time. */
   ogg_uint32_t     ResidueLastEndSB;  /* Where we were in the residue
-					 update loop last time. */
-  
+                                         update loop last time. */
+
   /* Controlling Block Selection */
-  ogg_uint32_t     MVChangeFactor;     
-  ogg_uint32_t     FourMvChangeFactor;           
-  ogg_uint32_t     MinImprovementForNewMV;   
+  ogg_uint32_t     MVChangeFactor;
+  ogg_uint32_t     FourMvChangeFactor;
+  ogg_uint32_t     MinImprovementForNewMV;
   ogg_uint32_t     ExhaustiveSearchThresh;
-  ogg_uint32_t     MinImprovementForFourMV;   
+  ogg_uint32_t     MinImprovementForFourMV;
   ogg_uint32_t     FourMVThreshold;
-  
-  /* Module shared data structures. */            
+
+  /* Module shared data structures. */
   ogg_int32_t      frame_target_rate;
   ogg_int32_t      BaseLineFrameTargetRate;
   ogg_int32_t      min_blocks_per_frame;
   ogg_uint32_t     tot_bytes_old;
-  
-  //********************************************************************/
+
+  /*********************************************************************/
   /* Frames  Used in the selecetive convolution filtering of the Y plane. */
   unsigned char    *ConvDestBuffer;
   YUV_BUFFER_ENTRY *yuv0ptr;
@@ -547,18 +547,18 @@
   ogg_uint32_t     *OptimisedTokenListEb; /* Optimised token list extra bits */
   unsigned char    *OptimisedTokenList;   /* Optimised token list. */
   unsigned char    *OptimisedTokenListHi; /* Optimised token list huffman
-					     table index */
-  
+                                             table index */
+
   unsigned char    *OptimisedTokenListPl; /* Plane to which the token
-					     belongs Y = 0 or UV = 1 */
-  ogg_int32_t       OptimisedTokenCount;	   /* Count of Optimized tokens */
+                                             belongs Y = 0 or UV = 1 */
+  ogg_int32_t       OptimisedTokenCount;           /* Count of Optimized tokens */
   ogg_uint32_t      RunHuffIndex;         /* Huffman table in force at
-					     the start of a run */
+                                             the start of a run */
   ogg_uint32_t      RunPlaneIndex;        /* The plane (Y=0 UV=1) to
-					     which the first token in
-					     an EOB run belonged. */
-  
-  
+                                             which the first token in
+                                             an EOB run belonged. */
+
+
   ogg_uint32_t      TotTokenCount;
   ogg_int32_t       TokensToBeCoded;
   ogg_int32_t       TokensCoded;
@@ -569,39 +569,39 @@
   unsigned char    *PartiallyCodedFlags;
   unsigned char    *PartiallyCodedMbPatterns;
   unsigned char    *UncodedMbFlags;
-  
+
   unsigned char    *extra_fragments;   /* extra updates not
-					  recommended by pre-processor */
+                                          recommended by pre-processor */
   ogg_int16_t      *OriginalDC;
-  
+
   ogg_uint32_t     *FragmentLastQ;     /* Array used to keep track of
-					  quality at which each
-					  fragment was last
-					  updated. */
+                                          quality at which each
+                                          fragment was last
+                                          updated. */
   unsigned char    *FragTokens;
   ogg_uint32_t     *FragTokenCounts;   /* Number of tokens per fragment */
-  
+
   ogg_uint32_t     *RunHuffIndices;
-  ogg_uint32_t     *LastCodedErrorScore; 
+  ogg_uint32_t     *LastCodedErrorScore;
   ogg_uint32_t     *ModeList;
   MOTION_VECTOR    *MVList;
-  
+
   unsigned char    *BlockCodedFlags;
-	
+
   ogg_uint32_t      MvListCount;
   ogg_uint32_t      ModeListCount;
-  
-  
+
+
   unsigned char    *DataOutputBuffer;
   /*********************************************************************/
-	
+
   ogg_uint32_t      RunLength;
   ogg_uint32_t      MaxBitTarget;     /* Cut off target for rate capping */
   double            BitRateCapFactor; /* Factor relating normal frame target
-					 to cut off target. */
-	
+                                         to cut off target. */
+
   unsigned char     MBCodingMode;     /* Coding mode flags */
-  
+
   ogg_int32_t       MVPixelOffsetY[MAX_SEARCH_SITES];
   ogg_uint32_t      InterTripOutThresh;
   unsigned char     MVEnabled;
@@ -614,23 +614,23 @@
                                                compensation */
   signed char       HalfPixelXOffset[9];    /* Half pixel MV offsets for X */
   signed char       HalfPixelYOffset[9];    /* Half pixel MV offsets for Y */
-  
+
   ogg_uint32_t      bit_pattern ;
-  unsigned char     bits_so_far ; 
+  unsigned char     bits_so_far ;
   ogg_uint32_t      lastval ;
   ogg_uint32_t      lastrun ;
-  
-  Q_LIST_ENTRY     *quantized_list;  
-  
+
+  Q_LIST_ENTRY     *quantized_list;
+
   MOTION_VECTOR     MVector;
   ogg_uint32_t      TempBitCount;
   ogg_int16_t      *DCT_codes; /* Buffer that stores the result of
                                   Forward DCT */
   ogg_int16_t      *DCTDataBuffer; /* Input data buffer for Forward DCT */
-  
+
   /* Motion compensation related variables */
   ogg_uint32_t      MvMaxExtent;
-  
+
   double            QTargetModifier[Q_TABLE_SIZE];
 
   /* instances (used for reconstructing buffers and to hold tokens etc.) */
@@ -648,12 +648,11 @@
 static ogg_int32_t andmask[2]={0xff,0x00};
 static ogg_int32_t ormask[4]={0x00,0xff,0xff,0xff};
 
-//#define clamp255(val)  ( val<0 ? 0: ( val>255 ? 255:val ) )
 #define clamp255(x) ((unsigned char)((((x)<0)-1) & ((x) | -((x)>255))))
 
 extern void ConfigurePP( PP_INSTANCE *ppi, int Level ) ;
-extern ogg_uint32_t YUVAnalyseFrame( PP_INSTANCE *ppi, 
-				     ogg_uint32_t * KFIndicator );
+extern ogg_uint32_t YUVAnalyseFrame( PP_INSTANCE *ppi,
+                                     ogg_uint32_t * KFIndicator );
 
 extern void ClearPPInstance(PP_INSTANCE *ppi);
 extern void InitPPInstance(PP_INSTANCE *ppi);
@@ -662,55 +661,55 @@
 extern void ClearPBInstance(PB_INSTANCE *pbi);
 
 
-extern void IDctSlow(  Q_LIST_ENTRY * InputData, 
-		       ogg_int16_t *QuantMatrix, 
-		       ogg_int16_t * OutputData ) ;
-
-extern void IDct10( Q_LIST_ENTRY * InputData, 
-		    ogg_int16_t *QuantMatrix, 
-		    ogg_int16_t * OutputData );
-
-extern void IDct1( Q_LIST_ENTRY * InputData, 
-		   ogg_int16_t *QuantMatrix, 
-		   ogg_int16_t * OutputData );
-
-extern void ReconIntra( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
-			ogg_int16_t * ChangePtr, ogg_uint32_t LineStep );
-
-extern void ReconInter( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
-			unsigned char * RefPtr, ogg_int16_t * ChangePtr, 
-			ogg_uint32_t LineStep ) ;
-
-extern void ReconInterHalfPixel2( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
-				  unsigned char * RefPtr1, 
-				  unsigned char * RefPtr2, 
-				  ogg_int16_t * ChangePtr, 
-				  ogg_uint32_t LineStep ) ;
+extern void IDctSlow(  Q_LIST_ENTRY * InputData,
+                       ogg_int16_t *QuantMatrix,
+                       ogg_int16_t * OutputData ) ;
+
+extern void IDct10( Q_LIST_ENTRY * InputData,
+                    ogg_int16_t *QuantMatrix,
+                    ogg_int16_t * OutputData );
+
+extern void IDct1( Q_LIST_ENTRY * InputData,
+                   ogg_int16_t *QuantMatrix,
+                   ogg_int16_t * OutputData );
+
+extern void ReconIntra( PB_INSTANCE *pbi, unsigned char * ReconPtr,
+                        ogg_int16_t * ChangePtr, ogg_uint32_t LineStep );
+
+extern void ReconInter( PB_INSTANCE *pbi, unsigned char * ReconPtr,
+                        unsigned char * RefPtr, ogg_int16_t * ChangePtr,
+                        ogg_uint32_t LineStep ) ;
+
+extern void ReconInterHalfPixel2( PB_INSTANCE *pbi, unsigned char * ReconPtr,
+                                  unsigned char * RefPtr1,
+                                  unsigned char * RefPtr2,
+                                  ogg_int16_t * ChangePtr,
+                                  ogg_uint32_t LineStep ) ;
 
 extern void SetupLoopFilter(PB_INSTANCE *pbi);
-extern void CopyBlock(unsigned char *src, 
-		      unsigned char *dest, 
-		      unsigned int srcstride);
+extern void CopyBlock(unsigned char *src,
+                      unsigned char *dest,
+                      unsigned int srcstride);
 extern void LoopFilter(PB_INSTANCE *pbi);
 extern void ReconRefFrames (PB_INSTANCE *pbi);
-extern void ExpandToken( Q_LIST_ENTRY * ExpandedBlock, 
-			 unsigned char * CoeffIndex, ogg_uint32_t Token, 
-			 ogg_int32_t ExtraBits );
+extern void ExpandToken( Q_LIST_ENTRY * ExpandedBlock,
+                         unsigned char * CoeffIndex, ogg_uint32_t Token,
+                         ogg_int32_t ExtraBits );
 extern void ClearDownQFragData(PB_INSTANCE *pbi);
 extern void select_Y_quantiser ( PB_INSTANCE *pbi );
 extern void select_Inter_quantiser ( PB_INSTANCE *pbi );
 extern void select_UV_quantiser ( PB_INSTANCE *pbi );
 extern void select_InterUV_quantiser ( PB_INSTANCE *pbi );
-extern void quantize( PB_INSTANCE *pbi, 
-		      ogg_int16_t * DCT_block, 
-		      Q_LIST_ENTRY * quantized_list);
+extern void quantize( PB_INSTANCE *pbi,
+                      ogg_int16_t * DCT_block,
+                      Q_LIST_ENTRY * quantized_list);
 extern void UpdateQ( PB_INSTANCE *pbi, ogg_uint32_t NewQ );
 extern void UpdateQC( CP_INSTANCE *cpi, ogg_uint32_t NewQ );
 extern void fdct_short ( ogg_int16_t * InputData, ogg_int16_t * OutputData );
-extern ogg_uint32_t DPCMTokenizeBlock (CP_INSTANCE *cpi, 
-				       ogg_int32_t FragIndex);
-extern void TransformQuantizeBlock (CP_INSTANCE *cpi, ogg_int32_t FragIndex, 
-				    ogg_uint32_t PixelsPerLine ) ;
+extern ogg_uint32_t DPCMTokenizeBlock (CP_INSTANCE *cpi,
+                                       ogg_int32_t FragIndex);
+extern void TransformQuantizeBlock (CP_INSTANCE *cpi, ogg_int32_t FragIndex,
+                                    ogg_uint32_t PixelsPerLine ) ;
 extern void ClearFragmentInfo(PB_INSTANCE * pbi);
 extern void InitFragmentInfo(PB_INSTANCE * pbi);
 extern void ClearFrameInfo(PB_INSTANCE * pbi);
@@ -733,63 +732,60 @@
 extern void UpdateFragQIndex(PB_INSTANCE *pbi);
 extern void PostProcess(PB_INSTANCE *pbi);
 extern void InitMotionCompensation ( CP_INSTANCE *cpi );
-extern ogg_uint32_t GetMBIntraError (CP_INSTANCE *cpi, ogg_uint32_t FragIndex, 
-				     ogg_uint32_t PixelsPerLine ) ;
-extern ogg_uint32_t GetMBInterError (CP_INSTANCE *cpi, 
-				     unsigned char * SrcPtr, 
-				     unsigned char * RefPtr, 
-				     ogg_uint32_t FragIndex, 
-				     ogg_int32_t LastXMV, 
-				     ogg_int32_t LastYMV, 
-				     ogg_uint32_t PixelsPerLine ) ;
+extern ogg_uint32_t GetMBIntraError (CP_INSTANCE *cpi, ogg_uint32_t FragIndex,
+                                     ogg_uint32_t PixelsPerLine ) ;
+extern ogg_uint32_t GetMBInterError (CP_INSTANCE *cpi,
+                                     unsigned char * SrcPtr,
+                                     unsigned char * RefPtr,
+                                     ogg_uint32_t FragIndex,
+                                     ogg_int32_t LastXMV,
+                                     ogg_int32_t LastYMV,
+                                     ogg_uint32_t PixelsPerLine ) ;
 extern void WriteFrameHeader( CP_INSTANCE *cpi) ;
-extern ogg_uint32_t GetMBMVInterError (CP_INSTANCE *cpi, 
-				       unsigned char * RefFramePtr, 
-				       ogg_uint32_t FragIndex, 
-				       ogg_uint32_t PixelsPerLine, 
-				       ogg_int32_t *MVPixelOffset, 
-				       MOTION_VECTOR *MV );
-extern ogg_uint32_t GetMBMVExhaustiveSearch (CP_INSTANCE *cpi, 
-					     unsigned char * RefFramePtr, 
-					     ogg_uint32_t FragIndex, 
-					     ogg_uint32_t PixelsPerLine, 
-					     MOTION_VECTOR *MV );
-extern ogg_uint32_t GetFOURMVExhaustiveSearch (CP_INSTANCE *cpi, 
-					       unsigned char * RefFramePtr, 
-					       ogg_uint32_t FragIndex, 
-					       ogg_uint32_t PixelsPerLine, 
-					       MOTION_VECTOR *MV ) ;
+extern ogg_uint32_t GetMBMVInterError (CP_INSTANCE *cpi,
+                                       unsigned char * RefFramePtr,
+                                       ogg_uint32_t FragIndex,
+                                       ogg_uint32_t PixelsPerLine,
+                                       ogg_int32_t *MVPixelOffset,
+                                       MOTION_VECTOR *MV );
+extern ogg_uint32_t GetMBMVExhaustiveSearch (CP_INSTANCE *cpi,
+                                             unsigned char * RefFramePtr,
+                                             ogg_uint32_t FragIndex,
+                                             ogg_uint32_t PixelsPerLine,
+                                             MOTION_VECTOR *MV );
+extern ogg_uint32_t GetFOURMVExhaustiveSearch (CP_INSTANCE *cpi,
+                                               unsigned char * RefFramePtr,
+                                               ogg_uint32_t FragIndex,
+                                               ogg_uint32_t PixelsPerLine,
+                                               MOTION_VECTOR *MV ) ;
 extern ogg_uint32_t EncodeData(CP_INSTANCE *cpi);
-extern ogg_uint32_t PickIntra( CP_INSTANCE *cpi, 
-			       ogg_uint32_t SBRows, 
-			       ogg_uint32_t SBCols);
-extern ogg_uint32_t PickModes(CP_INSTANCE *cpi, 
-			      ogg_uint32_t SBRows, 
-			      ogg_uint32_t SBCols, 
-			      ogg_uint32_t PixelsPerLine, 
-			      ogg_uint32_t *InterError, 
-			      ogg_uint32_t *IntraError);
+extern ogg_uint32_t PickIntra( CP_INSTANCE *cpi,
+                               ogg_uint32_t SBRows,
+                               ogg_uint32_t SBCols);
+extern ogg_uint32_t PickModes(CP_INSTANCE *cpi,
+                              ogg_uint32_t SBRows,
+                              ogg_uint32_t SBCols,
+                              ogg_uint32_t PixelsPerLine,
+                              ogg_uint32_t *InterError,
+                              ogg_uint32_t *IntraError);
 
 extern CODING_MODE FrArrayUnpackMode(PB_INSTANCE *pbi);
-extern void CreateBlockMapping ( ogg_int32_t  (*BlockMap)[4][4], 
-				 ogg_uint32_t YSuperBlocks, 
-				 ogg_uint32_t UVSuperBlocks, 
-				 ogg_uint32_t HFrags, ogg_uint32_t VFrags );
-extern void UpRegulateDataStream (CP_INSTANCE *cpi, ogg_uint32_t RegulationQ, 
-				  ogg_int32_t RecoveryBlocks ) ;
+extern void CreateBlockMapping ( ogg_int32_t  (*BlockMap)[4][4],
+                                 ogg_uint32_t YSuperBlocks,
+                                 ogg_uint32_t UVSuperBlocks,
+                                 ogg_uint32_t HFrags, ogg_uint32_t VFrags );
+extern void UpRegulateDataStream (CP_INSTANCE *cpi, ogg_uint32_t RegulationQ,
+                                  ogg_int32_t RecoveryBlocks ) ;
 extern void RegulateQ( CP_INSTANCE *cpi, ogg_int32_t UpdateScore );
 extern void CopyBackExtraFrags(CP_INSTANCE *cpi);
-extern void UpdateUMVBorder( PB_INSTANCE *pbi, 
-			     unsigned char * DestReconPtr );
+extern void UpdateUMVBorder( PB_INSTANCE *pbi,
+                             unsigned char * DestReconPtr );
 extern void PInitFrameInfo(PP_INSTANCE * ppi);
 extern int GetFrameType(PB_INSTANCE *pbi);
 extern void SetFrameType( PB_INSTANCE *pbi,unsigned char FrType );
 extern double GetEstimatedBpb( CP_INSTANCE *cpi, ogg_uint32_t TargetQ );
 extern void ClearTmpBuffers(PB_INSTANCE * pbi);
 extern void InitTmpBuffers(PB_INSTANCE * pbi);
-extern void ScanYUVInit( PP_INSTANCE *  ppi, 
-			 SCAN_CONFIG_DATA * ScanConfigPtr);
+extern void ScanYUVInit( PP_INSTANCE *  ppi,
+                         SCAN_CONFIG_DATA * ScanConfigPtr);
 extern int LoadAndDecode(PB_INSTANCE *pbi);
-
-
-

<p><p>1.5       +39 -43    theora/lib/encoder_lookup.h

Index: encoder_lookup.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/encoder_lookup.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- encoder_lookup.h	8 Jun 2003 00:08:38 -0000	1.4
+++ encoder_lookup.h	10 Jun 2003 01:31:33 -0000	1.5
@@ -11,30 +11,30 @@
  ********************************************************************
 
   function: simple static lookups for VP3 frame encoder
-  last mod: $Id: encoder_lookup.h,v 1.4 2003/06/08 00:08:38 giles Exp $
+  last mod: $Id: encoder_lookup.h,v 1.5 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
-ogg_uint32_t MvPattern[(MAX_MV_EXTENT * 2) + 1] = {   
-  0x000000ff, 0x000000fd, 0x000000fb, 0x000000f9, 
+ogg_uint32_t MvPattern[(MAX_MV_EXTENT * 2) + 1] = {
+  0x000000ff, 0x000000fd, 0x000000fb, 0x000000f9,
   0x000000f7, 0x000000f5, 0x000000f3, 0x000000f1,
-  0x000000ef, 0x000000ed, 0x000000eb, 0x000000e9, 
+  0x000000ef, 0x000000ed, 0x000000eb, 0x000000e9,
   0x000000e7, 0x000000e5, 0x000000e3, 0x000000e1,
-  0x0000006f, 0x0000006d, 0x0000006b, 0x00000069, 
+  0x0000006f, 0x0000006d, 0x0000006b, 0x00000069,
   0x00000067, 0x00000065, 0x00000063, 0x00000061,
-  0x0000002f, 0x0000002d, 0x0000002b, 0x00000029, 
+  0x0000002f, 0x0000002d, 0x0000002b, 0x00000029,
   0x00000009, 0x00000007, 0x00000002, 0x00000000,
-  0x00000001, 0x00000006, 0x00000008, 0x00000028, 
-  0x0000002a, 0x0000002c, 0x0000002e, 0x00000060, 
-  0x00000062, 0x00000064, 0x00000066, 0x00000068, 
+  0x00000001, 0x00000006, 0x00000008, 0x00000028,
+  0x0000002a, 0x0000002c, 0x0000002e, 0x00000060,
+  0x00000062, 0x00000064, 0x00000066, 0x00000068,
   0x0000006a, 0x0000006c, 0x0000006e, 0x000000e0,
-  0x000000e2, 0x000000e4, 0x000000e6, 0x000000e8, 
+  0x000000e2, 0x000000e4, 0x000000e6, 0x000000e8,
   0x000000ea, 0x000000ec, 0x000000ee, 0x000000f0,
-  0x000000f2, 0x000000f4, 0x000000f6, 0x000000f8, 
+  0x000000f2, 0x000000f4, 0x000000f6, 0x000000f8,
   0x000000fa, 0x000000fc, 0x000000fe,
 };
 
-ogg_uint32_t MvBits[(MAX_MV_EXTENT * 2) + 1] = {   
+ogg_uint32_t MvBits[(MAX_MV_EXTENT * 2) + 1] = {
   8, 8, 8, 8, 8, 8, 8, 8,
   8, 8, 8, 8, 8, 8, 8, 8,
   7, 7, 7, 7, 7, 7, 7, 7,
@@ -45,26 +45,26 @@
   8, 8, 8, 8, 8, 8, 8,
 };
 
-ogg_uint32_t MvPattern2[(MAX_MV_EXTENT * 2) + 1] = {   
-  0x0000003f, 0x0000003d, 0x0000003b, 0x00000039, 
+ogg_uint32_t MvPattern2[(MAX_MV_EXTENT * 2) + 1] = {
+  0x0000003f, 0x0000003d, 0x0000003b, 0x00000039,
   0x00000037, 0x00000035, 0x00000033, 0x00000031,
-  0x0000002f, 0x0000002d, 0x0000002b, 0x00000029, 
+  0x0000002f, 0x0000002d, 0x0000002b, 0x00000029,
   0x00000027, 0x00000025, 0x00000023, 0x00000021,
-  0x0000001f, 0x0000001d, 0x0000001b, 0x00000019, 
+  0x0000001f, 0x0000001d, 0x0000001b, 0x00000019,
   0x00000017, 0x00000015, 0x00000013, 0x00000011,
-  0x0000000f, 0x0000000d, 0x0000000b, 0x00000009, 
+  0x0000000f, 0x0000000d, 0x0000000b, 0x00000009,
   0x00000007, 0x00000005, 0x00000003, 0x00000000,
-  0x00000002, 0x00000004, 0x00000006, 0x00000008, 
+  0x00000002, 0x00000004, 0x00000006, 0x00000008,
   0x0000000a, 0x0000000c, 0x0000000e, 0x00000010,
-  0x00000012, 0x00000014, 0x00000016, 0x00000018, 
+  0x00000012, 0x00000014, 0x00000016, 0x00000018,
   0x0000001a, 0x0000001c, 0x0000001e, 0x00000020,
-  0x00000022, 0x00000024, 0x00000026, 0x00000028, 
+  0x00000022, 0x00000024, 0x00000026, 0x00000028,
   0x0000002a, 0x0000002c, 0x0000002e, 0x00000030,
-  0x00000032, 0x00000034, 0x00000036, 0x00000038, 
-  0x0000003a, 0x0000003c, 0x0000003e, 
+  0x00000032, 0x00000034, 0x00000036, 0x00000038,
+  0x0000003a, 0x0000003c, 0x0000003e,
 };
 
-ogg_uint32_t MvBits2[(MAX_MV_EXTENT * 2) + 1] = {   
+ogg_uint32_t MvBits2[(MAX_MV_EXTENT * 2) + 1] = {
   6, 6, 6, 6, 6, 6, 6, 6,
   6, 6, 6, 6, 6, 6, 6, 6,
   6, 6, 6, 6, 6, 6, 6, 6,
@@ -75,41 +75,38 @@
   6, 6, 6, 6, 6, 6, 6,
 };
 
-ogg_uint32_t ModeBitPatterns[MAX_MODES] = { 
+ogg_uint32_t ModeBitPatterns[MAX_MODES] = {
   0x00, 0x02, 0x06, 0x0E, 0x1E, 0x3E, 0x7E, 0x7F };
 
-ogg_int32_t ModeBitLengths[MAX_MODES] =  { 
+ogg_int32_t ModeBitLengths[MAX_MODES] =  {
   1,    2,    3,    4,    5,    6,    7,    7 };
 
-unsigned char ModeSchemes[MODE_METHODS-1][MAX_MODES] =  {   
-  /* Reserved for optimal */
-  { 0,    0,    0,    0,    0,    0,    0,    0 },    
-  
+unsigned char ModeSchemes[MODE_METHODS-1][MAX_MODES] =  {
   /* Last Mv dominates */
-  { 3,    4,    2,    0,    1,    5,    6,    7 },    // L P  M N I G GM 4     
-  { 2,    4,    3,    0,    1,    5,    6,    7 },    // L P  N M I G GM 4
-  { 3,    4,    1,    0,    2,    5,    6,    7 },    // L M  P N I G GM 4
-  { 2,    4,    1,    0,    3,    5,    6,    7 },    // L M  N P I G GM 4
-  
+  { 3,    4,    2,    0,    1,    5,    6,    7 },    /* L P  M N I G GM 4 */
+  { 2,    4,    3,    0,    1,    5,    6,    7 },    /* L P  N M I G GM 4 */
+  { 3,    4,    1,    0,    2,    5,    6,    7 },    /* L M  P N I G GM 4 */
+  { 2,    4,    1,    0,    3,    5,    6,    7 },    /* L M  N P I G GM 4 */
+
   /* No MV dominates */
-  { 0,    4,    3,    1,    2,    5,    6,    7 },    // N L P M I G GM 4 
-  { 0,    5,    4,    2,    3,    1,    6,    7 },    // N G L P M I GM 4
-  
+  { 0,    4,    3,    1,    2,    5,    6,    7 },    /* N L P M I G GM 4 */
+  { 0,    5,    4,    2,    3,    1,    6,    7 },    /* N G L P M I GM 4 */
+
 };
 
 
-ogg_uint32_t MvThreshTable[Q_TABLE_SIZE] = {   
+ogg_uint32_t MvThreshTable[Q_TABLE_SIZE] = {
   65, 65, 65, 65, 50, 50, 50, 50,
   40, 40, 40, 40, 40, 40, 40, 40,
   30, 30, 30, 30, 30, 30, 30, 30,
   20, 20, 20, 20, 20, 20, 20, 20,
   15, 15, 15, 15, 15, 15, 15, 15,
   10, 10, 10, 10, 10, 10, 10, 10,
-  5,  5,  5,  5,  5,  5,  5,  5, 
-  0,  0,  0,  0,  0,  0,  0,  0 
+  5,  5,  5,  5,  5,  5,  5,  5,
+  0,  0,  0,  0,  0,  0,  0,  0
 };
 
-ogg_uint32_t MVChangeFactorTable[Q_TABLE_SIZE] = {   
+ogg_uint32_t MVChangeFactorTable[Q_TABLE_SIZE] = {
   11, 11, 11, 11, 12, 12, 12, 12,
   13, 13, 13, 13, 13, 13, 13, 13,
   14, 14, 14, 14, 14, 14, 14, 14,
@@ -118,5 +115,4 @@
   14, 14, 14, 14, 14, 14, 14, 14,
   15, 15, 15, 15, 15, 15, 15, 15,
   15, 15, 15, 15, 15, 15, 15, 15
-};  
-
+};

<p><p>1.6       +232 -231  theora/lib/frarray.c

Index: frarray.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/frarray.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- frarray.c	8 Jun 2003 00:08:38 -0000	1.5
+++ frarray.c	10 Jun 2003 01:31:33 -0000	1.6
@@ -10,11 +10,12 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: frarray.c,v 1.5 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: frarray.c,v 1.6 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
+#include <string.h>
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 #include "block_inline.h"
@@ -22,84 +23,84 @@
 static ogg_uint32_t FrArrayCodeSBRun( CP_INSTANCE *cpi, ogg_uint32_t value ){
   ogg_uint32_t CodedVal = 0;
   ogg_uint32_t CodedBits = 0;
-  
-  // Coding scheme:
-  //	Codeword	      RunLength
-  //  0                       1
-  //  10x		      2-3
-  //  110x		      4-5
-  //  1110xx		      6-9
-  //  11110xxx                10-17
-  //  111110xxxx              18-33
-  //  111111xxxxxxxxxxxx      34-4129
+
+  /* Coding scheme:
+        Codeword              RunLength
+      0                       1
+      10x                     2-3
+      110x                    4-5
+      1110xx                  6-9
+      11110xxx                10-17
+      111110xxxx              18-33
+      111111xxxxxxxxxxxx      34-4129 */
 
   if ( value == 1 ){
-    CodedVal = 0;    
-    CodedBits = 1;   
+    CodedVal = 0;
+    CodedBits = 1;
   } else if ( value <= 3 ) {
-    CodedVal = 0x0004 + (value - 2);    
-    CodedBits = 3;   
+    CodedVal = 0x0004 + (value - 2);
+    CodedBits = 3;
   } else if ( value <= 5 ) {
-    CodedVal = 0x000C + (value - 4);    
-    CodedBits = 4;   
+    CodedVal = 0x000C + (value - 4);
+    CodedBits = 4;
   } else if ( value <= 9 ) {
-    CodedVal = 0x0038 + (value - 6);    
-    CodedBits = 6;   
-  } else if ( value <= 17 ) { 
-    CodedVal = 0x00F0 + (value - 10);    
-    CodedBits = 8;   
+    CodedVal = 0x0038 + (value - 6);
+    CodedBits = 6;
+  } else if ( value <= 17 ) {
+    CodedVal = 0x00F0 + (value - 10);
+    CodedBits = 8;
   } else if ( value <= 33 ) {
-    CodedVal = 0x03E0 + (value - 18);    
-    CodedBits = 10;   
+    CodedVal = 0x03E0 + (value - 18);
+    CodedBits = 10;
   } else {
-    CodedVal = 0x3F000 + (value - 34);    
+    CodedVal = 0x3F000 + (value - 34);
     CodedBits = 18;
   }
-  
-  /* Add the bits to the encode holding buffer. */    
+
+  /* Add the bits to the encode holding buffer. */
   oggpackB_write( &cpi->oggbuffer, CodedVal, (ogg_uint32_t)CodedBits );
-  
+
   return CodedBits;
 }
 
-static ogg_uint32_t FrArrayCodeBlockRun( CP_INSTANCE *cpi, 
-					 ogg_uint32_t value ) {
+static ogg_uint32_t FrArrayCodeBlockRun( CP_INSTANCE *cpi,
+                                         ogg_uint32_t value ) {
   ogg_uint32_t CodedVal = 0;
   ogg_uint32_t CodedBits = 0;
-  
-  // Coding scheme:
-  //	Codeword				RunLength
-  //	0x					1-2
-  //	10x					3-4
-  //	110x					5-6
-  //	1110xx					7-10
-  //	11110xx					11-14
-  //	11111xxxx				15-30 	
+
+  /* Coding scheme:
+        Codeword                                RunLength
+        0x                                      1-2
+        10x                                     3-4
+        110x                                    5-6
+        1110xx                                  7-10
+        11110xx                                 11-14
+        11111xxxx                               15-30 */
 
   if ( value <= 2 ) {
-    CodedVal = value - 1;    
-    CodedBits = 2;   
+    CodedVal = value - 1;
+    CodedBits = 2;
   } else if ( value <= 4 ) {
-    CodedVal = 0x0004 + (value - 3);    
-    CodedBits = 3;   
-    
+    CodedVal = 0x0004 + (value - 3);
+    CodedBits = 3;
+
   } else if ( value <= 6 ) {
-    CodedVal = 0x000C + (value - 5);    
-    CodedBits = 4;   
-    
+    CodedVal = 0x000C + (value - 5);
+    CodedBits = 4;
+
   } else if ( value <= 10 ) {
-    CodedVal = 0x0038 + (value - 7);    
-    CodedBits = 6;   
-    
+    CodedVal = 0x0038 + (value - 7);
+    CodedBits = 6;
+
   } else if ( value <= 14 ) {
-    CodedVal = 0x0078 + (value - 11);    
-    CodedBits = 7;   
+    CodedVal = 0x0078 + (value - 11);
+    CodedBits = 7;
   } else {
-    CodedVal = 0x01F0 + (value - 15);    
-    CodedBits = 9;   
+    CodedVal = 0x01F0 + (value - 15);
+    CodedBits = 9;
  }
 
-  /* Add the bits to the encode holding buffer. */    
+  /* Add the bits to the encode holding buffer. */
   oggpackB_write( &cpi->oggbuffer, CodedVal, (ogg_uint32_t)CodedBits );
 
   return CodedBits;
@@ -107,12 +108,12 @@
 
 void PackAndWriteDFArray( CP_INSTANCE *cpi ){
   ogg_uint32_t  i;
-  unsigned char	val;
-  ogg_uint32_t  run_count; 
-     
-  ogg_uint32_t	SB, MB, B;   /* Block, MB and SB loop variables */
-  ogg_uint32_t  BListIndex = 0;    
-  ogg_uint32_t  LastSbBIndex = 0;  
+  unsigned char val;
+  ogg_uint32_t  run_count;
+
+  ogg_uint32_t  SB, MB, B;   /* Block, MB and SB loop variables */
+  ogg_uint32_t  BListIndex = 0;
+  ogg_uint32_t  LastSbBIndex = 0;
   ogg_int32_t   DfBlockIndex;  /* Block index in display_fragments */
 
   /* Initialise workspaces */
@@ -120,34 +121,34 @@
   memset( cpi->pb.SBCodedFlags, 0, cpi->pb.SuperBlocks );
   memset( cpi->PartiallyCodedFlags, 0, cpi->pb.SuperBlocks );
   memset( cpi->BlockCodedFlags, 0, cpi->pb.UnitFragments);
-  
+
   for( SB = 0; SB < cpi->pb.SuperBlocks; SB++ ) {
     /* Check for coded blocks and macro-blocks */
     for ( MB=0; MB<4; MB++ ) {
       /* If MB in frame */
       if ( QuadMapToMBTopLeft(cpi->pb.BlockMap,SB,MB) >= 0 ) {
-	for ( B=0; B<4; B++ ) {
-	  DfBlockIndex = QuadMapToIndex1( cpi->pb.BlockMap,SB, MB, B );
+        for ( B=0; B<4; B++ ) {
+          DfBlockIndex = QuadMapToIndex1( cpi->pb.BlockMap,SB, MB, B );
 
-	  /* Does Block lie in frame: */
-	  if ( DfBlockIndex >= 0 ) {
-	    /* In Frame: If it is not coded then this SB is only
+          /* Does Block lie in frame: */
+          if ( DfBlockIndex >= 0 ) {
+            /* In Frame: If it is not coded then this SB is only
                partly coded.: */
-	    if ( cpi->pb.display_fragments[DfBlockIndex] ) {
-	      cpi->pb.SBCodedFlags[SB] = 1; /* SB at least partly coded */
-	      cpi->BlockCodedFlags[BListIndex] = 1; /* Block is coded */
-	    }else{
-	      cpi->pb.SBFullyFlags[SB] = 0; /* SB not fully coded */
-	      cpi->BlockCodedFlags[BListIndex] = 0; /* Block is not coded */
-	    }
-	    
-	    BListIndex++;
-	  }				
-	}
+            if ( cpi->pb.display_fragments[DfBlockIndex] ) {
+              cpi->pb.SBCodedFlags[SB] = 1; /* SB at least partly coded */
+              cpi->BlockCodedFlags[BListIndex] = 1; /* Block is coded */
+            }else{
+              cpi->pb.SBFullyFlags[SB] = 0; /* SB not fully coded */
+              cpi->BlockCodedFlags[BListIndex] = 0; /* Block is not coded */
+            }
+
+            BListIndex++;
+          }
+        }
       }
     }
 
-    /* Is the SB fully coded or uncoded. 
+    /* Is the SB fully coded or uncoded.
        If so then backup BListIndex and MBListIndex */
     if ( cpi->pb.SBFullyFlags[SB] || !cpi->pb.SBCodedFlags[SB] ) {
       BListIndex = LastSbBIndex; /* Reset to values from previous SB */
@@ -167,8 +168,8 @@
     while ( (i<cpi->pb.SuperBlocks) && (cpi->PartiallyCodedFlags[i]==val) ) {
       i++;
       run_count++;
-    }      
-    
+    }
+
     /* Code the run */
     FrArrayCodeSBRun( cpi, run_count );
     val = ( val == 0 ) ? 1 : 0;
@@ -178,64 +179,64 @@
   i = 0;
 
   /* Skip partially coded blocks */
-  while( (i < cpi->pb.SuperBlocks) && cpi->PartiallyCodedFlags[i] ) 
+  while( (i < cpi->pb.SuperBlocks) && cpi->PartiallyCodedFlags[i] )
     i++;
-  
+
   if ( i < cpi->pb.SuperBlocks ) {
-    val = cpi->pb.SBFullyFlags[i];              
+    val = cpi->pb.SBFullyFlags[i];
     oggpackB_write( &cpi->oggbuffer, (ogg_uint32_t)val, 1);
-    
+
     while ( i < cpi->pb.SuperBlocks ) {
       run_count = 0;
       while ( (i < cpi->pb.SuperBlocks) && (cpi->pb.SBFullyFlags[i] == val) ) {
-	i++;
-	/* Skip partially coded blocks */
-	while( (i < cpi->pb.SuperBlocks) && cpi->PartiallyCodedFlags[i] )  
-	  i++;
-	run_count++;
-      }      
-    
+        i++;
+        /* Skip partially coded blocks */
+        while( (i < cpi->pb.SuperBlocks) && cpi->PartiallyCodedFlags[i] )
+          i++;
+        run_count++;
+      }
+
       /* Code the run */
       FrArrayCodeSBRun( cpi, run_count );
       val = ( val == 0 ) ? 1 : 0;
     }
   }
-    
+
   /*  Now code the block flags */
   if ( BListIndex > 0 ) {
     /* Code the block flags start value */
     val = cpi->BlockCodedFlags[0];
     oggpackB_write( &cpi->oggbuffer, (ogg_uint32_t)val, 1);
-    
+
     /* Now code the block flags. */
     for ( i = 0; i < BListIndex; ) {
       run_count = 0;
       while ( (cpi->BlockCodedFlags[i] == val) && (i < BListIndex) ) {
-	i++;
-	run_count++;
-      }   
-      
+        i++;
+        run_count++;
+      }
+
       FrArrayCodeBlockRun( cpi, run_count );
       val = ( val == 0 ) ? 1 : 0;
-      
+
     }
   }
 }
 
-static void FrArrayDeCodeInit(PB_INSTANCE *pbi){   
+static void FrArrayDeCodeInit(PB_INSTANCE *pbi){
   /* Initialise the decoding of a run.  */
   pbi->bit_pattern = 0;
-  pbi->bits_so_far = 0; 
+  pbi->bits_so_far = 0;
 }
 
-static int FrArrayDeCodeBlockRun(  PB_INSTANCE *pbi, ogg_uint32_t bit_value, 
-			    ogg_int32_t * run_value ){
+static int FrArrayDeCodeBlockRun(  PB_INSTANCE *pbi, ogg_uint32_t bit_value,
+                            ogg_int32_t * run_value ){
   int  ret_val = 0;
-  
+
   /* Add in the new bit value. */
   pbi->bits_so_far++;
   pbi->bit_pattern = (pbi->bit_pattern << 1) + (bit_value & 1);
-  
+
   /* Coding scheme:
      Codeword           RunLength
      0x                    1-2
@@ -243,67 +244,67 @@
      110x                  5-6
      1110xx                7-10
      11110xx              11-14
-     11111xxxx            15-30 	
+     11111xxxx            15-30
   */
 
   switch ( pbi->bits_so_far ){
-  case 2: 
+  case 2:
     /* If bit 1 is clear */
     if ( !(pbi->bit_pattern & 0x0002) ){
       ret_val = 1;
       *run_value = (pbi->bit_pattern & 0x0001) + 1;
-    }           
-    break;      
-    
-  case 3:  
+    }
+    break;
+
+  case 3:
     /* If bit 1 is clear */
     if ( !(pbi->bit_pattern & 0x0002) ){
       ret_val = 1;
       *run_value = (pbi->bit_pattern & 0x0001) + 3;
-    }           
-    break;      
-    
+    }
+    break;
+
   case 4:
     /* If bit 1 is clear */
     if ( !(pbi->bit_pattern & 0x0002) ){
       ret_val = 1;
       *run_value = (pbi->bit_pattern & 0x0001) + 5;
-    }           
-    break;      
-    
+    }
+    break;
+
   case 6:
     /* If bit 2 is clear */
     if ( !(pbi->bit_pattern & 0x0004) ){
       ret_val = 1;
       *run_value = (pbi->bit_pattern & 0x0003) + 7;
-    }           
-    break;      
-    
+    }
+    break;
+
   case 7:
     /* If bit 2 is clear */
     if ( !(pbi->bit_pattern & 0x0004) ){
       ret_val = 1;
       *run_value = (pbi->bit_pattern & 0x0003) + 11;
-    }           
-    break;      
-    
+    }
+    break;
+
   case 9:
     ret_val = 1;
     *run_value = (pbi->bit_pattern & 0x000F) + 15;
-    break;      
+    break;
   }
-  
+
   return ret_val;
 }
 
-static int FrArrayDeCodeSBRun (PB_INSTANCE *pbi, ogg_uint32_t bit_value, 
-			ogg_int32_t * run_value ){
+static int FrArrayDeCodeSBRun (PB_INSTANCE *pbi, ogg_uint32_t bit_value,
+                        ogg_int32_t * run_value ){
   int ret_val = 0;
-  
+
   /* Add in the new bit value. */
   pbi->bits_so_far++;
   pbi->bit_pattern = (pbi->bit_pattern << 1) + (bit_value & 1);
-  
+
   /* Coding scheme:
      Codeword            RunLength
      0                       1
@@ -316,73 +317,73 @@
   */
 
   switch ( pbi->bits_so_far ){
-  case 1:  
+  case 1:
     if ( pbi->bit_pattern == 0 ){
       ret_val = 1;
-      *run_value = 1;                             
+      *run_value = 1;
     }
-    break; 
+    break;
 
   case 3:
     /* Bit 1 clear */
     if ( !(pbi->bit_pattern & 0x0002) ){
       ret_val = 1;
-      *run_value = (pbi->bit_pattern & 0x0001) + 2; 
+      *run_value = (pbi->bit_pattern & 0x0001) + 2;
     }
-    break; 
-    
+    break;
+
   case 4:
     /* Bit 1 clear */
     if ( !(pbi->bit_pattern & 0x0002) ){
       ret_val = 1;
       *run_value = (pbi->bit_pattern & 0x0001) + 4;
     }
-    break; 
-    
+    break;
+
   case 6:
     /* Bit 2 clear */
     if ( !(pbi->bit_pattern & 0x0004) ){
       ret_val = 1;
       *run_value = (pbi->bit_pattern & 0x0003) + 6;
     }
-    break; 
-    
+    break;
+
   case 8:
     /* Bit 3 clear */
     if ( !(pbi->bit_pattern & 0x0008) ){
       ret_val = 1;
-      *run_value = (pbi->bit_pattern & 0x0007) + 10; 
+      *run_value = (pbi->bit_pattern & 0x0007) + 10;
     }
-    break; 
-          
+    break;
+
   case 10:
     /* Bit 4 clear */
     if ( !(pbi->bit_pattern & 0x0010) ){
       ret_val = 1;
-      *run_value = (pbi->bit_pattern & 0x000F) + 18; 
+      *run_value = (pbi->bit_pattern & 0x000F) + 18;
     }
-    break; 
-    
+    break;
+
   case 18:
     ret_val = 1;
-    *run_value = (pbi->bit_pattern & 0x0FFF) + 34;                             
-    break; 
-    
+    *run_value = (pbi->bit_pattern & 0x0FFF) + 34;
+    break;
+
   default:
     ret_val = 0;
     break;
   }
-  
+
   return ret_val;
 }
 
 static void GetNextBInit(PB_INSTANCE *pbi){
-  pbi->NextBit = oggpackB_read(&pbi->opb,1);
+  pbi->NextBit = (unsigned char)oggpackB_read(&pbi->opb,1);
 
   /* Read run length */
-  FrArrayDeCodeInit(pbi);               
-  while ( FrArrayDeCodeBlockRun( pbi, oggpackB_read(&pbi->opb,1), 
-				 &pbi->BitsLeft ) == 0 );
+  FrArrayDeCodeInit(pbi);
+  while ( FrArrayDeCodeBlockRun( pbi, oggpackB_read(&pbi->opb,1),
+                                 &pbi->BitsLeft ) == 0 );
 }
 
 static unsigned char GetNextBBit (PB_INSTANCE *pbi){
@@ -392,24 +393,24 @@
 
     /* Read next run */
     FrArrayDeCodeInit(pbi);
-    while ( FrArrayDeCodeBlockRun( pbi,oggpackB_read(&pbi->opb,1), 
-				   &pbi->BitsLeft ) == 0 );
+    while ( FrArrayDeCodeBlockRun( pbi,oggpackB_read(&pbi->opb,1),
+                                   &pbi->BitsLeft ) == 0 );
   }
 
   /* Have  read a bit */
   pbi->BitsLeft--;
-  
+
   /* Return next bit value */
   return pbi->NextBit;
 }
 
 static void GetNextSbInit(PB_INSTANCE *pbi){
-  pbi->NextBit = oggpackB_read(&pbi->opb,1);
-  
+  pbi->NextBit = (unsigned char)oggpackB_read(&pbi->opb,1);
+
   /* Read run length */
-  FrArrayDeCodeInit(pbi);               
-  while ( FrArrayDeCodeSBRun( pbi,oggpackB_read(&pbi->opb,1), 
-			      &pbi->BitsLeft ) == 0 );
+  FrArrayDeCodeInit(pbi);
+  while ( FrArrayDeCodeSBRun( pbi,oggpackB_read(&pbi->opb,1),
+                              &pbi->BitsLeft ) == 0 );
 }
 
 static unsigned char GetNextSbBit (PB_INSTANCE *pbi){
@@ -418,21 +419,21 @@
     pbi->NextBit = ( pbi->NextBit == 1 ) ? 0 : 1;
 
     /* Read next run */
-    FrArrayDeCodeInit(pbi);               
-    while ( FrArrayDeCodeSBRun( pbi, oggpackB_read(&pbi->opb,1), 
-				&pbi->BitsLeft ) == 0 );
+    FrArrayDeCodeInit(pbi);
+    while ( FrArrayDeCodeSBRun( pbi, oggpackB_read(&pbi->opb,1),
+                                &pbi->BitsLeft ) == 0 );
   }
-  
+
   /* Have  read a bit */
   pbi->BitsLeft--;
-  
+
   /* Return next bit value */
   return pbi->NextBit;
 }
 
 void QuadDecodeDisplayFragments ( PB_INSTANCE *pbi ){
   ogg_uint32_t  SB, MB, B;
-  int    DataToDecode; 
+  int    DataToDecode;
 
   ogg_int32_t   dfIndex;
   ogg_uint32_t  MBIndex = 0;
@@ -450,20 +451,20 @@
   }else{
     memset( pbi->SBFullyFlags, 0, pbi->SuperBlocks );
     memset( pbi->MBCodedFlags, 0, pbi->MacroBlocks );
-    
+
     /* Un-pack the list of partially coded Super-Blocks */
     GetNextSbInit(pbi);
     for( SB = 0; SB < pbi->SuperBlocks; SB++){
       pbi->SBCodedFlags[SB] = GetNextSbBit (pbi);
     }
-    
+
     /* Scan through the list of super blocks.  Unless all are marked
        as partially coded we have more to do. */
-    DataToDecode = 0; 
+    DataToDecode = 0;
     for ( SB=0; SB<pbi->SuperBlocks; SB++ ) {
       if ( !pbi->SBCodedFlags[SB] ) {
-	DataToDecode = 1;
-	break;
+        DataToDecode = 1;
+        break;
       }
     }
 
@@ -472,58 +473,58 @@
       /* Un-pack the Super-Block fully coded flags. */
       GetNextSbInit(pbi);
       for( SB = 0; SB < pbi->SuperBlocks; SB++) {
-	/* Skip blocks already marked as partially coded */
-	while( (SB < pbi->SuperBlocks) && pbi->SBCodedFlags[SB] )  
-	  SB++;
-	
-	if ( SB < pbi->SuperBlocks ) {
-	  pbi->SBFullyFlags[SB] = GetNextSbBit (pbi);
-	  
-	  if ( pbi->SBFullyFlags[SB] )       /* If SB is fully coded. */
-	    pbi->SBCodedFlags[SB] = 1;       /* Mark the SB as coded */
-	}
+        /* Skip blocks already marked as partially coded */
+        while( (SB < pbi->SuperBlocks) && pbi->SBCodedFlags[SB] )
+          SB++;
+
+        if ( SB < pbi->SuperBlocks ) {
+          pbi->SBFullyFlags[SB] = GetNextSbBit (pbi);
+
+          if ( pbi->SBFullyFlags[SB] )       /* If SB is fully coded. */
+            pbi->SBCodedFlags[SB] = 1;       /* Mark the SB as coded */
+        }
       }
     }
-    
+
     /* Scan through the list of coded super blocks.  If at least one
        is marked as partially coded then we have a block list to
        decode. */
     for ( SB=0; SB<pbi->SuperBlocks; SB++ ) {
       if ( pbi->SBCodedFlags[SB] && !pbi->SBFullyFlags[SB] ) {
-	/* Initialise the block list decoder. */
-	GetNextBInit(pbi);
-	break;
+        /* Initialise the block list decoder. */
+        GetNextBInit(pbi);
+        break;
       }
     }
   }
-  
+
   /* Decode the block data from the bit stream. */
   for ( SB=0; SB<pbi->SuperBlocks; SB++ ){
     for ( MB=0; MB<4; MB++ ){
       /* If MB is in the frame */
       if ( QuadMapToMBTopLeft(pbi->BlockMap, SB,MB) >= 0 ){
-	/* Only read block level data if SB was fully or partially coded */
-	if ( pbi->SBCodedFlags[SB] ) {
-	  for ( B=0; B<4; B++ ){
-	    /* If block is valid (in frame)... */
-	    dfIndex = QuadMapToIndex1( pbi->BlockMap, SB, MB, B );
-	    if ( dfIndex >= 0 ){
-	      if ( pbi->SBFullyFlags[SB] )
-		pbi->display_fragments[dfIndex] = 1;
-	      else
-		pbi->display_fragments[dfIndex] = GetNextBBit(pbi);
-	      
-	      /* Create linear list of coded block indices */
-	      if ( pbi->display_fragments[dfIndex] ) {
-		pbi->MBCodedFlags[MBIndex] = 1;
-		pbi->CodedBlockList[pbi->CodedBlockIndex] = dfIndex;
-		pbi->CodedBlockIndex++;
-	      }
-	    }
-	  }
-	}
-	MBIndex++;
-	
+        /* Only read block level data if SB was fully or partially coded */
+        if ( pbi->SBCodedFlags[SB] ) {
+          for ( B=0; B<4; B++ ){
+            /* If block is valid (in frame)... */
+            dfIndex = QuadMapToIndex1( pbi->BlockMap, SB, MB, B );
+            if ( dfIndex >= 0 ){
+              if ( pbi->SBFullyFlags[SB] )
+                pbi->display_fragments[dfIndex] = 1;
+              else
+                pbi->display_fragments[dfIndex] = GetNextBBit(pbi);
+
+              /* Create linear list of coded block indices */
+              if ( pbi->display_fragments[dfIndex] ) {
+                pbi->MBCodedFlags[MBIndex] = 1;
+                pbi->CodedBlockList[pbi->CodedBlockIndex] = dfIndex;
+                pbi->CodedBlockIndex++;
+              }
+            }
+          }
+        }
+        MBIndex++;
+
       }
     }
   }
@@ -533,58 +534,58 @@
   /* Coding scheme:
      Token                      Codeword           Bits
      Entry   0 (most frequent)  0                   1
-     Entry   1       	        10 	            2
-     Entry   2       	        110 		    3
-     Entry   3       	        1110 		    4
-     Entry   4       	        11110 		    5
-     Entry   5       	        111110 	            6
-     Entry   6       	        1111110 	    7
-     Entry   7       	        1111111 	    7
+     Entry   1                  10                  2
+     Entry   2                  110                 3
+     Entry   3                  1110                4
+     Entry   4                  11110               5
+     Entry   5                  111110              6
+     Entry   6                  1111110             7
+     Entry   7                  1111111             7
   */
 
   /* Initialise the decoding. */
   pbi->bit_pattern = 0;
-  pbi->bits_so_far = 0; 
-  
+  pbi->bits_so_far = 0;
+
   pbi->bit_pattern = oggpackB_read(&pbi->opb,1);
-  
+
   /* Do we have a match */
   if ( pbi->bit_pattern == 0 )
     return (CODING_MODE)0;
-  
+
   /* Get the next bit */
   pbi->bit_pattern = (pbi->bit_pattern << 1) | oggpackB_read(&pbi->opb,1);
 
   /* Do we have a match */
   if ( pbi->bit_pattern == 0x0002 )
     return (CODING_MODE)1;
-  
+
   pbi->bit_pattern = (pbi->bit_pattern << 1) | oggpackB_read(&pbi->opb,1);
-  
+
   /* Do we have a match  */
   if ( pbi->bit_pattern == 0x0006 )
     return (CODING_MODE)2;
-  
+
   pbi->bit_pattern = (pbi->bit_pattern << 1) | oggpackB_read(&pbi->opb,1);
-  
+
   /* Do we have a match */
   if ( pbi->bit_pattern == 0x000E )
     return (CODING_MODE)3;
-  
+
   pbi->bit_pattern = (pbi->bit_pattern << 1) | oggpackB_read(&pbi->opb,1);
-  
+
   /* Do we have a match */
   if ( pbi->bit_pattern == 0x001E )
     return (CODING_MODE)4;
-  
+
   pbi->bit_pattern = (pbi->bit_pattern << 1) | oggpackB_read(&pbi->opb,1);
-  
+
   /* Do we have a match */
   if ( pbi->bit_pattern == 0x003E )
     return (CODING_MODE)5;
-  
+
   pbi->bit_pattern = (pbi->bit_pattern << 1) | oggpackB_read(&pbi->opb,1);
-  
+
   /* Do we have a match */
   if ( pbi->bit_pattern == 0x007E )
     return (CODING_MODE)6;

<p><p>1.7       +116 -116  theora/lib/frinit.c

Index: frinit.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/frinit.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- frinit.c	8 Jun 2003 00:08:38 -0000	1.6
+++ frinit.c	10 Jun 2003 01:31:33 -0000	1.7
@@ -10,8 +10,8 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: frinit.c,v 1.6 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: frinit.c,v 1.7 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
@@ -23,23 +23,23 @@
 void InitializeFragCoordinates(PB_INSTANCE *pbi){
 
   ogg_uint32_t i, j;
-  
+
   ogg_uint32_t HorizFrags = pbi->HFragments;
   ogg_uint32_t VertFrags = pbi->VFragments;
   ogg_uint32_t StartFrag = 0;
-  
+
   /* Y */
-    
+
   for(i = 0; i< VertFrags; i++){
     for(j = 0; j< HorizFrags; j++){
-            
+
       ogg_uint32_t ThisFrag = i * HorizFrags + j;
       pbi->FragCoordinates[ ThisFrag ].x=j * BLOCK_HEIGHT_WIDTH;
-      pbi->FragCoordinates[ ThisFrag ].y=i * BLOCK_HEIGHT_WIDTH;            
-      
+      pbi->FragCoordinates[ ThisFrag ].y=i * BLOCK_HEIGHT_WIDTH;
+
     }
   }
-  
+
   /* U */
   HorizFrags >>= 1;
   VertFrags >>= 1;
@@ -49,19 +49,19 @@
     for(j = 0; j< HorizFrags; j++) {
       ogg_uint32_t ThisFrag = StartFrag + i * HorizFrags + j;
       pbi->FragCoordinates[ ThisFrag ].x=j * BLOCK_HEIGHT_WIDTH;
-      pbi->FragCoordinates[ ThisFrag ].y=i * BLOCK_HEIGHT_WIDTH;            
-      
+      pbi->FragCoordinates[ ThisFrag ].y=i * BLOCK_HEIGHT_WIDTH;
+
     }
   }
-  
+
   /* V */
   StartFrag = pbi->YPlaneFragments + pbi->UVPlaneFragments;
   for(i = 0; i< VertFrags; i++) {
     for(j = 0; j< HorizFrags; j++) {
       ogg_uint32_t ThisFrag = StartFrag + i * HorizFrags + j;
       pbi->FragCoordinates[ ThisFrag ].x=j * BLOCK_HEIGHT_WIDTH;
-      pbi->FragCoordinates[ ThisFrag ].y=i * BLOCK_HEIGHT_WIDTH;            
-      
+      pbi->FragCoordinates[ ThisFrag ].y=i * BLOCK_HEIGHT_WIDTH;
+
     }
   }
 }
@@ -69,25 +69,25 @@
 static void CalcPixelIndexTable( PB_INSTANCE *pbi){
   ogg_uint32_t i;
   ogg_uint32_t * PixelIndexTablePtr;
-  
+
   /* Calculate the pixel index table for normal image buffers */
   PixelIndexTablePtr = pbi->pixel_index_table;
   for ( i = 0; i < pbi->YPlaneFragments; i++ ) {
-    PixelIndexTablePtr[ i ] = 
-      ((i / pbi->HFragments) * VFRAGPIXELS * 
-       pbi->info.width);  
-    PixelIndexTablePtr[ i ] += 
+    PixelIndexTablePtr[ i ] =
+      ((i / pbi->HFragments) * VFRAGPIXELS *
+       pbi->info.width);
+    PixelIndexTablePtr[ i ] +=
       ((i % pbi->HFragments) * HFRAGPIXELS);
   }
-  
+
   PixelIndexTablePtr = &pbi->pixel_index_table[pbi->YPlaneFragments];
   for ( i = 0; i < ((pbi->HFragments >> 1) * pbi->VFragments); i++ ) {
-    PixelIndexTablePtr[ i ] =  
-      ((i / (pbi->HFragments / 2) ) * 
-       (VFRAGPIXELS * 
-	(pbi->info.width / 2)) );   
-    PixelIndexTablePtr[ i ] += 
-      ((i % (pbi->HFragments / 2) ) * 
+    PixelIndexTablePtr[ i ] =
+      ((i / (pbi->HFragments / 2) ) *
+       (VFRAGPIXELS *
+        (pbi->info.width / 2)) );
+    PixelIndexTablePtr[ i ] +=
+      ((i % (pbi->HFragments / 2) ) *
        HFRAGPIXELS) + pbi->YPlaneSize;
   }
 
@@ -95,36 +95,36 @@
   /* Now calculate the pixel index table for image reconstruction buffers */
   PixelIndexTablePtr = pbi->recon_pixel_index_table;
   for ( i = 0; i < pbi->YPlaneFragments; i++ ){
-    PixelIndexTablePtr[ i ] = 
+    PixelIndexTablePtr[ i ] =
       ((i / pbi->HFragments) * VFRAGPIXELS *
-       pbi->YStride);  
-    PixelIndexTablePtr[ i ] += 
-      ((i % pbi->HFragments) * HFRAGPIXELS) + 
+       pbi->YStride);
+    PixelIndexTablePtr[ i ] +=
+      ((i % pbi->HFragments) * HFRAGPIXELS) +
       pbi->ReconYDataOffset;
   }
-   
+
   /* U blocks */
   PixelIndexTablePtr = &pbi->recon_pixel_index_table[pbi->YPlaneFragments];
   for ( i = 0; i < pbi->UVPlaneFragments; i++ ) {
-    PixelIndexTablePtr[ i ] =  
-      ((i / (pbi->HFragments / 2) ) * 
-       (VFRAGPIXELS * (pbi->UVStride)) );   
-    PixelIndexTablePtr[ i ] += 
-      ((i % (pbi->HFragments / 2) ) * 
+    PixelIndexTablePtr[ i ] =
+      ((i / (pbi->HFragments / 2) ) *
+       (VFRAGPIXELS * (pbi->UVStride)) );
+    PixelIndexTablePtr[ i ] +=
+      ((i % (pbi->HFragments / 2) ) *
        HFRAGPIXELS) + pbi->ReconUDataOffset;
   }
-  
+
   /* V blocks */
-  PixelIndexTablePtr = 
-    &pbi->recon_pixel_index_table[pbi->YPlaneFragments + 
-				 pbi->UVPlaneFragments];
+  PixelIndexTablePtr =
+    &pbi->recon_pixel_index_table[pbi->YPlaneFragments +
+                                 pbi->UVPlaneFragments];
 
   for ( i = 0; i < pbi->UVPlaneFragments; i++ ) {
-    PixelIndexTablePtr[ i ] =  
-      ((i / (pbi->HFragments / 2) ) * 
-       (VFRAGPIXELS * (pbi->UVStride)) );   
-    PixelIndexTablePtr[ i ] += 
-      ((i % (pbi->HFragments / 2) ) * HFRAGPIXELS) + 
+    PixelIndexTablePtr[ i ] =
+      ((i / (pbi->HFragments / 2) ) *
+       (VFRAGPIXELS * (pbi->UVStride)) );
+    PixelIndexTablePtr[ i ] +=
+      ((i % (pbi->HFragments / 2) ) * HFRAGPIXELS) +
       pbi->ReconVDataOffset;
   }
 }
@@ -156,10 +156,10 @@
   if(pbi->SBFullyFlags) _ogg_free(pbi->SBFullyFlags);
   if(pbi->MBFullyFlags) _ogg_free(pbi->MBFullyFlags);
   if(pbi->MBCodedFlags) _ogg_free(pbi->MBCodedFlags);
-  
+
   if(pbi->_Nodes) _ogg_free(pbi->_Nodes);
-  pbi->_Nodes = 0;    
-  
+  pbi->_Nodes = 0;
+
   pbi->QFragData = 0;
   pbi->TokenList = 0;
   pbi->skipped_display_fragments = 0;
@@ -175,10 +175,10 @@
   pbi->MBCodedFlags = 0;
   pbi->MBFullyFlags = 0;
   pbi->BlockMap = 0;
-  
+
   pbi->SBCodedFlags = 0;
   pbi->SBFullyFlags = 0;
-  pbi->QFragData = 0;                  
+  pbi->QFragData = 0;
   pbi->TokenList = 0;
   pbi->skipped_display_fragments = 0;
   pbi->FragCoeffs = 0;
@@ -191,7 +191,7 @@
   pbi->FragCodingMethod = 0;
   pbi->FragCoordinates = 0;
   pbi->FragMVect = 0;
-  
+
   pbi->PPCoefBuffer=0;
   pbi->PPCoefBuffer=0;
   pbi->FragQIndex = 0;
@@ -206,72 +206,72 @@
   ClearFragmentInfo(pbi);
 
   /* Perform Fragment Allocations */
-  pbi->display_fragments = 
+  pbi->display_fragments =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->display_fragments));
 
-  pbi->pixel_index_table = 
+  pbi->pixel_index_table =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->pixel_index_table));
 
-  pbi->recon_pixel_index_table = 
+  pbi->recon_pixel_index_table =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->recon_pixel_index_table));
 
-  pbi->FragTokenCounts = 
+  pbi->FragTokenCounts =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragTokenCounts));
 
-  pbi->CodedBlockList = 
+  pbi->CodedBlockList =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->CodedBlockList));
-    
-  pbi->FragMVect = 
+
+  pbi->FragMVect =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragMVect));
-    
-  pbi->FragCoeffs = 
+
+  pbi->FragCoeffs =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragCoeffs));
-    
-  pbi->FragCoefEOB = 
+
+  pbi->FragCoefEOB =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragCoefEOB));
-    
-  pbi->skipped_display_fragments = 
+
+  pbi->skipped_display_fragments =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->skipped_display_fragments));
-    
-  pbi->QFragData = 
+
+  pbi->QFragData =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->QFragData));
-    
-  pbi->TokenList = 
+
+  pbi->TokenList =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->TokenList));
-    
-  pbi->FragCodingMethod = 
+
+  pbi->FragCodingMethod =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragCodingMethod));
 
-  pbi->FragCoordinates = 
+  pbi->FragCoordinates =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragCoordinates));
 
-  pbi->FragQIndex = 
+  pbi->FragQIndex =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragQIndex));
 
-  pbi->PPCoefBuffer = 
+  pbi->PPCoefBuffer =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->PPCoefBuffer));
 
-  pbi->FragmentVariances = 
+  pbi->FragmentVariances =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragmentVariances));
 
-  pbi->_Nodes = 
+  pbi->_Nodes =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->_Nodes));
-	
+
   /* Super Block Initialization */
   pbi->SBCodedFlags =
     _ogg_malloc(pbi->SuperBlocks * sizeof(*pbi->SBCodedFlags));
 
-  pbi->SBFullyFlags = 
+  pbi->SBFullyFlags =
     _ogg_malloc(pbi->SuperBlocks * sizeof(*pbi->SBFullyFlags));
 
   /* Macro Block Initialization */
-  pbi->MBCodedFlags = 
+  pbi->MBCodedFlags =
     _ogg_malloc(pbi->MacroBlocks * sizeof(*pbi->MBCodedFlags));
 
-  pbi->MBFullyFlags = 
+  pbi->MBFullyFlags =
     _ogg_malloc(pbi->MacroBlocks * sizeof(*pbi->MBFullyFlags));
 
-  pbi->BlockMap = 
+  pbi->BlockMap =
     _ogg_malloc(pbi->SuperBlocks * sizeof(*pbi->BlockMap));
 
 }
@@ -285,57 +285,57 @@
     _ogg_free(pbi->LastFrameRecon);
   if(pbi->PostProcessBuffer)
     _ogg_free(pbi->PostProcessBuffer);
-  
-  
+
+
   pbi->ThisFrameRecon = 0;
   pbi->GoldenFrame = 0;
   pbi->LastFrameRecon = 0;
   pbi->PostProcessBuffer = 0;
-  
-  
+
+
   pbi->ThisFrameRecon = 0;
   pbi->GoldenFrame = 0;
   pbi->LastFrameRecon = 0;
   pbi->PostProcessBuffer = 0;
-  
+
 }
 
 void InitFrameInfo(PB_INSTANCE * pbi, unsigned int FrameSize){
-  
+
   /* clear any existing info */
   ClearFrameInfo(pbi);
 
   /* allocate frames */
-  pbi->ThisFrameRecon = 
+  pbi->ThisFrameRecon =
     _ogg_malloc(FrameSize*sizeof(*pbi->ThisFrameRecon));
-  
-  pbi->GoldenFrame = 
+
+  pbi->GoldenFrame =
     _ogg_malloc(FrameSize*sizeof(*pbi->GoldenFrame));
-  
-  pbi->LastFrameRecon = 
+
+  pbi->LastFrameRecon =
     _ogg_malloc(FrameSize*sizeof(*pbi->LastFrameRecon));
-  
-  pbi->PostProcessBuffer = 
+
+  pbi->PostProcessBuffer =
     _ogg_malloc(FrameSize*sizeof(*pbi->PostProcessBuffer));
-  
+
 }
 
 void InitFrameDetails(PB_INSTANCE *pbi){
   int FrameSize;
-  
+
   /*pbi->PostProcessingLevel = 0;
     pbi->PostProcessingLevel = 4;
     pbi->PostProcessingLevel = 5;
     pbi->PostProcessingLevel = 6;*/
 
   pbi->PostProcessingLevel = 0;
-    
 
-    /* Set the frame size etc. */                
 
-  pbi->YPlaneSize = pbi->info.width * 
-    pbi->info.height; 
-  pbi->UVPlaneSize = pbi->YPlaneSize / 4;  
+    /* Set the frame size etc. */
+
+  pbi->YPlaneSize = pbi->info.width *
+    pbi->info.height;
+  pbi->UVPlaneSize = pbi->YPlaneSize / 4;
   pbi->HFragments = pbi->info.width / HFRAGPIXELS;
   pbi->VFragments = pbi->info.height / VFRAGPIXELS;
   pbi->UnitFragments = ((pbi->VFragments * pbi->HFragments)*3)/2;
@@ -344,38 +344,38 @@
 
   pbi->YStride = (pbi->info.width + STRIDE_EXTRA);
   pbi->UVStride = pbi->YStride / 2;
-  pbi->ReconYPlaneSize = pbi->YStride * 
+  pbi->ReconYPlaneSize = pbi->YStride *
     (pbi->info.height + STRIDE_EXTRA);
   pbi->ReconUVPlaneSize = pbi->ReconYPlaneSize / 4;
   FrameSize = pbi->ReconYPlaneSize + 2 * pbi->ReconUVPlaneSize;
-  
+
   pbi->YDataOffset = 0;
   pbi->UDataOffset = pbi->YPlaneSize;
   pbi->VDataOffset = pbi->YPlaneSize + pbi->UVPlaneSize;
-  pbi->ReconYDataOffset = 
+  pbi->ReconYDataOffset =
     (pbi->YStride * UMV_BORDER) + UMV_BORDER;
-  pbi->ReconUDataOffset = pbi->ReconYPlaneSize + 
+  pbi->ReconUDataOffset = pbi->ReconYPlaneSize +
     (pbi->UVStride * (UMV_BORDER/2)) + (UMV_BORDER/2);
-  pbi->ReconVDataOffset = pbi->ReconYPlaneSize + pbi->ReconUVPlaneSize + 
+  pbi->ReconVDataOffset = pbi->ReconYPlaneSize + pbi->ReconUVPlaneSize +
     (pbi->UVStride * (UMV_BORDER/2)) + (UMV_BORDER/2);
-  
+
   /* Image dimensions in Super-Blocks */
-  pbi->YSBRows = (pbi->info.height/32)  + 
+  pbi->YSBRows = (pbi->info.height/32)  +
     ( pbi->info.height%32 ? 1 : 0 );
-  pbi->YSBCols = (pbi->info.width/32)  + 
+  pbi->YSBCols = (pbi->info.width/32)  +
     ( pbi->info.width%32 ? 1 : 0 );
-  pbi->UVSBRows = ((pbi->info.height/2)/32)  + 
+  pbi->UVSBRows = ((pbi->info.height/2)/32)  +
     ( (pbi->info.height/2)%32 ? 1 : 0 );
-  pbi->UVSBCols = ((pbi->info.width/2)/32)  + 
+  pbi->UVSBCols = ((pbi->info.width/2)/32)  +
     ( (pbi->info.width/2)%32 ? 1 : 0 );
-  
+
   /* Super-Blocks per component */
   pbi->YSuperBlocks = pbi->YSBRows * pbi->YSBCols;
   pbi->UVSuperBlocks = pbi->UVSBRows * pbi->UVSBCols;
   pbi->SuperBlocks = pbi->YSuperBlocks+2*pbi->UVSuperBlocks;
-  
+
   /* Useful externals */
-  pbi->YMacroBlocks = ((pbi->VFragments+1)/2)*((pbi->HFragments+1)/2);	
+  pbi->YMacroBlocks = ((pbi->VFragments+1)/2)*((pbi->HFragments+1)/2);
   pbi->UVMacroBlocks = ((pbi->VFragments/2+1)/2)*((pbi->HFragments/2+1)/2);
   pbi->MacroBlocks = pbi->YMacroBlocks+2*pbi->UVMacroBlocks;
 
@@ -384,9 +384,9 @@
   InitializeFragCoordinates(pbi);
 
   /* Configure mapping between quad-tree and fragments */
-  CreateBlockMapping ( pbi->BlockMap, pbi->YSuperBlocks, 
-		       pbi->UVSuperBlocks, pbi->HFragments, pbi->VFragments);
-    
+  CreateBlockMapping ( pbi->BlockMap, pbi->YSuperBlocks,
+                       pbi->UVSuperBlocks, pbi->HFragments, pbi->VFragments);
+
   /* Re-initialise the pixel index table. */
 
   CalcPixelIndexTable( pbi );

<p><p>1.9       +94 -155   theora/lib/huffman.c

Index: huffman.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/huffman.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- huffman.c	9 Jun 2003 01:45:19 -0000	1.8
+++ huffman.c	10 Jun 2003 01:31:33 -0000	1.9
@@ -10,8 +10,8 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: huffman.c,v 1.8 2003/06/09 01:45:19 tterribe Exp $
+  function:
+  last mod: $Id: huffman.c,v 1.9 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
@@ -21,25 +21,25 @@
 #include "encoder_internal.h"
 #include "hufftables.h"
 
-static void CreateHuffmanList(HUFF_ENTRY ** HuffRoot, 
-			      ogg_uint32_t HIndex, ogg_uint32_t *FreqList ) {
+static void CreateHuffmanList(HUFF_ENTRY ** HuffRoot,
+                              ogg_uint32_t HIndex, ogg_uint32_t *FreqList ) {
   int i;
   HUFF_ENTRY *entry_ptr;
   HUFF_ENTRY *search_ptr;
-  
+
   /* Create a HUFF entry for token zero. */
   HuffRoot[HIndex] = (HUFF_ENTRY *)_ogg_calloc(1,sizeof(*HuffRoot[HIndex]));
-  
+
   HuffRoot[HIndex]->Previous = NULL;
   HuffRoot[HIndex]->Next = NULL;
   HuffRoot[HIndex]->ZeroChild = NULL;
   HuffRoot[HIndex]->OneChild = NULL;
   HuffRoot[HIndex]->Value = 0;
-  HuffRoot[HIndex]->Frequency = FreqList[0];   
-  
+  HuffRoot[HIndex]->Frequency = FreqList[0];
+
   if ( HuffRoot[HIndex]->Frequency == 0 )
-    HuffRoot[HIndex]->Frequency = 1; 
-    
+    HuffRoot[HIndex]->Frequency = 1;
+
   /* Now add entries for all the other possible tokens. */
   for ( i = 1; i < MAX_ENTROPY_TOKENS; i++ ) {
     entry_ptr = (HUFF_ENTRY *)_ogg_calloc(1,sizeof(*entry_ptr));
@@ -48,42 +48,42 @@
     entry_ptr->Frequency = FreqList[i];
     entry_ptr->ZeroChild = NULL;
     entry_ptr->OneChild = NULL;
-    
+
     /* Force min value of 1. This prevents the tree getting too deep. */
     if ( entry_ptr->Frequency == 0 )
       entry_ptr->Frequency = 1;
-    
+
     if ( entry_ptr->Frequency <= HuffRoot[HIndex]->Frequency ){
-      entry_ptr->Next = HuffRoot[HIndex];  
+      entry_ptr->Next = HuffRoot[HIndex];
       HuffRoot[HIndex]->Previous = entry_ptr;
-      entry_ptr->Previous = NULL;   
+      entry_ptr->Previous = NULL;
       HuffRoot[HIndex] = entry_ptr;
-    }else{  
+    }else{
       search_ptr = HuffRoot[HIndex];
-      while ( (search_ptr->Next != NULL) && 
-	      (search_ptr->Frequency < entry_ptr->Frequency) ){
-	search_ptr = (HUFF_ENTRY *)search_ptr->Next;
+      while ( (search_ptr->Next != NULL) &&
+              (search_ptr->Frequency < entry_ptr->Frequency) ){
+        search_ptr = (HUFF_ENTRY *)search_ptr->Next;
       }
-            
+
       if ( search_ptr->Frequency < entry_ptr->Frequency ){
-	entry_ptr->Next = NULL;
-	entry_ptr->Previous = search_ptr;   
-	search_ptr->Next = entry_ptr;
+        entry_ptr->Next = NULL;
+        entry_ptr->Previous = search_ptr;
+        search_ptr->Next = entry_ptr;
       }else{
-	entry_ptr->Next = search_ptr;
-	entry_ptr->Previous = search_ptr->Previous; 
-	search_ptr->Previous->Next = entry_ptr;
-	search_ptr->Previous = entry_ptr;
+        entry_ptr->Next = search_ptr;
+        entry_ptr->Previous = search_ptr->Previous;
+        search_ptr->Previous->Next = entry_ptr;
+        search_ptr->Previous = entry_ptr;
       }
     }
   }
 }
 
-static void CreateCodeArray( HUFF_ENTRY * HuffRoot, 
-		      ogg_uint32_t *HuffCodeArray, 
-		      unsigned char *HuffCodeLengthArray, 
-		      ogg_uint32_t CodeValue, 
-		      unsigned char CodeLength ) {
+static void CreateCodeArray( HUFF_ENTRY * HuffRoot,
+                      ogg_uint32_t *HuffCodeArray,
+                      unsigned char *HuffCodeLengthArray,
+                      ogg_uint32_t CodeValue,
+                      unsigned char CodeLength ) {
 
   /* If we are at a leaf then fill in a code array entry. */
   if ( ( HuffRoot->ZeroChild == NULL ) && ( HuffRoot->OneChild == NULL ) ){
@@ -92,79 +92,18 @@
   }else{
     /* Recursive calls to scan down the tree. */
     CodeLength++;
-    CreateCodeArray(HuffRoot->ZeroChild, HuffCodeArray, HuffCodeLengthArray, 
-		    ((CodeValue << 1) + 0), CodeLength);
-    CreateCodeArray(HuffRoot->OneChild, HuffCodeArray, HuffCodeLengthArray, 
-		    ((CodeValue << 1) + 1), CodeLength);
+    CreateCodeArray(HuffRoot->ZeroChild, HuffCodeArray, HuffCodeLengthArray,
+                    ((CodeValue << 1) + 0), CodeLength);
+    CreateCodeArray(HuffRoot->OneChild, HuffCodeArray, HuffCodeLengthArray,
+                    ((CodeValue << 1) + 1), CodeLength);
   }
 }
 
-/*TODO note: not reentrant, scheduled for cleanup/optimization before beta1 */
-static int huff_x;								///	rude!
-static unsigned char huffset_bits[2230];		///	totally rude!
-
-static void write_root(oggpack_buffer* opb, HUFF_ENTRY * HuffRoot) {
-	if(HuffRoot->Value >= 0) {						///	if we have a leaf,
-		oggpackB_write(opb, 1, 1);
-		oggpackB_write(opb, HuffRoot->Value, 5);
-	} else {
-		oggpackB_write(opb, 0, 1);
-		if(HuffRoot->ZeroChild) {
-			write_root(opb, HuffRoot->ZeroChild);
-		}
-		if(HuffRoot->OneChild) {
-			write_root(opb, HuffRoot->OneChild);
-		}
-	}
-}
-
-
-static int read_root_bit() {
-	int i = huff_x >> 3;
-	int r = huff_x & 7;
-	int m = 0x80 >> r;
-	int b = huffset_bits[i];
-	huff_x++;
-	if(b & m) b = 1;
-	else b = 0;
-	return b;
-}
-
-static int read_root_(int cnt) {
-	int v=0;
-	int x;
-	for(x=0; x< cnt; x++) {
-		v <<= 1;
-		v += read_root_bit();
-	}
-	return v;
-}
-
-static void read_root( HUFF_ENTRY * HuffRoot) {
-	if(!read_root_bit()) {
-//    entry_ptr = (HUFF_ENTRY *)_ogg_calloc(1,sizeof(*entry_ptr));
-		HuffRoot->ZeroChild = (HUFF_ENTRY *)_ogg_calloc(1,sizeof(HUFF_ENTRY));
-		read_root(HuffRoot->ZeroChild);
-		HuffRoot->OneChild = (HUFF_ENTRY *)_ogg_calloc(1,sizeof(HUFF_ENTRY));
-		read_root(HuffRoot->OneChild);
-		HuffRoot->Value = -1;
-	} else {
-		HuffRoot->ZeroChild = NULL;
-		HuffRoot->OneChild = NULL;
-		HuffRoot->Value = read_root_(5);
-	}
-}
-
-static void read_hufftree(HUFF_ENTRY ** huffarray, int index) {
-    huffarray[index] = (HUFF_ENTRY *)_ogg_calloc(1,sizeof(HUFF_ENTRY));
-	read_root(huffarray[index]);
-}
-
-static void  BuildHuffmanTree( HUFF_ENTRY **HuffRoot, 
-			ogg_uint32_t *HuffCodeArray, 
-			unsigned char *HuffCodeLengthArray, 
-			ogg_uint32_t HIndex, 
-			ogg_uint32_t *FreqList ){   
+static void  BuildHuffmanTree( HUFF_ENTRY **HuffRoot,
+                        ogg_uint32_t *HuffCodeArray,
+                        unsigned char *HuffCodeLengthArray,
+                        ogg_uint32_t HIndex,
+                        ogg_uint32_t *FreqList ){
 
   HUFF_ENTRY *entry_ptr;
   HUFF_ENTRY *search_ptr;
@@ -172,79 +111,79 @@
   /* First create a sorted linked list representing the frequencies of
      each token. */
   CreateHuffmanList( HuffRoot, HIndex, FreqList );
-    
+
   /* Now build the tree from the list. */
-     
-  /* While there are at least two items left in the list. */ 
-  while ( HuffRoot[HIndex]->Next != NULL ){                              
+
+  /* While there are at least two items left in the list. */
+  while ( HuffRoot[HIndex]->Next != NULL ){
     /* Create the new node as the parent of the first two in the list. */
     entry_ptr = (HUFF_ENTRY *)_ogg_calloc(1,sizeof(*entry_ptr));
     entry_ptr->Value = -1;
-    entry_ptr->Frequency = HuffRoot[HIndex]->Frequency + 
+    entry_ptr->Frequency = HuffRoot[HIndex]->Frequency +
       HuffRoot[HIndex]->Next->Frequency ;
     entry_ptr->ZeroChild = HuffRoot[HIndex];
-    entry_ptr->OneChild = HuffRoot[HIndex]->Next;  
-    
+    entry_ptr->OneChild = HuffRoot[HIndex]->Next;
+
     /* If there are still more items in the list then insert the new
        node into the list. */
-    if (entry_ptr->OneChild->Next != NULL ){   
-      /* Set up the provisional 'new root' */ 
+    if (entry_ptr->OneChild->Next != NULL ){
+      /* Set up the provisional 'new root' */
       HuffRoot[HIndex] = entry_ptr->OneChild->Next;
       HuffRoot[HIndex]->Previous = NULL;
-            
+
       /* Now scan through the remaining list to insert the new entry
          at the appropriate point. */
-      if ( entry_ptr->Frequency <= HuffRoot[HIndex]->Frequency ){ 
-	entry_ptr->Next = HuffRoot[HIndex];  
-	HuffRoot[HIndex]->Previous = entry_ptr;
-	entry_ptr->Previous = NULL;   
-	HuffRoot[HIndex] = entry_ptr;
-      }else{  
-	search_ptr = HuffRoot[HIndex];
-	while ( (search_ptr->Next != NULL) && 
-		(search_ptr->Frequency < entry_ptr->Frequency) ){
-	  search_ptr = search_ptr->Next;
-	}
-	
-	if ( search_ptr->Frequency < entry_ptr->Frequency ){
-	  entry_ptr->Next = NULL;
-	  entry_ptr->Previous = search_ptr;   
-	  search_ptr->Next = entry_ptr;
-	}else{
-	  entry_ptr->Next = search_ptr;
-	  entry_ptr->Previous = search_ptr->Previous; 
-	  search_ptr->Previous->Next = entry_ptr;
-	  search_ptr->Previous = entry_ptr;
-	}
-      }                                     
-    }else{   
-      /* Build has finished. */ 
+      if ( entry_ptr->Frequency <= HuffRoot[HIndex]->Frequency ){
+        entry_ptr->Next = HuffRoot[HIndex];
+        HuffRoot[HIndex]->Previous = entry_ptr;
+        entry_ptr->Previous = NULL;
+        HuffRoot[HIndex] = entry_ptr;
+      }else{
+        search_ptr = HuffRoot[HIndex];
+        while ( (search_ptr->Next != NULL) &&
+                (search_ptr->Frequency < entry_ptr->Frequency) ){
+          search_ptr = search_ptr->Next;
+        }
+
+        if ( search_ptr->Frequency < entry_ptr->Frequency ){
+          entry_ptr->Next = NULL;
+          entry_ptr->Previous = search_ptr;
+          search_ptr->Next = entry_ptr;
+        }else{
+          entry_ptr->Next = search_ptr;
+          entry_ptr->Previous = search_ptr->Previous;
+          search_ptr->Previous->Next = entry_ptr;
+          search_ptr->Previous = entry_ptr;
+        }
+      }
+    }else{
+      /* Build has finished. */
       entry_ptr->Next = NULL;
       entry_ptr->Previous = NULL;
       HuffRoot[HIndex] = entry_ptr;
     }
-    
-    /* Delete the Next/Previous properties of the children (PROB NOT NEC). */ 
+
+    /* Delete the Next/Previous properties of the children (PROB NOT NEC). */
     entry_ptr->ZeroChild->Next = NULL;
     entry_ptr->ZeroChild->Previous = NULL;
     entry_ptr->OneChild->Next = NULL;
     entry_ptr->OneChild->Previous = NULL;
-    
-  } 
-    
+
+  }
+
   /* Now build a code array from the tree. */
-  CreateCodeArray( HuffRoot[HIndex], HuffCodeArray, 
-		   HuffCodeLengthArray, 0, 0);
+  CreateCodeArray( HuffRoot[HIndex], HuffCodeArray,
+                   HuffCodeLengthArray, 0, 0);
 }
 
 static void  DestroyHuffTree(HUFF_ENTRY *root_ptr){
   if (root_ptr){
     if ( root_ptr->ZeroChild )
       DestroyHuffTree(root_ptr->ZeroChild);
-    
+
     if ( root_ptr->OneChild )
       DestroyHuffTree(root_ptr->OneChild);
-    
+
     _ogg_free(root_ptr);
   }
 }
@@ -255,11 +194,11 @@
   ClearHuffmanTrees(pbi->HuffRoot_VP3x);
 
   for ( i = 0; i < NUM_HUFF_TABLES; i++ )
-    if (pbi->HuffCodeArray_VP3x[i]) 
+    if (pbi->HuffCodeArray_VP3x[i])
       _ogg_free (pbi->HuffCodeArray_VP3x[i]);
 
   for ( i = 0; i < NUM_HUFF_TABLES; i++ )
-    if (pbi->HuffCodeLengthArray_VP3x[i]) 
+    if (pbi->HuffCodeLengthArray_VP3x[i])
       _ogg_free (pbi->HuffCodeLengthArray_VP3x[i]);
 }
 
@@ -271,16 +210,16 @@
   pbi->ExtraBitLengths_VP3x = ExtraBitLengths_VP31;
 
   for ( i = 0; i < NUM_HUFF_TABLES; i++ ){
-    pbi->HuffCodeArray_VP3x[i] = 
+    pbi->HuffCodeArray_VP3x[i] =
       _ogg_calloc(MAX_ENTROPY_TOKENS,
-		  sizeof(*pbi->HuffCodeArray_VP3x[i]));
-    pbi->HuffCodeLengthArray_VP3x[i] = 
+                  sizeof(*pbi->HuffCodeArray_VP3x[i]));
+    pbi->HuffCodeLengthArray_VP3x[i] =
       _ogg_calloc(MAX_ENTROPY_TOKENS,
-		  sizeof(*pbi->HuffCodeLengthArray_VP3x[i]));
-    BuildHuffmanTree( pbi->HuffRoot_VP3x, 
-		      pbi->HuffCodeArray_VP3x[i],
-		      pbi->HuffCodeLengthArray_VP3x[i],
-		      i, FrequencyCounts_VP3[i]);
+                  sizeof(*pbi->HuffCodeLengthArray_VP3x[i]));
+    BuildHuffmanTree( pbi->HuffRoot_VP3x,
+                      pbi->HuffCodeArray_VP3x[i],
+                      pbi->HuffCodeLengthArray_VP3x[i],
+                      i, FrequencyCounts_VP3[i]);
   }
 }
 

<p><p>1.3       +6 -7      theora/lib/huffman.h

Index: huffman.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/huffman.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- huffman.h	8 Jun 2003 00:08:38 -0000	1.2
+++ huffman.h	10 Jun 2003 01:31:33 -0000	1.3
@@ -10,8 +10,8 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: huffman.h,v 1.2 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: huffman.h,v 1.3 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
@@ -53,9 +53,9 @@
 #define DCT_ZRL_TOKEN           8
 
 #define ONE_TOKEN               9       /* Special tokens for -1,1,-2,2 */
-#define MINUS_ONE_TOKEN         10 
-#define TWO_TOKEN               11 
-#define MINUS_TWO_TOKEN         12 
+#define MINUS_ONE_TOKEN         10
+#define TWO_TOKEN               11
+#define MINUS_TWO_TOKEN         12
 
 #define LOW_VAL_TOKENS          (MINUS_TWO_TOKEN + 1)
 #define DCT_VAL_CATEGORY3       (LOW_VAL_TOKENS + 4)
@@ -71,5 +71,4 @@
 #define DCT_RUN_CATEGORY2       (DCT_RUN_CATEGORY1C + 1)
 
 /* 35 */
-#define MAX_ENTROPY_TOKENS      (DCT_RUN_CATEGORY2 + 2)  
-
+#define MAX_ENTROPY_TOKENS      (DCT_RUN_CATEGORY2 + 2)

<p><p>1.5       +20 -20    theora/lib/hufftables.h

Index: hufftables.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/hufftables.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- hufftables.h	8 Jun 2003 00:08:38 -0000	1.4
+++ hufftables.h	10 Jun 2003 01:31:33 -0000	1.5
@@ -10,22 +10,22 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: hufftables.h,v 1.4 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: hufftables.h,v 1.5 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
 #include "huffman.h"
 
-unsigned char ExtraBitLengths_VP31[MAX_ENTROPY_TOKENS] = { 
-  0, 0, 0, 2, 3, 4, 12,3, 6,                 // EOB and Zero-run tokens. 
-  0, 0, 0, 0,                                // Very low value tokens. 
-  1, 1, 1, 1, 2, 3, 4, 5, 6, 10,             // Other value tokens 
-  1, 1, 1, 1, 1, 3, 4,                       // Category 1 runs. 
-  2, 3,                                      // Category 2 runs. 
+unsigned char ExtraBitLengths_VP31[MAX_ENTROPY_TOKENS] = {
+  0, 0, 0, 2, 3, 4, 12,3, 6,                 /* EOB and Zero-run tokens. */
+  0, 0, 0, 0,                                /* Very low value tokens. */
+  1, 1, 1, 1, 2, 3, 4, 5, 6, 10,             /* Other value tokens */
+  1, 1, 1, 1, 1, 3, 4,                       /* Category 1 runs. */
+  2, 3,                                      /* Category 2 runs. */
 };
 
-#define NEW_FREQS 0 /// dbm - test new frequency tables
+#define NEW_FREQS 0 /* dbm - test new frequency tables */
 
 #if NEW_FREQS
 /* New baseline frequency tables for encoder version >= 2 */
@@ -79,7 +79,7 @@
      159,   121,    17,    6,    16,    6,    2,
      69,    53,
   },
-  
+
   /* DC Inter Bias */
   {  534,   174,    71,    68,    10,    1,    1,    68,   119,
      1674,  1526,   560,   536,
@@ -129,7 +129,7 @@
      285,   223,   101,    66,   104,   120,    74,
      35,    22,
   },
-  
+
   /* AC INTRA Tables  */
   /* AC Intra bias group 1 tables */
   {  245,    68,    25,    28,    5,    1,    1,   359,    4,
@@ -229,7 +229,7 @@
      1222,   551,   462,   391,   220,   322,   156,
      290,   136,
   },
-  
+
   /* AC Intra bias group 2 tables */
   {  245,    49,    15,    11,    1,    1,    1,   332,    38,
      1163,  1162,   685,   683,
@@ -328,7 +328,7 @@
      930,   475,   345,   249,   236,  1124,   376,
      91,    56,
   },
-  
+
   /* AC Intra bias group 3 tables */
   {  278,    55,    17,    12,    1,    1,    1,   288,    71,
      1315,  1304,   725,   724,
@@ -427,7 +427,7 @@
      248,   131,   149,   272,   165,   535,   813,
      3,    3,
   },
-  
+
   /* AC Intra bias group 4 tables */
   {  599,   150,    55,    50,    9,    1,    1,   181,    19,
      1487,  1487,   625,   625,
@@ -580,7 +580,7 @@
      139,   109,    9,    6,   20,    2,    1,
      94,   50,
   },
-  
+
   /* DC Inter Bias */
   {  490,   154,   57,   53,   10,    2,    1,   238,   160,
      1391,  1390,   579,   578,
@@ -630,7 +630,7 @@
      120,   97,   55,   39,   60,   38,   15,
      11,    8,
   },
-  
+
   /* AC INTRA Tables  */
   /* AC Intra bias group 1 tables */
   {  242,   62,   22,   20,    4,    1,    1,   438,    1,
@@ -730,7 +730,7 @@
      1187,   527,   498,   409,   147,   210,   56,
      263,   117,
   },
-  
+
   /* AC Intra bias group 2 tables */
   {  311,   74,   27,   27,    5,    1,    1,   470,   24,
      665,   667,   637,   638,
@@ -829,7 +829,7 @@
      914,   370,   235,   138,   145,   949,   128,
      94,   41,
   },
-  
+
   /* AC Intra bias group 3 tables */
   {  486,   112,   39,   34,    6,    1,    1,   541,   67,
      819,   818,   762,   763,
@@ -928,8 +928,8 @@
      18,   18,    9,   55,   36,   184,   323,
      1,    1,
   },
-  
-  
+
+
   /* AC Intra bias group 4 tables */
   {  921,   264,   101,   100,   19,    2,    1,   331,   98,
      1015,  1016,   799,   799,

<p><p>1.5       +132 -131  theora/lib/idct.c

Index: idct.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/idct.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- idct.c	8 Jun 2003 00:08:38 -0000	1.4
+++ idct.c	10 Jun 2003 01:31:33 -0000	1.5
@@ -11,10 +11,11 @@
  ********************************************************************
 
   function:
-  last mod: $Id: idct.c,v 1.4 2003/06/08 00:08:38 giles Exp $
+  last mod: $Id: idct.c,v 1.5 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
+#include <string.h>
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 #include "quant_lookup.h"
@@ -28,27 +29,27 @@
 #define xC6S2 25080
 #define xC7S1 12785
 
-static void dequant_slow( ogg_int16_t * dequant_coeffs, 
-		   ogg_int16_t * quantized_list, 
-		   ogg_int32_t * DCT_block) {
+static void dequant_slow( ogg_int16_t * dequant_coeffs,
+                   ogg_int16_t * quantized_list,
+                   ogg_int32_t * DCT_block) {
   int i;
   for(i=0;i<64;i++)
     DCT_block[dequant_index[i]] = quantized_list[i] * dequant_coeffs[i];
 }
 
-void IDctSlow(  Q_LIST_ENTRY * InputData, 
-		ogg_int16_t *QuantMatrix, 
-		ogg_int16_t * OutputData ) {
+void IDctSlow(  Q_LIST_ENTRY * InputData,
+                ogg_int16_t *QuantMatrix,
+                ogg_int16_t * OutputData ) {
   ogg_int32_t IntermediateData[64];
   ogg_int32_t * ip = IntermediateData;
   ogg_int16_t * op = OutputData;
-  
+
   ogg_int32_t _A, _B, _C, _D, _Ad, _Bd, _Cd, _Dd, _E, _F, _G, _H;
   ogg_int32_t _Ed, _Gd, _Add, _Bdd, _Fd, _Hd;
   ogg_int32_t t1, t2;
-  
+
   int loop;
-  
+
   dequant_slow( QuantMatrix, InputData, IntermediateData);
 
   /* Inverse DCT on the rows now */
@@ -60,37 +61,37 @@
       t1 >>= 16;
       t2 >>= 16;
       _A = t1 + t2;
-      
+
       t1 = (xC7S1 * ip[1]);
       t2 = (xC1S7 * ip[7]);
       t1 >>= 16;
       t2 >>= 16;
       _B = t1 - t2;
-      
+
       t1 = (xC3S5 * ip[3]);
       t2 = (xC5S3 * ip[5]);
       t1 >>= 16;
       t2 >>= 16;
       _C = t1 + t2;
-      
+
       t1 = (xC3S5 * ip[5]);
       t2 = (xC5S3 * ip[3]);
       t1 >>= 16;
       t2 >>= 16;
       _D = t1 - t2;
-      
+
       t1 = (xC4S4 * (_A - _C));
       t1 >>= 16;
       _Ad = t1;
-      
+
       t1 = (xC4S4 * (_B - _D));
       t1 >>= 16;
       _Bd = t1;
-      
-      
+
+
       _Cd = _A + _C;
       _Dd = _B + _D;
-      
+
       t1 = (xC4S4 * (ip[0] + ip[4]));
       t1 >>= 16;
       _E = t1;
@@ -98,134 +99,134 @@
       t1 = (xC4S4 * (ip[0] - ip[4]));
       t1 >>= 16;
       _F = t1;
-      
+
       t1 = (xC2S6 * ip[2]);
       t2 = (xC6S2 * ip[6]);
       t1 >>= 16;
       t2 >>= 16;
       _G = t1 + t2;
-      
+
       t1 = (xC6S2 * ip[2]);
       t2 = (xC2S6 * ip[6]);
       t1 >>= 16;
       t2 >>= 16;
       _H = t1 - t2;
-      
-      
+
+
       _Ed = _E - _G;
       _Gd = _E + _G;
-      
+
       _Add = _F + _Ad;
       _Bdd = _Bd - _H;
-      
+
       _Fd = _F - _Ad;
       _Hd = _Bd + _H;
-      
+
       /* Final sequence of operations over-write original inputs. */
       ip[0] = (ogg_int16_t)((_Gd + _Cd )   >> 0);
       ip[7] = (ogg_int16_t)((_Gd - _Cd )   >> 0);
 
       ip[1] = (ogg_int16_t)((_Add + _Hd )  >> 0);
       ip[2] = (ogg_int16_t)((_Add - _Hd )  >> 0);
-      
+
       ip[3] = (ogg_int16_t)((_Ed + _Dd )   >> 0);
       ip[4] = (ogg_int16_t)((_Ed - _Dd )   >> 0);
-      
+
       ip[5] = (ogg_int16_t)((_Fd + _Bdd )  >> 0);
       ip[6] = (ogg_int16_t)((_Fd - _Bdd )  >> 0);
-      
+
     }
-    
-    ip += 8;			/* next row */
+
+    ip += 8;                    /* next row */
   }
-  
+
   ip = IntermediateData;
 
-  for ( loop = 0; loop < 8; loop++){	
+  for ( loop = 0; loop < 8; loop++){
     /* Check for non-zero values (bitwise or faster than ||) */
     if ( ip[0 * 8] | ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |
-	 ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) {
+         ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) {
 
       t1 = (xC1S7 * ip[1*8]);
       t2 = (xC7S1 * ip[7*8]);
       t1 >>= 16;
       t2 >>= 16;
       _A = t1 + t2;
-      
+
       t1 = (xC7S1 * ip[1*8]);
       t2 = (xC1S7 * ip[7*8]);
       t1 >>= 16;
       t2 >>= 16;
       _B = t1 - t2;
-      
+
       t1 = (xC3S5 * ip[3*8]);
       t2 = (xC5S3 * ip[5*8]);
       t1 >>= 16;
       t2 >>= 16;
       _C = t1 + t2;
-      
+
       t1 = (xC3S5 * ip[5*8]);
       t2 = (xC5S3 * ip[3*8]);
       t1 >>= 16;
       t2 >>= 16;
       _D = t1 - t2;
-      
+
       t1 = (xC4S4 * (_A - _C));
       t1 >>= 16;
       _Ad = t1;
-      
+
       t1 = (xC4S4 * (_B - _D));
       t1 >>= 16;
       _Bd = t1;
-			
-      
+
+
       _Cd = _A + _C;
       _Dd = _B + _D;
-      
+
       t1 = (xC4S4 * (ip[0*8] + ip[4*8]));
       t1 >>= 16;
       _E = t1;
-      
+
       t1 = (xC4S4 * (ip[0*8] - ip[4*8]));
       t1 >>= 16;
       _F = t1;
-      
+
       t1 = (xC2S6 * ip[2*8]);
       t2 = (xC6S2 * ip[6*8]);
       t1 >>= 16;
       t2 >>= 16;
       _G = t1 + t2;
-      
+
       t1 = (xC6S2 * ip[2*8]);
       t2 = (xC2S6 * ip[6*8]);
       t1 >>= 16;
       t2 >>= 16;
       _H = t1 - t2;
-      
+
       _Ed = _E - _G;
       _Gd = _E + _G;
-      
+
       _Add = _F + _Ad;
       _Bdd = _Bd - _H;
-      
+
       _Fd = _F - _Ad;
       _Hd = _Bd + _H;
-      
+
       _Gd += IdctAdjustBeforeShift;
       _Add += IdctAdjustBeforeShift;
       _Ed += IdctAdjustBeforeShift;
       _Fd += IdctAdjustBeforeShift;
-      
+
       /* Final sequence of operations over-write original inputs. */
       op[0*8] = (ogg_int16_t)((_Gd + _Cd )   >> 4);
       op[7*8] = (ogg_int16_t)((_Gd - _Cd )   >> 4);
-      
+
       op[1*8] = (ogg_int16_t)((_Add + _Hd )  >> 4);
       op[2*8] = (ogg_int16_t)((_Add - _Hd )  >> 4);
-      
+
       op[3*8] = (ogg_int16_t)((_Ed + _Dd )   >> 4);
       op[4*8] = (ogg_int16_t)((_Ed - _Dd )   >> 4);
-      
+
       op[5*8] = (ogg_int16_t)((_Fd + _Bdd )  >> 4);
       op[6*8] = (ogg_int16_t)((_Fd - _Bdd )  >> 4);
     }else{
@@ -238,26 +239,26 @@
       op[5*8] = 0;
       op[6*8] = 0;
     }
-    
-    ip++;			/* next column */
+
+    ip++;                       /* next column */
     op++;
   }
 }
 
 /************************
-  x  x  x  x  0  0  0  0 
+  x  x  x  x  0  0  0  0
   x  x  x  0  0  0  0  0
   x  x  0  0  0  0  0  0
-  x  0  0  0  0  0  0  0 
+  x  0  0  0  0  0  0  0
   0  0  0  0  0  0  0  0
   0  0  0  0  0  0  0  0
   0  0  0  0  0  0  0  0
   0  0  0  0  0  0  0  0
 *************************/
 
-static void dequant_slow10( ogg_int16_t * dequant_coeffs, 
-		     ogg_int16_t * quantized_list, 
-		     ogg_int32_t * DCT_block){
+static void dequant_slow10( ogg_int16_t * dequant_coeffs,
+                     ogg_int16_t * quantized_list,
+                     ogg_int32_t * DCT_block){
   int i;
   memset(DCT_block,0, 128);
   for(i=0;i<10;i++)
@@ -265,9 +266,9 @@
 
 }
 
-void IDct10( Q_LIST_ENTRY * InputData, 
-	     ogg_int16_t *QuantMatrix, 
-	     ogg_int16_t * OutputData ){
+void IDct10( Q_LIST_ENTRY * InputData,
+             ogg_int16_t *QuantMatrix,
+             ogg_int16_t * OutputData ){
   ogg_int32_t IntermediateData[64];
   ogg_int32_t * ip = IntermediateData;
   ogg_int16_t * op = OutputData;
@@ -275,144 +276,144 @@
   ogg_int32_t _A, _B, _C, _D, _Ad, _Bd, _Cd, _Dd, _E, _F, _G, _H;
   ogg_int32_t _Ed, _Gd, _Add, _Bdd, _Fd, _Hd;
   ogg_int32_t t1, t2;
-  
+
   int loop;
-  
+
   dequant_slow10( QuantMatrix, InputData, IntermediateData);
-  
+
   /* Inverse DCT on the rows now */
   for ( loop = 0; loop < 4; loop++){
     /* Check for non-zero values */
     if ( ip[0] | ip[1] | ip[2] | ip[3] ){
       t1 = (xC1S7 * ip[1]);
       t1 >>= 16;
-      _A = t1; 
-      
+      _A = t1;
+
       t1 = (xC7S1 * ip[1]);
       t1 >>= 16;
       _B = t1 ;
-      
+
       t1 = (xC3S5 * ip[3]);
       t1 >>= 16;
-      _C = t1; 
-      
+      _C = t1;
+
       t2 = (xC5S3 * ip[3]);
       t2 >>= 16;
-      _D = -t2; 
-      
+      _D = -t2;
+
 
       t1 = (xC4S4 * (_A - _C));
       t1 >>= 16;
       _Ad = t1;
-      
+
       t1 = (xC4S4 * (_B - _D));
       t1 >>= 16;
       _Bd = t1;
-      
-      
+
+
       _Cd = _A + _C;
       _Dd = _B + _D;
-      
+
       t1 = (xC4S4 * ip[0] );
       t1 >>= 16;
       _E = t1;
-      
+
       _F = t1;
-      
+
       t1 = (xC2S6 * ip[2]);
       t1 >>= 16;
-      _G = t1; 
-      
+      _G = t1;
+
       t1 = (xC6S2 * ip[2]);
       t1 >>= 16;
       _H = t1 ;
-      
-      
+
+
       _Ed = _E - _G;
       _Gd = _E + _G;
-      
+
       _Add = _F + _Ad;
       _Bdd = _Bd - _H;
-      
+
       _Fd = _F - _Ad;
       _Hd = _Bd + _H;
-      
+
       /* Final sequence of operations over-write original inputs. */
       ip[0] = (ogg_int16_t)((_Gd + _Cd )   >> 0);
       ip[7] = (ogg_int16_t)((_Gd - _Cd )   >> 0);
-      
+
       ip[1] = (ogg_int16_t)((_Add + _Hd )  >> 0);
       ip[2] = (ogg_int16_t)((_Add - _Hd )  >> 0);
-      
+
       ip[3] = (ogg_int16_t)((_Ed + _Dd )   >> 0);
       ip[4] = (ogg_int16_t)((_Ed - _Dd )   >> 0);
-      
+
       ip[5] = (ogg_int16_t)((_Fd + _Bdd )  >> 0);
       ip[6] = (ogg_int16_t)((_Fd - _Bdd )  >> 0);
-      
+
     }
-    
-    ip += 8;			/* next row */
+
+    ip += 8;                    /* next row */
   }
-  
+
   ip = IntermediateData;
-  
-  for ( loop = 0; loop < 8; loop++) {	
+
+  for ( loop = 0; loop < 8; loop++) {
     /* Check for non-zero values (bitwise or faster than ||) */
     if ( ip[0 * 8] | ip[1 * 8] | ip[2 * 8] | ip[3 * 8] ) {
-      
+
       t1 = (xC1S7 * ip[1*8]);
       t1 >>= 16;
       _A = t1 ;
-      
+
       t1 = (xC7S1 * ip[1*8]);
       t1 >>= 16;
       _B = t1 ;
-      
+
       t1 = (xC3S5 * ip[3*8]);
       t1 >>= 16;
       _C = t1 ;
-      
+
       t2 = (xC5S3 * ip[3*8]);
       t2 >>= 16;
       _D = - t2;
-      
-      
+
+
       t1 = (xC4S4 * (_A - _C));
       t1 >>= 16;
       _Ad = t1;
-      
+
       t1 = (xC4S4 * (_B - _D));
       t1 >>= 16;
       _Bd = t1;
-      
-      
+
+
       _Cd = _A + _C;
       _Dd = _B + _D;
-      
+
       t1 = (xC4S4 * ip[0*8]);
       t1 >>= 16;
       _E = t1;
       _F = t1;
-      
+
       t1 = (xC2S6 * ip[2*8]);
       t1 >>= 16;
       _G = t1;
-      
+
       t1 = (xC6S2 * ip[2*8]);
       t1 >>= 16;
       _H = t1;
-      
-      
+
+
       _Ed = _E - _G;
       _Gd = _E + _G;
-      
+
       _Add = _F + _Ad;
       _Bdd = _Bd - _H;
-      
+
       _Fd = _F - _Ad;
       _Hd = _Bd + _H;
-      
+
       _Gd += IdctAdjustBeforeShift;
       _Add += IdctAdjustBeforeShift;
       _Ed += IdctAdjustBeforeShift;
@@ -421,13 +422,13 @@
       /* Final sequence of operations over-write original inputs. */
       op[0*8] = (ogg_int16_t)((_Gd + _Cd )   >> 4);
       op[7*8] = (ogg_int16_t)((_Gd - _Cd )   >> 4);
-      
+
       op[1*8] = (ogg_int16_t)((_Add + _Hd )  >> 4);
       op[2*8] = (ogg_int16_t)((_Add - _Hd )  >> 4);
-      
+
       op[3*8] = (ogg_int16_t)((_Ed + _Dd )   >> 4);
       op[4*8] = (ogg_int16_t)((_Ed - _Dd )   >> 4);
-      
+
       op[5*8] = (ogg_int16_t)((_Fd + _Bdd )  >> 4);
       op[6*8] = (ogg_int16_t)((_Fd - _Bdd )  >> 4);
     }else{
@@ -440,33 +441,33 @@
       op[5*8] = 0;
       op[6*8] = 0;
     }
-    
-    ip++;			/* next column */
+
+    ip++;                       /* next column */
     op++;
   }
 }
 
 /***************************
-  x   0   0  0  0  0  0  0	
-  0   0   0  0  0  0  0  0	
-  0   0   0  0  0  0  0  0	
-  0   0   0  0  0  0  0  0	
-  0   0   0  0  0  0  0  0	
-  0   0   0  0  0  0  0  0	
-  0   0   0  0  0  0  0  0	
-  0   0   0  0  0  0  0  0	
+  x   0   0  0  0  0  0  0
+  0   0   0  0  0  0  0  0
+  0   0   0  0  0  0  0  0
+  0   0   0  0  0  0  0  0
+  0   0   0  0  0  0  0  0
+  0   0   0  0  0  0  0  0
+  0   0   0  0  0  0  0  0
+  0   0   0  0  0  0  0  0
 **************************/
 
-void IDct1( Q_LIST_ENTRY * InputData, 
-	    ogg_int16_t *QuantMatrix, 
-	    ogg_int16_t * OutputData ){
+void IDct1( Q_LIST_ENTRY * InputData,
+            ogg_int16_t *QuantMatrix,
+            ogg_int16_t * OutputData ){
   int loop;
-  
+
   ogg_int16_t  OutD;
-  
+
   OutD=(ogg_int16_t) ((ogg_int32_t)(InputData[0]*QuantMatrix[0]+15)>>5);
-  
+
   for(loop=0;loop<64;loop++)
     OutputData[loop]=OutD;
-  
+
 }

<p><p>1.7       +364 -363  theora/lib/mcomp.c

Index: mcomp.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/mcomp.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- mcomp.c	8 Jun 2003 00:08:38 -0000	1.6
+++ mcomp.c	10 Jun 2003 01:31:33 -0000	1.7
@@ -10,11 +10,12 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: mcomp.c,v 1.6 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: mcomp.c,v 1.7 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
+#include <stdlib.h>
 #include <stdio.h>
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
@@ -25,10 +26,10 @@
   int SearchSite=0;
   int Len;
   int LineStepY = (ogg_int32_t)cpi->pb.YStride;
-	
+
   Len=((MAX_MV_EXTENT/2)+1)/2;
-  
-  
+
+
   /* How many search stages are there. */
   cpi->MVSearchSteps = 0;
 
@@ -42,7 +43,7 @@
   cpi->HalfPixelRef2Offset[6] = LineStepY - 1;
   cpi->HalfPixelRef2Offset[7] = LineStepY;
   cpi->HalfPixelRef2Offset[8] = LineStepY + 1;
-  
+
   cpi->HalfPixelXOffset[0] = -1;
   cpi->HalfPixelXOffset[1] = 0;
   cpi->HalfPixelXOffset[2] = 1;
@@ -52,7 +53,7 @@
   cpi->HalfPixelXOffset[6] = -1;
   cpi->HalfPixelXOffset[7] = 0;
   cpi->HalfPixelXOffset[8] = 1;
-  
+
   cpi->HalfPixelYOffset[0] = -1;
   cpi->HalfPixelYOffset[1] = -1;
   cpi->HalfPixelYOffset[2] = -1;
@@ -62,13 +63,13 @@
   cpi->HalfPixelYOffset[6] = 1;
   cpi->HalfPixelYOffset[7] = 1;
   cpi->HalfPixelYOffset[8] = 1;
-  
-  
+
+
   /* Generate offsets for 8 search sites per step. */
   while ( Len>0 ) {
     /* Another step. */
     cpi->MVSearchSteps += 1;
-    
+
     /* Compute offsets for search sites. */
     cpi->MVOffsetX[SearchSite] = -Len;
     cpi->MVOffsetY[SearchSite++] = -Len;
@@ -86,26 +87,26 @@
     cpi->MVOffsetY[SearchSite++] = Len;
     cpi->MVOffsetX[SearchSite] = Len;
     cpi->MVOffsetY[SearchSite++] = Len;
-    
+
     /* Contract. */
     Len /= 2;
   }
 
   /* Compute pixel index offsets. */
-  for ( i=SearchSite-1; i>=0; i-- ) 
+  for ( i=SearchSite-1; i>=0; i-- )
     cpi->MVPixelOffsetY[i] = (cpi->MVOffsetY[i]*LineStepY) + cpi->MVOffsetX[i];
 }
 
-static ogg_uint32_t GetInterErr (unsigned char * NewDataPtr, 
-			  unsigned char * RefDataPtr1,  
-			  unsigned char * RefDataPtr2, 
-			  ogg_uint32_t PixelsPerLine ) {
-  ogg_uint32_t	i;
-  ogg_int32_t	XSum=0;
-  ogg_int32_t	XXSum=0;
-  ogg_int32_t	DiffVal;
+static ogg_uint32_t GetInterErr (unsigned char * NewDataPtr,
+                          unsigned char * RefDataPtr1,
+                          unsigned char * RefDataPtr2,
+                          ogg_uint32_t PixelsPerLine ) {
+  ogg_uint32_t  i;
+  ogg_int32_t   XSum=0;
+  ogg_int32_t   XXSum=0;
+  ogg_int32_t   DiffVal;
   ogg_int32_t   AbsRefOffset = abs((int)(RefDataPtr1 - RefDataPtr2));
-  
+
   /* Mode of interpolation chosen based upon on the offset of the
      second reference pointer */
   if ( AbsRefOffset == 0 ) {
@@ -115,35 +116,35 @@
 
       /* negative array indexes are strictly forbidden by ANSI C and C99 */
       XXSum += DiffVal*DiffVal;
-      
+
       DiffVal = ((int)NewDataPtr[1]) - (int)RefDataPtr1[1];
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
+
       DiffVal = ((int)NewDataPtr[2]) - (int)RefDataPtr1[2];
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
+
       DiffVal = ((int)NewDataPtr[3]) - (int)RefDataPtr1[3];
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
+
       DiffVal = ((int)NewDataPtr[4]) - (int)RefDataPtr1[4];
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
+
       DiffVal = ((int)NewDataPtr[5]) - (int)RefDataPtr1[5];
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
+
       DiffVal = ((int)NewDataPtr[6]) - (int)RefDataPtr1[6];
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
+
       DiffVal = ((int)NewDataPtr[7]) - (int)RefDataPtr1[7];
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
+
       /* Step to next row of block. */
       NewDataPtr += PixelsPerLine;
       RefDataPtr1 += STRIDE_EXTRA + PixelsPerLine;
@@ -153,64 +154,64 @@
 
     /* Simple two reference interpolation */
     for ( i=0; i<BLOCK_HEIGHT_WIDTH; i++ ) {
-      DiffVal = ((int)NewDataPtr[0]) - 
-	(((int)RefDataPtr1[0] + (int)RefDataPtr2[0]) / 2);
+      DiffVal = ((int)NewDataPtr[0]) -
+        (((int)RefDataPtr1[0] + (int)RefDataPtr2[0]) / 2);
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
-      DiffVal = ((int)NewDataPtr[1]) - 
-	(((int)RefDataPtr1[1] + (int)RefDataPtr2[1]) / 2);
+
+      DiffVal = ((int)NewDataPtr[1]) -
+        (((int)RefDataPtr1[1] + (int)RefDataPtr2[1]) / 2);
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
-      DiffVal = ((int)NewDataPtr[2]) - 
-	(((int)RefDataPtr1[2] + (int)RefDataPtr2[2]) / 2);
+
+      DiffVal = ((int)NewDataPtr[2]) -
+        (((int)RefDataPtr1[2] + (int)RefDataPtr2[2]) / 2);
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
-      DiffVal = ((int)NewDataPtr[3]) - 
-	(((int)RefDataPtr1[3] + (int)RefDataPtr2[3]) / 2);
+
+      DiffVal = ((int)NewDataPtr[3]) -
+        (((int)RefDataPtr1[3] + (int)RefDataPtr2[3]) / 2);
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
 
-      DiffVal = ((int)NewDataPtr[4]) - 
-	(((int)RefDataPtr1[4] + (int)RefDataPtr2[4]) / 2);
+      DiffVal = ((int)NewDataPtr[4]) -
+        (((int)RefDataPtr1[4] + (int)RefDataPtr2[4]) / 2);
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
-      DiffVal = ((int)NewDataPtr[5]) - 
-	(((int)RefDataPtr1[5] + (int)RefDataPtr2[5]) / 2);
+
+      DiffVal = ((int)NewDataPtr[5]) -
+        (((int)RefDataPtr1[5] + (int)RefDataPtr2[5]) / 2);
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
-      DiffVal = ((int)NewDataPtr[6]) - 
-	(((int)RefDataPtr1[6] + (int)RefDataPtr2[6]) / 2);
+
+      DiffVal = ((int)NewDataPtr[6]) -
+        (((int)RefDataPtr1[6] + (int)RefDataPtr2[6]) / 2);
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
+
       DiffVal = ((int)NewDataPtr[7]) -
-	(((int)RefDataPtr1[7] + (int)RefDataPtr2[7]) / 2);
+        (((int)RefDataPtr1[7] + (int)RefDataPtr2[7]) / 2);
       XSum += DiffVal;
       XXSum += DiffVal*DiffVal;
-      
+
       /* Step to next row of block. */
       NewDataPtr += PixelsPerLine;
       RefDataPtr1 += STRIDE_EXTRA+PixelsPerLine;
       RefDataPtr2 += STRIDE_EXTRA+PixelsPerLine;
     }
   }
-  
+
   /* Compute and return population variance as mis-match metric. */
   return (( (XXSum<<6) - XSum*XSum ));
 }
 
-static ogg_uint32_t GetSumAbsDiffs  (unsigned char * NewDataPtr, 
-			      unsigned char  * RefDataPtr, 
-			      ogg_uint32_t PixelsPerLine, 
-			      ogg_uint32_t ErrorSoFar) {
-  ogg_uint32_t	i;
-  ogg_uint32_t	DiffVal = ErrorSoFar;
-  
+static ogg_uint32_t GetSumAbsDiffs  (unsigned char * NewDataPtr,
+                              unsigned char  * RefDataPtr,
+                              ogg_uint32_t PixelsPerLine,
+                              ogg_uint32_t ErrorSoFar) {
+  ogg_uint32_t  i;
+  ogg_uint32_t  DiffVal = ErrorSoFar;
+
   /* Decide on standard or MMX implementation */
   for ( i=0; i < BLOCK_HEIGHT_WIDTH; i++ ) {
     DiffVal += abs( ((int)NewDataPtr[0]) - ((int)RefDataPtr[0]) );
@@ -227,17 +228,17 @@
     RefDataPtr += STRIDE_EXTRA+PixelsPerLine;
   }
 
-  return DiffVal;  
+  return DiffVal;
 }
 
-static ogg_uint32_t GetNextSumAbsDiffs (unsigned char * NewDataPtr, 
-				 unsigned char * RefDataPtr, 
-				 ogg_uint32_t PixelsPerLine, 
-				 ogg_uint32_t ErrorSoFar, 
-				 ogg_uint32_t BestSoFar ) {
-  ogg_uint32_t	i;
-  ogg_uint32_t	DiffVal = ErrorSoFar;
-  
+static ogg_uint32_t GetNextSumAbsDiffs (unsigned char * NewDataPtr,
+                                 unsigned char * RefDataPtr,
+                                 ogg_uint32_t PixelsPerLine,
+                                 ogg_uint32_t ErrorSoFar,
+                                 ogg_uint32_t BestSoFar ) {
+  ogg_uint32_t  i;
+  ogg_uint32_t  DiffVal = ErrorSoFar;
+
   for ( i=0; i < BLOCK_HEIGHT_WIDTH; i++ ) {
     DiffVal += abs( ((int)NewDataPtr[0]) - ((int)RefDataPtr[0]) );
     DiffVal += abs( ((int)NewDataPtr[1]) - ((int)RefDataPtr[1]) );
@@ -255,44 +256,44 @@
     RefDataPtr += STRIDE_EXTRA+PixelsPerLine;
   }
 
-  return DiffVal;  
+  return DiffVal;
 }
 
-static ogg_uint32_t GetHalfPixelSumAbsDiffs (unsigned char * SrcData, 
-				      unsigned char * RefDataPtr1, 
-				      unsigned char * RefDataPtr2, 
-				      ogg_uint32_t PixelsPerLine, 
-				      ogg_uint32_t ErrorSoFar, 
-				      ogg_uint32_t BestSoFar ) {
-       
-  ogg_uint32_t	i;
-  ogg_uint32_t	DiffVal = ErrorSoFar;
+static ogg_uint32_t GetHalfPixelSumAbsDiffs (unsigned char * SrcData,
+                                      unsigned char * RefDataPtr1,
+                                      unsigned char * RefDataPtr2,
+                                      ogg_uint32_t PixelsPerLine,
+                                      ogg_uint32_t ErrorSoFar,
+                                      ogg_uint32_t BestSoFar ) {
+
+  ogg_uint32_t  i;
+  ogg_uint32_t  DiffVal = ErrorSoFar;
   ogg_int32_t   RefOffset = (int)(RefDataPtr1 - RefDataPtr2);
   ogg_uint32_t  RefPixelsPerLine = PixelsPerLine + STRIDE_EXTRA;
-  
+
   if ( RefOffset == 0 ) {
     /* Simple case as for non 0.5 pixel */
-    DiffVal += GetSumAbsDiffs( SrcData, RefDataPtr1, PixelsPerLine, 
-			       ErrorSoFar);
+    DiffVal += GetSumAbsDiffs( SrcData, RefDataPtr1, PixelsPerLine,
+                               ErrorSoFar);
   } else  {
     for ( i=0; i < BLOCK_HEIGHT_WIDTH; i++ ) {
-      DiffVal += abs( ((int)SrcData[0]) - (((int)RefDataPtr1[0] + 
-					    (int)RefDataPtr2[0]) / 2) );
-      DiffVal += abs( ((int)SrcData[1]) - (((int)RefDataPtr1[1] + 
-					    (int)RefDataPtr2[1]) / 2) );
-      DiffVal += abs( ((int)SrcData[2]) - (((int)RefDataPtr1[2] + 
-					    (int)RefDataPtr2[2]) / 2) );
-      DiffVal += abs( ((int)SrcData[3]) - (((int)RefDataPtr1[3] + 
-					    (int)RefDataPtr2[3]) / 2) );
-      DiffVal += abs( ((int)SrcData[4]) - (((int)RefDataPtr1[4] + 
-					    (int)RefDataPtr2[4]) / 2) );
-      DiffVal += abs( ((int)SrcData[5]) - (((int)RefDataPtr1[5] + 
-					    (int)RefDataPtr2[5]) / 2) );
-      DiffVal += abs( ((int)SrcData[6]) - (((int)RefDataPtr1[6] + 
-					    (int)RefDataPtr2[6]) / 2) );
-      DiffVal += abs( ((int)SrcData[7]) - (((int)RefDataPtr1[7] + 
-					    (int)RefDataPtr2[7]) / 2) );
-      
+      DiffVal += abs( ((int)SrcData[0]) - (((int)RefDataPtr1[0] +
+                                            (int)RefDataPtr2[0]) / 2) );
+      DiffVal += abs( ((int)SrcData[1]) - (((int)RefDataPtr1[1] +
+                                            (int)RefDataPtr2[1]) / 2) );
+      DiffVal += abs( ((int)SrcData[2]) - (((int)RefDataPtr1[2] +
+                                            (int)RefDataPtr2[2]) / 2) );
+      DiffVal += abs( ((int)SrcData[3]) - (((int)RefDataPtr1[3] +
+                                            (int)RefDataPtr2[3]) / 2) );
+      DiffVal += abs( ((int)SrcData[4]) - (((int)RefDataPtr1[4] +
+                                            (int)RefDataPtr2[4]) / 2) );
+      DiffVal += abs( ((int)SrcData[5]) - (((int)RefDataPtr1[5] +
+                                            (int)RefDataPtr2[5]) / 2) );
+      DiffVal += abs( ((int)SrcData[6]) - (((int)RefDataPtr1[6] +
+                                            (int)RefDataPtr2[6]) / 2) );
+      DiffVal += abs( ((int)SrcData[7]) - (((int)RefDataPtr1[7] +
+                                            (int)RefDataPtr2[7]) / 2) );
+
       if ( DiffVal > BestSoFar ) break;
 
       /* Step to next row of block. */
@@ -302,21 +303,21 @@
     }
   }
 
-  return DiffVal;  
+  return DiffVal;
 }
 
-static ogg_uint32_t GetIntraError (unsigned char * DataPtr, 
-			    ogg_uint32_t PixelsPerLine ) {
-  ogg_uint32_t	i;
-  ogg_uint32_t	XSum=0;
-  ogg_uint32_t	XXSum=0;
-  unsigned char	*DiffPtr;
-    
+static ogg_uint32_t GetIntraError (unsigned char * DataPtr,
+                            ogg_uint32_t PixelsPerLine ) {
+  ogg_uint32_t  i;
+  ogg_uint32_t  XSum=0;
+  ogg_uint32_t  XXSum=0;
+  unsigned char *DiffPtr;
+
   /* Loop expanded out for speed. */
   DiffPtr = DataPtr;
-  
+
   for ( i=0; i<BLOCK_HEIGHT_WIDTH; i++ ) {
-	
+
     /* Examine alternate pixel locations. */
     XSum += DiffPtr[0];
     XXSum += DiffPtr[0]*DiffPtr[0];
@@ -343,66 +344,66 @@
   return (( (XXSum<<6) - XSum*XSum ) );
 }
 
-ogg_uint32_t GetMBIntraError (CP_INSTANCE *cpi, ogg_uint32_t FragIndex, 
-			      ogg_uint32_t PixelsPerLine ) {
-  ogg_uint32_t	LocalFragIndex = FragIndex;
+ogg_uint32_t GetMBIntraError (CP_INSTANCE *cpi, ogg_uint32_t FragIndex,
+                              ogg_uint32_t PixelsPerLine ) {
+  ogg_uint32_t  LocalFragIndex = FragIndex;
   ogg_uint32_t  IntraError = 0;
-  
+
   /* Add together the intra errors for those blocks in the macro block
      that are coded (Y only) */
-  if ( cpi->pb.display_fragments[LocalFragIndex] ) 
-    IntraError += 
+  if ( cpi->pb.display_fragments[LocalFragIndex] )
+    IntraError +=
       GetIntraError(&cpi->
-		    ConvDestBuffer[cpi->pb.pixel_index_table[LocalFragIndex]], 
-		    PixelsPerLine );
-  
+                    ConvDestBuffer[cpi->pb.pixel_index_table[LocalFragIndex]],
+                    PixelsPerLine );
+
 
   LocalFragIndex++;
-  if ( cpi->pb.display_fragments[LocalFragIndex] ) 
-    IntraError += 
+  if ( cpi->pb.display_fragments[LocalFragIndex] )
+    IntraError +=
       GetIntraError(&cpi->
-		    ConvDestBuffer[cpi->pb.pixel_index_table[LocalFragIndex]], 
-		    PixelsPerLine );
-  
+                    ConvDestBuffer[cpi->pb.pixel_index_table[LocalFragIndex]],
+                    PixelsPerLine );
+
   LocalFragIndex = FragIndex + cpi->pb.HFragments;
   if ( cpi->pb.display_fragments[LocalFragIndex] )
-    IntraError += 
+    IntraError +=
       GetIntraError(&cpi->
-		     ConvDestBuffer[cpi->pb.pixel_index_table[LocalFragIndex]],
-		     PixelsPerLine );
+                     ConvDestBuffer[cpi->pb.pixel_index_table[LocalFragIndex]],
+                     PixelsPerLine );
 
   LocalFragIndex++;
   if ( cpi->pb.display_fragments[LocalFragIndex] )
-    IntraError += 
+    IntraError +=
       GetIntraError(&cpi->
-		    ConvDestBuffer[cpi->pb.pixel_index_table[LocalFragIndex]], 
-		    PixelsPerLine );
-  
+                    ConvDestBuffer[cpi->pb.pixel_index_table[LocalFragIndex]],
+                    PixelsPerLine );
+
   return IntraError;
 }
 
-ogg_uint32_t GetMBInterError (CP_INSTANCE *cpi, 
-			      unsigned char * SrcPtr, 
-			      unsigned char * RefPtr, 
-			      ogg_uint32_t FragIndex, 
-			      ogg_int32_t LastXMV, 
-			      ogg_int32_t LastYMV, 
-			      ogg_uint32_t PixelsPerLine ) {
+ogg_uint32_t GetMBInterError (CP_INSTANCE *cpi,
+                              unsigned char * SrcPtr,
+                              unsigned char * RefPtr,
+                              ogg_uint32_t FragIndex,
+                              ogg_int32_t LastXMV,
+                              ogg_int32_t LastYMV,
+                              ogg_uint32_t PixelsPerLine ) {
   ogg_uint32_t  RefPixelsPerLine = cpi->pb.YStride;
-  ogg_uint32_t	LocalFragIndex = FragIndex;
+  ogg_uint32_t  LocalFragIndex = FragIndex;
   ogg_int32_t   PixelIndex;
   ogg_int32_t   RefPixelIndex;
   ogg_int32_t   RefPixelOffset;
   ogg_int32_t   RefPtr2Offset;
-  
+
   ogg_uint32_t  InterError = 0;
-  
+
   unsigned char * SrcPtr1;
   unsigned char * RefPtr1;
-  
+
   /* Work out pixel offset into source buffer. */
   PixelIndex = cpi->pb.pixel_index_table[LocalFragIndex];
-  
+
   /* Work out the pixel offset in reference buffer for the default
      motion vector */
   RefPixelIndex = cpi->pb.recon_pixel_index_table[LocalFragIndex];
@@ -428,19 +429,19 @@
   if ( cpi->pb.display_fragments[LocalFragIndex] ) {
     SrcPtr1 = &SrcPtr[PixelIndex];
     RefPtr1 = &RefPtr[RefPixelIndex + RefPixelOffset];
-    InterError += GetInterErr( SrcPtr1, RefPtr1, 
-				 &RefPtr1[RefPtr2Offset], PixelsPerLine );
+    InterError += GetInterErr( SrcPtr1, RefPtr1,
+                                 &RefPtr1[RefPtr2Offset], PixelsPerLine );
   }
-  
+
   LocalFragIndex++;
   if ( cpi->pb.display_fragments[LocalFragIndex] ) {
     PixelIndex = cpi->pb.pixel_index_table[LocalFragIndex];
     RefPixelIndex = cpi->pb.recon_pixel_index_table[LocalFragIndex];
     SrcPtr1 = &SrcPtr[PixelIndex];
     RefPtr1 = &RefPtr[RefPixelIndex + RefPixelOffset];
-    InterError += GetInterErr( SrcPtr1, RefPtr1, 
-				 &RefPtr1[RefPtr2Offset], PixelsPerLine );
-    
+    InterError += GetInterErr( SrcPtr1, RefPtr1,
+                                 &RefPtr1[RefPtr2Offset], PixelsPerLine );
+
   }
 
   LocalFragIndex = FragIndex + cpi->pb.HFragments;
@@ -449,64 +450,64 @@
     RefPixelIndex = cpi->pb.recon_pixel_index_table[LocalFragIndex];
     SrcPtr1 = &SrcPtr[PixelIndex];
     RefPtr1 = &RefPtr[RefPixelIndex + RefPixelOffset];
-    InterError += GetInterErr( SrcPtr1, RefPtr1, 
-				 &RefPtr1[RefPtr2Offset], PixelsPerLine );
+    InterError += GetInterErr( SrcPtr1, RefPtr1,
+                                 &RefPtr1[RefPtr2Offset], PixelsPerLine );
   }
-  
+
   LocalFragIndex++;
   if ( cpi->pb.display_fragments[LocalFragIndex] ) {
     PixelIndex = cpi->pb.pixel_index_table[LocalFragIndex];
     RefPixelIndex = cpi->pb.recon_pixel_index_table[LocalFragIndex];
     SrcPtr1 = &SrcPtr[PixelIndex];
     RefPtr1 = &RefPtr[RefPixelIndex + RefPixelOffset];
-    InterError += GetInterErr( SrcPtr1, RefPtr1, 
-				 &RefPtr1[RefPtr2Offset], PixelsPerLine );
+    InterError += GetInterErr( SrcPtr1, RefPtr1,
+                                 &RefPtr1[RefPtr2Offset], PixelsPerLine );
   }
   return InterError;
 }
 
-ogg_uint32_t GetMBMVInterError (CP_INSTANCE *cpi, 
-				unsigned char * RefFramePtr, 
-				ogg_uint32_t FragIndex, 
-				ogg_uint32_t PixelsPerLine, 
-				ogg_int32_t *MVPixelOffset, 
-				MOTION_VECTOR *MV ) {
-  ogg_uint32_t	Error = 0;
-  ogg_uint32_t	MinError;
+ogg_uint32_t GetMBMVInterError (CP_INSTANCE *cpi,
+                                unsigned char * RefFramePtr,
+                                ogg_uint32_t FragIndex,
+                                ogg_uint32_t PixelsPerLine,
+                                ogg_int32_t *MVPixelOffset,
+                                MOTION_VECTOR *MV ) {
+  ogg_uint32_t  Error = 0;
+  ogg_uint32_t  MinError;
   ogg_uint32_t  InterMVError = 0;
-  
-  ogg_int32_t	i;
-  ogg_int32_t	x=0, y=0;
-  ogg_int32_t	step;
-  ogg_int32_t	SearchSite=0;
-  
-  unsigned char	*SrcPtr[4] = {NULL,NULL,NULL,NULL};
-  unsigned char	*RefPtr=NULL;
-  unsigned char	*CandidateBlockPtr=NULL;
-  unsigned char	*BestBlockPtr=NULL;
-  
+
+  ogg_int32_t   i;
+  ogg_int32_t   x=0, y=0;
+  ogg_int32_t   step;
+  ogg_int32_t   SearchSite=0;
+
+  unsigned char *SrcPtr[4] = {NULL,NULL,NULL,NULL};
+  unsigned char *RefPtr=NULL;
+  unsigned char *CandidateBlockPtr=NULL;
+  unsigned char *BestBlockPtr=NULL;
+
   ogg_uint32_t  RefRow2Offset = cpi->pb.YStride * 8;
-  
+
   int    MBlockDispFrags[4];
-  
+
   /* Half pixel variables */
   ogg_int32_t   HalfPixelError;
   ogg_int32_t   BestHalfPixelError;
   unsigned char   BestHalfOffset;
   unsigned char * RefDataPtr1;
   unsigned char * RefDataPtr2;
-  
+
   /* Note which of the four blocks in the macro block are to be
      included in the search. */
-  MBlockDispFrags[0] = 
+  MBlockDispFrags[0] =
     cpi->pb.display_fragments[FragIndex];
-  MBlockDispFrags[1] = 
+  MBlockDispFrags[1] =
     cpi->pb.display_fragments[FragIndex + 1];
-  MBlockDispFrags[2] = 
+  MBlockDispFrags[2] =
     cpi->pb.display_fragments[FragIndex + cpi->pb.HFragments];
-  MBlockDispFrags[3] = 
+  MBlockDispFrags[3] =
     cpi->pb.display_fragments[FragIndex + cpi->pb.HFragments + 1];
-  
+
   /* Set up the source pointers for the four source blocks.  */
   SrcPtr[0] = &cpi->ConvDestBuffer[cpi->pb.pixel_index_table[FragIndex]];
   SrcPtr[1] = SrcPtr[0] + 8;
@@ -515,25 +516,25 @@
 
   /* Set starting reference point for search. */
   RefPtr = &RefFramePtr[cpi->pb.recon_pixel_index_table[FragIndex]];
-  
+
   /* Check the 0,0 candidate. */
   if ( MBlockDispFrags[0] ) {
-    Error = GetSumAbsDiffs( SrcPtr[0], RefPtr, 
-			 PixelsPerLine, Error);
+    Error = GetSumAbsDiffs( SrcPtr[0], RefPtr,
+                         PixelsPerLine, Error);
   }
   if ( MBlockDispFrags[1] ) {
-    Error = GetSumAbsDiffs( SrcPtr[1], RefPtr + 8, 
-			 PixelsPerLine, Error);         
+    Error = GetSumAbsDiffs( SrcPtr[1], RefPtr + 8,
+                         PixelsPerLine, Error);
   }
   if ( MBlockDispFrags[2] ) {
-    Error = GetSumAbsDiffs( SrcPtr[2], RefPtr + RefRow2Offset, 
-			 PixelsPerLine, Error);        
+    Error = GetSumAbsDiffs( SrcPtr[2], RefPtr + RefRow2Offset,
+                         PixelsPerLine, Error);
   }
   if ( MBlockDispFrags[3] ) {
-    Error = GetSumAbsDiffs( SrcPtr[3], RefPtr + RefRow2Offset + 8, 
-			 PixelsPerLine, Error);
+    Error = GetSumAbsDiffs( SrcPtr[3], RefPtr + RefRow2Offset + 8,
+                         PixelsPerLine, Error);
   }
-  
+
   /* Set starting values to results of 0, 0 vector. */
   MinError = Error;
   BestBlockPtr = RefPtr;
@@ -541,47 +542,47 @@
   y = 0;
   MV->x = 0;
   MV->y = 0;
-  
+
   /* Proceed through N-steps. */
   for (  step=0; step<cpi->MVSearchSteps; step++ ) {
     /* Search the 8-neighbours at distance pertinent to current step.*/
     for ( i=0; i<8; i++ ) {
       /* Set pointer to next candidate matching block. */
       CandidateBlockPtr = RefPtr + MVPixelOffset[SearchSite];
-      
+
       /* Reset error */
       Error = 0;
-      
+
       /* Get the score for the current offset */
       if ( MBlockDispFrags[0] ) {
-	Error = GetSumAbsDiffs( SrcPtr[0], CandidateBlockPtr, 
-			     PixelsPerLine, Error);
+        Error = GetSumAbsDiffs( SrcPtr[0], CandidateBlockPtr,
+                             PixelsPerLine, Error);
       }
 
       if ( MBlockDispFrags[1] && (Error < MinError) ) {
-	Error = GetNextSumAbsDiffs( SrcPtr[1], CandidateBlockPtr + 8, 
-				 PixelsPerLine, Error, MinError );         
+        Error = GetNextSumAbsDiffs( SrcPtr[1], CandidateBlockPtr + 8,
+                                 PixelsPerLine, Error, MinError );
       }
 
       if ( MBlockDispFrags[2] && (Error < MinError) ) {
-	Error = GetNextSumAbsDiffs( SrcPtr[2], CandidateBlockPtr + RefRow2Offset, 
-				 PixelsPerLine, Error, MinError );        
+        Error = GetNextSumAbsDiffs( SrcPtr[2], CandidateBlockPtr + RefRow2Offset,
+                                 PixelsPerLine, Error, MinError );
       }
-      
+
       if ( MBlockDispFrags[3] && (Error < MinError) ) {
-	Error = GetNextSumAbsDiffs( SrcPtr[3], 
-				 CandidateBlockPtr + RefRow2Offset + 8, 
-				 PixelsPerLine, Error, MinError );
+        Error = GetNextSumAbsDiffs( SrcPtr[3],
+                                 CandidateBlockPtr + RefRow2Offset + 8,
+                                 PixelsPerLine, Error, MinError );
       }
-      
+
       if ( Error < MinError ) {
-	/* Remember best match. */
-	MinError = Error;
-	BestBlockPtr = CandidateBlockPtr;
-	
-				/* Where is it. */
-	x = MV->x + cpi->MVOffsetX[SearchSite];
-	y = MV->y + cpi->MVOffsetY[SearchSite];
+        /* Remember best match. */
+        MinError = Error;
+        BestBlockPtr = CandidateBlockPtr;
+
+                                /* Where is it. */
+        x = MV->x + cpi->MVOffsetX[SearchSite];
+        y = MV->y + cpi->MVOffsetY[SearchSite];
       }
 
       /* Move to next search location. */
@@ -597,47 +598,47 @@
   /* Factor vectors to 1/2 pixel resoultion. */
   MV->x = (MV->x * 2);
   MV->y = (MV->y * 2);
-  
+
   /* Now do the half pixel pass */
-  BestHalfOffset = 4;     // Default to the no offset case.
+  BestHalfOffset = 4;     /* Default to the no offset case. */
   BestHalfPixelError = MinError;
-  
+
   /* Get the half pixel error for each half pixel offset */
   for ( i=0; i < 9; i++ ) {
     HalfPixelError = 0;
-    
+
     if ( MBlockDispFrags[0] ) {
       RefDataPtr1 = BestBlockPtr;
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
-      HalfPixelError = 
-	GetHalfPixelSumAbsDiffs( SrcPtr[0], RefDataPtr1, RefDataPtr2, 
-			 PixelsPerLine, HalfPixelError, BestHalfPixelError );
+      HalfPixelError =
+        GetHalfPixelSumAbsDiffs( SrcPtr[0], RefDataPtr1, RefDataPtr2,
+                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
     }
-    
+
     if ( MBlockDispFrags[1]  && (HalfPixelError < BestHalfPixelError) ) {
       RefDataPtr1 = BestBlockPtr + 8;
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
-      HalfPixelError = 
-	GetHalfPixelSumAbsDiffs( SrcPtr[1], RefDataPtr1, RefDataPtr2,
-			 PixelsPerLine, HalfPixelError, BestHalfPixelError );
+      HalfPixelError =
+        GetHalfPixelSumAbsDiffs( SrcPtr[1], RefDataPtr1, RefDataPtr2,
+                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
     }
-    
+
     if ( MBlockDispFrags[2] && (HalfPixelError < BestHalfPixelError) ) {
       RefDataPtr1 = BestBlockPtr + RefRow2Offset;
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
-      HalfPixelError = 
-	GetHalfPixelSumAbsDiffs( SrcPtr[2], RefDataPtr1, RefDataPtr2,
-			 PixelsPerLine, HalfPixelError, BestHalfPixelError );
+      HalfPixelError =
+        GetHalfPixelSumAbsDiffs( SrcPtr[2], RefDataPtr1, RefDataPtr2,
+                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
     }
-    
+
     if ( MBlockDispFrags[3] && (HalfPixelError < BestHalfPixelError) ) {
       RefDataPtr1 = BestBlockPtr + RefRow2Offset + 8;
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
-      HalfPixelError = 
-	GetHalfPixelSumAbsDiffs( SrcPtr[3], RefDataPtr1, RefDataPtr2, 
-			 PixelsPerLine, HalfPixelError, BestHalfPixelError );
+      HalfPixelError =
+        GetHalfPixelSumAbsDiffs( SrcPtr[3], RefDataPtr1, RefDataPtr2,
+                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
     }
-    
+
     if ( HalfPixelError < BestHalfPixelError ) {
       BestHalfOffset = (unsigned char)i;
       BestHalfPixelError = HalfPixelError;
@@ -649,41 +650,41 @@
   MV->y += cpi->HalfPixelYOffset[BestHalfOffset];
 
   /* Get the error score for the chosen 1/2 pixel offset as a variance. */
-  InterMVError = GetMBInterError( cpi, cpi->ConvDestBuffer, RefFramePtr, 
-				  FragIndex, MV->x, MV->y, PixelsPerLine );
-  
+  InterMVError = GetMBInterError( cpi, cpi->ConvDestBuffer, RefFramePtr,
+                                  FragIndex, MV->x, MV->y, PixelsPerLine );
+
   /* Return score of best matching block. */
   return InterMVError;
 }
 
-ogg_uint32_t GetMBMVExhaustiveSearch (CP_INSTANCE *cpi, 
-				      unsigned char * RefFramePtr, 
-				      ogg_uint32_t FragIndex, 
-				      ogg_uint32_t PixelsPerLine, 
-				      MOTION_VECTOR *MV ) {
-  ogg_uint32_t	Error = 0;
-  ogg_uint32_t	MinError = HUGE_ERROR;
+ogg_uint32_t GetMBMVExhaustiveSearch (CP_INSTANCE *cpi,
+                                      unsigned char * RefFramePtr,
+                                      ogg_uint32_t FragIndex,
+                                      ogg_uint32_t PixelsPerLine,
+                                      MOTION_VECTOR *MV ) {
+  ogg_uint32_t  Error = 0;
+  ogg_uint32_t  MinError = HUGE_ERROR;
   ogg_uint32_t  InterMVError = 0;
-  
-  ogg_int32_t	i, j;
-  ogg_int32_t	x=0, y=0;
-	
-  unsigned char	*SrcPtr[4] = {NULL,NULL,NULL,NULL};
-  unsigned char	*RefPtr;
-  unsigned char	*CandidateBlockPtr=NULL;
-  unsigned char	*BestBlockPtr=NULL;
-  
+
+  ogg_int32_t   i, j;
+  ogg_int32_t   x=0, y=0;
+
+  unsigned char *SrcPtr[4] = {NULL,NULL,NULL,NULL};
+  unsigned char *RefPtr;
+  unsigned char *CandidateBlockPtr=NULL;
+  unsigned char *BestBlockPtr=NULL;
+
   ogg_uint32_t  RefRow2Offset = cpi->pb.YStride * 8;
-  
+
   int    MBlockDispFrags[4];
-  
+
   /* Half pixel variables */
   ogg_int32_t   HalfPixelError;
   ogg_int32_t   BestHalfPixelError;
   unsigned char   BestHalfOffset;
   unsigned char * RefDataPtr1;
   unsigned char * RefDataPtr2;
-  
+
   /* Note which of the four blocks in the macro block are to be
      included in the search. */
   MBlockDispFrags[0] = cpi->
@@ -694,7 +695,7 @@
     pb.display_fragments[FragIndex + cpi->pb.HFragments];
   MBlockDispFrags[3] = cpi->
     pb.display_fragments[FragIndex + cpi->pb.HFragments + 1];
-  
+
   /* Set up the source pointers for the four source blocks. */
   SrcPtr[0] = &cpi->
     ConvDestBuffer[cpi->pb.pixel_index_table[FragIndex]];
@@ -704,243 +705,243 @@
 
   RefPtr = &RefFramePtr[cpi->pb.recon_pixel_index_table[FragIndex]];
   RefPtr = RefPtr - ((MAX_MV_EXTENT/2) * cpi->
-		     pb.YStride) - (MAX_MV_EXTENT/2);
+                     pb.YStride) - (MAX_MV_EXTENT/2);
 
   /* Search each pixel alligned site */
   for ( i = 0; i < (ogg_int32_t)MAX_MV_EXTENT; i ++ ) {
     /* Starting position in row */
     CandidateBlockPtr = RefPtr;
-    
+
     for ( j = 0; j < (ogg_int32_t)MAX_MV_EXTENT; j++ ) {
       /* Reset error */
       Error = 0;
-      
+
       /* Summ errors for each block. */
       if ( MBlockDispFrags[0] ) {
-	Error = GetSumAbsDiffs( SrcPtr[0], CandidateBlockPtr, 
-			     PixelsPerLine, Error);
+        Error = GetSumAbsDiffs( SrcPtr[0], CandidateBlockPtr,
+                             PixelsPerLine, Error);
       }
       if ( MBlockDispFrags[1] ){
-	Error = GetSumAbsDiffs( SrcPtr[1], CandidateBlockPtr + 8, 
-			     PixelsPerLine, Error);         
+        Error = GetSumAbsDiffs( SrcPtr[1], CandidateBlockPtr + 8,
+                             PixelsPerLine, Error);
       }
       if ( MBlockDispFrags[2] ){
-	Error = GetSumAbsDiffs( SrcPtr[2], CandidateBlockPtr + RefRow2Offset, 
-			     PixelsPerLine, Error);        
+        Error = GetSumAbsDiffs( SrcPtr[2], CandidateBlockPtr + RefRow2Offset,
+                             PixelsPerLine, Error);
       }
       if ( MBlockDispFrags[3] ){
-	Error = GetSumAbsDiffs( SrcPtr[3], CandidateBlockPtr + RefRow2Offset + 8, 
-			     PixelsPerLine, Error);
+        Error = GetSumAbsDiffs( SrcPtr[3], CandidateBlockPtr + RefRow2Offset + 8,
+                             PixelsPerLine, Error);
       }
-      
+
       /* Was this the best so far */
       if ( Error < MinError ) {
-	MinError = Error;
-	BestBlockPtr = CandidateBlockPtr;
-	x = 16 + j - MAX_MV_EXTENT;
-	y = 16 + i - MAX_MV_EXTENT;
+        MinError = Error;
+        BestBlockPtr = CandidateBlockPtr;
+        x = 16 + j - MAX_MV_EXTENT;
+        y = 16 + i - MAX_MV_EXTENT;
       }
-      
+
       /* Move the the next site */
       CandidateBlockPtr ++;
     }
-    
+
     /* Move on to the next row. */
     RefPtr += cpi->pb.YStride;
-    
+
   }
 
   /* Factor vectors to 1/2 pixel resoultion. */
   MV->x = (x * 2);
   MV->y = (y * 2);
-  
+
   /* Now do the half pixel pass */
   BestHalfOffset = 4;     /* Default to the no offset case. */
   BestHalfPixelError = MinError;
-  
+
   /* Get the half pixel error for each half pixel offset */
   for ( i=0; i < 9; i++ ) {
     HalfPixelError = 0;
-    
+
     if ( MBlockDispFrags[0] ) {
       RefDataPtr1 = BestBlockPtr;
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
-      HalfPixelError = 
-	GetHalfPixelSumAbsDiffs( SrcPtr[0], RefDataPtr1, RefDataPtr2, 
-			 PixelsPerLine, HalfPixelError, BestHalfPixelError );
+      HalfPixelError =
+        GetHalfPixelSumAbsDiffs( SrcPtr[0], RefDataPtr1, RefDataPtr2,
+                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
     }
-    
+
     if ( MBlockDispFrags[1]  && (HalfPixelError < BestHalfPixelError) ) {
       RefDataPtr1 = BestBlockPtr + 8;
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
-      HalfPixelError = 
-	GetHalfPixelSumAbsDiffs( SrcPtr[1], RefDataPtr1, RefDataPtr2,
-			 PixelsPerLine, HalfPixelError, BestHalfPixelError );
+      HalfPixelError =
+        GetHalfPixelSumAbsDiffs( SrcPtr[1], RefDataPtr1, RefDataPtr2,
+                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
     }
-    
+
     if ( MBlockDispFrags[2] && (HalfPixelError < BestHalfPixelError) ) {
       RefDataPtr1 = BestBlockPtr + RefRow2Offset;
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
-      HalfPixelError = 
-	GetHalfPixelSumAbsDiffs( SrcPtr[2], RefDataPtr1, RefDataPtr2,
-			 PixelsPerLine, HalfPixelError, BestHalfPixelError );
+      HalfPixelError =
+        GetHalfPixelSumAbsDiffs( SrcPtr[2], RefDataPtr1, RefDataPtr2,
+                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
     }
-    
+
     if ( MBlockDispFrags[3] && (HalfPixelError < BestHalfPixelError) ) {
       RefDataPtr1 = BestBlockPtr + RefRow2Offset + 8;
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
-      HalfPixelError = 
-	GetHalfPixelSumAbsDiffs( SrcPtr[3], RefDataPtr1, RefDataPtr2, 
-			 PixelsPerLine, HalfPixelError, BestHalfPixelError );
+      HalfPixelError =
+        GetHalfPixelSumAbsDiffs( SrcPtr[3], RefDataPtr1, RefDataPtr2,
+                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
     }
-    
+
     if ( HalfPixelError < BestHalfPixelError ){
       BestHalfOffset = (unsigned char)i;
       BestHalfPixelError = HalfPixelError;
     }
   }
-  
+
   /* Half pixel adjust the MV */
   MV->x += cpi->HalfPixelXOffset[BestHalfOffset];
   MV->y += cpi->HalfPixelYOffset[BestHalfOffset];
-  
+
   /* Get the error score for the chosen 1/2 pixel offset as a variance. */
-  InterMVError = GetMBInterError( cpi, cpi->ConvDestBuffer, RefFramePtr, 
-				  FragIndex, MV->x, MV->y, PixelsPerLine );
-  
+  InterMVError = GetMBInterError( cpi, cpi->ConvDestBuffer, RefFramePtr,
+                                  FragIndex, MV->x, MV->y, PixelsPerLine );
+
   /* Return score of best matching block. */
   return InterMVError;
 }
 
-static ogg_uint32_t GetBMVExhaustiveSearch (CP_INSTANCE *cpi, 
-					    unsigned char * RefFramePtr, 
-					    ogg_uint32_t FragIndex, 
-					    ogg_uint32_t PixelsPerLine, 
-					    MOTION_VECTOR *MV ) {
-  ogg_uint32_t	Error = 0;
-  ogg_uint32_t	MinError = HUGE_ERROR;
+static ogg_uint32_t GetBMVExhaustiveSearch (CP_INSTANCE *cpi,
+                                            unsigned char * RefFramePtr,
+                                            ogg_uint32_t FragIndex,
+                                            ogg_uint32_t PixelsPerLine,
+                                            MOTION_VECTOR *MV ) {
+  ogg_uint32_t  Error = 0;
+  ogg_uint32_t  MinError = HUGE_ERROR;
   ogg_uint32_t  InterMVError = 0;
-  
-  ogg_int32_t	i, j;
-  ogg_int32_t	x=0, y=0;
-  
-  unsigned char	*SrcPtr = NULL;
-  unsigned char	*RefPtr;
-  unsigned char	*CandidateBlockPtr=NULL;
-  unsigned char	*BestBlockPtr=NULL;
-  
+
+  ogg_int32_t   i, j;
+  ogg_int32_t   x=0, y=0;
+
+  unsigned char *SrcPtr = NULL;
+  unsigned char *RefPtr;
+  unsigned char *CandidateBlockPtr=NULL;
+  unsigned char *BestBlockPtr=NULL;
+
   /* Half pixel variables */
   ogg_int32_t   HalfPixelError;
   ogg_int32_t   BestHalfPixelError;
   unsigned char   BestHalfOffset;
   unsigned char * RefDataPtr2;
-  
+
   /* Set up the source pointer for the block. */
   SrcPtr = &cpi->
     ConvDestBuffer[cpi->pb.pixel_index_table[FragIndex]];
- 
+
   RefPtr = &RefFramePtr[cpi->pb.recon_pixel_index_table[FragIndex]];
-  RefPtr = RefPtr - ((MAX_MV_EXTENT/2) * 
-		     cpi->pb.YStride) - (MAX_MV_EXTENT/2);
-  
+  RefPtr = RefPtr - ((MAX_MV_EXTENT/2) *
+                     cpi->pb.YStride) - (MAX_MV_EXTENT/2);
+
   /* Search each pixel alligned site */
   for ( i = 0; i < (ogg_int32_t)MAX_MV_EXTENT; i ++ ) {
     /* Starting position in row */
     CandidateBlockPtr = RefPtr;
-    
+
     for ( j = 0; j < (ogg_int32_t)MAX_MV_EXTENT; j++ ){
       /* Get the block error score. */
-      Error = GetSumAbsDiffs( SrcPtr, CandidateBlockPtr, 
-			   PixelsPerLine, 0);
-      
+      Error = GetSumAbsDiffs( SrcPtr, CandidateBlockPtr,
+                           PixelsPerLine, 0);
+
       /* Was this the best so far */
       if ( Error < MinError ) {
-	MinError = Error;
-	BestBlockPtr = CandidateBlockPtr;
-	x = 16 + j - MAX_MV_EXTENT;
-	y = 16 + i - MAX_MV_EXTENT;
+        MinError = Error;
+        BestBlockPtr = CandidateBlockPtr;
+        x = 16 + j - MAX_MV_EXTENT;
+        y = 16 + i - MAX_MV_EXTENT;
       }
-      
+
       /* Move the the next site */
       CandidateBlockPtr ++;
     }
-    
+
     /* Move on to the next row. */
     RefPtr += cpi->pb.YStride;
   }
-  
+
   /* Factor vectors to 1/2 pixel resoultion. */
   MV->x = (x * 2);
   MV->y = (y * 2);
-  
+
   /* Now do the half pixel pass */
   BestHalfOffset = 4;     /* Default to the no offset case. */
   BestHalfPixelError = MinError;
-  
+
   /* Get the half pixel error for each half pixel offset */
   for ( i=0; i < 9; i++ ) {
     RefDataPtr2 = BestBlockPtr + cpi->HalfPixelRef2Offset[i];
-    HalfPixelError = 
-      GetHalfPixelSumAbsDiffs( SrcPtr, BestBlockPtr, RefDataPtr2, 
-			    PixelsPerLine, 0, BestHalfPixelError );
-    
+    HalfPixelError =
+      GetHalfPixelSumAbsDiffs( SrcPtr, BestBlockPtr, RefDataPtr2,
+                            PixelsPerLine, 0, BestHalfPixelError );
+
     if ( HalfPixelError < BestHalfPixelError ){
       BestHalfOffset = (unsigned char)i;
       BestHalfPixelError = HalfPixelError;
     }
   }
-  
+
   /* Half pixel adjust the MV */
   MV->x += cpi->HalfPixelXOffset[BestHalfOffset];
   MV->y += cpi->HalfPixelYOffset[BestHalfOffset];
-  
+
   /* Get the variance score at the chosen offset */
   RefDataPtr2 = BestBlockPtr + cpi->HalfPixelRef2Offset[BestHalfOffset];
-  
-  InterMVError = 
+
+  InterMVError =
     GetInterErr( SrcPtr, BestBlockPtr, RefDataPtr2, PixelsPerLine );
-  
+
   /* Return score of best matching block. */
   return InterMVError;
 }
 
-ogg_uint32_t GetFOURMVExhaustiveSearch (CP_INSTANCE *cpi, 
-					unsigned char * RefFramePtr, 
-					ogg_uint32_t FragIndex, 
-					ogg_uint32_t PixelsPerLine, 
-					MOTION_VECTOR *MV ) {
+ogg_uint32_t GetFOURMVExhaustiveSearch (CP_INSTANCE *cpi,
+                                        unsigned char * RefFramePtr,
+                                        ogg_uint32_t FragIndex,
+                                        ogg_uint32_t PixelsPerLine,
+                                        MOTION_VECTOR *MV ) {
   ogg_uint32_t  InterMVError;
-  
+
   /* For the moment the 4MV mode is only deemd to be valid if all four
      Y blocks are to be updated */
   /* This May be adapted later. */
-  if ( cpi->pb.display_fragments[FragIndex] && 
+  if ( cpi->pb.display_fragments[FragIndex] &&
        cpi->pb.display_fragments[FragIndex + 1] &&
-       cpi->pb.display_fragments[FragIndex + cpi->pb.HFragments] && 
+       cpi->pb.display_fragments[FragIndex + cpi->pb.HFragments] &&
        cpi->pb.display_fragments[FragIndex + cpi->pb.HFragments + 1] ) {
-    
+
     /* Reset the error score. */
     InterMVError = 0;
-    
+
     /* Get the error component from each coded block */
-    InterMVError += 
-      GetBMVExhaustiveSearch(cpi, RefFramePtr, FragIndex, 
-			     PixelsPerLine, &(MV[0]) );
-    InterMVError += 
+    InterMVError +=
+      GetBMVExhaustiveSearch(cpi, RefFramePtr, FragIndex,
+                             PixelsPerLine, &(MV[0]) );
+    InterMVError +=
       GetBMVExhaustiveSearch(cpi, RefFramePtr, (FragIndex + 1),
-			     PixelsPerLine, &(MV[1]) );
-    InterMVError += 
-      GetBMVExhaustiveSearch(cpi, RefFramePtr, 
-			     (FragIndex + cpi->pb.HFragments), 
-			     PixelsPerLine, &(MV[2]) );
-    InterMVError += 
-      GetBMVExhaustiveSearch(cpi, RefFramePtr, 
-			     (FragIndex + cpi->pb.HFragments + 1), 
-			     PixelsPerLine, &(MV[3]) );
+                             PixelsPerLine, &(MV[1]) );
+    InterMVError +=
+      GetBMVExhaustiveSearch(cpi, RefFramePtr,
+                             (FragIndex + cpi->pb.HFragments),
+                             PixelsPerLine, &(MV[2]) );
+    InterMVError +=
+      GetBMVExhaustiveSearch(cpi, RefFramePtr,
+                             (FragIndex + cpi->pb.HFragments + 1),
+                             PixelsPerLine, &(MV[3]) );
   }else{
     InterMVError = HUGE_ERROR;
   }
-  
+
   /* Return score of best matching block. */
   return InterMVError;
 }

<p><p>1.3       +65 -67    theora/lib/mcomp.h

Index: mcomp.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/mcomp.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mcomp.h	8 Jun 2003 00:08:38 -0000	1.2
+++ mcomp.h	10 Jun 2003 01:31:33 -0000	1.3
@@ -11,74 +11,72 @@
  ********************************************************************
 
   function: simple static lookups for VP3 codec
-  last mod: $Id: mcomp.h,v 1.2 2003/06/08 00:08:38 giles Exp $
+  last mod: $Id: mcomp.h,v 1.3 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
-ogg_int32_t XX_LUT[511]={  
-  65025, 64516, 64009, 63504, 63001, 62500, 62001, 61504, 
-  61009, 60516, 60025, 59536, 59049, 58564, 58081, 57600, 
-  57121, 56644, 56169, 55696, 55225, 54756, 54289, 53824, 
-  53361, 52900, 52441, 51984, 51529, 51076, 50625, 50176, 
-  49729, 49284, 48841, 48400, 47961, 47524, 47089, 46656, 
-  46225, 45796, 45369, 44944, 44521, 44100, 43681, 43264, 
-  42849, 42436, 42025, 41616, 41209, 40804, 40401, 40000, 
-  39601, 39204, 38809, 38416, 38025, 37636, 37249, 36864, 
-  36481, 36100, 35721, 35344, 34969, 34596, 34225, 33856, 
-  33489, 33124, 32761, 32400, 32041, 31684, 31329, 30976, 
-  30625, 30276, 29929, 29584, 29241, 28900, 28561, 28224, 
-  27889, 27556, 27225, 26896, 26569, 26244, 25921, 25600, 
-  25281, 24964, 24649, 24336, 24025, 23716, 23409, 23104, 
-  22801, 22500, 22201, 21904, 21609, 21316, 21025, 20736, 
-  20449, 20164, 19881, 19600, 19321, 19044, 18769, 18496, 
-  18225, 17956, 17689, 17424, 17161, 16900, 16641, 16384, 
-  16129, 15876, 15625, 15376, 15129, 14884, 14641, 14400, 
-  14161, 13924, 13689, 13456, 13225, 12996, 12769, 12544, 
-  12321, 12100, 11881, 11664, 11449, 11236, 11025, 10816, 
-  10609, 10404, 10201, 10000,  9801,  9604,  9409,  9216, 
-   9025,  8836,  8649,  8464,  8281,  8100,  7921,  7744, 
-   7569,  7396,  7225,  7056,  6889,  6724,  6561,  6400, 
-   6241,  6084,  5929,  5776,  5625,  5476,  5329,  5184, 
-   5041,  4900,  4761,  4624,  4489,  4356,  4225,  4096, 
-   3969,  3844,  3721,  3600,  3481,  3364,  3249,  3136, 
-   3025,  2916,  2809,  2704,  2601,  2500,  2401,  2304, 
-   2209,  2116,  2025,  1936,  1849,  1764,  1681,  1600, 
-   1521,  1444,  1369,  1296,  1225,  1156,  1089,  1024, 
-    961,   900,   841,   784,   729,   676,   625,   576, 
-    529,   484,   441,   400,   361,   324,   289,   256, 
-    225,   196,   169,   144,   121,   100,    81,    64, 
-     49,    36,    25,    16,     9,     4,     1,     0, 
-      1,     4,     9,    16,    25,    36,    49,    64, 
-     81,   100,   121,   144,   169,   196,   225,   256, 
-    289,   324,   361,   400,   441,   484,   529,   576, 
-    625,   676,   729,   784,   841,   900,   961,  1024, 
-   1089,  1156,  1225,  1296,  1369,  1444,  1521,  1600, 
-   1681,  1764,  1849,  1936,  2025,  2116,  2209,  2304, 
-   2401,  2500,  2601,  2704,  2809,  2916,  3025,  3136, 
-   3249,  3364,  3481,  3600,  3721,  3844,  3969,  4096, 
-   4225,  4356,  4489,  4624,  4761,  4900,  5041,  5184, 
-   5329,  5476,  5625,  5776,  5929,  6084,  6241,  6400, 
-   6561,  6724,  6889,  7056,  7225,  7396,  7569,  7744, 
-   7921,  8100,  8281,  8464,  8649,  8836,  9025,  9216, 
-   9409,  9604,  9801, 10000, 10201, 10404, 10609, 10816, 
-  11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 
-  12769, 12996, 13225, 13456, 13689, 13924, 14161, 14400, 
-  14641, 14884, 15129, 15376, 15625, 15876, 16129, 16384, 
-  16641, 16900, 17161, 17424, 17689, 17956, 18225, 18496, 
-  18769, 19044, 19321, 19600, 19881, 20164, 20449, 20736, 
-  21025, 21316, 21609, 21904, 22201, 22500, 22801, 23104, 
-  23409, 23716, 24025, 24336, 24649, 24964, 25281, 25600, 
-  25921, 26244, 26569, 26896, 27225, 27556, 27889, 28224, 
-  28561, 28900, 29241, 29584, 29929, 30276, 30625, 30976, 
-  31329, 31684, 32041, 32400, 32761, 33124, 33489, 33856, 
-  34225, 34596, 34969, 35344, 35721, 36100, 36481, 36864, 
-  37249, 37636, 38025, 38416, 38809, 39204, 39601, 40000, 
-  40401, 40804, 41209, 41616, 42025, 42436, 42849, 43264, 
-  43681, 44100, 44521, 44944, 45369, 45796, 46225, 46656, 
-  47089, 47524, 47961, 48400, 48841, 49284, 49729, 50176, 
-  50625, 51076, 51529, 51984, 52441, 52900, 53361, 53824, 
-  54289, 54756, 55225, 55696, 56169, 56644, 57121, 57600, 
-  58081, 58564, 59049, 59536, 60025, 60516, 61009, 61504, 
+ogg_int32_t XX_LUT[511]={
+  65025, 64516, 64009, 63504, 63001, 62500, 62001, 61504,
+  61009, 60516, 60025, 59536, 59049, 58564, 58081, 57600,
+  57121, 56644, 56169, 55696, 55225, 54756, 54289, 53824,
+  53361, 52900, 52441, 51984, 51529, 51076, 50625, 50176,
+  49729, 49284, 48841, 48400, 47961, 47524, 47089, 46656,
+  46225, 45796, 45369, 44944, 44521, 44100, 43681, 43264,
+  42849, 42436, 42025, 41616, 41209, 40804, 40401, 40000,
+  39601, 39204, 38809, 38416, 38025, 37636, 37249, 36864,
+  36481, 36100, 35721, 35344, 34969, 34596, 34225, 33856,
+  33489, 33124, 32761, 32400, 32041, 31684, 31329, 30976,
+  30625, 30276, 29929, 29584, 29241, 28900, 28561, 28224,
+  27889, 27556, 27225, 26896, 26569, 26244, 25921, 25600,
+  25281, 24964, 24649, 24336, 24025, 23716, 23409, 23104,
+  22801, 22500, 22201, 21904, 21609, 21316, 21025, 20736,
+  20449, 20164, 19881, 19600, 19321, 19044, 18769, 18496,
+  18225, 17956, 17689, 17424, 17161, 16900, 16641, 16384,
+  16129, 15876, 15625, 15376, 15129, 14884, 14641, 14400,
+  14161, 13924, 13689, 13456, 13225, 12996, 12769, 12544,
+  12321, 12100, 11881, 11664, 11449, 11236, 11025, 10816,
+  10609, 10404, 10201, 10000,  9801,  9604,  9409,  9216,
+   9025,  8836,  8649,  8464,  8281,  8100,  7921,  7744,
+   7569,  7396,  7225,  7056,  6889,  6724,  6561,  6400,
+   6241,  6084,  5929,  5776,  5625,  5476,  5329,  5184,
+   5041,  4900,  4761,  4624,  4489,  4356,  4225,  4096,
+   3969,  3844,  3721,  3600,  3481,  3364,  3249,  3136,
+   3025,  2916,  2809,  2704,  2601,  2500,  2401,  2304,
+   2209,  2116,  2025,  1936,  1849,  1764,  1681,  1600,
+   1521,  1444,  1369,  1296,  1225,  1156,  1089,  1024,
+    961,   900,   841,   784,   729,   676,   625,   576,
+    529,   484,   441,   400,   361,   324,   289,   256,
+    225,   196,   169,   144,   121,   100,    81,    64,
+     49,    36,    25,    16,     9,     4,     1,     0,
+      1,     4,     9,    16,    25,    36,    49,    64,
+     81,   100,   121,   144,   169,   196,   225,   256,
+    289,   324,   361,   400,   441,   484,   529,   576,
+    625,   676,   729,   784,   841,   900,   961,  1024,
+   1089,  1156,  1225,  1296,  1369,  1444,  1521,  1600,
+   1681,  1764,  1849,  1936,  2025,  2116,  2209,  2304,
+   2401,  2500,  2601,  2704,  2809,  2916,  3025,  3136,
+   3249,  3364,  3481,  3600,  3721,  3844,  3969,  4096,
+   4225,  4356,  4489,  4624,  4761,  4900,  5041,  5184,
+   5329,  5476,  5625,  5776,  5929,  6084,  6241,  6400,
+   6561,  6724,  6889,  7056,  7225,  7396,  7569,  7744,
+   7921,  8100,  8281,  8464,  8649,  8836,  9025,  9216,
+   9409,  9604,  9801, 10000, 10201, 10404, 10609, 10816,
+  11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544,
+  12769, 12996, 13225, 13456, 13689, 13924, 14161, 14400,
+  14641, 14884, 15129, 15376, 15625, 15876, 16129, 16384,
+  16641, 16900, 17161, 17424, 17689, 17956, 18225, 18496,
+  18769, 19044, 19321, 19600, 19881, 20164, 20449, 20736,
+  21025, 21316, 21609, 21904, 22201, 22500, 22801, 23104,
+  23409, 23716, 24025, 24336, 24649, 24964, 25281, 25600,
+  25921, 26244, 26569, 26896, 27225, 27556, 27889, 28224,
+  28561, 28900, 29241, 29584, 29929, 30276, 30625, 30976,
+  31329, 31684, 32041, 32400, 32761, 33124, 33489, 33856,
+  34225, 34596, 34969, 35344, 35721, 36100, 36481, 36864,
+  37249, 37636, 38025, 38416, 38809, 39204, 39601, 40000,
+  40401, 40804, 41209, 41616, 42025, 42436, 42849, 43264,
+  43681, 44100, 44521, 44944, 45369, 45796, 46225, 46656,
+  47089, 47524, 47961, 48400, 48841, 49284, 49729, 50176,
+  50625, 51076, 51529, 51984, 52441, 52900, 53361, 53824,
+  54289, 54756, 55225, 55696, 56169, 56644, 57121, 57600,
+  58081, 58564, 59049, 59536, 60025, 60516, 61009, 61504,
   62001, 62500, 63001, 63504, 64009, 64516, 65025};
-
-

<p><p>1.9       +112 -111  theora/lib/misc_common.c

Index: misc_common.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/misc_common.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- misc_common.c	8 Jun 2003 00:08:38 -0000	1.8
+++ misc_common.c	10 Jun 2003 01:31:33 -0000	1.9
@@ -10,37 +10,38 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: misc_common.c,v 1.8 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: misc_common.c,v 1.9 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
+#include <string.h>
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 #include "block_inline.h"
 
-#define FIXED_Q	                150
-#define MAX_UP_REG_LOOPS        2    
+#define FIXED_Q                 150
+#define MAX_UP_REG_LOOPS        2
 
 /* Gives the initial bytes per block estimate for each Q value */
-double BpbTable[Q_TABLE_SIZE] = {   
+double BpbTable[Q_TABLE_SIZE] = {
   0.42,  0.45,  0.46,  0.49,  0.51,  0.53,  0.56,  0.58,
   0.61,  0.64,  0.68,  0.71,  0.74,  0.77,  0.80,  0.84,
   0.89,  0.92,  0.98,  1.01,  1.04,  1.13,  1.17,  1.23,
   1.28,  1.34,  1.41,  1.45,  1.51,  1.59,  1.69,  1.80,
   1.84,  1.94,  2.02,  2.15,  2.23,  2.34,  2.44,  2.50,
-  2.69,  2.80,  2.87,  3.04,  3.16,  3.29,  3.59,  3.66, 
+  2.69,  2.80,  2.87,  3.04,  3.16,  3.29,  3.59,  3.66,
   3.86,  3.94,  4.22,  4.50,  4.64,  4.70,  5.24,  5.34,
   5.61,  5.87,  6.11,  6.41,  6.71,  6.99,  7.36,  7.69
 };
 
-double KfBpbTable[Q_TABLE_SIZE] = {   
+double KfBpbTable[Q_TABLE_SIZE] = {
   0.74,  0.81,  0.88,  0.94,  1.00,  1.06,  1.14,  1.19,
   1.27,  1.34,  1.42,  1.49,  1.54,  1.59,  1.66,  1.73,
   1.80,  1.87,  1.97,  2.01,  2.08,  2.21,  2.25,  2.36,
   2.39,  2.50,  2.55,  2.65,  2.71,  2.82,  2.95,  3.01,
   3.11,  3.19,  3.31,  3.42,  3.58,  3.66,  3.78,  3.89,
-  4.11,  4.26,  4.36,  4.39,  4.63,  4.76,  4.85,  5.04, 
+  4.11,  4.26,  4.36,  4.39,  4.63,  4.76,  4.85,  5.04,
   5.26,  5.29,  5.47,  5.64,  5.76,  6.05,  6.35,  6.67,
   6.91,  7.17,  7.40,  7.56,  8.02,  8.45,  8.86,  9.38
 };
@@ -67,56 +68,56 @@
     BytesPerBlock = BpbTable[ThreshTableIndex];
     BytesPerBlock = BytesPerBlock * cpi->BpbCorrectionFactor;
   }
-  
+
   return BytesPerBlock;
 }
 
-static void UpRegulateMB( CP_INSTANCE *cpi, ogg_uint32_t RegulationQ, 
-		   ogg_uint32_t SB, ogg_uint32_t MB, int NoCheck ) {
+static void UpRegulateMB( CP_INSTANCE *cpi, ogg_uint32_t RegulationQ,
+                   ogg_uint32_t SB, ogg_uint32_t MB, int NoCheck ) {
   ogg_int32_t  FragIndex;
-  ogg_uint32_t B; 
-  
+  ogg_uint32_t B;
+
   /* Variables used in calculating corresponding row,col and index in
      UV planes */
   ogg_uint32_t UVRow;
   ogg_uint32_t UVColumn;
   ogg_uint32_t UVFragOffset;
-  
+
   /* There may be MB's lying out of frame which must be ignored. For
    these MB's Top left block will have a negative Fragment Index. */
   if ( QuadMapToMBTopLeft(cpi->pb.BlockMap, SB, MB ) >= 0 ) {
     /* Up regulate the component blocks Y then UV. */
     for ( B=0; B<4; B++ ){
       FragIndex = QuadMapToIndex1( cpi->pb.BlockMap, SB, MB, B );
-      
+
       if ( ( !cpi->pb.display_fragments[FragIndex] ) &&
-	   ( (NoCheck) || (cpi->FragmentLastQ[FragIndex] > RegulationQ) ) ){
-	cpi->pb.display_fragments[FragIndex] = 1;
-	cpi->extra_fragments[FragIndex] = 1;
-	cpi->FragmentLastQ[FragIndex] = RegulationQ;
-	cpi->MotionScore++;
+           ( (NoCheck) || (cpi->FragmentLastQ[FragIndex] > RegulationQ) ) ){
+        cpi->pb.display_fragments[FragIndex] = 1;
+        cpi->extra_fragments[FragIndex] = 1;
+        cpi->FragmentLastQ[FragIndex] = RegulationQ;
+        cpi->MotionScore++;
       }
     }
-    
+
     /* Check the two UV blocks */
     FragIndex = QuadMapToMBTopLeft(cpi->pb.BlockMap, SB, MB );
-    
+
     UVRow = (FragIndex / (cpi->pb.HFragments * 2));
     UVColumn = (FragIndex % cpi->pb.HFragments) / 2;
     UVFragOffset = (UVRow * (cpi->pb.HFragments / 2)) + UVColumn;
-    
+
     FragIndex = cpi->pb.YPlaneFragments + UVFragOffset;
     if ( ( !cpi->pb.display_fragments[FragIndex] ) &&
-	 ( (NoCheck) || (cpi->FragmentLastQ[FragIndex] > RegulationQ) ) ) {
+         ( (NoCheck) || (cpi->FragmentLastQ[FragIndex] > RegulationQ) ) ) {
       cpi->pb.display_fragments[FragIndex] = 1;
       cpi->extra_fragments[FragIndex] = 1;
       cpi->FragmentLastQ[FragIndex] = RegulationQ;
       cpi->MotionScore++;
     }
-    
+
     FragIndex += cpi->pb.UVPlaneFragments;
     if ( ( !cpi->pb.display_fragments[FragIndex] ) &&
-	 ( (NoCheck) || (cpi->FragmentLastQ[FragIndex] > RegulationQ) ) ) {
+         ( (NoCheck) || (cpi->FragmentLastQ[FragIndex] > RegulationQ) ) ) {
       cpi->pb.display_fragments[FragIndex] = 1;
       cpi->extra_fragments[FragIndex] = 1;
       cpi->FragmentLastQ[FragIndex] = RegulationQ;
@@ -125,43 +126,43 @@
   }
 }
 
-static void UpRegulateBlocks (CP_INSTANCE *cpi, ogg_uint32_t RegulationQ, 
-		       ogg_int32_t RecoveryBlocks, 
-		       ogg_uint32_t * LastSB, ogg_uint32_t * LastMB ) {
+static void UpRegulateBlocks (CP_INSTANCE *cpi, ogg_uint32_t RegulationQ,
+                       ogg_int32_t RecoveryBlocks,
+                       ogg_uint32_t * LastSB, ogg_uint32_t * LastMB ) {
 
   ogg_uint32_t LoopTimesRound = 0;
-  ogg_uint32_t MaxSB = cpi->pb.YSBRows * 
+  ogg_uint32_t MaxSB = cpi->pb.YSBRows *
     cpi->pb.YSBCols;   /* Tot super blocks in image */
   ogg_uint32_t SB, MB; /* Super-Block and macro block indices. */
-  
+
   /* First scan for blocks for which a residue update is outstanding. */
-  while ( (cpi->MotionScore < RecoveryBlocks) && 
-	  (LoopTimesRound < MAX_UP_REG_LOOPS) ) {
+  while ( (cpi->MotionScore < RecoveryBlocks) &&
+          (LoopTimesRound < MAX_UP_REG_LOOPS) ) {
     LoopTimesRound++;
-    
+
     for ( SB = (*LastSB); SB < MaxSB; SB++ ) {
       /* Check its four Macro-Blocks */
       for ( MB=(*LastMB); MB<4; MB++ ) {
-	/* Mark relevant blocks for update */
-	UpRegulateMB( cpi, RegulationQ, SB, MB, 0 );
-	
-	/* Keep track of the last refresh MB. */
-	(*LastMB) += 1;
-	if ( (*LastMB) == 4 )
-	  (*LastMB) = 0;
-	
-	/* Termination clause */
-	if (cpi->MotionScore >= RecoveryBlocks) {
-	  /* Make sure we don't stall at SB level */
-	  if ( *LastMB == 0 )
-	    SB++;
-	  break;
-	}
+        /* Mark relevant blocks for update */
+        UpRegulateMB( cpi, RegulationQ, SB, MB, 0 );
+
+        /* Keep track of the last refresh MB. */
+        (*LastMB) += 1;
+        if ( (*LastMB) == 4 )
+          (*LastMB) = 0;
+
+        /* Termination clause */
+        if (cpi->MotionScore >= RecoveryBlocks) {
+          /* Make sure we don't stall at SB level */
+          if ( *LastMB == 0 )
+            SB++;
+          break;
+        }
       }
-      
+
       /* Termination clause */
       if (cpi->MotionScore >= RecoveryBlocks)
-	break;
+        break;
     }
 
     /* Update super block start index  */
@@ -173,26 +174,26 @@
   }
 }
 
-void UpRegulateDataStream (CP_INSTANCE *cpi, ogg_uint32_t RegulationQ, 
-			   ogg_int32_t RecoveryBlocks ) {  
+void UpRegulateDataStream (CP_INSTANCE *cpi, ogg_uint32_t RegulationQ,
+                           ogg_int32_t RecoveryBlocks ) {
   ogg_uint32_t LastPassMBPos = 0;
   ogg_uint32_t StdLastMBPos = 0;
-  
-  ogg_uint32_t MaxSB = cpi->pb.YSBRows * 
+
+  ogg_uint32_t MaxSB = cpi->pb.YSBRows *
     cpi->pb.YSBCols;    /* Tot super blocks in image */
 
-  ogg_uint32_t SB=0;	/* Super-Block index */
-  ogg_uint32_t MB;	/* Macro-Block index */
-  
+  ogg_uint32_t SB=0;    /* Super-Block index */
+  ogg_uint32_t MB;      /* Macro-Block index */
+
   /* Decduct the number of blocks in an MB / 2 from the recover block count.
      This will compensate for the fact that once we start checking an MB
      we test every block in that macro block */
-  if ( RecoveryBlocks > 3 ) 
+  if ( RecoveryBlocks > 3 )
     RecoveryBlocks -= 3;
 
   /* Up regulate blocks last coded at higher Q */
-  UpRegulateBlocks( cpi, RegulationQ, RecoveryBlocks, 
-		    &cpi->LastEndSB, &StdLastMBPos );
+  UpRegulateBlocks( cpi, RegulationQ, RecoveryBlocks,
+                    &cpi->LastEndSB, &StdLastMBPos );
 
   /* If we have still not used up the minimum number of blocks and are
      at the minimum Q then run through a final pass of the data to
@@ -201,50 +202,50 @@
        (cpi->MotionScore < RecoveryBlocks) ) {
     if ( cpi->FinalPassLastPos < MaxSB ) {
       for ( SB = cpi->FinalPassLastPos; SB < MaxSB; SB++ ) {
-	/* Check its four Macro-Blocks */
-	for ( MB=LastPassMBPos; MB<4; MB++ ) {
-	  /* Mark relevant blocks for update */
-	  UpRegulateMB( cpi, RegulationQ, SB, MB, 1 );
-	  
-	  /* Keep track of the last refresh MB. */
-	  LastPassMBPos += 1;
-	  if ( LastPassMBPos == 4 ) {
-	    LastPassMBPos = 0;
-	    
-	    /* Increment SB index */
-	    cpi->FinalPassLastPos += 1;
-	  }
-	  
-	  /* Termination clause */
-	  if (cpi->MotionScore >= RecoveryBlocks)
-	    break;
-	}
-
-	/* Termination clause */
-	if (cpi->MotionScore >= RecoveryBlocks)
-	  break;
+        /* Check its four Macro-Blocks */
+        for ( MB=LastPassMBPos; MB<4; MB++ ) {
+          /* Mark relevant blocks for update */
+          UpRegulateMB( cpi, RegulationQ, SB, MB, 1 );
+
+          /* Keep track of the last refresh MB. */
+          LastPassMBPos += 1;
+          if ( LastPassMBPos == 4 ) {
+            LastPassMBPos = 0;
+
+            /* Increment SB index */
+            cpi->FinalPassLastPos += 1;
+          }
+
+          /* Termination clause */
+          if (cpi->MotionScore >= RecoveryBlocks)
+            break;
+        }
+
+        /* Termination clause */
+        if (cpi->MotionScore >= RecoveryBlocks)
+          break;
 
       }
     }
   }
 }
 
-void RegulateQ( CP_INSTANCE *cpi, ogg_int32_t UpdateScore ) {   
-  double TargetUnitScoreBytes = (double)cpi->ThisFrameTargetBytes / 
+void RegulateQ( CP_INSTANCE *cpi, ogg_int32_t UpdateScore ) {
+  double TargetUnitScoreBytes = (double)cpi->ThisFrameTargetBytes /
     (double)UpdateScore;
   double PredUnitScoreBytes;
   double LastBitError = 10000.0;       /* Silly high number */
   ogg_uint32_t QIndex = Q_TABLE_SIZE - 1;
   ogg_uint32_t i;
-  
+
   /* Search for the best Q for the target bitrate. */
   for ( i = 0; i < Q_TABLE_SIZE; i++ ) {
     PredUnitScoreBytes = GetEstimatedBpb( cpi, cpi->pb.QThreshTable[i] );
     if ( PredUnitScoreBytes > TargetUnitScoreBytes ) {
       if ( (PredUnitScoreBytes - TargetUnitScoreBytes) <= LastBitError ) {
-	QIndex = i;
+        QIndex = i;
       } else {
-	QIndex = i - 1;
+        QIndex = i - 1;
       }
       break;
     } else {
@@ -254,7 +255,7 @@
 
   /* QIndex should now indicate the optimal Q. */
   cpi->pb.ThisFrameQualityValue = cpi->pb.QThreshTable[QIndex];
-  
+
   /* Apply range restrictions for key frames. */
   if ( GetFrameType(&cpi->pb) == BASE_FRAME ) {
     if ( cpi->pb.ThisFrameQualityValue > cpi->pb.QThreshTable[20] )
@@ -262,14 +263,14 @@
     else if ( cpi->pb.ThisFrameQualityValue < cpi->pb.QThreshTable[50] )
       cpi->pb.ThisFrameQualityValue = cpi->pb.QThreshTable[50];
   }
-  
+
   /* Limit the Q value to the maximum available value */
-  if (cpi->pb.ThisFrameQualityValue > 
+  if (cpi->pb.ThisFrameQualityValue >
       cpi->pb.QThreshTable[cpi->Configuration.ActiveMaxQ]) {
-    cpi->pb.ThisFrameQualityValue = 
+    cpi->pb.ThisFrameQualityValue =
       (ogg_uint32_t)cpi->pb.QThreshTable[cpi->Configuration.ActiveMaxQ];
-  }  
-  
+  }
+
   if(cpi->FixedQ) {
     if ( GetFrameType(&cpi->pb) == BASE_FRAME ) {
       cpi->pb.ThisFrameQualityValue = cpi->pb.QThreshTable[43];
@@ -278,7 +279,7 @@
       cpi->pb.ThisFrameQualityValue = cpi->FixedQ;
     }
   }
-  
+
   /* If th quantiser value has changed then re-initialise it */
   if ( cpi->pb.ThisFrameQualityValue != cpi->pb.LastFrameQualityValue ) {
     /* Initialise quality tables. */
@@ -291,9 +292,9 @@
   ogg_uint32_t  i,j;
   unsigned char * SrcPtr;
   unsigned char * DestPtr;
-  ogg_uint32_t  PlaneLineStep;   
+  ogg_uint32_t  PlaneLineStep;
   ogg_uint32_t  PixelIndex;
-  
+
   /*  Copy back for Y plane. */
   PlaneLineStep = cpi->pb.info.width;
   for ( i = 0; i < cpi->pb.YPlaneFragments; i++ ) {
@@ -303,21 +304,21 @@
       PixelIndex = cpi->pb.pixel_index_table[i];
       SrcPtr = &cpi->yuv1ptr[PixelIndex];
       DestPtr = &cpi->ConvDestBuffer[PixelIndex];
-      
+
       for ( j = 0; j < VFRAGPIXELS; j++ ) {
-	memcpy( DestPtr, SrcPtr, HFRAGPIXELS);
-	
-	SrcPtr += PlaneLineStep;
-	DestPtr += PlaneLineStep;
+        memcpy( DestPtr, SrcPtr, HFRAGPIXELS);
+
+        SrcPtr += PlaneLineStep;
+        DestPtr += PlaneLineStep;
       }
     }
   }
- 
+
   /* Now the U and V planes */
   PlaneLineStep = cpi->pb.info.width / 2;
-  for ( i = cpi->pb.YPlaneFragments; 
-	i < (cpi->pb.YPlaneFragments + (2 * cpi->pb.UVPlaneFragments)) ; 
-	i++ ) {
+  for ( i = cpi->pb.YPlaneFragments;
+        i < (cpi->pb.YPlaneFragments + (2 * cpi->pb.UVPlaneFragments)) ;
+        i++ ) {
 
     /* We are only interested in updated fragments. */
     if ( cpi->extra_fragments[i] ) {
@@ -325,12 +326,12 @@
       PixelIndex = cpi->pb.pixel_index_table[i];
       SrcPtr = &cpi->yuv1ptr[PixelIndex];
       DestPtr = &cpi->ConvDestBuffer[PixelIndex];
-      
+
       for ( j = 0; j < VFRAGPIXELS; j++ ) {
-	memcpy( DestPtr, SrcPtr, HFRAGPIXELS);
-	SrcPtr += PlaneLineStep;
-	DestPtr += PlaneLineStep;
-      }   
+        memcpy( DestPtr, SrcPtr, HFRAGPIXELS);
+        SrcPtr += PlaneLineStep;
+        DestPtr += PlaneLineStep;
+      }
     }
   }
 }

<p><p>1.5       +26 -25    theora/lib/pb.c

Index: pb.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/pb.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- pb.c	8 Jun 2003 00:08:38 -0000	1.4
+++ pb.c	10 Jun 2003 01:31:33 -0000	1.5
@@ -10,12 +10,13 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: pb.c,v 1.4 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: pb.c,v 1.5 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
 #include <stdlib.h>
+#include <string.h>
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 
@@ -37,7 +38,7 @@
     _ogg_free(pbi->dequant_Inter_coeffs);
   if(pbi->dequant_InterUV_coeffs)
     _ogg_free(pbi->dequant_InterUV_coeffs);
-  
+
 
   pbi->ReconDataBuffer=0;
   pbi->DequantBuffer = 0;
@@ -51,35 +52,35 @@
 }
 
 void InitTmpBuffers(PB_INSTANCE * pbi){
-  
+
   /* clear any existing info */
   ClearTmpBuffers(pbi);
-  
+
   /* Adjust the position of all of our temporary */
-  pbi->ReconDataBuffer      = 
+  pbi->ReconDataBuffer      =
     _ogg_malloc(64*sizeof(*pbi->ReconDataBuffer));
-  
-  pbi->DequantBuffer        = 
+
+  pbi->DequantBuffer        =
     _ogg_malloc(64 * sizeof(*pbi->DequantBuffer));
-  
-  pbi->TmpDataBuffer        = 
+
+  pbi->TmpDataBuffer        =
     _ogg_malloc(64 * sizeof(*pbi->TmpDataBuffer));
-  
-  pbi->TmpReconBuffer       = 
+
+  pbi->TmpReconBuffer       =
     _ogg_malloc(64 * sizeof(*pbi->TmpReconBuffer));
-  
-  pbi->dequant_Y_coeffs     = 
+
+  pbi->dequant_Y_coeffs     =
     _ogg_malloc(64 * sizeof(*pbi->dequant_Y_coeffs));
-  
-  pbi->dequant_UV_coeffs    = 
+
+  pbi->dequant_UV_coeffs    =
     _ogg_malloc(64 * sizeof(*pbi->dequant_UV_coeffs));
-  
-  pbi->dequant_Inter_coeffs = 
+
+  pbi->dequant_Inter_coeffs =
     _ogg_malloc(64 * sizeof(*pbi->dequant_Inter_coeffs));
-  
-  pbi->dequant_InterUV_coeffs = 
+
+  pbi->dequant_InterUV_coeffs =
     _ogg_malloc(64 * sizeof(*pbi->dequant_InterUV_coeffs));
-  
+
 }
 
 void ClearPBInstance(PB_INSTANCE *pbi){
@@ -91,16 +92,16 @@
 void InitPBInstance(PB_INSTANCE *pbi){
   /* initialize whole structure to 0 */
   memset(pbi, 0, sizeof(*pbi));
-  
+
   InitTmpBuffers(pbi);
-  
+
   /* variables needing initialization (not being set to 0) */
-  
+
   pbi->ModifierPointer[0] = &pbi->Modifier[0][255];
   pbi->ModifierPointer[1] = &pbi->Modifier[1][255];
   pbi->ModifierPointer[2] = &pbi->Modifier[2][255];
   pbi->ModifierPointer[3] = &pbi->Modifier[3][255];
-  
+
   pbi->DecoderErrorCode = 0;
   pbi->KeyFrameType = DCT_KEY_FRAME;
   pbi->FramesHaveBeenSkipped = 0;

<p><p>1.8       +367 -366  theora/lib/pp.c

Index: pp.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/pp.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- pp.c	8 Jun 2003 00:08:38 -0000	1.7
+++ pp.c	10 Jun 2003 01:31:33 -0000	1.8
@@ -10,12 +10,13 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: pp.c,v 1.7 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: pp.c,v 1.8 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
 #include <stdlib.h>
+#include <string.h>
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 #include "pp.h"
@@ -26,7 +27,7 @@
 
 static ogg_int32_t SharpenModifier[ Q_TABLE_SIZE ] =
 {  -12, -11, -10, -10,  -9,  -9,  -9,  -9,
-   -6,  -6,  -6,  -6,  -6,  -6,  -6,  -6, 
+   -6,  -6,  -6,  -6,  -6,  -6,  -6,  -6,
    -4,  -4,  -4,  -4,  -4,  -4,  -4,  -4,
    -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2,
    -2,  -2,  -2,  -2,  -2,  -2,  -2,  -2,
@@ -35,7 +36,7 @@
    0,  0,  0,  0,  0,  0,  0,  0
 };
 
-static ogg_uint32_t DcQuantScaleV1[ Q_TABLE_SIZE ] = { 
+static ogg_uint32_t DcQuantScaleV1[ Q_TABLE_SIZE ] = {
   22, 20, 19, 18, 17, 17, 16, 16,
   15, 15, 14, 14, 13, 13, 12, 12,
   11, 11, 10, 10, 9,  9,  9,  8,
@@ -43,7 +44,7 @@
   6,  5,  5,  5,  5,  4,  4,  4,
   4,  4,  3,  3,  3,  3,  3,  3,
   3,  2,  2,  2,  2,  2,  2,  2,
-  2,  1,  1,  1,  1,  1,  1,  1 
+  2,  1,  1,  1,  1,  1,  1,  1
 };
 
 static ogg_uint32_t *DeringModifierV1=DcQuantScaleV1;
@@ -57,7 +58,7 @@
   if(ppi->ScanDisplayFragments) _ogg_free(ppi->ScanDisplayFragments);
   ppi->ScanDisplayFragments=0;
 
-  for(i = 0 ; i < MAX_PREV_FRAMES ; i ++) 
+  for(i = 0 ; i < MAX_PREV_FRAMES ; i ++)
     if(ppi->PrevFragments[i]){
       _ogg_free(ppi->PrevFragments[i]);
       ppi->PrevFragments[i]=0;
@@ -92,57 +93,57 @@
 
   if(ppi->yuv_differences) _ogg_free(ppi->yuv_differences);
   ppi->yuv_differences=0;
-  
+
 }
 
 void PInitFrameInfo(PP_INSTANCE * ppi){
   int i;
   PClearFrameInfo(ppi);
 
-  ppi->ScanPixelIndexTable = 
+  ppi->ScanPixelIndexTable =
     _ogg_malloc(ppi->ScanFrameFragments*sizeof(*ppi->ScanPixelIndexTable));
 
-  ppi->ScanDisplayFragments = 
+  ppi->ScanDisplayFragments =
     _ogg_malloc(ppi->ScanFrameFragments*sizeof(*ppi->ScanDisplayFragments));
 
-  for(i = 0 ; i < MAX_PREV_FRAMES ; i ++) 
-    ppi->PrevFragments[i] = 
+  for(i = 0 ; i < MAX_PREV_FRAMES ; i ++)
+    ppi->PrevFragments[i] =
       _ogg_malloc(ppi->ScanFrameFragments*sizeof(*ppi->PrevFragments));
-   
-  ppi->FragScores = 
+
+  ppi->FragScores =
     _ogg_malloc(ppi->ScanFrameFragments*sizeof(*ppi->FragScores));
 
-  ppi->SameGreyDirPixels = 
+  ppi->SameGreyDirPixels =
     _ogg_malloc(ppi->ScanFrameFragments*sizeof(*ppi->SameGreyDirPixels));
 
-  ppi->FragDiffPixels = 
+  ppi->FragDiffPixels =
     _ogg_malloc(ppi->ScanFrameFragments*sizeof(*ppi->FragScores));
-  
-  ppi->BarBlockMap= 
+
+  ppi->BarBlockMap=
     _ogg_malloc(3 * ppi->ScanHFragments*sizeof(*ppi->BarBlockMap));
 
-  ppi->TmpCodedMap = 
+  ppi->TmpCodedMap =
     _ogg_malloc(ppi->ScanHFragments*sizeof(*ppi->TmpCodedMap));
 
-  ppi->RowChangedPixels = 
+  ppi->RowChangedPixels =
     _ogg_malloc(3 * ppi->ScanConfig.VideoFrameHeight*
-		sizeof(*ppi->RowChangedPixels));
+                sizeof(*ppi->RowChangedPixels));
 
-  ppi->PixelScores = 
+  ppi->PixelScores =
     _ogg_malloc(ppi->ScanConfig.VideoFrameWidth*
-		sizeof(*ppi->PixelScores) * PSCORE_CB_ROWS);
+                sizeof(*ppi->PixelScores) * PSCORE_CB_ROWS);
 
-  ppi->PixelChangedMap = 
+  ppi->PixelChangedMap =
     _ogg_malloc(ppi->ScanConfig.VideoFrameWidth*
-		sizeof(*ppi->PixelChangedMap) * PMAP_CB_ROWS);
+                sizeof(*ppi->PixelChangedMap) * PMAP_CB_ROWS);
 
-  ppi->ChLocals = 
+  ppi->ChLocals =
     _ogg_malloc(ppi->ScanConfig.VideoFrameWidth*
-		sizeof(*ppi->ChLocals) * CHLOCALS_CB_ROWS);
+                sizeof(*ppi->ChLocals) * CHLOCALS_CB_ROWS);
 
-  ppi->yuv_differences = 
+  ppi->yuv_differences =
     _ogg_malloc(ppi->ScanConfig.VideoFrameWidth*
-		sizeof(*ppi->yuv_differences) * YDIFF_CB_ROWS);
+                sizeof(*ppi->yuv_differences) * YDIFF_CB_ROWS);
 }
 
 void ClearPPInstance(PP_INSTANCE *ppi){
@@ -156,54 +157,54 @@
 
   /* Initializations */
   ppi->PrevFrameLimit = 3; /* Must not exceed MAX_PREV_FRAMES (Note
-			      that this number includes the current
-			      frame so "1 = no effect") */
+                              that this number includes the current
+                              frame so "1 = no effect") */
 
   /* Scan control variables. */
   ppi->HFragPixels = 8;
   ppi->VFragPixels = 8;
-  
+
   ppi->SRFGreyThresh = 4;
   ppi->SRFColThresh = 5;
   ppi->NoiseSupLevel = 3;
   ppi->SgcLevelThresh = 3;
   ppi->SuvcLevelThresh = 4;
-  
+
   /* Variables controlling S.A.D. breakouts. */
   ppi->GrpLowSadThresh = 10;
   ppi->GrpHighSadThresh = 64;
   ppi->PrimaryBlockThreshold = 5;
   ppi->SgcThresh = 16;  /* (Default values for 8x8 blocks). */
-  
+
   ppi->UVBlockThreshCorrection = 1.25;
   ppi->UVSgcCorrection = 1.5;
-  
+
   ppi->MaxLineSearchLen = MAX_SEARCH_LINE_LEN;
 }
 
 static void DeringBlockStrong(unsigned char *SrcPtr,
-			      unsigned char *DstPtr,
-			      ogg_int32_t Pitch,
-			      ogg_uint32_t FragQIndex,
-			      ogg_uint32_t *QuantScale){
-    
+                              unsigned char *DstPtr,
+                              ogg_int32_t Pitch,
+                              ogg_uint32_t FragQIndex,
+                              ogg_uint32_t *QuantScale){
+
   ogg_int16_t UDMod[72];
   ogg_int16_t LRMod[72];
   unsigned int j,k,l;
   const unsigned char * Src;
   unsigned int QValue = QuantScale[FragQIndex];
-  
+
   unsigned char p;
   unsigned char pl;
   unsigned char pr;
   unsigned char pu;
   unsigned char pd;
-  
+
   int  al;
   int  ar;
   int  au;
   int  ad;
-  
+
   int  atot;
   int  B;
   int  newVal;
@@ -212,61 +213,61 @@
   unsigned char *dstRow = DstPtr;
   const unsigned char *lastRow = SrcPtr-Pitch;
   const unsigned char *nextRow = SrcPtr+Pitch;
- 
+
   unsigned int rowOffset = 0;
   unsigned int round = (1<<6);
-  
+
   int High;
   int Low;
   int TmpMod;
-  
+
   int Sharpen = SharpenModifier[FragQIndex];
   High = 3 * QValue;
   if(High>32)High=32;
   Low = 0;
 
-    
+
   /* Initialize the Mod Data */
   Src = SrcPtr-Pitch;
-  for(k=0;k<9;k++){           
+  for(k=0;k<9;k++){
     for(j=0;j<8;j++){
-      
+
       TmpMod = 32 + QValue - (abs(Src[j+Pitch]-Src[j]));
-      
+
       if(TmpMod< -64)
-	TmpMod = Sharpen;
-      
+        TmpMod = Sharpen;
+
       else if(TmpMod<Low)
-	TmpMod = Low;
-      
+        TmpMod = Low;
+
       else if(TmpMod>High)
-	TmpMod = High;
-      
+        TmpMod = High;
+
       UDMod[k*8+j] = (ogg_int16_t)TmpMod;
     }
     Src +=Pitch;
   }
-  
+
   Src = SrcPtr-1;
-  
-  for(k=0;k<8;k++){           
+
+  for(k=0;k<8;k++){
     for(j=0;j<9;j++){
       TmpMod = 32 + QValue - (abs(Src[j+1]-Src[j]));
-      
+
       if(TmpMod< -64 )
-	TmpMod = Sharpen;
-      
+        TmpMod = Sharpen;
+
       else if(TmpMod<0)
-	TmpMod = Low;
-      
+        TmpMod = Low;
+
       else if(TmpMod>High)
-	TmpMod = High;
-      
+        TmpMod = High;
+
       LRMod[k*9+j] = (ogg_int16_t)TmpMod;
     }
     Src+=Pitch;
   }
-  
+
   for(k=0;k<8;k++){
     /* In the case that this function called with same buffer for
      source and destination, To keep the c and the mmx version to have
@@ -274,33 +275,33 @@
      eight pixel value before writing them to destination
      (i.e. Overwriting souce for the speical case) */
     for(l=0;l<8;l++){
-    
+
       atot = 128;
       B = round;
       p = curRow[ rowOffset +l +1];
-      
+
       pl = curRow[ rowOffset +l];
       al = LRMod[k*9+l];
       atot -= al;
-      B += al * pl; 
-      
+      B += al * pl;
+
       pu = lastRow[ rowOffset +l];
       au = UDMod[k*8+l];
       atot -= au;
       B += au * pu;
-      
+
       pd = nextRow[ rowOffset +l];
       ad = UDMod[(k+1)*8+l];
       atot -= ad;
       B += ad * pd;
-      
+
       pr = curRow[ rowOffset +l+2];
       ar = LRMod[k*9+l+1];
       atot -= ar;
       B += ar * pr;
-      
+
       newVal = ( atot * p + B) >> 7;
-      
+
       dstRow[ rowOffset +l]= clamp255( newVal );
     }
     rowOffset += Pitch;
@@ -308,40 +309,40 @@
 }
 
 static void DeringBlockWeak(unsigned char *SrcPtr,
-			    unsigned char *DstPtr,
-			    ogg_int32_t Pitch,
-			    ogg_uint32_t FragQIndex,
-			    ogg_uint32_t *QuantScale){
-  
+                            unsigned char *DstPtr,
+                            ogg_int32_t Pitch,
+                            ogg_uint32_t FragQIndex,
+                            ogg_uint32_t *QuantScale){
+
   ogg_int16_t UDMod[72];
   ogg_int16_t LRMod[72];
   unsigned int j,k;
   const unsigned char * Src;
   unsigned int QValue = QuantScale[FragQIndex];
-  
+
   unsigned char p;
   unsigned char pl;
   unsigned char pr;
   unsigned char pu;
   unsigned char pd;
-  
+
   int  al;
   int  ar;
   int  au;
   int  ad;
-  
+
   int  atot;
   int  B;
   int  newVal;
-  
+
   const unsigned char *curRow = SrcPtr-1;
   unsigned char *dstRow = DstPtr;
   const unsigned char *lastRow = SrcPtr-Pitch;
   const unsigned char *nextRow = SrcPtr+Pitch;
-  
+
   unsigned int rowOffset = 0;
   unsigned int round = (1<<6);
-  
+
   int High;
   int Low;
   int TmpMod;
@@ -351,85 +352,85 @@
   if(High>24)
     High=24;
   Low = 0 ;
-  
+
   /* Initialize the Mod Data */
   Src=SrcPtr-Pitch;
-  for(k=0;k<9;k++) {           
+  for(k=0;k<9;k++) {
     for(j=0;j<8;j++) {
-      
+
       TmpMod = 32 + QValue - 2*(abs(Src[j+Pitch]-Src[j]));
 
       if(TmpMod< -64)
-	TmpMod = Sharpen;
-      
+        TmpMod = Sharpen;
+
       else if(TmpMod<Low)
-	TmpMod = Low;
-      
+        TmpMod = Low;
+
             else if(TmpMod>High)
-	      TmpMod = High;
-      
+              TmpMod = High;
+
       UDMod[k*8+j] = (ogg_int16_t)TmpMod;
     }
     Src +=Pitch;
   }
-  
+
   Src = SrcPtr-1;
 
-  for(k=0;k<8;k++){           
+  for(k=0;k<8;k++){
     for(j=0;j<9;j++){
       TmpMod = 32 + QValue - 2*(abs(Src[j+1]-Src[j]));
-            
+
       if(TmpMod< -64 )
-	TmpMod = Sharpen;
-      
+        TmpMod = Sharpen;
+
       else if(TmpMod<Low)
-	TmpMod = Low;
-      
+        TmpMod = Low;
+
       else if(TmpMod>High)
-	TmpMod = High;
-      
+        TmpMod = High;
+
       LRMod[k*9+j] = (ogg_int16_t)TmpMod;
     }
     Src+=Pitch;
   }
-  
+
   for(k=0;k<8;k++) {
     for(j=0;j<8;j++){
       atot = 128;
       B = round;
       p = curRow[ rowOffset +j+1];
-      
+
       pl = curRow[ rowOffset +j];
       al = LRMod[k*9+j];
       atot -= al;
       B += al * pl;
-	
+
       pu = lastRow[ rowOffset +j];
       au = UDMod[k*8+j];
       atot -= au;
       B += au * pu;
-	
+
       pd = nextRow[ rowOffset +j];
       ad = UDMod[(k+1)*8+j];
       atot -= ad;
       B += ad * pd;
-      
+
       pr = curRow[ rowOffset +j+2];
       ar = LRMod[k*9+j+1];
       atot -= ar;
       B += ar * pr;
-      
+
       newVal = ( atot * p + B) >> 7;
-      
+
       dstRow[ rowOffset +j] = clamp255( newVal );
     }
-    
+
     rowOffset += Pitch;
   }
 }
 
-static void DeringFrame(PB_INSTANCE *pbi, 
-			unsigned char *Src, unsigned char *Dst){
+static void DeringFrame(PB_INSTANCE *pbi,
+                        unsigned char *Src, unsigned char *Dst){
   ogg_uint32_t  col,row;
   unsigned char  *SrcPtr;
   unsigned char  *DestPtr;
@@ -437,65 +438,65 @@
   ogg_uint32_t *QuantScale;
   ogg_uint32_t Block;
   ogg_uint32_t LineLength;
-  
+
   ogg_int32_t Thresh1,Thresh2,Thresh3,Thresh4;
 
-  Thresh1 = 384;                  
-  Thresh2 = 4 * Thresh1;          
-  Thresh3 = 5 * Thresh2/4;        
-  Thresh4 = 5 * Thresh2/2;        
-  
+  Thresh1 = 384;
+  Thresh2 = 4 * Thresh1;
+  Thresh3 = 5 * Thresh2/4;
+  Thresh4 = 5 * Thresh2/2;
+
   QuantScale = DeringModifierV1;
-  
+
   BlocksAcross = pbi->HFragments;
   BlocksDown = pbi->VFragments;
-  
+
   SrcPtr = Src + pbi->ReconYDataOffset;
   DestPtr = Dst + pbi->ReconYDataOffset;
   LineLength = pbi->YStride;
-  
+
   Block = 0;
-  
+
   for ( row = 0 ; row < BlocksDown; row ++){
     for (col = 0; col < BlocksAcross; col ++){
-      ogg_uint32_t Quality = pbi->FragQIndex[Block]; 
-      ogg_int32_t Variance = pbi->FragmentVariances[Block]; 
-      
+      ogg_uint32_t Quality = pbi->FragQIndex[Block];
+      ogg_int32_t Variance = pbi->FragmentVariances[Block];
+
       if( pbi->PostProcessingLevel >5 && Variance > Thresh3 ){
-	DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			  LineLength,Quality,QuantScale);
-				
-	if( (col > 0 && 
-	     pbi->FragmentVariances[Block-1] > Thresh4 ) ||
-	    (col + 1 < BlocksAcross && 
-	     pbi->FragmentVariances[Block+1] > Thresh4 ) ||
-	    (row + 1 < BlocksDown && 
-	     pbi->FragmentVariances[Block+BlocksAcross] > Thresh4) ||
-	    (row > 0 && 
-	     pbi->FragmentVariances[Block-BlocksAcross] > Thresh4) ){
-
-	  DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			    LineLength,Quality,QuantScale);
-	  DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			    LineLength,Quality,QuantScale);
-	}			
+        DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                          LineLength,Quality,QuantScale);
+
+        if( (col > 0 &&
+             pbi->FragmentVariances[Block-1] > Thresh4 ) ||
+            (col + 1 < BlocksAcross &&
+             pbi->FragmentVariances[Block+1] > Thresh4 ) ||
+            (row + 1 < BlocksDown &&
+             pbi->FragmentVariances[Block+BlocksAcross] > Thresh4) ||
+            (row > 0 &&
+             pbi->FragmentVariances[Block-BlocksAcross] > Thresh4) ){
+
+          DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                            LineLength,Quality,QuantScale);
+          DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                            LineLength,Quality,QuantScale);
+        }
       } else if(Variance > Thresh2 ) {
-	
-	DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			  LineLength,Quality,QuantScale);
+
+        DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                          LineLength,Quality,QuantScale);
       } else if(Variance > Thresh1 ) {
 
-	DeringBlockWeak(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			LineLength,Quality,QuantScale);
-      
+        DeringBlockWeak(SrcPtr + 8 * col, DestPtr + 8 * col,
+                        LineLength,Quality,QuantScale);
+
       } else {
 
-	CopyBlock(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength);
+        CopyBlock(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength);
 
       }
-			
+
       ++Block;
-      
+
     }
     SrcPtr += 8 * LineLength;
     DestPtr += 8 * LineLength;
@@ -506,101 +507,101 @@
   BlocksAcross /= 2;
   BlocksDown /= 2;
   LineLength /= 2;
-  
+
   SrcPtr = Src + pbi->ReconUDataOffset;
   DestPtr = Dst + pbi->ReconUDataOffset;
   for ( row = 0 ; row < BlocksDown; row ++) {
     for (col = 0; col < BlocksAcross; col ++) {
-      ogg_uint32_t Quality = pbi->FragQIndex[Block]; 
-      ogg_int32_t Variance = pbi->FragmentVariances[Block]; 
-			
+      ogg_uint32_t Quality = pbi->FragQIndex[Block];
+      ogg_int32_t Variance = pbi->FragmentVariances[Block];
+
       if( pbi->PostProcessingLevel >5 && Variance > Thresh4 ) {
-	DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			  LineLength,Quality,QuantScale);
-	DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			  LineLength,Quality,QuantScale);
-	DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			  LineLength,Quality,QuantScale);
-	
+        DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                          LineLength,Quality,QuantScale);
+        DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                          LineLength,Quality,QuantScale);
+        DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                          LineLength,Quality,QuantScale);
+
       }else if(Variance > Thresh2 ){
-	DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			  LineLength,Quality,QuantScale);
+        DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                          LineLength,Quality,QuantScale);
       }else if(Variance > Thresh1 ){
-	DeringBlockWeak(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			LineLength,Quality,QuantScale);
+        DeringBlockWeak(SrcPtr + 8 * col, DestPtr + 8 * col,
+                        LineLength,Quality,QuantScale);
       }else{
-	CopyBlock(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength);
+        CopyBlock(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength);
       }
-      
+
       ++Block;
-      
+
     }
     SrcPtr += 8 * LineLength;
     DestPtr += 8 * LineLength;
   }
-  
+
   /* Then V */
   SrcPtr = Src + pbi->ReconVDataOffset;
   DestPtr = Dst + pbi->ReconVDataOffset;
-  
+
   for ( row = 0 ; row < BlocksDown; row ++){
     for (col = 0; col < BlocksAcross; col ++){
-      
-      ogg_uint32_t Quality = pbi->FragQIndex[Block]; 
-      ogg_int32_t Variance = pbi->FragmentVariances[Block]; 
-      
-			
+
+      ogg_uint32_t Quality = pbi->FragQIndex[Block];
+      ogg_int32_t Variance = pbi->FragmentVariances[Block];
+
+
       if( pbi->PostProcessingLevel >5 && Variance > Thresh4 ) {
-	DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			  LineLength,Quality,QuantScale);
-	DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			  LineLength,Quality,QuantScale);
-	DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			  LineLength,Quality,QuantScale);
-				
+        DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                          LineLength,Quality,QuantScale);
+        DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                          LineLength,Quality,QuantScale);
+        DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                          LineLength,Quality,QuantScale);
+
       }else if(Variance > Thresh2 ){
-	DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			  LineLength,Quality,QuantScale);
+        DeringBlockStrong(SrcPtr + 8 * col, DestPtr + 8 * col,
+                          LineLength,Quality,QuantScale);
       }else if(Variance > Thresh1 ){
-	DeringBlockWeak(SrcPtr + 8 * col, DestPtr + 8 * col, 
-			LineLength,Quality,QuantScale);
+        DeringBlockWeak(SrcPtr + 8 * col, DestPtr + 8 * col,
+                        LineLength,Quality,QuantScale);
       }else{
-	CopyBlock(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength);
+        CopyBlock(SrcPtr + 8 * col, DestPtr + 8 * col, LineLength);
       }
-      
+
       ++Block;
-      
+
     }
     SrcPtr += 8 * LineLength;
     DestPtr += 8 * LineLength;
-    
+
   }
-  
+
 }
 
 void UpdateFragQIndex(PB_INSTANCE *pbi){
-  
+
   ogg_uint32_t  ThisFrameQIndex;
   ogg_uint32_t  i;
 
   /* Check this frame quality  index */
   ThisFrameQIndex = pbi->FrameQIndex;
-  
-  
+
+
   /* It is not a key frame, so only reset those are coded */
   for( i = 0; i < pbi->UnitFragments; i++  )
     if( pbi->display_fragments[i])
       pbi->FragQIndex[i] = ThisFrameQIndex;
-  
+
 }
 
-static void DeblockLoopFilteredBand(PB_INSTANCE *pbi, 
-			     unsigned char *SrcPtr, 
-			     unsigned char *DesPtr,
-			     ogg_uint32_t PlaneLineStep, 
-			     ogg_uint32_t FragsAcross,
-			     ogg_uint32_t StartFrag,
-			     ogg_uint32_t *QuantScale){
+static void DeblockLoopFilteredBand(PB_INSTANCE *pbi,
+                             unsigned char *SrcPtr,
+                             unsigned char *DesPtr,
+                             ogg_uint32_t PlaneLineStep,
+                             ogg_uint32_t FragsAcross,
+                             ogg_uint32_t StartFrag,
+                             ogg_uint32_t *QuantScale){
   ogg_uint32_t j,k;
   ogg_uint32_t CurrentFrag=StartFrag;
   ogg_int32_t QStep;
@@ -608,15 +609,15 @@
   unsigned char *Src, *Des;
   ogg_int32_t  x[10];
   ogg_int32_t  Sum1, Sum2;
-  
+
   while(CurrentFrag < StartFrag + FragsAcross){
-    
+
     Src=SrcPtr+8*(CurrentFrag-StartFrag)-PlaneLineStep*5;
     Des=DesPtr+8*(CurrentFrag-StartFrag)-PlaneLineStep*4;
-    
+
     QStep = QuantScale[pbi->FragQIndex[CurrentFrag+FragsAcross]];
     FLimit = ( QStep * 3 ) >> 2;
-    
+
     for( j=0; j<8 ; j++){
       x[0] = Src[0];
       x[1] = Src[PlaneLineStep];
@@ -630,53 +631,53 @@
       x[9] = Src[PlaneLineStep*9];
 
       Sum1=Sum2=0;
-      
-      for(k=1;k<=4;k++){   
-	Sum1 += abs(x[k]-x[k-1]);
-	Sum2 += abs(x[k+4]-x[k+5]);           
+
+      for(k=1;k<=4;k++){
+        Sum1 += abs(x[k]-x[k-1]);
+        Sum2 += abs(x[k+4]-x[k+5]);
       }
-      
+
       pbi->FragmentVariances[CurrentFrag] +=((Sum1>255)?255:Sum1);
       pbi->FragmentVariances[CurrentFrag + FragsAcross] += ((Sum2>255)?255:Sum2);
-      
+
       if( Sum1 < FLimit &&
-	  Sum2 < FLimit &&
-	  (x[5] - x[4]) < QStep && 
-	  (x[4] - x[5]) < QStep ){
-	
-	/* low pass filtering (LPF7: 1 1 1 2 1 1 1) */
-	Des[0              ] = (x[0] + x[0] +x[0] + x[1] * 2 + 
-				x[2] + x[3] +x[4] + 4) >> 3;
-	Des[PlaneLineStep  ] = (x[0] + x[0] +x[1] + x[2] * 2 + 
-				x[3] + x[4] +x[5] + 4) >> 3;
-	Des[PlaneLineStep*2] = (x[0] + x[1] +x[2] + x[3] * 2 + 
-				x[4] + x[5] +x[6] + 4) >> 3;
-	Des[PlaneLineStep*3] = (x[1] + x[2] +x[3] + x[4] * 2 + 
-				x[5] + x[6] +x[7] + 4) >> 3;
-	Des[PlaneLineStep*4] = (x[2] + x[3] +x[4] + x[5] * 2 + 
-				x[6] + x[7] +x[8] + 4) >> 3;
-	Des[PlaneLineStep*5] = (x[3] + x[4] +x[5] + x[6] * 2 + 
-				x[7] + x[8] +x[9] + 4) >> 3;
-	Des[PlaneLineStep*6] = (x[4] + x[5] +x[6] + x[7] * 2 + 
-				x[8] + x[9] +x[9] + 4) >> 3;
-	Des[PlaneLineStep*7] = (x[5] + x[6] +x[7] + x[8] * 2 + 
-				x[9] + x[9] +x[9] + 4) >> 3;
-	
+          Sum2 < FLimit &&
+          (x[5] - x[4]) < QStep &&
+          (x[4] - x[5]) < QStep ){
+
+        /* low pass filtering (LPF7: 1 1 1 2 1 1 1) */
+        Des[0              ] = (x[0] + x[0] +x[0] + x[1] * 2 +
+                                x[2] + x[3] +x[4] + 4) >> 3;
+        Des[PlaneLineStep  ] = (x[0] + x[0] +x[1] + x[2] * 2 +
+                                x[3] + x[4] +x[5] + 4) >> 3;
+        Des[PlaneLineStep*2] = (x[0] + x[1] +x[2] + x[3] * 2 +
+                                x[4] + x[5] +x[6] + 4) >> 3;
+        Des[PlaneLineStep*3] = (x[1] + x[2] +x[3] + x[4] * 2 +
+                                x[5] + x[6] +x[7] + 4) >> 3;
+        Des[PlaneLineStep*4] = (x[2] + x[3] +x[4] + x[5] * 2 +
+                                x[6] + x[7] +x[8] + 4) >> 3;
+        Des[PlaneLineStep*5] = (x[3] + x[4] +x[5] + x[6] * 2 +
+                                x[7] + x[8] +x[9] + 4) >> 3;
+        Des[PlaneLineStep*6] = (x[4] + x[5] +x[6] + x[7] * 2 +
+                                x[8] + x[9] +x[9] + 4) >> 3;
+        Des[PlaneLineStep*7] = (x[5] + x[6] +x[7] + x[8] * 2 +
+                                x[9] + x[9] +x[9] + 4) >> 3;
+
       }else {
-	/* copy the pixels to destination */
-	Des[0              ]= x[1];
-	Des[PlaneLineStep  ]= x[2];
-	Des[PlaneLineStep*2]= x[3];
-	Des[PlaneLineStep*3]= x[4];
-	Des[PlaneLineStep*4]= x[5];
-	Des[PlaneLineStep*5]= x[6];
-	Des[PlaneLineStep*6]= x[7];
-	Des[PlaneLineStep*7]= x[8];
+        /* copy the pixels to destination */
+        Des[0              ]= (unsigned char)x[1];
+        Des[PlaneLineStep  ]= (unsigned char)x[2];
+        Des[PlaneLineStep*2]= (unsigned char)x[3];
+        Des[PlaneLineStep*3]= (unsigned char)x[4];
+        Des[PlaneLineStep*4]= (unsigned char)x[5];
+        Des[PlaneLineStep*5]= (unsigned char)x[6];
+        Des[PlaneLineStep*6]= (unsigned char)x[7];
+        Des[PlaneLineStep*7]= (unsigned char)x[8];
       }
       Src ++;
-      Des ++;             
+      Des ++;
     }
-    
+
 
     /* done with filtering the horizontal edge, now let's do the
        vertical one */
@@ -687,63 +688,63 @@
       Des=DesPtr-8*PlaneLineStep+8*(CurrentFrag-StartFrag);
       Src=Des-5;
       Des-=4;
-      
+
       QStep = QuantScale[pbi->FragQIndex[CurrentFrag]];
       FLimit = ( QStep * 3 ) >> 2;
-      
+
       for( j=0; j<8 ; j++){
-	x[0] = Src[0];
-	x[1] = Src[1];
-	x[2] = Src[2];
-	x[3] = Src[3];
-	x[4] = Src[4];
-	x[5] = Src[5];
-	x[6] = Src[6];
-	x[7] = Src[7];
-	x[8] = Src[8];
-	x[9] = Src[9];
-	
-	Sum1=Sum2=0;
-	
-	for(k=1;k<=4;k++){   
-	  Sum1 += abs(x[k]-x[k-1]);
-	  Sum2 += abs(x[k+4]-x[k+5]);           
-	}
-	
-	pbi->FragmentVariances[CurrentFrag-1] += ((Sum1>255)?255:Sum1);
-	pbi->FragmentVariances[CurrentFrag] += ((Sum2>255)?255:Sum2);
-	
-	if( Sum1 < FLimit &&
-	    Sum2 < FLimit &&
-	    (x[5] - x[4]) < QStep && 
-	    (x[4] - x[5]) < QStep ){
-	  
-	  /* low pass filtering (LPF7: 1 1 1 2 1 1 1) */
-	  Des[0] = (x[0] + x[0] +x[0] + x[1] * 2 + x[2] + x[3] +x[4] + 4) >> 3;
-	  Des[1] = (x[0] + x[0] +x[1] + x[2] * 2 + x[3] + x[4] +x[5] + 4) >> 3;
-	  Des[2] = (x[0] + x[1] +x[2] + x[3] * 2 + x[4] + x[5] +x[6] + 4) >> 3;
-	  Des[3] = (x[1] + x[2] +x[3] + x[4] * 2 + x[5] + x[6] +x[7] + 4) >> 3;
-	  Des[4] = (x[2] + x[3] +x[4] + x[5] * 2 + x[6] + x[7] +x[8] + 4) >> 3;
-	  Des[5] = (x[3] + x[4] +x[5] + x[6] * 2 + x[7] + x[8] +x[9] + 4) >> 3;
-	  Des[6] = (x[4] + x[5] +x[6] + x[7] * 2 + x[8] + x[9] +x[9] + 4) >> 3;
-	  Des[7] = (x[5] + x[6] +x[7] + x[8] * 2 + x[9] + x[9] +x[9] + 4) >> 3;
-	}
-	
-	Src += PlaneLineStep;
-	Des += PlaneLineStep;               
+        x[0] = Src[0];
+        x[1] = Src[1];
+        x[2] = Src[2];
+        x[3] = Src[3];
+        x[4] = Src[4];
+        x[5] = Src[5];
+        x[6] = Src[6];
+        x[7] = Src[7];
+        x[8] = Src[8];
+        x[9] = Src[9];
+
+        Sum1=Sum2=0;
+
+        for(k=1;k<=4;k++){
+          Sum1 += abs(x[k]-x[k-1]);
+          Sum2 += abs(x[k+4]-x[k+5]);
+        }
+
+        pbi->FragmentVariances[CurrentFrag-1] += ((Sum1>255)?255:Sum1);
+        pbi->FragmentVariances[CurrentFrag] += ((Sum2>255)?255:Sum2);
+
+        if( Sum1 < FLimit &&
+            Sum2 < FLimit &&
+            (x[5] - x[4]) < QStep &&
+            (x[4] - x[5]) < QStep ){
+
+          /* low pass filtering (LPF7: 1 1 1 2 1 1 1) */
+          Des[0] = (x[0] + x[0] +x[0] + x[1] * 2 + x[2] + x[3] +x[4] + 4) >> 3;
+          Des[1] = (x[0] + x[0] +x[1] + x[2] * 2 + x[3] + x[4] +x[5] + 4) >> 3;
+          Des[2] = (x[0] + x[1] +x[2] + x[3] * 2 + x[4] + x[5] +x[6] + 4) >> 3;
+          Des[3] = (x[1] + x[2] +x[3] + x[4] * 2 + x[5] + x[6] +x[7] + 4) >> 3;
+          Des[4] = (x[2] + x[3] +x[4] + x[5] * 2 + x[6] + x[7] +x[8] + 4) >> 3;
+          Des[5] = (x[3] + x[4] +x[5] + x[6] * 2 + x[7] + x[8] +x[9] + 4) >> 3;
+          Des[6] = (x[4] + x[5] +x[6] + x[7] * 2 + x[8] + x[9] +x[9] + 4) >> 3;
+          Des[7] = (x[5] + x[6] +x[7] + x[8] * 2 + x[9] + x[9] +x[9] + 4) >> 3;
+        }
+
+        Src += PlaneLineStep;
+        Des += PlaneLineStep;
       }
       CurrentFrag ++;
     }
   }
 }
 
-static void DeblockVerticalEdgesInLoopFilteredBand(PB_INSTANCE *pbi, 
-					    unsigned char *SrcPtr, 
-					    unsigned char *DesPtr, 
-					    ogg_uint32_t PlaneLineStep,
-					    ogg_uint32_t FragsAcross,
-					    ogg_uint32_t StartFrag,
-					    ogg_uint32_t *QuantScale){
+static void DeblockVerticalEdgesInLoopFilteredBand(PB_INSTANCE *pbi,
+                                            unsigned char *SrcPtr,
+                                            unsigned char *DesPtr,
+                                            ogg_uint32_t PlaneLineStep,
+                                            ogg_uint32_t FragsAcross,
+                                            ogg_uint32_t StartFrag,
+                                            ogg_uint32_t *QuantScale){
   ogg_uint32_t j,k;
   ogg_uint32_t CurrentFrag=StartFrag;
   ogg_int32_t QStep;
@@ -751,16 +752,16 @@
   unsigned char *Src, *Des;
   ogg_int32_t  x[10];
   ogg_int32_t  Sum1, Sum2;
-    
+
   while(CurrentFrag < StartFrag + FragsAcross-1) {
-    
+
     Src=SrcPtr+8*(CurrentFrag-StartFrag+1)-5;
     Des=DesPtr+8*(CurrentFrag-StartFrag+1)-4;
-    
+
     QStep = QuantScale[pbi->FragQIndex[CurrentFrag+1]];
-    FLimit = ( QStep * 3)>>2 ;        
-    
-    for( j=0; j<8 ; j++){                
+    FLimit = ( QStep * 3)>>2 ;
+
+    for( j=0; j<8 ; j++){
       x[0] = Src[0];
       x[1] = Src[1];
       x[2] = Src[2];
@@ -771,46 +772,46 @@
       x[7] = Src[7];
       x[8] = Src[8];
       x[9] = Src[9];
-                
+
       Sum1=Sum2=0;
-      
-      for(k=1;k<=4;k++){   
-	Sum1 += abs(x[k]-x[k-1]);
-	Sum2 += abs(x[k+4]-x[k+5]);           
+
+      for(k=1;k<=4;k++){
+        Sum1 += abs(x[k]-x[k-1]);
+        Sum2 += abs(x[k+4]-x[k+5]);
       }
-      
+
       pbi->FragmentVariances[CurrentFrag] += ((Sum1>255)?255:Sum1);
       pbi->FragmentVariances[CurrentFrag+1] += ((Sum2>255)?255:Sum2);
-      
-                               
+
+
       if( Sum1 < FLimit &&
-	  Sum2 < FLimit &&
-	  (x[5] - x[4]) < QStep && 
-	  (x[4] - x[5]) < QStep ){
-	
-	/* low pass filtering (LPF7: 1 1 1 2 1 1 1) */
-	Des[0] = (x[0] + x[0] +x[0] + x[1] * 2 + x[2] + x[3] +x[4] + 4) >> 3;
-	Des[1] = (x[0] + x[0] +x[1] + x[2] * 2 + x[3] + x[4] +x[5] + 4) >> 3;
-	Des[2] = (x[0] + x[1] +x[2] + x[3] * 2 + x[4] + x[5] +x[6] + 4) >> 3;
-	Des[3] = (x[1] + x[2] +x[3] + x[4] * 2 + x[5] + x[6] +x[7] + 4) >> 3;
-	Des[4] = (x[2] + x[3] +x[4] + x[5] * 2 + x[6] + x[7] +x[8] + 4) >> 3;
-	Des[5] = (x[3] + x[4] +x[5] + x[6] * 2 + x[7] + x[8] +x[9] + 4) >> 3;
-	Des[6] = (x[4] + x[5] +x[6] + x[7] * 2 + x[8] + x[9] +x[9] + 4) >> 3;
-	Des[7] = (x[5] + x[6] +x[7] + x[8] * 2 + x[9] + x[9] +x[9] + 4) >> 3;
+          Sum2 < FLimit &&
+          (x[5] - x[4]) < QStep &&
+          (x[4] - x[5]) < QStep ){
+
+        /* low pass filtering (LPF7: 1 1 1 2 1 1 1) */
+        Des[0] = (x[0] + x[0] +x[0] + x[1] * 2 + x[2] + x[3] +x[4] + 4) >> 3;
+        Des[1] = (x[0] + x[0] +x[1] + x[2] * 2 + x[3] + x[4] +x[5] + 4) >> 3;
+        Des[2] = (x[0] + x[1] +x[2] + x[3] * 2 + x[4] + x[5] +x[6] + 4) >> 3;
+        Des[3] = (x[1] + x[2] +x[3] + x[4] * 2 + x[5] + x[6] +x[7] + 4) >> 3;
+        Des[4] = (x[2] + x[3] +x[4] + x[5] * 2 + x[6] + x[7] +x[8] + 4) >> 3;
+        Des[5] = (x[3] + x[4] +x[5] + x[6] * 2 + x[7] + x[8] +x[9] + 4) >> 3;
+        Des[6] = (x[4] + x[5] +x[6] + x[7] * 2 + x[8] + x[9] +x[9] + 4) >> 3;
+        Des[7] = (x[5] + x[6] +x[7] + x[8] * 2 + x[9] + x[9] +x[9] + 4) >> 3;
       }
       Src +=PlaneLineStep;
-                Des +=PlaneLineStep;                
+                Des +=PlaneLineStep;
 
-    }     
+    }
     CurrentFrag ++;
-  } 
+  }
 }
 
-static void DeblockPlane(PB_INSTANCE *pbi, 
-		  unsigned char *SourceBuffer, 
-		  unsigned char *DestinationBuffer, 
-		  ogg_uint32_t Channel ){
-  
+static void DeblockPlane(PB_INSTANCE *pbi,
+                  unsigned char *SourceBuffer,
+                  unsigned char *DestinationBuffer,
+                  ogg_uint32_t Channel ){
+
   ogg_uint32_t i,k;
   ogg_uint32_t PlaneLineStep=0;
   ogg_uint32_t StartFrag =0;
@@ -819,11 +820,11 @@
   ogg_uint32_t FragsAcross=0;
   ogg_uint32_t FragsDown=0;
   ogg_uint32_t *QuantScale=0;
-  
-  switch( Channel ){    
+
+  switch( Channel ){
   case 0:
     /* Get the parameters */
-    PlaneLineStep = pbi->YStride; 
+    PlaneLineStep = pbi->YStride;
     FragsAcross = pbi->HFragments;
     FragsDown = pbi->VFragments;
     StartFrag = 0;
@@ -831,14 +832,14 @@
     SrcPtr = & SourceBuffer[PixelIndex];
     DesPtr = & DestinationBuffer[PixelIndex];
     break;
-    
+
   case 1:
     /* Get the parameters */
-    PlaneLineStep = pbi->UVStride;    
+    PlaneLineStep = pbi->UVStride;
     FragsAcross = pbi->HFragments / 2;
     FragsDown = pbi->VFragments / 2;
     StartFrag = pbi->YPlaneFragments;
-    
+
     PixelIndex = pbi->ReconUDataOffset;
     SrcPtr = & SourceBuffer[PixelIndex];
     DesPtr = & DestinationBuffer[PixelIndex];
@@ -846,19 +847,19 @@
 
   default:
     /* Get the parameters */
-    PlaneLineStep = pbi->UVStride;    
+    PlaneLineStep = pbi->UVStride;
     FragsAcross = pbi->HFragments / 2;
     FragsDown = pbi->VFragments / 2;
     StartFrag =   pbi->YPlaneFragments + pbi->UVPlaneFragments;
-	
+
     PixelIndex = pbi->ReconVDataOffset;
     SrcPtr = & SourceBuffer[PixelIndex];
     DesPtr = & DestinationBuffer[PixelIndex];
     break;
   }
-  
+
   QuantScale = DcQuantScaleV1;
-    
+
   for(i=0;i<4;i++)
     memcpy(DesPtr+i*PlaneLineStep, SrcPtr+i*PlaneLineStep, PlaneLineStep);
 
@@ -868,48 +869,48 @@
 
     SrcPtr += 8*PlaneLineStep;
     DesPtr += 8*PlaneLineStep;
-    
+
     /* Filter both the horizontal and vertical block edges inside the band */
-    DeblockLoopFilteredBand(pbi, SrcPtr, DesPtr, PlaneLineStep, 
-			    FragsAcross, StartFrag, QuantScale);
-    
+    DeblockLoopFilteredBand(pbi, SrcPtr, DesPtr, PlaneLineStep,
+                            FragsAcross, StartFrag, QuantScale);
+
     /* Move Pointers */
     StartFrag += FragsAcross;
-    
-    k ++;   
+
+    k ++;
   }
 
   /* The Last band */
   for(i=0;i<4;i++)
-    memcpy(DesPtr+(i+4)*PlaneLineStep, 
-	   SrcPtr+(i+4)*PlaneLineStep, 
-	   PlaneLineStep);
-  
-  DeblockVerticalEdgesInLoopFilteredBand(pbi,SrcPtr,DesPtr,PlaneLineStep, 
-					 FragsAcross,StartFrag,QuantScale);
-  
+    memcpy(DesPtr+(i+4)*PlaneLineStep,
+           SrcPtr+(i+4)*PlaneLineStep,
+           PlaneLineStep);
+
+  DeblockVerticalEdgesInLoopFilteredBand(pbi,SrcPtr,DesPtr,PlaneLineStep,
+                                         FragsAcross,StartFrag,QuantScale);
+
 }
 
-static void DeblockFrame(PB_INSTANCE *pbi, unsigned char *SourceBuffer, 
-		  unsigned char *DestinationBuffer){ 
+static void DeblockFrame(PB_INSTANCE *pbi, unsigned char *SourceBuffer,
+                  unsigned char *DestinationBuffer){
 
   memset(pbi->FragmentVariances, 0 , sizeof(ogg_int32_t) * pbi->UnitFragments);
-  
-  
+
+
   UpdateFragQIndex(pbi);
 
-  
+
   SetupLoopFilter(pbi);
-  
+
   /* Y */
   DeblockPlane( pbi, SourceBuffer, DestinationBuffer, 0);
-        
+
   /* U */
   DeblockPlane( pbi, SourceBuffer, DestinationBuffer, 1);
-        
+
   /* V */
   DeblockPlane( pbi, SourceBuffer, DestinationBuffer, 2);
-  
+
 }
 
 void PostProcess(PB_INSTANCE *pbi){
@@ -919,13 +920,13 @@
     /* on a slow machine, use a simpler and faster deblocking filter */
     DeblockFrame(pbi, pbi->LastFrameRecon,pbi->PostProcessBuffer);
     break;
-    
+
   case 6:
     DeblockFrame(pbi, pbi->LastFrameRecon,pbi->PostProcessBuffer);
     UpdateUMVBorder(pbi, pbi->PostProcessBuffer );
     DeringFrame(pbi, pbi->PostProcessBuffer, pbi->PostProcessBuffer);
     break;
-    
+
   case 5:
     DeblockFrame(pbi, pbi->LastFrameRecon,pbi->PostProcessBuffer);
     UpdateUMVBorder(pbi, pbi->PostProcessBuffer );
@@ -937,10 +938,10 @@
   case 1:
     UpdateFragQIndex(pbi);
     break;
-    
+
   case 0:
     break;
-    
+
   default:
     DeblockFrame(pbi, pbi->LastFrameRecon, pbi->PostProcessBuffer);
     UpdateUMVBorder(pbi, pbi->PostProcessBuffer );

<p><p>1.3       +10 -11    theora/lib/pp.h

Index: pp.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/pp.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pp.h	8 Jun 2003 00:08:38 -0000	1.2
+++ pp.h	10 Jun 2003 01:31:33 -0000	1.3
@@ -10,8 +10,8 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: pp.h,v 1.2 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: pp.h,v 1.3 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
@@ -20,7 +20,7 @@
 #define INTERNAL_BLOCK_WIDTH    8
 
 
-/* NEW Line search values. */ 
+/* NEW Line search values. */
 #define UP      0
 #define DOWN    1
 #define LEFT    2
@@ -28,22 +28,21 @@
 
 #define FIRST_ROW           0
 #define NOT_EDGE_ROW        1
-#define LAST_ROW            2      
+#define LAST_ROW            2
 
 #define YDIFF_CB_ROWS                   (INTERNAL_BLOCK_HEIGHT * 3)
 #define CHLOCALS_CB_ROWS                (INTERNAL_BLOCK_HEIGHT * 3)
 #define PMAP_CB_ROWS                    (INTERNAL_BLOCK_HEIGHT * 3)
 #define PSCORE_CB_ROWS                  (INTERNAL_BLOCK_HEIGHT * 4)
 
-// Status values in block coding map
+/* Status values in block coding map */
 #define CANDIDATE_BLOCK_LOW                     -2
 #define CANDIDATE_BLOCK                         -1
 #define BLOCK_NOT_CODED                         0
-#define BLOCK_CODED_BAR                         3       
-#define BLOCK_CODED_SGC                         4       
-#define BLOCK_CODED_LOW                         4       
-#define BLOCK_CODED                             5       
+#define BLOCK_CODED_BAR                         3
+#define BLOCK_CODED_SGC                         4
+#define BLOCK_CODED_LOW                         4
+#define BLOCK_CODED                             5
 
 #define MAX_PREV_FRAMES             16
-#define MAX_SEARCH_LINE_LEN                     7   
-
+#define MAX_SEARCH_LINE_LEN                     7

<p><p>1.9       +235 -235  theora/lib/quant.c

Index: quant.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/quant.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- quant.c	9 Jun 2003 01:45:19 -0000	1.8
+++ quant.c	10 Jun 2003 01:31:33 -0000	1.9
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function:
-  last mod: $Id: quant.c,v 1.8 2003/06/09 01:45:19 tterribe Exp $
+  last mod: $Id: quant.c,v 1.9 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
@@ -20,18 +20,18 @@
 #include "encoder_internal.h"
 #include "quant_lookup.h"
 
-static ogg_uint32_t QThreshTableV1[Q_TABLE_SIZE] = { 
+static ogg_uint32_t QThreshTableV1[Q_TABLE_SIZE] = {
   500,  450,  400,  370,  340,  310, 285, 265,
-  245,  225,  210,  195,  185,  180, 170, 160, 
+  245,  225,  210,  195,  185,  180, 170, 160,
   150,  145,  135,  130,  125,  115, 110, 107,
   100,   96,   93,   89,   85,   82,  75,  74,
-  70,   68,   64,   60,   57,   56,  52,  50,  
-  49,   45,   44,   43,   40,   38,  37,  35,  
+  70,   68,   64,   60,   57,   56,  52,  50,
+  49,   45,   44,   43,   40,   38,  37,  35,
   33,   32,   30,   29,   28,   25,  24,  22,
-  21,   19,   18,   17,   15,   13,  12,  10 
+  21,   19,   18,   17,   15,   13,  12,  10
 };
 
-static Q_LIST_ENTRY DcScaleFactorTableV1[ Q_TABLE_SIZE ] = { 
+static Q_LIST_ENTRY DcScaleFactorTableV1[ Q_TABLE_SIZE ] = {
   220, 200, 190, 180, 170, 170, 160, 160,
   150, 150, 140, 140, 130, 130, 120, 120,
   110, 110, 100, 100, 90,  90,  90,  80,
@@ -39,7 +39,7 @@
   60,  50,  50,  50,  50,  40,  40,  40,
   40,  40,  30,  30,  30,  30,  30,  30,
   30,  20,  20,  20,  20,  20,  20,  20,
-  20,  10,  10,  10,  10,  10,  10,  10 
+  20,  10,  10,  10,  10,  10,  10,  10
 };
 
 /* dbm -- defined some alternative tables to test header packing */
@@ -48,72 +48,72 @@
 
 static Q_LIST_ENTRY Y_coeffsV1[64] =
 {
-	8,  16,  16,  16,  20,  20,  20,  20,
-	16,  16,  16,  16,  20,  20,  20,  20,
-	16,  16,  16,  16,  22,  22,  22,  22,
-	16,  16,  16,  16,  22,  22,  22,  22,
-	20,  20,  22,  22,  24,  24,  24,  24,
-	20,  20,  22,  22,  24,  24,  24,  24,
-	20,  20,  22,  22,  24,  24,  24,  24,
-	20,  20,  22,  22,  24,  24,  24,  24
+        8,  16,  16,  16,  20,  20,  20,  20,
+        16,  16,  16,  16,  20,  20,  20,  20,
+        16,  16,  16,  16,  22,  22,  22,  22,
+        16,  16,  16,  16,  22,  22,  22,  22,
+        20,  20,  22,  22,  24,  24,  24,  24,
+        20,  20,  22,  22,  24,  24,  24,  24,
+        20,  20,  22,  22,  24,  24,  24,  24,
+        20,  20,  22,  22,  24,  24,  24,  24
 };
 
 static Q_LIST_ENTRY UV_coeffsV1[64] =
-{	17,	18,	24,	47,	99,	99,	99,	99,
-	18,	21,	26,	66,	99,	99,	99,	99,
-	24,	26,	56,	99,	99,	99,	99,	99,
-	47,	66,	99,	99,	99,	99,	99,	99,
-	99,	99,	99,	99,	99,	99,	99,	99,
-	99,	99,	99,	99,	99,	99,	99,	99,
-	99,	99,	99,	99,	99,	99,	99,	99,
-	99,	99,	99,	99,	99,	99,	99,	99
+{       17,     18,     24,     47,     99,     99,     99,     99,
+        18,     21,     26,     66,     99,     99,     99,     99,
+        24,     26,     56,     99,     99,     99,     99,     99,
+        47,     66,     99,     99,     99,     99,     99,     99,
+        99,     99,     99,     99,     99,     99,     99,     99,
+        99,     99,     99,     99,     99,     99,     99,     99,
+        99,     99,     99,     99,     99,     99,     99,     99,
+        99,     99,     99,     99,     99,     99,     99,     99
 };
 
 /* Different matrices for different encoder versions */
 static Q_LIST_ENTRY Inter_coeffsV1[64] =
 {
-	12, 16,  16,  16,  20,  20,  20,  20,
-	16,  16,  16,  16,  20,  20,  20,  20,
-	16,  16,  16,  16,  22,  22,  22,  22,
-	16,  16,  16,  16,  22,  22,  22,  22,
-	20,  20,  22,  22,  24,  24,  24,  24,
-	20,  20,  22,  22,  24,  24,  24,  24,
-	20,  20,  22,  22,  24,  24,  24,  24,
-	20,  20,  22,  22,  24,  24,  24,  24
+        12, 16,  16,  16,  20,  20,  20,  20,
+        16,  16,  16,  16,  20,  20,  20,  20,
+        16,  16,  16,  16,  22,  22,  22,  22,
+        16,  16,  16,  16,  22,  22,  22,  22,
+        20,  20,  22,  22,  24,  24,  24,  24,
+        20,  20,  22,  22,  24,  24,  24,  24,
+        20,  20,  22,  22,  24,  24,  24,  24,
+        20,  20,  22,  22,  24,  24,  24,  24
 };
 
 #else /* these are the old VP3 values: */
 
 static Q_LIST_ENTRY Y_coeffsV1[64] ={
   16,  11,  10,  16,  24,  40,  51,  61,
-  12,  12,  14,  19,  26,  58,  60,  55, 
-  14,  13,  16,  24,  40,  57,  69,  56, 
-  14,  17,  22,  29,  51,  87,  80,  62, 
-  18,  22,  37,  58,  68, 109, 103,  77, 
-  24,  35,  55,  64,  81, 104, 113,  92, 
-  49,  64,  78,  87, 103, 121, 120, 101, 
+  12,  12,  14,  19,  26,  58,  60,  55,
+  14,  13,  16,  24,  40,  57,  69,  56,
+  14,  17,  22,  29,  51,  87,  80,  62,
+  18,  22,  37,  58,  68, 109, 103,  77,
+  24,  35,  55,  64,  81, 104, 113,  92,
+  49,  64,  78,  87, 103, 121, 120, 101,
   72,  92,  95,  98, 112, 100, 103,  99
 };
 
-static Q_LIST_ENTRY UV_coeffsV1[64] ={	
-  17,	18,	24,	47,	99,	99,	99,	99,
-  18,	21,	26,	66,	99,	99,	99,	99,
-  24,	26,	56,	99,	99,	99,	99,	99,
-  47,	66,	99,	99,	99,	99,	99,	99,
-  99,	99,	99,	99,	99,	99,	99,	99,
-  99,	99,	99,	99,	99,	99,	99,	99,
-  99,	99,	99,	99,	99,	99,	99,	99,
-  99,	99,	99,	99,	99,	99,	99,	99
+static Q_LIST_ENTRY UV_coeffsV1[64] ={
+  17,   18,     24,     47,     99,     99,     99,     99,
+  18,   21,     26,     66,     99,     99,     99,     99,
+  24,   26,     56,     99,     99,     99,     99,     99,
+  47,   66,     99,     99,     99,     99,     99,     99,
+  99,   99,     99,     99,     99,     99,     99,     99,
+  99,   99,     99,     99,     99,     99,     99,     99,
+  99,   99,     99,     99,     99,     99,     99,     99,
+  99,   99,     99,     99,     99,     99,     99,     99
 };
 
 /* Different matrices for different encoder versions */
 static Q_LIST_ENTRY Inter_coeffsV1[64] ={
   16,  16,  16,  20,  24,  28,  32,  40,
-  16,  16,  20,  24,  28,  32,  40,  48, 
-  16,  20,  24,  28,  32,  40,  48,  64, 
-  20,  24,  28,  32,  40,  48,  64,  64, 
-  24,  28,  32,  40,  48,  64,  64,  64, 
-  28,  32,  40,  48,  64,  64,  64,  96, 
+  16,  16,  20,  24,  28,  32,  40,  48,
+  16,  20,  24,  28,  32,  40,  48,  64,
+  20,  24,  28,  32,  40,  48,  64,  64,
+  24,  28,  32,  40,  48,  64,  64,  64,
+  28,  32,  40,  48,  64,  64,  64,  96,
   32,  40,  48,  64,  64,  64,  96,  128,
   40,  48,  64,  64,  64,  96,  128, 128
 };
@@ -150,22 +150,22 @@
   for(x=0; x<Q_TABLE_SIZE; x++) {
     bits=oggpackB_read(opb, 16);
     if(bits<0)return OC_BADHEADER;
-    ci->DcScaleFactorTable[x]=bits;
+    ci->DcScaleFactorTable[x]=(Q_LIST_ENTRY)bits;
   }
   for(x=0; x<64; x++) {
     bits=oggpackB_read(opb, 8);
     if(bits<0)return OC_BADHEADER;
-    ci->Y_coeffs[x]=bits;
+    ci->Y_coeffs[x]=(Q_LIST_ENTRY)bits;
   }
   for(x=0; x<64; x++) {
     bits=oggpackB_read(opb, 8);
     if(bits<0)return OC_BADHEADER;
-    ci->UV_coeffs[x]=bits;
+    ci->UV_coeffs[x]=(Q_LIST_ENTRY)bits;
   }
   for(x=0; x<64; x++) {
     bits=oggpackB_read(opb, 8);
     if(bits<0)return OC_BADHEADER;
-    ci->Inter_coeffs[x]=bits;
+    ci->Inter_coeffs[x]=(Q_LIST_ENTRY)bits;
   }
   return 0;
 }
@@ -193,29 +193,29 @@
 
 static void BuildQuantIndex_Generic(PB_INSTANCE *pbi){
   ogg_int32_t i,j;
-  
+
   /* invert the dequant index into the quant index */
-  for ( i = 0; i < BLOCK_SIZE; i++ ){	
+  for ( i = 0; i < BLOCK_SIZE; i++ ){
     j = dequant_index[i];
     pbi->quant_index[j] = i;
   }
 }
 
-static void init_quantizer ( CP_INSTANCE *cpi, 
-		      ogg_uint32_t scale_factor, 
-		      unsigned char QIndex ){
-    int i;                 
+static void init_quantizer ( CP_INSTANCE *cpi,
+                      ogg_uint32_t scale_factor,
+                      unsigned char QIndex ){
+    int i;
     double ZBinFactor;
     double RoundingFactor;
-    
+
     double temp_fp_quant_coeffs;
     double temp_fp_quant_round;
     double temp_fp_ZeroBinSize;
     PB_INSTANCE *pbi = &cpi->pb;
 
-    Q_LIST_ENTRY * Inter_coeffs;	 
-    Q_LIST_ENTRY * Y_coeffs;	 
-    Q_LIST_ENTRY * UV_coeffs;	 
+    Q_LIST_ENTRY * Inter_coeffs;
+    Q_LIST_ENTRY * Y_coeffs;
+    Q_LIST_ENTRY * UV_coeffs;
     Q_LIST_ENTRY * DcScaleFactorTable;
     Q_LIST_ENTRY * UVDcScaleFactorTable;
 
@@ -232,201 +232,201 @@
     DcScaleFactorTable = DcScaleFactorTableV1;
     UVDcScaleFactorTable = DcScaleFactorTableV1;
     ZBinFactor = 0.9;
-    
+
     switch(cpi->pb.info.sharpness){
     case 0:
       ZBinFactor = 0.65;
       if ( scale_factor <= 50 )
-	RoundingFactor = 0.499;
+        RoundingFactor = 0.499;
       else
-	RoundingFactor = 0.46;
+        RoundingFactor = 0.46;
       break;
     case 1:
       ZBinFactor = 0.75;
       if ( scale_factor <= 50 )
-	RoundingFactor = 0.476;
+        RoundingFactor = 0.476;
       else
-	RoundingFactor = 0.400;
+        RoundingFactor = 0.400;
       break;
-      
+
     default:
       ZBinFactor = 0.9;
       if ( scale_factor <= 50 )
-	RoundingFactor = 0.476;
+        RoundingFactor = 0.476;
       else
-	RoundingFactor = 0.333;
+        RoundingFactor = 0.333;
       break;
     }
-    
+
     /* Use fixed multiplier for intra Y DC */
-    temp_fp_quant_coeffs = 
+    temp_fp_quant_coeffs =
       (((ogg_uint32_t)(DcScaleFactorTable[QIndex] * Y_coeffs[0])/100) << 2);
     if ( temp_fp_quant_coeffs < MIN_LEGAL_QUANT_ENTRY * 2 )
       temp_fp_quant_coeffs = MIN_LEGAL_QUANT_ENTRY * 2;
-    
+
     temp_fp_quant_round = temp_fp_quant_coeffs * RoundingFactor;
-    pbi->fp_quant_Y_round[0]	= (ogg_int32_t) (0.5 + temp_fp_quant_round);
-    
+    pbi->fp_quant_Y_round[0]    = (ogg_int32_t) (0.5 + temp_fp_quant_round);
+
     temp_fp_ZeroBinSize = temp_fp_quant_coeffs * ZBinFactor;
-    pbi->fp_ZeroBinSize_Y[0]	= (ogg_int32_t) (0.5 + temp_fp_ZeroBinSize);
-    
+    pbi->fp_ZeroBinSize_Y[0]    = (ogg_int32_t) (0.5 + temp_fp_ZeroBinSize);
+
     temp_fp_quant_coeffs = 1.0 / temp_fp_quant_coeffs;
-    pbi->fp_quant_Y_coeffs[0]	= (0.5 + SHIFT16 * temp_fp_quant_coeffs);
-    
+    pbi->fp_quant_Y_coeffs[0]   = (0.5 + SHIFT16 * temp_fp_quant_coeffs);
+
     /* Intra UV */
-    temp_fp_quant_coeffs = 
+    temp_fp_quant_coeffs =
       (((ogg_uint32_t)(UVDcScaleFactorTable[QIndex] * UV_coeffs[0])/100) << 2);
     if ( temp_fp_quant_coeffs < MIN_LEGAL_QUANT_ENTRY * 2)
       temp_fp_quant_coeffs = MIN_LEGAL_QUANT_ENTRY * 2;
-    
+
     temp_fp_quant_round = temp_fp_quant_coeffs * RoundingFactor;
-    pbi->fp_quant_UV_round[0]	= (0.5 + temp_fp_quant_round);
-    
+    pbi->fp_quant_UV_round[0]   = (0.5 + temp_fp_quant_round);
+
     temp_fp_ZeroBinSize = temp_fp_quant_coeffs * ZBinFactor;
-    pbi->fp_ZeroBinSize_UV[0]	= (0.5 + temp_fp_ZeroBinSize);
-    
+    pbi->fp_ZeroBinSize_UV[0]   = (0.5 + temp_fp_ZeroBinSize);
+
     temp_fp_quant_coeffs = 1.0 / temp_fp_quant_coeffs;
     pbi->fp_quant_UV_coeffs[0]= (0.5 + SHIFT16 * temp_fp_quant_coeffs);
-    
+
     /* Inter Y */
-    temp_fp_quant_coeffs = 
+    temp_fp_quant_coeffs =
       (((ogg_uint32_t)(DcScaleFactorTable[QIndex] * Inter_coeffs[0])/100) << 2);
     if ( temp_fp_quant_coeffs < MIN_LEGAL_QUANT_ENTRY * 4)
       temp_fp_quant_coeffs = MIN_LEGAL_QUANT_ENTRY * 4;
-    
+
     temp_fp_quant_round = temp_fp_quant_coeffs * RoundingFactor;
-    pbi->fp_quant_Inter_round[0]= (0.5 + temp_fp_quant_round);    
-    
+    pbi->fp_quant_Inter_round[0]= (0.5 + temp_fp_quant_round);
+
     temp_fp_ZeroBinSize = temp_fp_quant_coeffs * ZBinFactor;
     pbi->fp_ZeroBinSize_Inter[0]= (0.5 + temp_fp_ZeroBinSize);
-    
+
     temp_fp_quant_coeffs= 1.0 / temp_fp_quant_coeffs;
     pbi->fp_quant_Inter_coeffs[0]= (0.5 + SHIFT16 * temp_fp_quant_coeffs);
-    
+
     /* Inter UV */
-    temp_fp_quant_coeffs = 
+    temp_fp_quant_coeffs =
       (((ogg_uint32_t)(UVDcScaleFactorTable[QIndex] * Inter_coeffs[0])/100) << 2);
     if ( temp_fp_quant_coeffs < MIN_LEGAL_QUANT_ENTRY * 4)
       temp_fp_quant_coeffs = MIN_LEGAL_QUANT_ENTRY * 4;
-    
+
     temp_fp_quant_round = temp_fp_quant_coeffs * RoundingFactor;
-    pbi->fp_quant_InterUV_round[0]= (0.5 + temp_fp_quant_round);    
-    
+    pbi->fp_quant_InterUV_round[0]= (0.5 + temp_fp_quant_round);
+
     temp_fp_ZeroBinSize = temp_fp_quant_coeffs * ZBinFactor;
     pbi->fp_ZeroBinSize_InterUV[0]= (0.5 + temp_fp_ZeroBinSize);
-    
+
     temp_fp_quant_coeffs= 1.0 / temp_fp_quant_coeffs;
-    pbi->fp_quant_InterUV_coeffs[0]= 
+    pbi->fp_quant_InterUV_coeffs[0]=
       (0.5 + SHIFT16 * temp_fp_quant_coeffs);
-    
+
     for ( i = 1; i < 64; i++ ){
       /* now scale coefficients by required compression factor */
       /* Intra Y */
-      temp_fp_quant_coeffs =  
-	(((ogg_uint32_t)(scale_factor * Y_coeffs[i]) / 100 ) << 2 );
+      temp_fp_quant_coeffs =
+        (((ogg_uint32_t)(scale_factor * Y_coeffs[i]) / 100 ) << 2 );
       if ( temp_fp_quant_coeffs < (MIN_LEGAL_QUANT_ENTRY) )
-	temp_fp_quant_coeffs = (MIN_LEGAL_QUANT_ENTRY);
-      
+        temp_fp_quant_coeffs = (MIN_LEGAL_QUANT_ENTRY);
+
       temp_fp_quant_round = temp_fp_quant_coeffs * RoundingFactor;
-      pbi->fp_quant_Y_round[i]	= (0.5 + temp_fp_quant_round);
-      
+      pbi->fp_quant_Y_round[i]  = (0.5 + temp_fp_quant_round);
+
       temp_fp_ZeroBinSize = temp_fp_quant_coeffs * ZBinFactor;
-      pbi->fp_ZeroBinSize_Y[i]	= (0.5 + temp_fp_ZeroBinSize);
-      
+      pbi->fp_ZeroBinSize_Y[i]  = (0.5 + temp_fp_ZeroBinSize);
+
       temp_fp_quant_coeffs = 1.0 / temp_fp_quant_coeffs;
-      pbi->fp_quant_Y_coeffs[i]	= (0.5 + SHIFT16 * temp_fp_quant_coeffs);
-      
+      pbi->fp_quant_Y_coeffs[i] = (0.5 + SHIFT16 * temp_fp_quant_coeffs);
+
       /* Intra UV */
-      temp_fp_quant_coeffs =  
-	(((ogg_uint32_t)(scale_factor * UV_coeffs[i]) / 100 ) << 2 );
+      temp_fp_quant_coeffs =
+        (((ogg_uint32_t)(scale_factor * UV_coeffs[i]) / 100 ) << 2 );
       if ( temp_fp_quant_coeffs < (MIN_LEGAL_QUANT_ENTRY))
-	temp_fp_quant_coeffs = (MIN_LEGAL_QUANT_ENTRY);
-      
+        temp_fp_quant_coeffs = (MIN_LEGAL_QUANT_ENTRY);
+
       temp_fp_quant_round = temp_fp_quant_coeffs * RoundingFactor;
-      pbi->fp_quant_UV_round[i]	= (0.5 + temp_fp_quant_round);
+      pbi->fp_quant_UV_round[i] = (0.5 + temp_fp_quant_round);
 
       temp_fp_ZeroBinSize = temp_fp_quant_coeffs * ZBinFactor;
-      pbi->fp_ZeroBinSize_UV[i]	= (0.5 + temp_fp_ZeroBinSize);
+      pbi->fp_ZeroBinSize_UV[i] = (0.5 + temp_fp_ZeroBinSize);
 
       temp_fp_quant_coeffs = 1.0 / temp_fp_quant_coeffs;
       pbi->fp_quant_UV_coeffs[i]= (0.5 + SHIFT16 * temp_fp_quant_coeffs);
 
       /* Inter Y */
-      temp_fp_quant_coeffs =  
-	(((ogg_uint32_t)(scale_factor * Inter_coeffs[i]) / 100 ) << 2 );
+      temp_fp_quant_coeffs =
+        (((ogg_uint32_t)(scale_factor * Inter_coeffs[i]) / 100 ) << 2 );
       if ( temp_fp_quant_coeffs < (MIN_LEGAL_QUANT_ENTRY * 2) )
-	temp_fp_quant_coeffs = (MIN_LEGAL_QUANT_ENTRY * 2);
-      
-      temp_fp_quant_round = temp_fp_quant_coeffs * RoundingFactor;    
-      pbi->fp_quant_Inter_round[i]= (0.5 + temp_fp_quant_round);    
-      
+        temp_fp_quant_coeffs = (MIN_LEGAL_QUANT_ENTRY * 2);
+
+      temp_fp_quant_round = temp_fp_quant_coeffs * RoundingFactor;
+      pbi->fp_quant_Inter_round[i]= (0.5 + temp_fp_quant_round);
+
       temp_fp_ZeroBinSize = temp_fp_quant_coeffs * ZBinFactor;
       pbi->fp_ZeroBinSize_Inter[i]= (0.5 + temp_fp_ZeroBinSize);
-      
+
       temp_fp_quant_coeffs = 1.0 / temp_fp_quant_coeffs;
       pbi->fp_quant_Inter_coeffs[i]= (0.5 + SHIFT16 * temp_fp_quant_coeffs);
-      
+
       /* Inter UV */
-      temp_fp_quant_coeffs = 
-	(((ogg_uint32_t)(scale_factor * Inter_coeffs[i]) / 100 ) << 2 );
+      temp_fp_quant_coeffs =
+        (((ogg_uint32_t)(scale_factor * Inter_coeffs[i]) / 100 ) << 2 );
       if ( temp_fp_quant_coeffs < (MIN_LEGAL_QUANT_ENTRY * 2) )
-	temp_fp_quant_coeffs = (MIN_LEGAL_QUANT_ENTRY * 2);
-      
-      temp_fp_quant_round = temp_fp_quant_coeffs * RoundingFactor;    
-      pbi->fp_quant_InterUV_round[i]= (0.5 + temp_fp_quant_round);    
-        
+        temp_fp_quant_coeffs = (MIN_LEGAL_QUANT_ENTRY * 2);
+
+      temp_fp_quant_round = temp_fp_quant_coeffs * RoundingFactor;
+      pbi->fp_quant_InterUV_round[i]= (0.5 + temp_fp_quant_round);
+
       temp_fp_ZeroBinSize = temp_fp_quant_coeffs * ZBinFactor;
       pbi->fp_ZeroBinSize_InterUV[i]= (0.5 + temp_fp_ZeroBinSize);
 
       temp_fp_quant_coeffs = 1.0 / temp_fp_quant_coeffs;
       pbi->fp_quant_InterUV_coeffs[i]= (0.5 + SHIFT16 * temp_fp_quant_coeffs);
-	
+
     }
 
     pbi->fquant_coeffs = pbi->fp_quant_Y_coeffs;
 
 }
 
-void select_Y_quantiser ( PB_INSTANCE *pbi ){	
+void select_Y_quantiser ( PB_INSTANCE *pbi ){
   pbi->fquant_coeffs = pbi->fp_quant_Y_coeffs;
   pbi->fquant_round = pbi->fp_quant_Y_round;
   pbi->fquant_ZbSize = pbi->fp_ZeroBinSize_Y;
 }
 
-void select_Inter_quantiser ( PB_INSTANCE *pbi ){	
+void select_Inter_quantiser ( PB_INSTANCE *pbi ){
   pbi->fquant_coeffs = pbi->fp_quant_Inter_coeffs;
   pbi->fquant_round = pbi->fp_quant_Inter_round;
   pbi->fquant_ZbSize = pbi->fp_ZeroBinSize_Inter;
 }
 
-void select_UV_quantiser ( PB_INSTANCE *pbi ){	
+void select_UV_quantiser ( PB_INSTANCE *pbi ){
   pbi->fquant_coeffs = pbi->fp_quant_UV_coeffs;
   pbi->fquant_round = pbi->fp_quant_UV_round;
   pbi->fquant_ZbSize = pbi->fp_quant_UV_round;
 }
 
-void select_InterUV_quantiser ( PB_INSTANCE *pbi ){	
+void select_InterUV_quantiser ( PB_INSTANCE *pbi ){
   pbi->fquant_coeffs = pbi->fp_quant_InterUV_coeffs;
   pbi->fquant_round = pbi->fp_quant_InterUV_round;
   pbi->fquant_ZbSize = pbi->fp_ZeroBinSize_InterUV;
 }
 
-void quantize( PB_INSTANCE *pbi, 
-	       ogg_int16_t * DCT_block, 
-	       Q_LIST_ENTRY * quantized_list){
-  ogg_uint32_t   	i;              /*	Row index */
+void quantize( PB_INSTANCE *pbi,
+               ogg_int16_t * DCT_block,
+               Q_LIST_ENTRY * quantized_list){
+  ogg_uint32_t          i;              /*      Row index */
   Q_LIST_ENTRY  val;            /* Quantised value. */
-  
+
   ogg_int32_t * FquantRoundPtr = pbi->fquant_round;
   ogg_int32_t * FquantCoeffsPtr = pbi->fquant_coeffs;
   ogg_int32_t * FquantZBinSizePtr = pbi->fquant_ZbSize;
   ogg_int16_t * DCT_blockPtr = DCT_block;
   ogg_uint32_t * QIndexPtr = (ogg_uint32_t *)pbi->quant_index;
   ogg_int32_t temp;
-  
+
   /* Set the quantized_list to default to 0 */
   memset( quantized_list, 0, 64 * sizeof(Q_LIST_ENTRY) );
-  
+
   /* Note that we add half divisor to effect rounding on positive number */
   for( i = 0; i < VFRAGPIXELS; i++) {
     /* Column 0  */
@@ -435,103 +435,103 @@
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[0]] = ( val > 511 ) ? 511 : val;
     } else if ( DCT_blockPtr[0] <= -FquantZBinSizePtr[0] ) {
-      temp = FquantCoeffsPtr[0] * 
-	( DCT_blockPtr[0] - FquantRoundPtr[0] ) + MIN16;
+      temp = FquantCoeffsPtr[0] *
+        ( DCT_blockPtr[0] - FquantRoundPtr[0] ) + MIN16;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[0]] = ( val < -511 ) ? -511 : val;
     }
 
     /* Column 1 */
     if ( DCT_blockPtr[1] >= FquantZBinSizePtr[1] ) {
-      temp = FquantCoeffsPtr[1] * 
-	( DCT_blockPtr[1] + FquantRoundPtr[1] ) ;
+      temp = FquantCoeffsPtr[1] *
+        ( DCT_blockPtr[1] + FquantRoundPtr[1] ) ;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[1]] = ( val > 511 ) ? 511 : val;
     } else if ( DCT_blockPtr[1] <= -FquantZBinSizePtr[1] ) {
-      temp = FquantCoeffsPtr[1] * 
-	( DCT_blockPtr[1] - FquantRoundPtr[1] ) + MIN16;
+      temp = FquantCoeffsPtr[1] *
+        ( DCT_blockPtr[1] - FquantRoundPtr[1] ) + MIN16;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[1]] = ( val < -511 ) ? -511 : val;
     }
 
     /* Column 2 */
     if ( DCT_blockPtr[2] >= FquantZBinSizePtr[2] ) {
-      temp = FquantCoeffsPtr[2] * 
-	( DCT_blockPtr[2] + FquantRoundPtr[2] ) ;
+      temp = FquantCoeffsPtr[2] *
+        ( DCT_blockPtr[2] + FquantRoundPtr[2] ) ;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[2]] = ( val > 511 ) ? 511 : val;
     } else if ( DCT_blockPtr[2] <= -FquantZBinSizePtr[2] ) {
-      temp = FquantCoeffsPtr[2] * 
-	( DCT_blockPtr[2] - FquantRoundPtr[2] ) + MIN16;
+      temp = FquantCoeffsPtr[2] *
+        ( DCT_blockPtr[2] - FquantRoundPtr[2] ) + MIN16;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[2]] = ( val < -511 ) ? -511 : val;
     }
-    
+
     /* Column 3 */
     if ( DCT_blockPtr[3] >= FquantZBinSizePtr[3] ) {
-      temp = FquantCoeffsPtr[3] * 
-	( DCT_blockPtr[3] + FquantRoundPtr[3] ) ;
+      temp = FquantCoeffsPtr[3] *
+        ( DCT_blockPtr[3] + FquantRoundPtr[3] ) ;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[3]] = ( val > 511 ) ? 511 : val;
     } else if ( DCT_blockPtr[3] <= -FquantZBinSizePtr[3] ) {
-      temp = FquantCoeffsPtr[3] * 
-	( DCT_blockPtr[3] - FquantRoundPtr[3] ) + MIN16;
+      temp = FquantCoeffsPtr[3] *
+        ( DCT_blockPtr[3] - FquantRoundPtr[3] ) + MIN16;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[3]] = ( val < -511 ) ? -511 : val;
     }
-    
+
     /* Column 4 */
     if ( DCT_blockPtr[4] >= FquantZBinSizePtr[4] ) {
-      temp = FquantCoeffsPtr[4] * 
-	( DCT_blockPtr[4] + FquantRoundPtr[4] ) ;
+      temp = FquantCoeffsPtr[4] *
+        ( DCT_blockPtr[4] + FquantRoundPtr[4] ) ;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[4]] = ( val > 511 ) ? 511 : val;
     } else if ( DCT_blockPtr[4] <= -FquantZBinSizePtr[4] ) {
-      temp = FquantCoeffsPtr[4] * 
-	( DCT_blockPtr[4] - FquantRoundPtr[4] ) + MIN16;
+      temp = FquantCoeffsPtr[4] *
+        ( DCT_blockPtr[4] - FquantRoundPtr[4] ) + MIN16;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[4]] = ( val < -511 ) ? -511 : val;
     }
 
     /* Column 5 */
     if ( DCT_blockPtr[5] >= FquantZBinSizePtr[5] ) {
-      temp = FquantCoeffsPtr[5] * 
-	( DCT_blockPtr[5] + FquantRoundPtr[5] ) ;
+      temp = FquantCoeffsPtr[5] *
+        ( DCT_blockPtr[5] + FquantRoundPtr[5] ) ;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[5]] = ( val > 511 ) ? 511 : val;
     } else if ( DCT_blockPtr[5] <= -FquantZBinSizePtr[5] ) {
-      temp = FquantCoeffsPtr[5] * 
-	( DCT_blockPtr[5] - FquantRoundPtr[5] ) + MIN16;
+      temp = FquantCoeffsPtr[5] *
+        ( DCT_blockPtr[5] - FquantRoundPtr[5] ) + MIN16;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[5]] = ( val < -511 ) ? -511 : val;
     }
-    
+
     /* Column 6 */
     if ( DCT_blockPtr[6] >= FquantZBinSizePtr[6] ) {
-      temp = FquantCoeffsPtr[6] * 
-	( DCT_blockPtr[6] + FquantRoundPtr[6] ) ;
+      temp = FquantCoeffsPtr[6] *
+        ( DCT_blockPtr[6] + FquantRoundPtr[6] ) ;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[6]] = ( val > 511 ) ? 511 : val;
     } else if ( DCT_blockPtr[6] <= -FquantZBinSizePtr[6] ) {
-      temp = FquantCoeffsPtr[6] * 
-	( DCT_blockPtr[6] - FquantRoundPtr[6] ) + MIN16;
+      temp = FquantCoeffsPtr[6] *
+        ( DCT_blockPtr[6] - FquantRoundPtr[6] ) + MIN16;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[6]] = ( val < -511 ) ? -511 : val;
     }
-    
+
     /* Column 7 */
     if ( DCT_blockPtr[7] >= FquantZBinSizePtr[7] ) {
-      temp = FquantCoeffsPtr[7] * 
-	( DCT_blockPtr[7] + FquantRoundPtr[7] ) ;
+      temp = FquantCoeffsPtr[7] *
+        ( DCT_blockPtr[7] + FquantRoundPtr[7] ) ;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[7]] = ( val > 511 ) ? 511 : val;
     } else if ( DCT_blockPtr[7] <= -FquantZBinSizePtr[7] ) {
-      temp = FquantCoeffsPtr[7] * 
-	( DCT_blockPtr[7] - FquantRoundPtr[7] ) + MIN16;
+      temp = FquantCoeffsPtr[7] *
+        ( DCT_blockPtr[7] - FquantRoundPtr[7] ) + MIN16;
       val = (Q_LIST_ENTRY) (temp>>16);
       quantized_list[QIndexPtr[7]] = ( val < -511 ) ? -511 : val;
     }
-    
+
     FquantRoundPtr += 8;
     FquantCoeffsPtr += 8;
     FquantZBinSizePtr += 8;
@@ -540,154 +540,154 @@
   }
 }
 
-static void init_dequantizer ( PB_INSTANCE *pbi, 
-			ogg_uint32_t scale_factor, 
-			unsigned char  QIndex ){
+static void init_dequantizer ( PB_INSTANCE *pbi,
+                        ogg_uint32_t scale_factor,
+                        unsigned char  QIndex ){
   int i, j;
-  
-  Q_LIST_ENTRY * Inter_coeffs;	 
-  Q_LIST_ENTRY * Y_coeffs;	 
-  Q_LIST_ENTRY * UV_coeffs;	 
+
+  Q_LIST_ENTRY * Inter_coeffs;
+  Q_LIST_ENTRY * Y_coeffs;
+  Q_LIST_ENTRY * UV_coeffs;
   Q_LIST_ENTRY * DcScaleFactorTable;
   Q_LIST_ENTRY * UVDcScaleFactorTable;
-  
+
   Inter_coeffs = pbi->Inter_coeffs;
   Y_coeffs = pbi->Y_coeffs;
   UV_coeffs = pbi->UV_coeffs;
   DcScaleFactorTable = pbi->DcScaleFactorTable;
   UVDcScaleFactorTable = pbi->DcScaleFactorTable;
-  
+
   /* invert the dequant index into the quant index
      the dxer has a different order than the cxer. */
   BuildQuantIndex_Generic(pbi);
-  
+
   /* Reorder dequantisation coefficients into dct zigzag order. */
-  for ( i = 0; i < BLOCK_SIZE; i++ ) {	
+  for ( i = 0; i < BLOCK_SIZE; i++ ) {
     j = pbi->quant_index[i];
     pbi->dequant_Y_coeffs[j] = Y_coeffs[i];
   }
-  for ( i = 0; i < BLOCK_SIZE; i++ ){	
+  for ( i = 0; i < BLOCK_SIZE; i++ ){
     j = pbi->quant_index[i];
     pbi->dequant_Inter_coeffs[j] = Inter_coeffs[i];
   }
-  for ( i = 0; i < BLOCK_SIZE; i++ ){	
+  for ( i = 0; i < BLOCK_SIZE; i++ ){
     j = pbi->quant_index[i];
     pbi->dequant_UV_coeffs[j] = UV_coeffs[i];
   }
-  for ( i = 0; i < BLOCK_SIZE; i++ ){	
+  for ( i = 0; i < BLOCK_SIZE; i++ ){
     j = pbi->quant_index[i];
     pbi->dequant_InterUV_coeffs[j] = Inter_coeffs[i];
   }
-  
+
   /* Intra Y */
-  pbi->dequant_Y_coeffs[0] = 
+  pbi->dequant_Y_coeffs[0] =
     ((DcScaleFactorTable[QIndex] * pbi->dequant_Y_coeffs[0])/100);
   if ( pbi->dequant_Y_coeffs[0] < MIN_DEQUANT_VAL * 2 )
     pbi->dequant_Y_coeffs[0] = MIN_DEQUANT_VAL * 2;
-  pbi->dequant_Y_coeffs[0] = 
+  pbi->dequant_Y_coeffs[0] =
     pbi->dequant_Y_coeffs[0] << IDCT_SCALE_FACTOR;
 
   /* Intra UV */
-  pbi->dequant_UV_coeffs[0] = 
+  pbi->dequant_UV_coeffs[0] =
     ((UVDcScaleFactorTable[QIndex] * pbi->dequant_UV_coeffs[0])/100);
   if ( pbi->dequant_UV_coeffs[0] < MIN_DEQUANT_VAL * 2 )
     pbi->dequant_UV_coeffs[0] = MIN_DEQUANT_VAL * 2;
-  pbi->dequant_UV_coeffs[0] = 
+  pbi->dequant_UV_coeffs[0] =
     pbi->dequant_UV_coeffs[0] << IDCT_SCALE_FACTOR;
-  
+
   /* Inter Y */
-  pbi->dequant_Inter_coeffs[0] = 
+  pbi->dequant_Inter_coeffs[0] =
     ((DcScaleFactorTable[QIndex] * pbi->dequant_Inter_coeffs[0])/100);
   if ( pbi->dequant_Inter_coeffs[0] < MIN_DEQUANT_VAL * 4 )
     pbi->dequant_Inter_coeffs[0] = MIN_DEQUANT_VAL * 4;
-  pbi->dequant_Inter_coeffs[0] = 
+  pbi->dequant_Inter_coeffs[0] =
     pbi->dequant_Inter_coeffs[0] << IDCT_SCALE_FACTOR;
-  
+
   /* Inter UV */
-  pbi->dequant_InterUV_coeffs[0] = 
+  pbi->dequant_InterUV_coeffs[0] =
     ((UVDcScaleFactorTable[QIndex] * pbi->dequant_InterUV_coeffs[0])/100);
   if ( pbi->dequant_InterUV_coeffs[0] < MIN_DEQUANT_VAL * 4 )
     pbi->dequant_InterUV_coeffs[0] = MIN_DEQUANT_VAL * 4;
-  pbi->dequant_InterUV_coeffs[0] = 
+  pbi->dequant_InterUV_coeffs[0] =
     pbi->dequant_InterUV_coeffs[0] << IDCT_SCALE_FACTOR;
-  
-  for ( i = 1; i < 64; i++ ){	
+
+  for ( i = 1; i < 64; i++ ){
     /* now scale coefficients by required compression factor */
-    pbi->dequant_Y_coeffs[i] = 
+    pbi->dequant_Y_coeffs[i] =
       (( scale_factor * pbi->dequant_Y_coeffs[i] ) / 100);
     if ( pbi->dequant_Y_coeffs[i] < MIN_DEQUANT_VAL )
       pbi->dequant_Y_coeffs[i] = MIN_DEQUANT_VAL;
-    pbi->dequant_Y_coeffs[i] = 
+    pbi->dequant_Y_coeffs[i] =
       pbi->dequant_Y_coeffs[i] << IDCT_SCALE_FACTOR;
 
-    pbi->dequant_UV_coeffs[i] = 
+    pbi->dequant_UV_coeffs[i] =
       (( scale_factor * pbi->dequant_UV_coeffs[i] ) / 100);
     if ( pbi->dequant_UV_coeffs[i] < MIN_DEQUANT_VAL )
       pbi->dequant_UV_coeffs[i] = MIN_DEQUANT_VAL;
-    pbi->dequant_UV_coeffs[i] = 
+    pbi->dequant_UV_coeffs[i] =
       pbi->dequant_UV_coeffs[i] << IDCT_SCALE_FACTOR;
-    
-    pbi->dequant_Inter_coeffs[i] = 
+
+    pbi->dequant_Inter_coeffs[i] =
       (( scale_factor * pbi->dequant_Inter_coeffs[i] ) / 100);
     if ( pbi->dequant_Inter_coeffs[i] < (MIN_DEQUANT_VAL * 2) )
       pbi->dequant_Inter_coeffs[i] = MIN_DEQUANT_VAL * 2;
-    pbi->dequant_Inter_coeffs[i] = 
+    pbi->dequant_Inter_coeffs[i] =
       pbi->dequant_Inter_coeffs[i] << IDCT_SCALE_FACTOR;
-    
-    pbi->dequant_InterUV_coeffs[i] = 
+
+    pbi->dequant_InterUV_coeffs[i] =
       (( scale_factor * pbi->dequant_InterUV_coeffs[i] ) / 100);
     if ( pbi->dequant_InterUV_coeffs[i] < (MIN_DEQUANT_VAL * 2) )
       pbi->dequant_InterUV_coeffs[i] = MIN_DEQUANT_VAL * 2;
-    pbi->dequant_InterUV_coeffs[i] = 
+    pbi->dequant_InterUV_coeffs[i] =
       pbi->dequant_InterUV_coeffs[i] << IDCT_SCALE_FACTOR;
   }
-  
+
   pbi->dequant_coeffs = pbi->dequant_Y_coeffs;
 }
 
-void UpdateQ( PB_INSTANCE *pbi, ogg_uint32_t NewQ ){  
+void UpdateQ( PB_INSTANCE *pbi, ogg_uint32_t NewQ ){
   ogg_uint32_t qscale;
-  
+
   /* Do bounds checking and convert to a float. */
-  qscale = NewQ; 
+  qscale = NewQ;
   if ( qscale < pbi->QThreshTable[Q_TABLE_SIZE-1] )
     qscale = pbi->QThreshTable[Q_TABLE_SIZE-1];
   else if ( qscale > pbi->QThreshTable[0] )
-    qscale = pbi->QThreshTable[0];       
-  
+    qscale = pbi->QThreshTable[0];
+
   /* Set the inter/intra descision control variables. */
   pbi->FrameQIndex = Q_TABLE_SIZE - 1;
   while ( (ogg_int32_t) pbi->FrameQIndex >= 0 ) {
-    if ( (pbi->FrameQIndex == 0) || 
-	 ( pbi->QThreshTable[pbi->FrameQIndex] >= NewQ) )
+    if ( (pbi->FrameQIndex == 0) ||
+         ( pbi->QThreshTable[pbi->FrameQIndex] >= NewQ) )
       break;
     pbi->FrameQIndex --;
   }
-  
+
   /* Re-initialise the q tables for forward and reverse transforms. */
   init_dequantizer ( pbi, qscale, (unsigned char) pbi->FrameQIndex );
 }
 
-void UpdateQC( CP_INSTANCE *cpi, ogg_uint32_t NewQ ){  
+void UpdateQC( CP_INSTANCE *cpi, ogg_uint32_t NewQ ){
   ogg_uint32_t qscale;
   PB_INSTANCE *pbi = &cpi->pb;
 
   /* Do bounds checking and convert to a float.  */
-  qscale = NewQ; 
+  qscale = NewQ;
   if ( qscale < pbi->QThreshTable[Q_TABLE_SIZE-1] )
     qscale = pbi->QThreshTable[Q_TABLE_SIZE-1];
   else if ( qscale > pbi->QThreshTable[0] )
-    qscale = pbi->QThreshTable[0];       
-  
+    qscale = pbi->QThreshTable[0];
+
   /* Set the inter/intra descision control variables. */
   pbi->FrameQIndex = Q_TABLE_SIZE - 1;
   while ((ogg_int32_t) pbi->FrameQIndex >= 0 ) {
-    if ( (pbi->FrameQIndex == 0) || 
-	 ( pbi->QThreshTable[pbi->FrameQIndex] >= NewQ) )
+    if ( (pbi->FrameQIndex == 0) ||
+         ( pbi->QThreshTable[pbi->FrameQIndex] >= NewQ) )
       break;
     pbi->FrameQIndex --;
   }
-  
+
   /* Re-initialise the q tables for forward and reverse transforms. */
   init_quantizer ( cpi, qscale, (unsigned char) pbi->FrameQIndex );
   init_dequantizer ( pbi, qscale, (unsigned char) pbi->FrameQIndex );

<p><p>1.4       +4 -6      theora/lib/quant_lookup.h

Index: quant_lookup.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/quant_lookup.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- quant_lookup.h	8 Jun 2003 00:08:38 -0000	1.3
+++ quant_lookup.h	10 Jun 2003 01:31:33 -0000	1.4
@@ -11,27 +11,25 @@
  ********************************************************************
 
   function:
-  last mod: $Id: quant_lookup.h,v 1.3 2003/06/08 00:08:38 giles Exp $
+  last mod: $Id: quant_lookup.h,v 1.4 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
 #define MIN16 ((1<<16)-1)
 #define SHIFT16 (1<<16)
 
-#define MIN_LEGAL_QUANT_ENTRY 8  
+#define MIN_LEGAL_QUANT_ENTRY 8
 #define MIN_DEQUANT_VAL       2
 #define IDCT_SCALE_FACTOR     2 /* Shift left bits to improve IDCT precision */
 #define OLD_SCHEME            1
 
-static ogg_uint32_t dequant_index[64] = {	
+static ogg_uint32_t dequant_index[64] = {
   0,  1,  8,  16,  9,  2,  3, 10,
   17, 24, 32, 25, 18, 11,  4,  5,
   12, 19, 26, 33, 40, 48, 41, 34,
   27, 20, 13,  6,  7, 14, 21, 28,
-  35, 42, 49, 56, 57, 50, 43, 36, 
+  35, 42, 49, 56, 57, 50, 43, 36,
   29, 22, 15, 23, 30, 37, 44, 51,
   58, 59, 52, 45, 38, 31, 39, 46,
   53, 60, 61, 54, 47, 55, 62, 63
 };
-
-

<p><p>1.5       +23 -23    theora/lib/reconstruct.c

Index: reconstruct.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/reconstruct.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- reconstruct.c	8 Jun 2003 00:08:38 -0000	1.4
+++ reconstruct.c	10 Jun 2003 01:31:33 -0000	1.5
@@ -10,19 +10,19 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: reconstruct.c,v 1.4 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: reconstruct.c,v 1.5 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 
-void ReconIntra( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
-		 ogg_int16_t * ChangePtr, ogg_uint32_t LineStep ) {
+void ReconIntra( PB_INSTANCE *pbi, unsigned char * ReconPtr,
+                 ogg_int16_t * ChangePtr, ogg_uint32_t LineStep ) {
   ogg_uint32_t i;
-  
-  for ( i = 0; i < BLOCK_HEIGHT_WIDTH; i++ ){	
+
+  for ( i = 0; i < BLOCK_HEIGHT_WIDTH; i++ ){
     /* Convert the data back to 8 bit unsigned */
     /* Saturate the output to unsigend 8 bit values */
     ReconPtr[0] = clamp255( ChangePtr[0] + 128 );
@@ -33,19 +33,19 @@
     ReconPtr[5] = clamp255( ChangePtr[5] + 128 );
     ReconPtr[6] = clamp255( ChangePtr[6] + 128 );
     ReconPtr[7] = clamp255( ChangePtr[7] + 128 );
-    
+
     ReconPtr += LineStep;
     ChangePtr += BLOCK_HEIGHT_WIDTH;
   }
-  
+
 }
 
-void ReconInter( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
-		 unsigned char * RefPtr, ogg_int16_t * ChangePtr, 
-		 ogg_uint32_t LineStep ) {
+void ReconInter( PB_INSTANCE *pbi, unsigned char * ReconPtr,
+                 unsigned char * RefPtr, ogg_int16_t * ChangePtr,
+                 ogg_uint32_t LineStep ) {
   ogg_uint32_t i;
-  
-  for ( i = 0; i < BLOCK_HEIGHT_WIDTH; i++) {	
+
+  for ( i = 0; i < BLOCK_HEIGHT_WIDTH; i++) {
     ReconPtr[0] = clamp255(RefPtr[0] + ChangePtr[0]);
     ReconPtr[1] = clamp255(RefPtr[1] + ChangePtr[1]);
     ReconPtr[2] = clamp255(RefPtr[2] + ChangePtr[2]);
@@ -54,20 +54,20 @@
     ReconPtr[5] = clamp255(RefPtr[5] + ChangePtr[5]);
     ReconPtr[6] = clamp255(RefPtr[6] + ChangePtr[6]);
     ReconPtr[7] = clamp255(RefPtr[7] + ChangePtr[7]);
-    
+
     ChangePtr += BLOCK_HEIGHT_WIDTH;
     ReconPtr += LineStep;
-    RefPtr += LineStep; 
+    RefPtr += LineStep;
   }
-  
+
 }
 
-void ReconInterHalfPixel2( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
-			   unsigned char * RefPtr1, unsigned char * RefPtr2, 
-			   ogg_int16_t * ChangePtr, ogg_uint32_t LineStep ) {
+void ReconInterHalfPixel2( PB_INSTANCE *pbi, unsigned char * ReconPtr,
+                           unsigned char * RefPtr1, unsigned char * RefPtr2,
+                           ogg_int16_t * ChangePtr, ogg_uint32_t LineStep ) {
   ogg_uint32_t  i;
-  
-  for ( i = 0; i < BLOCK_HEIGHT_WIDTH; i++ ){	
+
+  for ( i = 0; i < BLOCK_HEIGHT_WIDTH; i++ ){
     ReconPtr[0] = clamp255((((int)RefPtr1[0] + (int)RefPtr2[0]) >> 1) + ChangePtr[0] );
     ReconPtr[1] = clamp255((((int)RefPtr1[1] + (int)RefPtr2[1]) >> 1) + ChangePtr[1] );
     ReconPtr[2] = clamp255((((int)RefPtr1[2] + (int)RefPtr2[2]) >> 1) + ChangePtr[2] );
@@ -79,8 +79,8 @@
 
     ChangePtr += BLOCK_HEIGHT_WIDTH;
     ReconPtr += LineStep;
-    RefPtr1 += LineStep; 
-    RefPtr2 += LineStep; 
+    RefPtr1 += LineStep;
+    RefPtr2 += LineStep;
   }
 
 }

<p><p>1.7       +1215 -1214theora/lib/scan.c

Index: scan.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/scan.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- scan.c	8 Jun 2003 00:08:38 -0000	1.6
+++ scan.c	10 Jun 2003 01:31:33 -0000	1.7
@@ -10,20 +10,21 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: scan.c,v 1.6 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: scan.c,v 1.7 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
-#include <math.h>
 #include <stdlib.h>
+#include <math.h>
+#include <string.h>
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 
 #define MAX_SEARCH_LINE_LEN                   7
 
-static ogg_uint32_t LineLengthScores[ MAX_SEARCH_LINE_LEN + 1 ] = { 
-  0, 0, 0, 0, 2, 4, 12, 24 
+static ogg_uint32_t LineLengthScores[ MAX_SEARCH_LINE_LEN + 1 ] = {
+  0, 0, 0, 0, 2, 4, 12, 24
 };
 
 static ogg_uint32_t BodyNeighbourScore = 8;
@@ -52,7 +53,7 @@
 
 #define FIRST_ROW           0
 #define NOT_EDGE_ROW        1
-#define LAST_ROW            2      
+#define LAST_ROW            2
 
 #define YDIFF_CB_ROWS                   (INTERNAL_BLOCK_HEIGHT * 3)
 #define CHLOCALS_CB_ROWS                (INTERNAL_BLOCK_HEIGHT * 3)
@@ -61,44 +62,44 @@
 void ConfigurePP( PP_INSTANCE *ppi, int Level ) {
   switch ( Level ){
   case 0:
-    ppi->SRFGreyThresh = 1; 
-    ppi->SRFColThresh = 1; 
+    ppi->SRFGreyThresh = 1;
+    ppi->SRFColThresh = 1;
     ppi->NoiseSupLevel = 2;
-    ppi->SgcLevelThresh = 1; 
-    ppi->SuvcLevelThresh = 1; 
+    ppi->SgcLevelThresh = 1;
+    ppi->SuvcLevelThresh = 1;
     ppi->GrpLowSadThresh = 6;
     ppi->GrpHighSadThresh = 24;
     ppi->PrimaryBlockThreshold = 2;
     ppi->SgcThresh = 10;
-    
+
     ppi->PAKEnabled = 0;
     break;
-    
+
   case 1:
-    ppi->SRFGreyThresh = 2; 
-    ppi->SRFColThresh = 2; 
+    ppi->SRFGreyThresh = 2;
+    ppi->SRFColThresh = 2;
     ppi->NoiseSupLevel = 2;
-    ppi->SgcLevelThresh = 2; 
-    ppi->SuvcLevelThresh = 2; 
-    ppi->GrpLowSadThresh = 8; 
+    ppi->SgcLevelThresh = 2;
+    ppi->SuvcLevelThresh = 2;
+    ppi->GrpLowSadThresh = 8;
     ppi->GrpHighSadThresh = 32;
     ppi->PrimaryBlockThreshold = 5;
-    ppi->SgcThresh = 12; 
-    
+    ppi->SgcThresh = 12;
+
     ppi->PAKEnabled = 1;
     break;
-    
+
   case 2: /* Default VP3 settings */
-    ppi->SRFGreyThresh = 3; 
+    ppi->SRFGreyThresh = 3;
     ppi->SRFColThresh = 3;
     ppi->NoiseSupLevel = 2;
     ppi->SgcLevelThresh = 2;
     ppi->SuvcLevelThresh = 2;
     ppi->GrpLowSadThresh = 8;
-    ppi->GrpHighSadThresh = 32;         
+    ppi->GrpHighSadThresh = 32;
     ppi->PrimaryBlockThreshold = 5;
     ppi->SgcThresh = 16;
-    
+
     ppi->PAKEnabled = 1;
     break;
 
@@ -109,13 +110,13 @@
     ppi->SgcLevelThresh = 3;
     ppi->SuvcLevelThresh = 3;
     ppi->GrpLowSadThresh = 10;
-    ppi->GrpHighSadThresh = 48; 
+    ppi->GrpHighSadThresh = 48;
     ppi->PrimaryBlockThreshold = 5;
     ppi->SgcThresh = 18;
-    
+
     ppi->PAKEnabled = 1;
     break;
-    
+
   case 4:
     ppi->SRFGreyThresh = 5;
     ppi->SRFColThresh = 5;
@@ -126,11 +127,11 @@
     ppi->GrpHighSadThresh = 48;
     ppi->PrimaryBlockThreshold = 5;
     ppi->SgcThresh = 20;
-    
+
     ppi->PAKEnabled = 1;
     break;
 
-  case 5:                                                   
+  case 5:
     ppi->SRFGreyThresh = 6;
     ppi->SRFColThresh = 6;
     ppi->NoiseSupLevel = 3;
@@ -140,11 +141,11 @@
     ppi->GrpHighSadThresh = 64;
     ppi->PrimaryBlockThreshold = 10;
     ppi->SgcThresh = 24;
-    
+
     ppi->PAKEnabled = 1;
     break;
-    
-  case 6:                                                   
+
+  case 6:
     ppi->SRFGreyThresh = 6;
     ppi->SRFColThresh = 7;
     ppi->NoiseSupLevel = 3;
@@ -154,18 +155,18 @@
     ppi->GrpHighSadThresh = 64;
     ppi->PrimaryBlockThreshold = 10;
     ppi->SgcThresh = 24;
-    
+
     ppi->PAKEnabled = 1;
     break;
 
   default:
-    ppi->SRFGreyThresh = 3; 
+    ppi->SRFGreyThresh = 3;
     ppi->SRFColThresh = 3;
     ppi->NoiseSupLevel = 2;
     ppi->SgcLevelThresh = 2;
     ppi->SuvcLevelThresh = 2;
     ppi->GrpLowSadThresh = 10;
-    ppi->GrpHighSadThresh = 32;         
+    ppi->GrpHighSadThresh = 32;
     ppi->PrimaryBlockThreshold = 5;
     ppi->SgcThresh = 16;
     ppi->PAKEnabled = 1;
@@ -176,24 +177,24 @@
 static void ScanCalcPixelIndexTable(PP_INSTANCE *ppi){
   ogg_uint32_t i;
   ogg_uint32_t * PixelIndexTablePtr = ppi->ScanPixelIndexTable;
-    
+
   /* If appropriate add on extra inices for U and V planes. */
   for ( i = 0; i < (ppi->ScanYPlaneFragments); i++ ) {
-    PixelIndexTablePtr[ i ] = 
-      ((i / ppi->ScanHFragments) * 
-       VFRAGPIXELS * ppi->ScanConfig.VideoFrameWidth);  
-    PixelIndexTablePtr[ i ] += 
+    PixelIndexTablePtr[ i ] =
+      ((i / ppi->ScanHFragments) *
+       VFRAGPIXELS * ppi->ScanConfig.VideoFrameWidth);
+    PixelIndexTablePtr[ i ] +=
       ((i % ppi->ScanHFragments) * HFRAGPIXELS);
   }
-  
+
   PixelIndexTablePtr = &ppi->ScanPixelIndexTable[ppi->ScanYPlaneFragments];
-  
+
   for ( i = 0; i < (ppi->ScanUVPlaneFragments * 2); i++ ){
-    PixelIndexTablePtr[ i ] =  
-      ((i / (ppi->ScanHFragments >> 1) ) * 
-       (VFRAGPIXELS * (ppi->ScanConfig.VideoFrameWidth >> 1)) );   
-    PixelIndexTablePtr[ i ] += 
-      ((i % (ppi->ScanHFragments >> 1) ) * 
+    PixelIndexTablePtr[ i ] =
+      ((i / (ppi->ScanHFragments >> 1) ) *
+       (VFRAGPIXELS * (ppi->ScanConfig.VideoFrameWidth >> 1)) );
+    PixelIndexTablePtr[ i ] +=
+      ((i % (ppi->ScanHFragments >> 1) ) *
        HFRAGPIXELS) + ppi->YFramePixels;
     }
 }
@@ -201,17 +202,17 @@
 static void InitScanMapArrays(PP_INSTANCE *ppi){
   int i;
   unsigned char StepThresh;
-  
+
   /* Clear down the fragment level map arrays for the current frame. */
-  memset( ppi->FragScores, 0, 
-	  ppi->ScanFrameFragments * sizeof(*ppi->FragScores) );
-  memset( ppi->SameGreyDirPixels, 0, 
-	  ppi->ScanFrameFragments );
-  memset( ppi->FragDiffPixels, 0, 
-	  ppi->ScanFrameFragments );
-  memset( ppi->RowChangedPixels, 0, 
-	  3* ppi->ScanConfig.VideoFrameHeight*sizeof(*ppi->RowChangedPixels));
-  
+  memset( ppi->FragScores, 0,
+          ppi->ScanFrameFragments * sizeof(*ppi->FragScores) );
+  memset( ppi->SameGreyDirPixels, 0,
+          ppi->ScanFrameFragments );
+  memset( ppi->FragDiffPixels, 0,
+          ppi->ScanFrameFragments );
+  memset( ppi->RowChangedPixels, 0,
+          3* ppi->ScanConfig.VideoFrameHeight*sizeof(*ppi->RowChangedPixels));
+
   memset( ppi->ScanDisplayFragments, BLOCK_NOT_CODED, ppi->ScanFrameFragments);
 
   /* Threshold used in setting up ppi->NoiseScoreBoostTable[] */
@@ -241,11 +242,11 @@
       ppi->NoiseScoreBoostTable[i] = 2;
     else
       ppi->NoiseScoreBoostTable[i] = 3;
-    
+
   }
-  
+
   /* Set various other threshold parameters. */
-  
+
   /* Set variables that control access to the line search algorithms. */
   ppi->LineSearchTripTresh = 16;
   if ( ppi->LineSearchTripTresh > ppi->PrimaryBlockThreshold )
@@ -253,14 +254,14 @@
 
   /* Adjust line search length if block threshold low */
   ppi->MaxLineSearchLen = MAX_SEARCH_LINE_LEN;
-  while ( (ppi->MaxLineSearchLen > 0) && 
-	  (LineLengthScores[ppi->MaxLineSearchLen-1] > 
-	   ppi->PrimaryBlockThreshold) )
+  while ( (ppi->MaxLineSearchLen > 0) &&
+          (LineLengthScores[ppi->MaxLineSearchLen-1] >
+           ppi->PrimaryBlockThreshold) )
     ppi->MaxLineSearchLen -= 1;
 
 }
 
-void ScanYUVInit( PP_INSTANCE *  ppi, SCAN_CONFIG_DATA * ScanConfigPtr){  
+void ScanYUVInit( PP_INSTANCE *  ppi, SCAN_CONFIG_DATA * ScanConfigPtr){
   int i;
 
   /* Set up the various imported data structure pointers. */
@@ -268,94 +269,94 @@
   ppi->ScanConfig.Yuv1ptr = ScanConfigPtr->Yuv1ptr;
   ppi->ScanConfig.SrfWorkSpcPtr = ScanConfigPtr->SrfWorkSpcPtr;
   ppi->ScanConfig.disp_fragments = ScanConfigPtr->disp_fragments;
-  
+
   ppi->ScanConfig.RegionIndex = ScanConfigPtr->RegionIndex;
-  
+
   ppi->ScanConfig.VideoFrameWidth = ScanConfigPtr->VideoFrameWidth;
   ppi->ScanConfig.VideoFrameHeight = ScanConfigPtr->VideoFrameHeight;
-  
+
   /* UV plane sizes. */
   ppi->VideoUVPlaneWidth = ScanConfigPtr->VideoFrameWidth / 2;
   ppi->VideoUVPlaneHeight = ScanConfigPtr->VideoFrameHeight / 2;
-  
+
   /* Note the size of the entire frame and plaes in pixels. */
-  ppi->YFramePixels = ppi->ScanConfig.VideoFrameWidth * 
+  ppi->YFramePixels = ppi->ScanConfig.VideoFrameWidth *
     ppi->ScanConfig.VideoFrameHeight;
   ppi->UVFramePixels = ppi->VideoUVPlaneWidth * ppi->VideoUVPlaneHeight;
 
   /* Work out various fragment related values. */
-  ppi->ScanYPlaneFragments = ppi->YFramePixels / 
+  ppi->ScanYPlaneFragments = ppi->YFramePixels /
     (HFRAGPIXELS * VFRAGPIXELS);
-  ppi->ScanUVPlaneFragments = ppi->UVFramePixels / 
+  ppi->ScanUVPlaneFragments = ppi->UVFramePixels /
     (HFRAGPIXELS * VFRAGPIXELS);;
   ppi->ScanHFragments = ppi->ScanConfig.VideoFrameWidth / HFRAGPIXELS;
   ppi->ScanVFragments = ppi->ScanConfig.VideoFrameHeight / VFRAGPIXELS;
-  ppi->ScanFrameFragments = ppi->ScanYPlaneFragments + 
+  ppi->ScanFrameFragments = ppi->ScanYPlaneFragments +
     (2 * ppi->ScanUVPlaneFragments);
 
   PInitFrameInfo(ppi);
-  
+
   /* Set up the scan pixel index table. */
   ScanCalcPixelIndexTable(ppi);
-  
+
   /* Initialise the previous frame block history lists */
   for ( i = 0; i < MAX_PREV_FRAMES; i++ )
     memset( ppi->PrevFragments[i], BLOCK_NOT_CODED, ppi->ScanFrameFragments);
-  
+
   /* YUVAnalyseFrame() is not called for the first frame in a sequence
      (a key frame obviously).  This memset insures that for the second
      frame all blocks are marked for coding in line with the behaviour
      for other key frames. */
-  memset( ppi->PrevFragments[ppi->PrevFrameLimit-1], 
-	  BLOCK_CODED, ppi->ScanFrameFragments );
+  memset( ppi->PrevFragments[ppi->PrevFrameLimit-1],
+          BLOCK_CODED, ppi->ScanFrameFragments );
 
   /* Initialise scan arrays */
   InitScanMapArrays(ppi);
 }
 
-static void SetFromPrevious(PP_INSTANCE *ppi) { 
+static void SetFromPrevious(PP_INSTANCE *ppi) {
   unsigned int  i,j;
-  
+
   /* We buld up the list of previously updated blocks in the zero
      index list of PrevFragments[] so we must start by reseting its
      contents */
   memset( ppi->PrevFragments[0], BLOCK_NOT_CODED, ppi->ScanFrameFragments );
-  
+
   if ( ppi->PrevFrameLimit > 1 ){
     /* Now build up PrevFragments[0] from PrevFragments[1 to PrevFrameLimit] */
     for ( i = 0; i < ppi->ScanFrameFragments; i++ ){
       for ( j = 1; j < ppi->PrevFrameLimit; j++ ){
-	if ( ppi->PrevFragments[j][i] > BLOCK_CODED_BAR ){
-	  ppi->PrevFragments[0][i] = BLOCK_CODED;
-	  break;
-	}
+        if ( ppi->PrevFragments[j][i] > BLOCK_CODED_BAR ){
+          ppi->PrevFragments[0][i] = BLOCK_CODED;
+          break;
+        }
       }
     }
   }
 }
 
-static void UpdatePreviousBlockLists(PP_INSTANCE *ppi) { 
+static void UpdatePreviousBlockLists(PP_INSTANCE *ppi) {
   int  i;
 
   /* Shift previous frame block lists along. */
   for ( i = ppi->PrevFrameLimit; i > 1; i-- ){
-    memcpy( ppi->PrevFragments[i], ppi->PrevFragments[i-1], 
-	    ppi->ScanFrameFragments );
+    memcpy( ppi->PrevFragments[i], ppi->PrevFragments[i-1],
+            ppi->ScanFrameFragments );
   }
 
   /* Now copy in this frames block list */
-  memcpy( ppi->PrevFragments[1], ppi->ScanDisplayFragments, 
-	  ppi->ScanFrameFragments );
+  memcpy( ppi->PrevFragments[1], ppi->ScanDisplayFragments,
+          ppi->ScanFrameFragments );
 }
 
 static void CreateOutputDisplayMap( PP_INSTANCE *ppi,
-				    char *InternalFragmentsPtr, 
-				    char *RecentHistoryPtr,
-				    unsigned char *ExternalFragmentsPtr ) { 
+                                    char *InternalFragmentsPtr,
+                                    char *RecentHistoryPtr,
+                                    unsigned char *ExternalFragmentsPtr ) {
   ogg_uint32_t i;
   ogg_uint32_t HistoryBlocksAdded = 0;
   ogg_uint32_t YBand =  (ppi->ScanYPlaneFragments/8);   /* 1/8th of Y image. */
-  
+
   ppi->OutputBlocksUpdated = 0;
   for ( i = 0; i < ppi->ScanFrameFragments; i++ ) {
     if ( InternalFragmentsPtr[i] > BLOCK_NOT_CODED ) {
@@ -384,30 +385,30 @@
   ppi->KFIndicator = ((ppi->KFIndicator*100)/((ppi->ScanYPlaneFragments*3)/4));
 }
 
-static ogg_uint32_t ScalarRowSAD( unsigned char * Src1, 
-				  unsigned char * Src2 ){
+static ogg_uint32_t ScalarRowSAD( unsigned char * Src1,
+                                  unsigned char * Src2 ){
   ogg_uint32_t SadValue;
   ogg_uint32_t SadValue1;
-  
-  SadValue    = abs( Src1[0] - Src2[0] ) + abs( Src1[1] - Src2[1] ) + 
+
+  SadValue    = abs( Src1[0] - Src2[0] ) + abs( Src1[1] - Src2[1] ) +
     abs( Src1[2] - Src2[2] ) + abs( Src1[3] - Src2[3] );
-  
-  SadValue1   = abs( Src1[4] - Src2[4] ) + abs( Src1[5] - Src2[5] ) + 
+
+  SadValue1   = abs( Src1[4] - Src2[4] ) + abs( Src1[5] - Src2[5] ) +
     abs( Src1[6] - Src2[6] ) + abs( Src1[7] - Src2[7] );
-  
+
   SadValue = ( SadValue > SadValue1 ) ? SadValue : SadValue1;
-  
+
   return SadValue;
 }
 
-static ogg_uint32_t ScalarColSAD( PP_INSTANCE *ppi, 
-			   unsigned char * Src1, 
-			   unsigned char * Src2 ){
+static ogg_uint32_t ScalarColSAD( PP_INSTANCE *ppi,
+                           unsigned char * Src1,
+                           unsigned char * Src2 ){
   ogg_uint32_t SadValue[8] = {0,0,0,0,0,0,0,0};
   ogg_uint32_t SadValue2[8] = {0,0,0,0,0,0,0,0};
   ogg_uint32_t MaxSad = 0;
   ogg_uint32_t i;
-  
+
   for ( i = 0; i < 4; i++ ){
     SadValue[0] += abs(Src1[0] - Src2[0]);
     SadValue[1] += abs(Src1[1] - Src2[1]);
@@ -417,11 +418,11 @@
     SadValue[5] += abs(Src1[5] - Src2[5]);
     SadValue[6] += abs(Src1[6] - Src2[6]);
     SadValue[7] += abs(Src1[7] - Src2[7]);
-    
+
     Src1 += ppi->PlaneStride;
     Src2 += ppi->PlaneStride;
   }
-  
+
   for ( i = 0; i < 4; i++ ){
     SadValue2[0] += abs(Src1[0] - Src2[0]);
     SadValue2[1] += abs(Src1[1] - Src2[1]);
@@ -431,26 +432,26 @@
     SadValue2[5] += abs(Src1[5] - Src2[5]);
     SadValue2[6] += abs(Src1[6] - Src2[6]);
     SadValue2[7] += abs(Src1[7] - Src2[7]);
-    
+
     Src1 += ppi->PlaneStride;
     Src2 += ppi->PlaneStride;
   }
-  
+
   for ( i = 0; i < 8; i++ ){
     if ( SadValue[i] > MaxSad )
       MaxSad = SadValue[i];
     if ( SadValue2[i] > MaxSad )
       MaxSad = SadValue2[i];
   }
-  
+
   return MaxSad;
 }
 
 
-static int RowSadScan( PP_INSTANCE *ppi, 
-		       unsigned char * YuvPtr1, 
-		       unsigned char * YuvPtr2, 
-		       signed char *  DispFragPtr){
+static int RowSadScan( PP_INSTANCE *ppi,
+                       unsigned char * YuvPtr1,
+                       unsigned char * YuvPtr2,
+                       signed char *  DispFragPtr){
   ogg_int32_t    i, j;
   ogg_uint32_t   GrpSad;
   ogg_uint32_t   LocalGrpLowSadThresh = ppi->ModifiedGrpLowSadThresh;
@@ -458,64 +459,64 @@
   signed char   *LocalDispFragPtr;
   unsigned char *LocalYuvPtr1;
   unsigned char *LocalYuvPtr2;
-  
+
   int           InterestingBlocksInRow = 0;
 
   /* For each row of pixels in the row of blocks */
   for ( j = 0; j < VFRAGPIXELS; j++ ){
     /* Set local block map pointer. */
     LocalDispFragPtr = DispFragPtr;
-    
+
     /* Set the local pixel data pointers for this row.*/
     LocalYuvPtr1 = YuvPtr1;
     LocalYuvPtr2 = YuvPtr2;
-    
+
     /* Scan along the row of pixels If the block to which a group of
        pixels belongs is already marked for update then do nothing. */
     for ( i = 0; i < ppi->PlaneHFragments; i ++ ){
       if ( *LocalDispFragPtr <= BLOCK_NOT_CODED ){
-	/* Calculate the SAD score for the block row */
-	GrpSad = ScalarRowSAD(LocalYuvPtr1,LocalYuvPtr2);
+        /* Calculate the SAD score for the block row */
+        GrpSad = ScalarRowSAD(LocalYuvPtr1,LocalYuvPtr2);
 
-	/* Now test the group SAD score */
-	if ( GrpSad > LocalGrpLowSadThresh ){
-	  /* If SAD very high we must update else we have candidate block */
-	  if ( GrpSad > LocalGrpHighSadThresh ){
-	    /* Force update */
-	    *LocalDispFragPtr = BLOCK_CODED;
-	  }else{
-	    /* Possible Update required */
-	    *LocalDispFragPtr = CANDIDATE_BLOCK;
-	  }
-	  InterestingBlocksInRow = 1;
-	}
+        /* Now test the group SAD score */
+        if ( GrpSad > LocalGrpLowSadThresh ){
+          /* If SAD very high we must update else we have candidate block */
+          if ( GrpSad > LocalGrpHighSadThresh ){
+            /* Force update */
+            *LocalDispFragPtr = BLOCK_CODED;
+          }else{
+            /* Possible Update required */
+            *LocalDispFragPtr = CANDIDATE_BLOCK;
+          }
+          InterestingBlocksInRow = 1;
+        }
       }
       LocalDispFragPtr++;
-      
+
       LocalYuvPtr1 += 8;
       LocalYuvPtr2 += 8;
     }
-    
+
     /* Increment the base data pointers to the start of the next line. */
     YuvPtr1 += ppi->PlaneStride;
     YuvPtr2 += ppi->PlaneStride;
   }
-  
+
   return InterestingBlocksInRow;
 
 }
 
-static int ColSadScan( PP_INSTANCE *ppi, 
-		       unsigned char * YuvPtr1, 
-		       unsigned char * YuvPtr2, 
-		       signed char *  DispFragPtr ){
+static int ColSadScan( PP_INSTANCE *ppi,
+                       unsigned char * YuvPtr1,
+                       unsigned char * YuvPtr2,
+                       signed char *  DispFragPtr ){
   ogg_int32_t     i;
   ogg_uint32_t    MaxSad;
   ogg_uint32_t    LocalGrpLowSadThresh = ppi->ModifiedGrpLowSadThresh;
   ogg_uint32_t    LocalGrpHighSadThresh = ppi->ModifiedGrpHighSadThresh;
   signed char   * LocalDispFragPtr;
-  
-  unsigned char * LocalYuvPtr1;          
+
+  unsigned char * LocalYuvPtr1;
   unsigned char * LocalYuvPtr2;
 
   int     InterestingBlocksInRow = 0;
@@ -523,10 +524,10 @@
   /* Set the local pixel data pointers for this row. */
   LocalYuvPtr1 = YuvPtr1;
   LocalYuvPtr2 = YuvPtr2;
-  
+
   /* Set local block map pointer. */
   LocalDispFragPtr = DispFragPtr;
-  
+
   /* Scan along the row of blocks */
   for ( i = 0; i < ppi->PlaneHFragments; i ++ ){
     /* Skip if block already marked to be coded. */
@@ -536,21 +537,21 @@
 
       /* Now test the group SAD score */
       if ( MaxSad > LocalGrpLowSadThresh ){
-	/* If SAD very high we must update else we have candidate block */
-	if ( MaxSad > LocalGrpHighSadThresh ){
-	  /* Force update */
-	  *LocalDispFragPtr = BLOCK_CODED;
-	}else{
-	  /* Possible Update required */
-	  *LocalDispFragPtr = CANDIDATE_BLOCK;
-	}
-	InterestingBlocksInRow = 1;
+        /* If SAD very high we must update else we have candidate block */
+        if ( MaxSad > LocalGrpHighSadThresh ){
+          /* Force update */
+          *LocalDispFragPtr = BLOCK_CODED;
+        }else{
+          /* Possible Update required */
+          *LocalDispFragPtr = CANDIDATE_BLOCK;
+        }
+        InterestingBlocksInRow = 1;
       }
     }
-    
+
     /* Increment the block map pointer. */
-    LocalDispFragPtr++;                     
-    
+    LocalDispFragPtr++;
+
     /* Step data pointers on ready for next block */
     LocalYuvPtr1 += HFRAGPIXELS;
     LocalYuvPtr2 += HFRAGPIXELS;
@@ -559,52 +560,52 @@
   return InterestingBlocksInRow;
 }
 
-static void SadPass2( PP_INSTANCE *ppi, 
-		      ogg_int32_t RowNumber, 
-		      signed char *  DispFragPtr ){
+static void SadPass2( PP_INSTANCE *ppi,
+                      ogg_int32_t RowNumber,
+                      signed char *  DispFragPtr ){
   ogg_int32_t  i;
-  
+
   /* First row */
   if ( RowNumber == 0 ) {
     /* First block in row. */
     if ( DispFragPtr[0] == CANDIDATE_BLOCK ){
       if ( (DispFragPtr[1] == BLOCK_CODED) ||
-	   (DispFragPtr[ppi->PlaneHFragments] == BLOCK_CODED) ||
-	   (DispFragPtr[ppi->PlaneHFragments+1] == BLOCK_CODED) ){
-	ppi->TmpCodedMap[0] =  BLOCK_CODED_LOW;
+           (DispFragPtr[ppi->PlaneHFragments] == BLOCK_CODED) ||
+           (DispFragPtr[ppi->PlaneHFragments+1] == BLOCK_CODED) ){
+        ppi->TmpCodedMap[0] =  BLOCK_CODED_LOW;
       }else{
-	ppi->TmpCodedMap[0] = DispFragPtr[0];
+        ppi->TmpCodedMap[0] = DispFragPtr[0];
       }
     }else{
       ppi->TmpCodedMap[0] = DispFragPtr[0];
     }
-    
+
     /* All but first and last in row */
     for ( i = 1; (i < ppi->PlaneHFragments-1); i++ ){
       if ( DispFragPtr[i] == CANDIDATE_BLOCK ){
-	if ( (DispFragPtr[i-1] == BLOCK_CODED) || 
-	     (DispFragPtr[i+1] == BLOCK_CODED) ||
-	     (DispFragPtr[i+ppi->PlaneHFragments] == BLOCK_CODED) ||
-	     (DispFragPtr[i+ppi->PlaneHFragments-1] == BLOCK_CODED) ||
-	     (DispFragPtr[i+ppi->PlaneHFragments+1] == BLOCK_CODED) ){
-	  ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
-	}else{
-	  ppi->TmpCodedMap[i] = DispFragPtr[i];
-	}
+        if ( (DispFragPtr[i-1] == BLOCK_CODED) ||
+             (DispFragPtr[i+1] == BLOCK_CODED) ||
+             (DispFragPtr[i+ppi->PlaneHFragments] == BLOCK_CODED) ||
+             (DispFragPtr[i+ppi->PlaneHFragments-1] == BLOCK_CODED) ||
+             (DispFragPtr[i+ppi->PlaneHFragments+1] == BLOCK_CODED) ){
+          ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
+        }else{
+          ppi->TmpCodedMap[i] = DispFragPtr[i];
+        }
       }else{
-	ppi->TmpCodedMap[i] = DispFragPtr[i];
+        ppi->TmpCodedMap[i] = DispFragPtr[i];
       }
     }
-    
+
     /* Last block in row. */
     i = ppi->PlaneHFragments-1;
     if ( DispFragPtr[i] == CANDIDATE_BLOCK ){
-      if ( (DispFragPtr[i-1] == BLOCK_CODED) || 
-	   (DispFragPtr[i+ppi->PlaneHFragments] == BLOCK_CODED) ||
-	   (DispFragPtr[i+ppi->PlaneHFragments-1] == BLOCK_CODED) ){
-	ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
+      if ( (DispFragPtr[i-1] == BLOCK_CODED) ||
+           (DispFragPtr[i+ppi->PlaneHFragments] == BLOCK_CODED) ||
+           (DispFragPtr[i+ppi->PlaneHFragments-1] == BLOCK_CODED) ){
+        ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
       }else{
-	ppi->TmpCodedMap[i] = DispFragPtr[i];
+        ppi->TmpCodedMap[i] = DispFragPtr[i];
       }
     }else{
       ppi->TmpCodedMap[i] = DispFragPtr[i];
@@ -614,49 +615,49 @@
     /* First block in row. */
     if ( DispFragPtr[0] == CANDIDATE_BLOCK ){
       if ( (DispFragPtr[1] == BLOCK_CODED) ||
-	   (DispFragPtr[(-ppi->PlaneHFragments)] == BLOCK_CODED) ||
-	   (DispFragPtr[(-ppi->PlaneHFragments)+1] == BLOCK_CODED) ||
-	   (DispFragPtr[ppi->PlaneHFragments] == BLOCK_CODED) ||
-	   (DispFragPtr[ppi->PlaneHFragments+1] == BLOCK_CODED) ){
-	ppi->TmpCodedMap[0] =  BLOCK_CODED_LOW;
+           (DispFragPtr[(-ppi->PlaneHFragments)] == BLOCK_CODED) ||
+           (DispFragPtr[(-ppi->PlaneHFragments)+1] == BLOCK_CODED) ||
+           (DispFragPtr[ppi->PlaneHFragments] == BLOCK_CODED) ||
+           (DispFragPtr[ppi->PlaneHFragments+1] == BLOCK_CODED) ){
+        ppi->TmpCodedMap[0] =  BLOCK_CODED_LOW;
       }else{
-	ppi->TmpCodedMap[0] = DispFragPtr[0];
+        ppi->TmpCodedMap[0] = DispFragPtr[0];
       }
     }else{
       ppi->TmpCodedMap[0] = DispFragPtr[0];
     }
-    
+
     /* All but first and last in row */
     for ( i = 1; (i < ppi->PlaneHFragments-1); i++ ){
       if ( DispFragPtr[i] == CANDIDATE_BLOCK ){
-	if ( (DispFragPtr[i-1] == BLOCK_CODED) || 
-	     (DispFragPtr[i+1] == BLOCK_CODED) ||
-	     (DispFragPtr[i-ppi->PlaneHFragments] == BLOCK_CODED) ||
-	     (DispFragPtr[i-ppi->PlaneHFragments-1] == BLOCK_CODED) ||
-	     (DispFragPtr[i-ppi->PlaneHFragments+1] == BLOCK_CODED) ||
-	     (DispFragPtr[i+ppi->PlaneHFragments] == BLOCK_CODED) ||
-	     (DispFragPtr[i+ppi->PlaneHFragments-1] == BLOCK_CODED) ||
-	     (DispFragPtr[i+ppi->PlaneHFragments+1] == BLOCK_CODED) ){
-	  ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
-	}else{
-	  ppi->TmpCodedMap[i] = DispFragPtr[i];
-	}
+        if ( (DispFragPtr[i-1] == BLOCK_CODED) ||
+             (DispFragPtr[i+1] == BLOCK_CODED) ||
+             (DispFragPtr[i-ppi->PlaneHFragments] == BLOCK_CODED) ||
+             (DispFragPtr[i-ppi->PlaneHFragments-1] == BLOCK_CODED) ||
+             (DispFragPtr[i-ppi->PlaneHFragments+1] == BLOCK_CODED) ||
+             (DispFragPtr[i+ppi->PlaneHFragments] == BLOCK_CODED) ||
+             (DispFragPtr[i+ppi->PlaneHFragments-1] == BLOCK_CODED) ||
+             (DispFragPtr[i+ppi->PlaneHFragments+1] == BLOCK_CODED) ){
+          ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
+        }else{
+          ppi->TmpCodedMap[i] = DispFragPtr[i];
+        }
       }else{
-	ppi->TmpCodedMap[i] = DispFragPtr[i];
+        ppi->TmpCodedMap[i] = DispFragPtr[i];
       }
     }
-    
+
     /* Last block in row. */
     i = ppi->PlaneHFragments-1;
     if ( DispFragPtr[i] == CANDIDATE_BLOCK ){
-      if ( (DispFragPtr[i-1] == BLOCK_CODED) || 
-	   (DispFragPtr[i-ppi->PlaneHFragments] == BLOCK_CODED) ||
-	   (DispFragPtr[i-ppi->PlaneHFragments-1] == BLOCK_CODED) ||
-	   (DispFragPtr[i+ppi->PlaneHFragments] == BLOCK_CODED) ||
-	   (DispFragPtr[i+ppi->PlaneHFragments-1] == BLOCK_CODED) ){
-	ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
+      if ( (DispFragPtr[i-1] == BLOCK_CODED) ||
+           (DispFragPtr[i-ppi->PlaneHFragments] == BLOCK_CODED) ||
+           (DispFragPtr[i-ppi->PlaneHFragments-1] == BLOCK_CODED) ||
+           (DispFragPtr[i+ppi->PlaneHFragments] == BLOCK_CODED) ||
+           (DispFragPtr[i+ppi->PlaneHFragments-1] == BLOCK_CODED) ){
+        ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
       }else{
-	ppi->TmpCodedMap[i] = DispFragPtr[i];
+        ppi->TmpCodedMap[i] = DispFragPtr[i];
       }
     }else{
       ppi->TmpCodedMap[i] = DispFragPtr[i];
@@ -666,54 +667,54 @@
     /* First block in row. */
     if ( DispFragPtr[0] == CANDIDATE_BLOCK ){
       if ( (DispFragPtr[1] == BLOCK_CODED) ||
-	   (DispFragPtr[(-ppi->PlaneHFragments)] == BLOCK_CODED) ||
-	   (DispFragPtr[(-ppi->PlaneHFragments)+1] == BLOCK_CODED)){
-	ppi->TmpCodedMap[0] =  BLOCK_CODED_LOW;
+           (DispFragPtr[(-ppi->PlaneHFragments)] == BLOCK_CODED) ||
+           (DispFragPtr[(-ppi->PlaneHFragments)+1] == BLOCK_CODED)){
+        ppi->TmpCodedMap[0] =  BLOCK_CODED_LOW;
       }else{
-	ppi->TmpCodedMap[0] = DispFragPtr[0];
+        ppi->TmpCodedMap[0] = DispFragPtr[0];
       }
     }else{
       ppi->TmpCodedMap[0] = DispFragPtr[0];
     }
-    
+
     /* All but first and last in row */
     for ( i = 1; (i < ppi->PlaneHFragments-1); i++ ){
       if ( DispFragPtr[i] == CANDIDATE_BLOCK ){
-	if ( (DispFragPtr[i-1] == BLOCK_CODED) || 
-	     (DispFragPtr[i+1] == BLOCK_CODED) ||
-	     (DispFragPtr[i-ppi->PlaneHFragments] == BLOCK_CODED) ||
-	     (DispFragPtr[i-ppi->PlaneHFragments-1] == BLOCK_CODED) ||
-	     (DispFragPtr[i-ppi->PlaneHFragments+1] == BLOCK_CODED) ){
-	  ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
-	}else{
-	  ppi->TmpCodedMap[i] = DispFragPtr[i];
-	}
+        if ( (DispFragPtr[i-1] == BLOCK_CODED) ||
+             (DispFragPtr[i+1] == BLOCK_CODED) ||
+             (DispFragPtr[i-ppi->PlaneHFragments] == BLOCK_CODED) ||
+             (DispFragPtr[i-ppi->PlaneHFragments-1] == BLOCK_CODED) ||
+             (DispFragPtr[i-ppi->PlaneHFragments+1] == BLOCK_CODED) ){
+          ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
+        }else{
+          ppi->TmpCodedMap[i] = DispFragPtr[i];
+        }
       }else{
-	ppi->TmpCodedMap[i] = DispFragPtr[i];
+        ppi->TmpCodedMap[i] = DispFragPtr[i];
       }
     }
-    
+
     /* Last block in row. */
     i = ppi->PlaneHFragments-1;
     if ( DispFragPtr[i] == CANDIDATE_BLOCK ){
-      if ( (DispFragPtr[i-1] == BLOCK_CODED) || 
-	   (DispFragPtr[i-ppi->PlaneHFragments] == BLOCK_CODED) ||
-	   (DispFragPtr[i-ppi->PlaneHFragments-1] == BLOCK_CODED) ){
-	ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
+      if ( (DispFragPtr[i-1] == BLOCK_CODED) ||
+           (DispFragPtr[i-ppi->PlaneHFragments] == BLOCK_CODED) ||
+           (DispFragPtr[i-ppi->PlaneHFragments-1] == BLOCK_CODED) ){
+        ppi->TmpCodedMap[i] =  BLOCK_CODED_LOW;
       }else{
-	ppi->TmpCodedMap[i] = DispFragPtr[i];
+        ppi->TmpCodedMap[i] = DispFragPtr[i];
       }
     }else{
       ppi->TmpCodedMap[i] = DispFragPtr[i];
     }
   }
-  
+
   /* Now copy back the modified Fragment data */
-  memcpy( &DispFragPtr[0], &ppi->TmpCodedMap[0], (ppi->PlaneHFragments) ); 
+  memcpy( &DispFragPtr[0], &ppi->TmpCodedMap[0], (ppi->PlaneHFragments) );
 }
 
-static unsigned char ApplyPakLowPass( PP_INSTANCE *ppi, 
-				      unsigned char * SrcPtr ){
+static unsigned char ApplyPakLowPass( PP_INSTANCE *ppi,
+                                      unsigned char * SrcPtr ){
   unsigned char * SrcPtr1 = SrcPtr - 1;
   unsigned char * SrcPtr0 = SrcPtr1 - ppi->PlaneStride; /* Note the
                                                            use of
@@ -721,72 +722,72 @@
                                                            width. */
   unsigned char * SrcPtr2 = SrcPtr1 + ppi->PlaneStride;
 
-  return  ( ( (ogg_uint32_t)SrcPtr0[0] + 
-	      (ogg_uint32_t)SrcPtr0[1] + 
-	      (ogg_uint32_t)SrcPtr0[2] +
-	      (ogg_uint32_t)SrcPtr1[0] + 
-	      (ogg_uint32_t)SrcPtr1[2] +
-	      (ogg_uint32_t)SrcPtr2[0] + 
-	      (ogg_uint32_t)SrcPtr2[1] + 
-	      (ogg_uint32_t)SrcPtr2[2]   ) >> 3 );
-  
-}
-
-static void RowDiffScan( PP_INSTANCE *ppi, 
-			 unsigned char * YuvPtr1, 
-			 unsigned char * YuvPtr2, 
-			 ogg_int16_t   * YUVDiffsPtr, 
-			 unsigned char * bits_map_ptr, 
-			 signed char   * SgcPtr, 
-			 signed char   * DispFragPtr, 
-			 unsigned char * FDiffPixels, 
-			 ogg_int32_t   * RowDiffsPtr, 
-			 unsigned char * ChLocalsPtr, int EdgeRow ){
+  return  (unsigned char)( ( (ogg_uint32_t)SrcPtr0[0] +
+              (ogg_uint32_t)SrcPtr0[1] +
+              (ogg_uint32_t)SrcPtr0[2] +
+              (ogg_uint32_t)SrcPtr1[0] +
+              (ogg_uint32_t)SrcPtr1[2] +
+              (ogg_uint32_t)SrcPtr2[0] +
+              (ogg_uint32_t)SrcPtr2[1] +
+              (ogg_uint32_t)SrcPtr2[2]   ) >> 3 );
+
+}
+
+static void RowDiffScan( PP_INSTANCE *ppi,
+                         unsigned char * YuvPtr1,
+                         unsigned char * YuvPtr2,
+                         ogg_int16_t   * YUVDiffsPtr,
+                         unsigned char * bits_map_ptr,
+                         signed char   * SgcPtr,
+                         signed char   * DispFragPtr,
+                         unsigned char * FDiffPixels,
+                         ogg_int32_t   * RowDiffsPtr,
+                         unsigned char * ChLocalsPtr, int EdgeRow ){
 
   ogg_int32_t    i,j;
   ogg_int32_t    FragChangedPixels;
-  
+
   ogg_int16_t Diff;     /* Temp local workspace. */
-  
+
   /* Cannot use kernel if at edge or if PAK disabled */
   if ( (!ppi->PAKEnabled) || EdgeRow ){
     for ( i = 0; i < ppi->PlaneWidth; i += HFRAGPIXELS ){
       /* Reset count of pixels changed for the current fragment. */
       FragChangedPixels = 0;
-      
+
       /* Test for break out conditions to save time. */
       if (*DispFragPtr == CANDIDATE_BLOCK){
 
-	/* Clear down entries in changed locals array */
-	memset(ChLocalsPtr,0,8);
-	
-	for ( j = 0; j < HFRAGPIXELS; j++ ){
-	  /* Take a local copy of the measured difference. */
-	  Diff = (int)YuvPtr1[j] - (int)YuvPtr2[j];
-
-	  /* Store the actual difference value */
-	  YUVDiffsPtr[j] = Diff;
-
-	  /* Test against the Level thresholds and record the results */
-	  SgcPtr[0] += ppi->SgcThreshTable[Diff+255];
-
-	  /* Test against the SRF thresholds */
-	  bits_map_ptr[j] = ppi->SrfThreshTable[Diff+255];
-	  FragChangedPixels += ppi->SrfThreshTable[Diff+255];
-	}
+        /* Clear down entries in changed locals array */
+        memset(ChLocalsPtr,0,8);
+
+        for ( j = 0; j < HFRAGPIXELS; j++ ){
+          /* Take a local copy of the measured difference. */
+          Diff = (int)YuvPtr1[j] - (int)YuvPtr2[j];
+
+          /* Store the actual difference value */
+          YUVDiffsPtr[j] = Diff;
+
+          /* Test against the Level thresholds and record the results */
+          SgcPtr[0] += ppi->SgcThreshTable[Diff+255];
+
+          /* Test against the SRF thresholds */
+          bits_map_ptr[j] = ppi->SrfThreshTable[Diff+255];
+          FragChangedPixels += ppi->SrfThreshTable[Diff+255];
+        }
       }else{
-	/* If we are breaking out here mark all pixels as changed. */
-	if ( *DispFragPtr > BLOCK_NOT_CODED ){
-	  memset(bits_map_ptr,1,8);
-	  memset(ChLocalsPtr,8,8);
-	}else{
-	  memset(ChLocalsPtr,0,8);
-	}
+        /* If we are breaking out here mark all pixels as changed. */
+        if ( *DispFragPtr > BLOCK_NOT_CODED ){
+          memset(bits_map_ptr,1,8);
+          memset(ChLocalsPtr,8,8);
+        }else{
+          memset(ChLocalsPtr,0,8);
+        }
       }
 
       *RowDiffsPtr += FragChangedPixels;
       *FDiffPixels += (unsigned char)FragChangedPixels;
-      
+
       YuvPtr1 += HFRAGPIXELS;
       YuvPtr2 += HFRAGPIXELS;
       bits_map_ptr += HFRAGPIXELS;
@@ -794,61 +795,61 @@
       YUVDiffsPtr += HFRAGPIXELS;
       SgcPtr ++;
       FDiffPixels ++;
-      
+
       /* If we have a lot of changed pixels for this fragment on this
-	 row then the fragment is almost sure to be picked (e.g. through
-	 the line search) so we can mark it as selected and then ignore
-	 it. */
+         row then the fragment is almost sure to be picked (e.g. through
+         the line search) so we can mark it as selected and then ignore
+         it. */
       if (FragChangedPixels >= 7){
-	*DispFragPtr = BLOCK_CODED_LOW;
+        *DispFragPtr = BLOCK_CODED_LOW;
       }
-      DispFragPtr++;    
+      DispFragPtr++;
     }
   }else{
-        
+
     /*************************************************************/
     /* First fragment of row !! */
-        
+
     i = 0;
     /* Reset count of pixels changed for the current fragment. */
     FragChangedPixels = 0;
-    
+
     /* Test for break out conditions to save time. */
     if (*DispFragPtr == CANDIDATE_BLOCK){
       /* Clear down entries in changed locals array */
       memset(ChLocalsPtr,0,8);
-      
+
       for ( j = 0; j < HFRAGPIXELS; j++ ){
-	/* Take a local copy of the measured difference. */
-	Diff = (int)YuvPtr1[j] - (int)YuvPtr2[j];
-	
-	/* Store the actual difference value */
-	YUVDiffsPtr[j] = Diff;
-                
-	/* Test against the Level thresholds and record the results */
-	SgcPtr[0] += ppi->SgcThreshTable[Diff+255];
-	
-	if (j>0 && ppi->SrfPakThreshTable[Diff+255] )
-	  Diff = (int)ApplyPakLowPass( ppi, &YuvPtr1[j] ) - 
-	    (int)ApplyPakLowPass( ppi, &YuvPtr2[j] );
-	
-	/* Test against the SRF thresholds */
-	bits_map_ptr[j] = ppi->SrfThreshTable[Diff+255];
-	FragChangedPixels += ppi->SrfThreshTable[Diff+255];
+        /* Take a local copy of the measured difference. */
+        Diff = (int)YuvPtr1[j] - (int)YuvPtr2[j];
+
+        /* Store the actual difference value */
+        YUVDiffsPtr[j] = Diff;
+
+        /* Test against the Level thresholds and record the results */
+        SgcPtr[0] += ppi->SgcThreshTable[Diff+255];
+
+        if (j>0 && ppi->SrfPakThreshTable[Diff+255] )
+          Diff = (int)ApplyPakLowPass( ppi, &YuvPtr1[j] ) -
+            (int)ApplyPakLowPass( ppi, &YuvPtr2[j] );
+
+        /* Test against the SRF thresholds */
+        bits_map_ptr[j] = ppi->SrfThreshTable[Diff+255];
+        FragChangedPixels += ppi->SrfThreshTable[Diff+255];
       }
     }else{
       /* If we are breaking out here mark all pixels as changed. */
       if ( *DispFragPtr > BLOCK_NOT_CODED ){
-	memset(bits_map_ptr,1,8);
-	memset(ChLocalsPtr,8,8);
+        memset(bits_map_ptr,1,8);
+        memset(ChLocalsPtr,8,8);
       }else{
-	memset(ChLocalsPtr,0,8);
+        memset(ChLocalsPtr,0,8);
       }
     }
-    
+
     *RowDiffsPtr += FragChangedPixels;
     *FDiffPixels += (unsigned char)FragChangedPixels;
-    
+
     YuvPtr1 += HFRAGPIXELS;
     YuvPtr2 += HFRAGPIXELS;
     bits_map_ptr += HFRAGPIXELS;
@@ -856,7 +857,7 @@
     YUVDiffsPtr += HFRAGPIXELS;
     SgcPtr ++;
     FDiffPixels ++;
-    
+
     /* If we have a lot of changed pixels for this fragment on this
        row then the fragment is almost sure to be picked
        (e.g. through the line search) so we can mark it as selected
@@ -864,51 +865,51 @@
     if (FragChangedPixels >= 7){
       *DispFragPtr = BLOCK_CODED_LOW;
     }
-    DispFragPtr++;    
+    DispFragPtr++;
     /*************************************************************/
     /* Fragment in between!! */
-    
-    for ( i = HFRAGPIXELS ; i < ppi->PlaneWidth-HFRAGPIXELS; 
-	  i += HFRAGPIXELS ){
+
+    for ( i = HFRAGPIXELS ; i < ppi->PlaneWidth-HFRAGPIXELS;
+          i += HFRAGPIXELS ){
       /* Reset count of pixels changed for the current fragment. */
       FragChangedPixels = 0;
-      
+
       /* Test for break out conditions to save time. */
       if (*DispFragPtr == CANDIDATE_BLOCK){
-	/* Clear down entries in changed locals array */
-	memset(ChLocalsPtr,0,8);
-	for ( j = 0; j < HFRAGPIXELS; j++ ){
-	  /* Take a local copy of the measured difference. */
-	  Diff = (int)YuvPtr1[j] - (int)YuvPtr2[j];
-	  
-	  /* Store the actual difference value */
-	  YUVDiffsPtr[j] = Diff;
-	  
-	  /* Test against the Level thresholds and record the results */
-	  SgcPtr[0] += ppi->SgcThreshTable[Diff+255];
-	  
-	  if (ppi->SrfPakThreshTable[Diff+255] )
-	    Diff = (int)ApplyPakLowPass( ppi, &YuvPtr1[j] ) - 
-	      (int)ApplyPakLowPass( ppi, &YuvPtr2[j] );
-	  
-	  
-	  /* Test against the SRF thresholds */
-	  bits_map_ptr[j] = ppi->SrfThreshTable[Diff+255];
-	  FragChangedPixels += ppi->SrfThreshTable[Diff+255];
-	}
+        /* Clear down entries in changed locals array */
+        memset(ChLocalsPtr,0,8);
+        for ( j = 0; j < HFRAGPIXELS; j++ ){
+          /* Take a local copy of the measured difference. */
+          Diff = (int)YuvPtr1[j] - (int)YuvPtr2[j];
+
+          /* Store the actual difference value */
+          YUVDiffsPtr[j] = Diff;
+
+          /* Test against the Level thresholds and record the results */
+          SgcPtr[0] += ppi->SgcThreshTable[Diff+255];
+
+          if (ppi->SrfPakThreshTable[Diff+255] )
+            Diff = (int)ApplyPakLowPass( ppi, &YuvPtr1[j] ) -
+              (int)ApplyPakLowPass( ppi, &YuvPtr2[j] );
+
+
+          /* Test against the SRF thresholds */
+          bits_map_ptr[j] = ppi->SrfThreshTable[Diff+255];
+          FragChangedPixels += ppi->SrfThreshTable[Diff+255];
+        }
       }else{
-	/* If we are breaking out here mark all pixels as changed. */
-	if ( *DispFragPtr > BLOCK_NOT_CODED ){
-	  memset(bits_map_ptr,1,8);
-	  memset(ChLocalsPtr,8,8);
-	}else{
-	  memset(ChLocalsPtr,0,8);
-	}
+        /* If we are breaking out here mark all pixels as changed. */
+        if ( *DispFragPtr > BLOCK_NOT_CODED ){
+          memset(bits_map_ptr,1,8);
+          memset(ChLocalsPtr,8,8);
+        }else{
+          memset(ChLocalsPtr,0,8);
+        }
       }
-      
+
       *RowDiffsPtr += FragChangedPixels;
       *FDiffPixels += (unsigned char)FragChangedPixels;
-      
+
       YuvPtr1 += HFRAGPIXELS;
       YuvPtr2 += HFRAGPIXELS;
       bits_map_ptr += HFRAGPIXELS;
@@ -916,54 +917,54 @@
       YUVDiffsPtr += HFRAGPIXELS;
       SgcPtr ++;
       FDiffPixels ++;
-      
+
       /* If we have a lot of changed pixels for this fragment on this
-	 row then the fragment is almost sure to be picked
-	 (e.g. through the line search) so we can mark it as selected
-	 and then ignore it. */
+         row then the fragment is almost sure to be picked
+         (e.g. through the line search) so we can mark it as selected
+         and then ignore it. */
       if (FragChangedPixels >= 7){
-	*DispFragPtr = BLOCK_CODED_LOW;
+        *DispFragPtr = BLOCK_CODED_LOW;
       }
-      DispFragPtr++;    
+      DispFragPtr++;
     }
     /*************************************************************/
     /* Last fragment of row !! */
 
     /* Reset count of pixels changed for the current fragment. */
     FragChangedPixels = 0;
-    
+
     /* Test for break out conditions to save time. */
     if (*DispFragPtr == CANDIDATE_BLOCK){
       /* Clear down entries in changed locals array */
       memset(ChLocalsPtr,0,8);
-      
+
       for ( j = 0; j < HFRAGPIXELS; j++ ){
-	/* Take a local copy of the measured difference. */
-	Diff = (int)YuvPtr1[j] - (int)YuvPtr2[j];
-                
-	/* Store the actual difference value */
-	YUVDiffsPtr[j] = Diff;
-                
-	/* Test against the Level thresholds and record the results */
-	SgcPtr[0] += ppi->SgcThreshTable[Diff+255];
-	
-	if (j<7 && ppi->SrfPakThreshTable[Diff+255] )
-	  Diff = (int)ApplyPakLowPass( ppi, &YuvPtr1[j] ) - 
-	    (int)ApplyPakLowPass( ppi, &YuvPtr2[j] );
-	
-	
-	/* Test against the SRF thresholds */
-	bits_map_ptr[j] = ppi->SrfThreshTable[Diff+255];
-	FragChangedPixels += ppi->SrfThreshTable[Diff+255];
+        /* Take a local copy of the measured difference. */
+        Diff = (int)YuvPtr1[j] - (int)YuvPtr2[j];
+
+        /* Store the actual difference value */
+        YUVDiffsPtr[j] = Diff;
+
+        /* Test against the Level thresholds and record the results */
+        SgcPtr[0] += ppi->SgcThreshTable[Diff+255];
+
+        if (j<7 && ppi->SrfPakThreshTable[Diff+255] )
+          Diff = (int)ApplyPakLowPass( ppi, &YuvPtr1[j] ) -
+            (int)ApplyPakLowPass( ppi, &YuvPtr2[j] );
+
+
+        /* Test against the SRF thresholds */
+        bits_map_ptr[j] = ppi->SrfThreshTable[Diff+255];
+        FragChangedPixels += ppi->SrfThreshTable[Diff+255];
       }
     }else{
       /* If we are breaking out here mark all pixels as changed.*/
       if ( *DispFragPtr > BLOCK_NOT_CODED ) {
-	  memset(bits_map_ptr,1,8);
-	  memset(ChLocalsPtr,8,8);
-	}else{
-	  memset(ChLocalsPtr,0,8);
-	}
+          memset(bits_map_ptr,1,8);
+          memset(ChLocalsPtr,8,8);
+        }else{
+          memset(ChLocalsPtr,0,8);
+        }
     }
     /* If we have a lot of changed pixels for this fragment on this
        row then the fragment is almost sure to be picked (e.g. through
@@ -971,7 +972,7 @@
        it. */
     *RowDiffsPtr += FragChangedPixels;
     *FDiffPixels += (unsigned char)FragChangedPixels;
-    
+
     /* If we have a lot of changed pixels for this fragment on this
        row then the fragment is almost sure to be picked (e.g. through
        the line search) so we can mark it as selected and then ignore
@@ -979,59 +980,59 @@
     if (FragChangedPixels >= 7){
       *DispFragPtr = BLOCK_CODED_LOW;
     }
-    DispFragPtr++;    
-    
+    DispFragPtr++;
+
   }
 }
 
-static void ConsolidateDiffScanResults( PP_INSTANCE *ppi, 
-					unsigned char * FDiffPixels, 
-					signed char * SgcScoresPtr, 
-					signed char * DispFragPtr ){
+static void ConsolidateDiffScanResults( PP_INSTANCE *ppi,
+                                        unsigned char * FDiffPixels,
+                                        signed char * SgcScoresPtr,
+                                        signed char * DispFragPtr ){
   ogg_int32_t i;
-  
+
   for ( i = 0; i < ppi->PlaneHFragments; i ++ ){
     /* Consider only those blocks that were candidates in the
        difference scan. Ignore definite YES and NO cases. */
     if ( DispFragPtr[i] == CANDIDATE_BLOCK ){
       if ( ((ogg_uint32_t)abs(SgcScoresPtr[i]) > ppi->BlockSgcThresh) ){
-	/* Block marked for update due to Sgc change */
-	DispFragPtr[i] = BLOCK_CODED_SGC;
+        /* Block marked for update due to Sgc change */
+        DispFragPtr[i] = BLOCK_CODED_SGC;
       }else if ( FDiffPixels[i] == 0 ){
-	/* Block is no longer a candidate for the main tests but will 
-	   still be considered a candidate in RowBarEnhBlockMap() */
-	DispFragPtr[i] = CANDIDATE_BLOCK_LOW;
+        /* Block is no longer a candidate for the main tests but will
+           still be considered a candidate in RowBarEnhBlockMap() */
+        DispFragPtr[i] = CANDIDATE_BLOCK_LOW;
       }
     }
   }
 }
 
-static void RowChangedLocalsScan( PP_INSTANCE *ppi, 
-				  unsigned char * PixelMapPtr, 
-				  unsigned char * ChLocalsPtr, 
-				  signed char  * DispFragPtr, 
-				  unsigned char   RowType ){
+static void RowChangedLocalsScan( PP_INSTANCE *ppi,
+                                  unsigned char * PixelMapPtr,
+                                  unsigned char * ChLocalsPtr,
+                                  signed char  * DispFragPtr,
+                                  unsigned char   RowType ){
 
-  unsigned char changed_locals = 0; 
+  unsigned char changed_locals = 0;
   unsigned char * PixelsChangedPtr0;
   unsigned char * PixelsChangedPtr1;
   unsigned char * PixelsChangedPtr2;
   ogg_int32_t i, j;
   ogg_int32_t LastRowIndex = ppi->PlaneWidth - 1;
-  
+
   /* Set up the line based pointers into the bits changed map. */
   PixelsChangedPtr0 = PixelMapPtr - ppi->PlaneWidth;
   if ( PixelsChangedPtr0 < ppi->PixelChangedMap )
     PixelsChangedPtr0 += ppi->PixelMapCircularBufferSize;
-  PixelsChangedPtr0 -= 1; 
-  
+  PixelsChangedPtr0 -= 1;
+
   PixelsChangedPtr1 = PixelMapPtr - 1;
-  
+
   PixelsChangedPtr2 = PixelMapPtr + ppi->PlaneWidth;
-  if ( PixelsChangedPtr2 >= 
+  if ( PixelsChangedPtr2 >=
        (ppi->PixelChangedMap + ppi->PixelMapCircularBufferSize) )
     PixelsChangedPtr2 -= ppi->PixelMapCircularBufferSize;
-  PixelsChangedPtr2 -= 1; 
+  PixelsChangedPtr2 -= 1;
 
   if ( RowType == NOT_EDGE_ROW ){
     /* Scan through the row of pixels and calculate changed locals. */
@@ -1039,50 +1040,50 @@
       /* Skip a group of 8 pixels if the assosciated fragment has no
          pixels of interest. */
       if ( *DispFragPtr == CANDIDATE_BLOCK ){
-	for ( j = 0; j < HFRAGPIXELS; j++ ){
-	  changed_locals = 0;
+        for ( j = 0; j < HFRAGPIXELS; j++ ){
+          changed_locals = 0;
 
-	  /* If the pixel itself has changed */
-	  if ( PixelsChangedPtr1[1] ){
-	    if ( (i > 0) || (j > 0) ){
-	      changed_locals += PixelsChangedPtr0[0];
-	      changed_locals += PixelsChangedPtr1[0];
-	      changed_locals += PixelsChangedPtr2[0];
-	    }
-	    
-	    changed_locals += PixelsChangedPtr0[1];
-	    changed_locals += PixelsChangedPtr2[1];
-
-	    if ( (i + j) < LastRowIndex ){
-	      changed_locals += PixelsChangedPtr0[2];
-	      changed_locals += PixelsChangedPtr1[2];
-	      changed_locals += PixelsChangedPtr2[2];
-	    }
-	    
-	    /* Store the number of changed locals */
-	    *ChLocalsPtr |= changed_locals;
-	  }
-	  
-	  /* Increment to next pixel in the row */
-	  ChLocalsPtr++;
-	  PixelsChangedPtr0++;
-	  PixelsChangedPtr1++;
-	  PixelsChangedPtr2++;
-	}
+          /* If the pixel itself has changed */
+          if ( PixelsChangedPtr1[1] ){
+            if ( (i > 0) || (j > 0) ){
+              changed_locals += PixelsChangedPtr0[0];
+              changed_locals += PixelsChangedPtr1[0];
+              changed_locals += PixelsChangedPtr2[0];
+            }
+
+            changed_locals += PixelsChangedPtr0[1];
+            changed_locals += PixelsChangedPtr2[1];
+
+            if ( (i + j) < LastRowIndex ){
+              changed_locals += PixelsChangedPtr0[2];
+              changed_locals += PixelsChangedPtr1[2];
+              changed_locals += PixelsChangedPtr2[2];
+            }
+
+            /* Store the number of changed locals */
+            *ChLocalsPtr |= changed_locals;
+          }
+
+          /* Increment to next pixel in the row */
+          ChLocalsPtr++;
+          PixelsChangedPtr0++;
+          PixelsChangedPtr1++;
+          PixelsChangedPtr2++;
+        }
       }else{
-	if ( *DispFragPtr > BLOCK_NOT_CODED )
-	  memset(ChLocalsPtr,0,8);
-	
-	/* Step pointers */
-	ChLocalsPtr += HFRAGPIXELS;
-	PixelsChangedPtr0 += HFRAGPIXELS;
-	PixelsChangedPtr1 += HFRAGPIXELS;
-	PixelsChangedPtr2 += HFRAGPIXELS;
+        if ( *DispFragPtr > BLOCK_NOT_CODED )
+          memset(ChLocalsPtr,0,8);
+
+        /* Step pointers */
+        ChLocalsPtr += HFRAGPIXELS;
+        PixelsChangedPtr0 += HFRAGPIXELS;
+        PixelsChangedPtr1 += HFRAGPIXELS;
+        PixelsChangedPtr2 += HFRAGPIXELS;
       }
-      
+
       /* Move on to next fragment. */
-      DispFragPtr++;    
-      
+      DispFragPtr++;
+
     }
   }else{
     /* Scan through the row of pixels and calculate changed locals. */
@@ -1090,78 +1091,78 @@
       /* Skip a group of 8 pixels if the assosciated fragment has no
          pixels of interest */
       if ( *DispFragPtr == CANDIDATE_BLOCK ){
-	for ( j = 0; j < HFRAGPIXELS; j++ ){
-	  changed_locals = 0;
-	  
-	  /* If the pixel itself has changed */
-	  if ( PixelsChangedPtr1[1] ){
-	    if ( RowType == FIRST_ROW ){
-	      if ( (i > 0) || (j > 0) ){
-		changed_locals += PixelsChangedPtr1[0];
-		changed_locals += PixelsChangedPtr2[0];
-	      }
-	      
-	      changed_locals += PixelsChangedPtr2[1];
-	      
-	      if ( (i + j) < LastRowIndex ){
-		changed_locals += PixelsChangedPtr1[2];
-		changed_locals += PixelsChangedPtr2[2];
-	      }
-	    }else{
-	      if ( (i > 0) || (j > 0 ) ){
-		changed_locals += PixelsChangedPtr0[0];
-		changed_locals += PixelsChangedPtr1[0];
-	      }
-	      
-	      changed_locals += PixelsChangedPtr0[1];
-	      
-	      if ( (i + j) < LastRowIndex ){
-		changed_locals += PixelsChangedPtr0[2];
-		changed_locals += PixelsChangedPtr1[2];
-	      }
-	    }
-	    
-	    /* Store the number of changed locals */
-	    *ChLocalsPtr |= changed_locals;
-	  }
-	  
-	  /* Increment to next pixel in the row */
-	  ChLocalsPtr++;
-	  PixelsChangedPtr0++;
-	  PixelsChangedPtr1++;
-	  PixelsChangedPtr2++;
-	}
+        for ( j = 0; j < HFRAGPIXELS; j++ ){
+          changed_locals = 0;
+
+          /* If the pixel itself has changed */
+          if ( PixelsChangedPtr1[1] ){
+            if ( RowType == FIRST_ROW ){
+              if ( (i > 0) || (j > 0) ){
+                changed_locals += PixelsChangedPtr1[0];
+                changed_locals += PixelsChangedPtr2[0];
+              }
+
+              changed_locals += PixelsChangedPtr2[1];
+
+              if ( (i + j) < LastRowIndex ){
+                changed_locals += PixelsChangedPtr1[2];
+                changed_locals += PixelsChangedPtr2[2];
+              }
+            }else{
+              if ( (i > 0) || (j > 0 ) ){
+                changed_locals += PixelsChangedPtr0[0];
+                changed_locals += PixelsChangedPtr1[0];
+              }
+
+              changed_locals += PixelsChangedPtr0[1];
+
+              if ( (i + j) < LastRowIndex ){
+                changed_locals += PixelsChangedPtr0[2];
+                changed_locals += PixelsChangedPtr1[2];
+              }
+            }
+
+            /* Store the number of changed locals */
+            *ChLocalsPtr |= changed_locals;
+          }
+
+          /* Increment to next pixel in the row */
+          ChLocalsPtr++;
+          PixelsChangedPtr0++;
+          PixelsChangedPtr1++;
+          PixelsChangedPtr2++;
+        }
       }else{
-	if ( *DispFragPtr > BLOCK_NOT_CODED )
-	  memset(ChLocalsPtr,0,8);
-	
-	/* Step pointers */
-	ChLocalsPtr += HFRAGPIXELS;
-	PixelsChangedPtr0 += HFRAGPIXELS;
-	PixelsChangedPtr1 += HFRAGPIXELS;
-	PixelsChangedPtr2 += HFRAGPIXELS;
+        if ( *DispFragPtr > BLOCK_NOT_CODED )
+          memset(ChLocalsPtr,0,8);
+
+        /* Step pointers */
+        ChLocalsPtr += HFRAGPIXELS;
+        PixelsChangedPtr0 += HFRAGPIXELS;
+        PixelsChangedPtr1 += HFRAGPIXELS;
+        PixelsChangedPtr2 += HFRAGPIXELS;
       }
 
       /* Move on to next fragment. */
-      DispFragPtr++;    
+      DispFragPtr++;
     }
   }
 }
 
-static void NoiseScoreRow( PP_INSTANCE *ppi, 
-			   unsigned char * PixelMapPtr, 
-			   unsigned char * ChLocalsPtr, 
-			   ogg_int16_t   * YUVDiffsPtr, 
-			   unsigned char * PixelNoiseScorePtr, 
-			   ogg_uint32_t  * FragScorePtr, 
-			   signed char   * DispFragPtr,
-			   ogg_int32_t   * RowDiffsPtr ){ 
+static void NoiseScoreRow( PP_INSTANCE *ppi,
+                           unsigned char * PixelMapPtr,
+                           unsigned char * ChLocalsPtr,
+                           ogg_int16_t   * YUVDiffsPtr,
+                           unsigned char * PixelNoiseScorePtr,
+                           ogg_uint32_t  * FragScorePtr,
+                           signed char   * DispFragPtr,
+                           ogg_int32_t   * RowDiffsPtr ){
   ogg_int32_t i,j;
-  unsigned char  changed_locals = 0; 
+  unsigned char  changed_locals = 0;
   ogg_int32_t  Score;
   ogg_uint32_t FragScore;
   ogg_int32_t  AbsDiff;
-  
+
   /* For each pixel in the row */
   for ( i = 0; i < ppi->PlaneWidth; i += HFRAGPIXELS ){
     /* Skip a group of 8 pixels if the assosciated fragment has no
@@ -1169,55 +1170,55 @@
     if ( *DispFragPtr == CANDIDATE_BLOCK ){
       /* Reset the cumulative fragment score. */
       FragScore = 0;
-      
+
       /* Pixels grouped along the row into fragments */
       for ( j = 0; j < HFRAGPIXELS; j++ ){
-	if ( PixelMapPtr[j] ){
-	  AbsDiff = (ogg_int32_t)( abs(YUVDiffsPtr[j]) );
-	  changed_locals = ChLocalsPtr[j];
-	  
-	  /* Give this pixel a score based on changed locals and level
+        if ( PixelMapPtr[j] ){
+          AbsDiff = (ogg_int32_t)( abs(YUVDiffsPtr[j]) );
+          changed_locals = ChLocalsPtr[j];
+
+          /* Give this pixel a score based on changed locals and level
              of its own change. */
-	  Score = (1 + ((ogg_int32_t)(changed_locals + 
-				      ppi->NoiseScoreBoostTable[AbsDiff]) - 
-			ppi->NoiseSupLevel));  
-	  
-	  /* For no zero scores adjust by a level based score multiplier. */
-	  if ( Score > 0 ){
-	    Score = ((double)Score * 
-		     ppi->AbsDiff_ScoreMultiplierTable[AbsDiff] );
-	    if ( Score < 1 )
-	      Score = 1;
-	  }else{
-	    /* Set -ve values to 0 */
-	    Score = 0;
-	    
-	    /* If there are no changed locals then clear the pixel
-	       changed flag and decrement the pixels changed in
-	       fragment count to speed later stages. */
-	    if ( changed_locals == 0 ){
-	      PixelMapPtr[j] = 0; 
-	      *RowDiffsPtr -= 1;
-	    }
-	  }
-	  
-	  /* Update the pixel scores etc. */
-	  PixelNoiseScorePtr[j] = (unsigned char)Score;
-	  FragScore += (ogg_uint32_t)Score;
-	}
+          Score = (1 + ((ogg_int32_t)(changed_locals +
+                                      ppi->NoiseScoreBoostTable[AbsDiff]) -
+                        ppi->NoiseSupLevel));
+
+          /* For no zero scores adjust by a level based score multiplier. */
+          if ( Score > 0 ){
+            Score = ((double)Score *
+                     ppi->AbsDiff_ScoreMultiplierTable[AbsDiff] );
+            if ( Score < 1 )
+              Score = 1;
+          }else{
+            /* Set -ve values to 0 */
+            Score = 0;
+
+            /* If there are no changed locals then clear the pixel
+               changed flag and decrement the pixels changed in
+               fragment count to speed later stages. */
+            if ( changed_locals == 0 ){
+              PixelMapPtr[j] = 0;
+              *RowDiffsPtr -= 1;
+            }
+          }
+
+          /* Update the pixel scores etc. */
+          PixelNoiseScorePtr[j] = (unsigned char)Score;
+          FragScore += (ogg_uint32_t)Score;
+        }
       }
-      
+
       /* Add fragment score (with plane correction factor) into main
          data structure */
-      *FragScorePtr += (ogg_int32_t)(FragScore * 
-				     ppi->YUVPlaneCorrectionFactor);
-      
+      *FragScorePtr += (ogg_int32_t)(FragScore *
+                                     ppi->YUVPlaneCorrectionFactor);
+
       /* If score is greater than trip threshold then mark blcok for update. */
       if ( *FragScorePtr > ppi->BlockThreshold ){
-	*DispFragPtr = BLOCK_CODED_LOW;
+        *DispFragPtr = BLOCK_CODED_LOW;
       }
     }
-    
+
     /* Increment the various pointers */
     FragScorePtr++;
     DispFragPtr++;
@@ -1228,16 +1229,16 @@
   }
 }
 
-static void PrimaryEdgeScoreRow( PP_INSTANCE *ppi, 
-				 unsigned char * ChangedLocalsPtr, 
-				 ogg_int16_t   * YUVDiffsPtr, 
-				 unsigned char * PixelNoiseScorePtr, 
-				 ogg_uint32_t  * FragScorePtr,
-				 signed char   * DispFragPtr,
-				 unsigned char   RowType ){ 
+static void PrimaryEdgeScoreRow( PP_INSTANCE *ppi,
+                                 unsigned char * ChangedLocalsPtr,
+                                 ogg_int16_t   * YUVDiffsPtr,
+                                 unsigned char * PixelNoiseScorePtr,
+                                 ogg_uint32_t  * FragScorePtr,
+                                 signed char   * DispFragPtr,
+                                 unsigned char   RowType ){
   ogg_uint32_t     BodyNeighbours;
   ogg_uint32_t     AbsDiff;
-  unsigned char    changed_locals = 0; 
+  unsigned char    changed_locals = 0;
   ogg_int32_t      Score;
   ogg_uint32_t     FragScore;
   unsigned char  * CHLocalsPtr0;
@@ -1251,16 +1252,16 @@
   CHLocalsPtr0 = ChangedLocalsPtr - ppi->PlaneWidth;
   if ( CHLocalsPtr0 < ppi->ChLocals )
     CHLocalsPtr0 += ppi->ChLocalsCircularBufferSize;
-  CHLocalsPtr0 -= 1;      
-  
+  CHLocalsPtr0 -= 1;
+
   CHLocalsPtr1 = ChangedLocalsPtr - 1;
-  
+
   CHLocalsPtr2 = ChangedLocalsPtr + ppi->PlaneWidth;
   if ( CHLocalsPtr2 >= (ppi->ChLocals + ppi->ChLocalsCircularBufferSize) )
     CHLocalsPtr2 -= ppi->ChLocalsCircularBufferSize;
-  CHLocalsPtr2 -= 1;      
-  
-  
+  CHLocalsPtr2 -= 1;
+
+
   /* The defining rule used here is as follows. */
   /* An edge pixels has 3-5 changed locals. */
   /* And one or more of these changed locals has itself got 7-8
@@ -1271,213 +1272,213 @@
     for ( i = 0; i < ppi->PlaneWidth; i += HFRAGPIXELS ){
       /* Does the fragment contain anything interesting to work with. */
       if ( *DispFragPtr == CANDIDATE_BLOCK ){
-	/* Reset the cumulative fragment score. */
-	FragScore = 0;
-	
-	/* Pixels grouped along the row into fragments */
-	for ( j = 0; j < HFRAGPIXELS; j++ ){
-	  /* How many changed locals has the current pixel got. */
-	  changed_locals = ChangedLocalsPtr[j];
-	  
-	  /* Is the pixel a suitable candidate */
-	  if ( (changed_locals > 2) && (changed_locals < 6) ){
-	    /* The pixel may qualify... have a closer look.  */
-	    BodyNeighbours = 0;
-	    
-	    /* Count the number of "BodyNeighbours" .. Pixels that
-	       have 7 or more changed neighbours.  */
-	    if ( (i > 0) || (j > 0 ) ){
-	      if ( CHLocalsPtr0[0] >= 7 )
-		BodyNeighbours++;
-	      if ( CHLocalsPtr1[0] >= 7 )
-		BodyNeighbours++;
-	      if ( CHLocalsPtr2[0] >= 7 )
-		BodyNeighbours++;
-	    }
-	    
-	    if ( CHLocalsPtr0[1] >= 7 )
-	      BodyNeighbours++;
-	    if ( CHLocalsPtr2[1] >= 7 )
-	      BodyNeighbours++;
-	    
-	    if ( (i + j) < LastRowIndex ){
-	      if ( CHLocalsPtr0[2] >= 7 )
-		BodyNeighbours++;
-	      if ( CHLocalsPtr1[2] >= 7 )
-		BodyNeighbours++;
-	      if ( CHLocalsPtr2[2] >= 7 )
-		BodyNeighbours++;
-	    }
-	    
-	    if ( BodyNeighbours > 0 ){
-	      AbsDiff = abs( YUVDiffsPtr[j] );
-	      Score = (ogg_int32_t)
-		( (double)(BodyNeighbours * 
-			   BodyNeighbourScore) * 
-		  ppi->AbsDiff_ScoreMultiplierTable[AbsDiff] );
-	      if ( Score < 1 )
-		Score = 1;
-	      
-	      /* Increment the score by a value determined by the
+        /* Reset the cumulative fragment score. */
+        FragScore = 0;
+
+        /* Pixels grouped along the row into fragments */
+        for ( j = 0; j < HFRAGPIXELS; j++ ){
+          /* How many changed locals has the current pixel got. */
+          changed_locals = ChangedLocalsPtr[j];
+
+          /* Is the pixel a suitable candidate */
+          if ( (changed_locals > 2) && (changed_locals < 6) ){
+            /* The pixel may qualify... have a closer look.  */
+            BodyNeighbours = 0;
+
+            /* Count the number of "BodyNeighbours" .. Pixels that
+               have 7 or more changed neighbours.  */
+            if ( (i > 0) || (j > 0 ) ){
+              if ( CHLocalsPtr0[0] >= 7 )
+                BodyNeighbours++;
+              if ( CHLocalsPtr1[0] >= 7 )
+                BodyNeighbours++;
+              if ( CHLocalsPtr2[0] >= 7 )
+                BodyNeighbours++;
+            }
+
+            if ( CHLocalsPtr0[1] >= 7 )
+              BodyNeighbours++;
+            if ( CHLocalsPtr2[1] >= 7 )
+              BodyNeighbours++;
+
+            if ( (i + j) < LastRowIndex ){
+              if ( CHLocalsPtr0[2] >= 7 )
+                BodyNeighbours++;
+              if ( CHLocalsPtr1[2] >= 7 )
+                BodyNeighbours++;
+              if ( CHLocalsPtr2[2] >= 7 )
+                BodyNeighbours++;
+            }
+
+            if ( BodyNeighbours > 0 ){
+              AbsDiff = abs( YUVDiffsPtr[j] );
+              Score = (ogg_int32_t)
+                ( (double)(BodyNeighbours *
+                           BodyNeighbourScore) *
+                  ppi->AbsDiff_ScoreMultiplierTable[AbsDiff] );
+              if ( Score < 1 )
+                Score = 1;
+
+              /* Increment the score by a value determined by the
                  number of body neighbours. */
-	      PixelNoiseScorePtr[j] += (unsigned char)Score;  
-	      FragScore += (ogg_uint32_t)Score;
-	    }
-	  }
-	  
-	  /* Increment pointers into changed locals buffer */
-	  CHLocalsPtr0 ++;
-	  CHLocalsPtr1 ++;
-	  CHLocalsPtr2 ++;
-	}
-	
-	/* Add fragment score (with plane correction factor) into main
+              PixelNoiseScorePtr[j] += (unsigned char)Score;
+              FragScore += (ogg_uint32_t)Score;
+            }
+          }
+
+          /* Increment pointers into changed locals buffer */
+          CHLocalsPtr0 ++;
+          CHLocalsPtr1 ++;
+          CHLocalsPtr2 ++;
+        }
+
+        /* Add fragment score (with plane correction factor) into main
            data structure */
-	*FragScorePtr += (ogg_int32_t)(FragScore * 
-				       ppi->YUVPlaneCorrectionFactor);
-	
-	/* If score is greater than trip threshold then mark blcok for
+        *FragScorePtr += (ogg_int32_t)(FragScore *
+                                       ppi->YUVPlaneCorrectionFactor);
+
+        /* If score is greater than trip threshold then mark blcok for
            update. */
-	if ( *FragScorePtr > ppi->BlockThreshold ){
-	  *DispFragPtr = BLOCK_CODED_LOW;
-	}
-	
+        if ( *FragScorePtr > ppi->BlockThreshold ){
+          *DispFragPtr = BLOCK_CODED_LOW;
+        }
+
       }else{
-	/* Nothing to do for this fragment group */
-	/* Advance pointers into changed locals buffer */
-	CHLocalsPtr0 += HFRAGPIXELS;
-	CHLocalsPtr1 += HFRAGPIXELS;
-	CHLocalsPtr2 += HFRAGPIXELS;
+        /* Nothing to do for this fragment group */
+        /* Advance pointers into changed locals buffer */
+        CHLocalsPtr0 += HFRAGPIXELS;
+        CHLocalsPtr1 += HFRAGPIXELS;
+        CHLocalsPtr2 += HFRAGPIXELS;
       }
-      
+
       /* Increment the various pointers */
       FragScorePtr++;
       DispFragPtr++;
       PixelNoiseScorePtr += HFRAGPIXELS;
       ChangedLocalsPtr += HFRAGPIXELS;
       YUVDiffsPtr += HFRAGPIXELS;
-    }  
+    }
   }else{
     /* This is either the top or bottom row of pixels in a plane. */
     /* Loop for all pixels in the row. */
     for ( i = 0; i < ppi->PlaneWidth; i += HFRAGPIXELS ){
       /* Does the fragment contain anything interesting to work with. */
       if ( *DispFragPtr == CANDIDATE_BLOCK ){
-	/* Reset the cumulative fragment score. */
-	FragScore = 0;
-	
-	/* Pixels grouped along the row into fragments */
-	for ( j = 0; j < HFRAGPIXELS; j++ ){
-	  /* How many changed locals has the current pixel got. */
-	  changed_locals = ChangedLocalsPtr[j];
-	  
-	  /* Is the pixel a suitable candidate */
-	  if ( (changed_locals > 2) && (changed_locals < 6) ){
-	    /* The pixel may qualify... have a closer look. */
-	    BodyNeighbours = 0;
-	    
-	    /* Count the number of "BodyNeighbours" .. Pixels
-	       that have 7 or more changed neighbours. */
-	    if ( RowType == LAST_ROW ){
-	      /* Test for cases where it could be the first pixel on
+        /* Reset the cumulative fragment score. */
+        FragScore = 0;
+
+        /* Pixels grouped along the row into fragments */
+        for ( j = 0; j < HFRAGPIXELS; j++ ){
+          /* How many changed locals has the current pixel got. */
+          changed_locals = ChangedLocalsPtr[j];
+
+          /* Is the pixel a suitable candidate */
+          if ( (changed_locals > 2) && (changed_locals < 6) ){
+            /* The pixel may qualify... have a closer look. */
+            BodyNeighbours = 0;
+
+            /* Count the number of "BodyNeighbours" .. Pixels
+               that have 7 or more changed neighbours. */
+            if ( RowType == LAST_ROW ){
+              /* Test for cases where it could be the first pixel on
                  the line */
-	      if ( (i > 0) || (j > 0) ){
-		if ( CHLocalsPtr0[0] >= 7 )
-		  BodyNeighbours++;
-		if ( CHLocalsPtr1[0] >= 7 )
-		  BodyNeighbours++;
-	      }
-	      
-	      if ( CHLocalsPtr0[1] >= 7 )
-		BodyNeighbours++;
-	      
-	      // Test for the end of line case
-	      if ( (i + j) < LastRowIndex ){
-		if ( CHLocalsPtr0[2] >= 7 )
-		  BodyNeighbours++;
-		
-		if ( CHLocalsPtr1[2] >= 7 )
-		  BodyNeighbours++;
-	      }
-	    }else{
-	      /* First Row */
-	      /* Test for cases where it could be the first pixel on
+              if ( (i > 0) || (j > 0) ){
+                if ( CHLocalsPtr0[0] >= 7 )
+                  BodyNeighbours++;
+                if ( CHLocalsPtr1[0] >= 7 )
+                  BodyNeighbours++;
+              }
+
+              if ( CHLocalsPtr0[1] >= 7 )
+                BodyNeighbours++;
+
+              /* Test for the end of line case */
+              if ( (i + j) < LastRowIndex ){
+                if ( CHLocalsPtr0[2] >= 7 )
+                  BodyNeighbours++;
+
+                if ( CHLocalsPtr1[2] >= 7 )
+                  BodyNeighbours++;
+              }
+            }else{
+              /* First Row */
+              /* Test for cases where it could be the first pixel on
                  the line */
-	      if ( (i > 0) || (j > 0) ){
-		if ( CHLocalsPtr1[0] >= 7 )
-		  BodyNeighbours++;
-		if ( CHLocalsPtr2[0] >= 7 )
-		  BodyNeighbours++;
-	      }
-	      
-	      /* Test for the end of line case */
-	      if ( CHLocalsPtr2[1] >= 7 )
-		BodyNeighbours++;
-	      
-	      if ( (i + j) < LastRowIndex ){
-		if ( CHLocalsPtr1[2] >= 7 )
-		  BodyNeighbours++;
-		if ( CHLocalsPtr2[2] >= 7 )
-		  BodyNeighbours++;
-	      }
-	    }
-	    
-	    /* Allocate a score according to the number of Body neighbours. */
-	    if ( BodyNeighbours > 0 ){
-	      AbsDiff = abs( YUVDiffsPtr[j] );
-	      Score = (ogg_int32_t)
-		( (double)(BodyNeighbours * BodyNeighbourScore) * 
-		  ppi->AbsDiff_ScoreMultiplierTable[AbsDiff] );
-	      if ( Score < 1 )
-		Score = 1;
-	      
-	      PixelNoiseScorePtr[j] += (unsigned char)Score;  
-	      FragScore += (ogg_uint32_t)Score;
-	    }
-	  }
-	  
-	  /* Increment pointers into changed locals buffer */
-	  CHLocalsPtr0 ++;
-	  CHLocalsPtr1 ++;
-	  CHLocalsPtr2 ++;
-	}
+              if ( (i > 0) || (j > 0) ){
+                if ( CHLocalsPtr1[0] >= 7 )
+                  BodyNeighbours++;
+                if ( CHLocalsPtr2[0] >= 7 )
+                  BodyNeighbours++;
+              }
+
+              /* Test for the end of line case */
+              if ( CHLocalsPtr2[1] >= 7 )
+                BodyNeighbours++;
+
+              if ( (i + j) < LastRowIndex ){
+                if ( CHLocalsPtr1[2] >= 7 )
+                  BodyNeighbours++;
+                if ( CHLocalsPtr2[2] >= 7 )
+                  BodyNeighbours++;
+              }
+            }
+
+            /* Allocate a score according to the number of Body neighbours. */
+            if ( BodyNeighbours > 0 ){
+              AbsDiff = abs( YUVDiffsPtr[j] );
+              Score = (ogg_int32_t)
+                ( (double)(BodyNeighbours * BodyNeighbourScore) *
+                  ppi->AbsDiff_ScoreMultiplierTable[AbsDiff] );
+              if ( Score < 1 )
+                Score = 1;
+
+              PixelNoiseScorePtr[j] += (unsigned char)Score;
+              FragScore += (ogg_uint32_t)Score;
+            }
+          }
+
+          /* Increment pointers into changed locals buffer */
+          CHLocalsPtr0 ++;
+          CHLocalsPtr1 ++;
+          CHLocalsPtr2 ++;
+        }
 
-	/* Add fragment score (with plane correction factor) into main
+        /* Add fragment score (with plane correction factor) into main
            data structure */
-	*FragScorePtr += 
-	  (ogg_int32_t)(FragScore * ppi->YUVPlaneCorrectionFactor);
-	
-	/* If score is greater than trip threshold then mark blcok for
+        *FragScorePtr +=
+          (ogg_int32_t)(FragScore * ppi->YUVPlaneCorrectionFactor);
+
+        /* If score is greater than trip threshold then mark blcok for
            update. */
-	if ( *FragScorePtr > ppi->BlockThreshold ){
-	  *DispFragPtr = BLOCK_CODED_LOW;
-	}
-	
+        if ( *FragScorePtr > ppi->BlockThreshold ){
+          *DispFragPtr = BLOCK_CODED_LOW;
+        }
+
       }else{
-	/* Nothing to do for this fragment group */
-	/* Advance pointers into changed locals buffer */
-	CHLocalsPtr0 += HFRAGPIXELS;
-	CHLocalsPtr1 += HFRAGPIXELS;
-	CHLocalsPtr2 += HFRAGPIXELS;
+        /* Nothing to do for this fragment group */
+        /* Advance pointers into changed locals buffer */
+        CHLocalsPtr0 += HFRAGPIXELS;
+        CHLocalsPtr1 += HFRAGPIXELS;
+        CHLocalsPtr2 += HFRAGPIXELS;
       }
-      
+
       /* Increment the various pointers */
       FragScorePtr++;
       DispFragPtr++;
       PixelNoiseScorePtr += HFRAGPIXELS;
       ChangedLocalsPtr += HFRAGPIXELS;
       YUVDiffsPtr += HFRAGPIXELS;
-    }  
+    }
   }
 }
 
-static void PixelLineSearch( PP_INSTANCE *ppi, 
-			     unsigned char * ChangedLocalsPtr, 
-			     ogg_int32_t RowNumber, 
-			     ogg_int32_t ColNumber, 
-			     unsigned char direction, 
-			     ogg_uint32_t * line_length ){   
-  /* Exit if the pixel does not qualify or we have fallen off the edge    
+static void PixelLineSearch( PP_INSTANCE *ppi,
+                             unsigned char * ChangedLocalsPtr,
+                             ogg_int32_t RowNumber,
+                             ogg_int32_t ColNumber,
+                             unsigned char direction,
+                             ogg_uint32_t * line_length ){
+  /* Exit if the pixel does not qualify or we have fallen off the edge
      of either the image plane or the row. */
   if ( ((*ChangedLocalsPtr) <= 1) ||
        ((*ChangedLocalsPtr) >= 6) ||
@@ -1489,381 +1490,381 @@
     return;
   }
 
-  if (*line_length < ppi->MaxLineSearchLen){   
-    ogg_uint32_t TmpLineLength; 
+  if (*line_length < ppi->MaxLineSearchLen){
+    ogg_uint32_t TmpLineLength;
     ogg_uint32_t BestLineLength;
     unsigned char * search_ptr;
-    
+
     /* Increment the line length to include this pixel. */
     *line_length += 1;
     BestLineLength = *line_length;
-    
+
     /* Continue search  */
     /* up */
     if ( direction == UP ){
       TmpLineLength = *line_length;
-      
+
       search_ptr = ChangedLocalsPtr - ppi->PlaneWidth;
       if ( search_ptr < ppi->ChLocals )
-	search_ptr += ppi->ChLocalsCircularBufferSize;
-      
-      PixelLineSearch( ppi, search_ptr, RowNumber - 1, ColNumber, 
-		       direction, &TmpLineLength );    
-      
+        search_ptr += ppi->ChLocalsCircularBufferSize;
+
+      PixelLineSearch( ppi, search_ptr, RowNumber - 1, ColNumber,
+                       direction, &TmpLineLength );
+
       if ( TmpLineLength > BestLineLength )
-	BestLineLength = TmpLineLength;
+        BestLineLength = TmpLineLength;
     }
-    
+
     /* up and left */
-    if ( (BestLineLength < ppi->MaxLineSearchLen) && 
-	 ((direction == UP) || (direction == LEFT)) ){   
+    if ( (BestLineLength < ppi->MaxLineSearchLen) &&
+         ((direction == UP) || (direction == LEFT)) ){
       TmpLineLength = *line_length;
-      
+
       search_ptr = ChangedLocalsPtr - ppi->PlaneWidth;
       if ( search_ptr < ppi->ChLocals )
-	search_ptr += ppi->ChLocalsCircularBufferSize;
+        search_ptr += ppi->ChLocalsCircularBufferSize;
       search_ptr -= 1;
-      
-      PixelLineSearch( ppi, search_ptr, RowNumber - 1, ColNumber - 1, 
-		       direction,  &TmpLineLength );    
-      
+
+      PixelLineSearch( ppi, search_ptr, RowNumber - 1, ColNumber - 1,
+                       direction,  &TmpLineLength );
+
       if ( TmpLineLength > BestLineLength )
-	BestLineLength = TmpLineLength;
-    } 
-    
+        BestLineLength = TmpLineLength;
+    }
+
     /* up and right */
-    if ( (BestLineLength < ppi->MaxLineSearchLen) && 
-	 ((direction == UP) || (direction == RIGHT)) ){   
+    if ( (BestLineLength < ppi->MaxLineSearchLen) &&
+         ((direction == UP) || (direction == RIGHT)) ){
       TmpLineLength = *line_length;
-      
+
       search_ptr = ChangedLocalsPtr - ppi->PlaneWidth;
       if ( search_ptr < ppi->ChLocals )
-	search_ptr += ppi->ChLocalsCircularBufferSize;
+        search_ptr += ppi->ChLocalsCircularBufferSize;
       search_ptr += 1;
-      
-      PixelLineSearch( ppi, search_ptr, RowNumber - 1, ColNumber + 1, 
-		       direction, &TmpLineLength );   
-      
+
+      PixelLineSearch( ppi, search_ptr, RowNumber - 1, ColNumber + 1,
+                       direction, &TmpLineLength );
+
       if ( TmpLineLength > BestLineLength )
-	BestLineLength = TmpLineLength;
+        BestLineLength = TmpLineLength;
     }
-    
+
     /* left */
-    if ( (BestLineLength < ppi->MaxLineSearchLen) && ( direction == LEFT ) ){  
+    if ( (BestLineLength < ppi->MaxLineSearchLen) && ( direction == LEFT ) ){
       TmpLineLength = *line_length;
-      PixelLineSearch( ppi, ChangedLocalsPtr - 1, RowNumber, ColNumber - 1, 
-		       direction, &TmpLineLength );    
-      
+      PixelLineSearch( ppi, ChangedLocalsPtr - 1, RowNumber, ColNumber - 1,
+                       direction, &TmpLineLength );
+
       if ( TmpLineLength > BestLineLength )
-	BestLineLength = TmpLineLength;
-    }      
-    
+        BestLineLength = TmpLineLength;
+    }
+
     /* right */
-    if ( (BestLineLength < ppi->MaxLineSearchLen) && ( direction == RIGHT ) ){ 
+    if ( (BestLineLength < ppi->MaxLineSearchLen) && ( direction == RIGHT ) ){
       TmpLineLength = *line_length;
-      PixelLineSearch( ppi, ChangedLocalsPtr + 1, RowNumber, ColNumber + 1, 
-		       direction, &TmpLineLength );    
-      
+      PixelLineSearch( ppi, ChangedLocalsPtr + 1, RowNumber, ColNumber + 1,
+                       direction, &TmpLineLength );
+
       if ( TmpLineLength > BestLineLength )
-	BestLineLength = TmpLineLength;
+        BestLineLength = TmpLineLength;
     }
-    
+
     /* Down */
-    if ( BestLineLength < ppi->MaxLineSearchLen ){   
+    if ( BestLineLength < ppi->MaxLineSearchLen ){
       TmpLineLength = *line_length;
       if ( direction == DOWN ){
-	search_ptr = ChangedLocalsPtr + ppi->PlaneWidth;
-	if ( search_ptr >= (ppi->ChLocals + ppi->ChLocalsCircularBufferSize) )
-	  search_ptr -= ppi->ChLocalsCircularBufferSize;
-	
-	PixelLineSearch( ppi, search_ptr, RowNumber + 1, ColNumber, direction,
-			 &TmpLineLength );    
-	
-	if ( TmpLineLength > BestLineLength )
-	  BestLineLength = TmpLineLength;
+        search_ptr = ChangedLocalsPtr + ppi->PlaneWidth;
+        if ( search_ptr >= (ppi->ChLocals + ppi->ChLocalsCircularBufferSize) )
+          search_ptr -= ppi->ChLocalsCircularBufferSize;
+
+        PixelLineSearch( ppi, search_ptr, RowNumber + 1, ColNumber, direction,
+                         &TmpLineLength );
+
+        if ( TmpLineLength > BestLineLength )
+          BestLineLength = TmpLineLength;
       }
-      
-      
+
+
       /* down and left */
-      if ( (BestLineLength < ppi->MaxLineSearchLen) && 
-	   ((direction == DOWN) || (direction == LEFT)) ){   
-	TmpLineLength = *line_length;
-	
-	search_ptr = ChangedLocalsPtr + ppi->PlaneWidth;
-	if ( search_ptr >= (ppi->ChLocals + ppi->ChLocalsCircularBufferSize) )
-	  search_ptr -= ppi->ChLocalsCircularBufferSize;
-	search_ptr -= 1;
-	
-	PixelLineSearch( ppi, search_ptr, RowNumber + 1, ColNumber - 1, 
-			 direction, &TmpLineLength );    
-                
-	if ( TmpLineLength > BestLineLength )
-	  BestLineLength = TmpLineLength;
-      } 
-      
+      if ( (BestLineLength < ppi->MaxLineSearchLen) &&
+           ((direction == DOWN) || (direction == LEFT)) ){
+        TmpLineLength = *line_length;
+
+        search_ptr = ChangedLocalsPtr + ppi->PlaneWidth;
+        if ( search_ptr >= (ppi->ChLocals + ppi->ChLocalsCircularBufferSize) )
+          search_ptr -= ppi->ChLocalsCircularBufferSize;
+        search_ptr -= 1;
+
+        PixelLineSearch( ppi, search_ptr, RowNumber + 1, ColNumber - 1,
+                         direction, &TmpLineLength );
+
+        if ( TmpLineLength > BestLineLength )
+          BestLineLength = TmpLineLength;
+      }
+
       /* down and right */
-      if ( (BestLineLength < ppi->MaxLineSearchLen) && 
-	   ((direction == DOWN) || (direction == RIGHT)) ){   
-	TmpLineLength = *line_length;
-	
-	search_ptr = ChangedLocalsPtr + ppi->PlaneWidth;
-	if ( search_ptr >= (ppi->ChLocals + ppi->ChLocalsCircularBufferSize) )
-	  search_ptr -= ppi->ChLocalsCircularBufferSize;
-	search_ptr += 1;
-	
-	PixelLineSearch( ppi, search_ptr, RowNumber + 1, ColNumber + 1, 
-			 direction, &TmpLineLength );   
-	
-	if ( TmpLineLength > BestLineLength )
-	  BestLineLength = TmpLineLength;
+      if ( (BestLineLength < ppi->MaxLineSearchLen) &&
+           ((direction == DOWN) || (direction == RIGHT)) ){
+        TmpLineLength = *line_length;
+
+        search_ptr = ChangedLocalsPtr + ppi->PlaneWidth;
+        if ( search_ptr >= (ppi->ChLocals + ppi->ChLocalsCircularBufferSize) )
+          search_ptr -= ppi->ChLocalsCircularBufferSize;
+        search_ptr += 1;
+
+        PixelLineSearch( ppi, search_ptr, RowNumber + 1, ColNumber + 1,
+                         direction, &TmpLineLength );
+
+        if ( TmpLineLength > BestLineLength )
+          BestLineLength = TmpLineLength;
       }
-    }    
-    
+    }
+
     /* Note the search value for this pixel. */
     *line_length = BestLineLength;
   }
 }
 
-static unsigned char LineSearchScorePixel( PP_INSTANCE *ppi, 
-					   unsigned char * ChangedLocalsPtr, 
-					   ogg_int32_t RowNumber, 
-					   ogg_int32_t ColNumber ){
-    ogg_uint32_t line_length = 0; 
-    ogg_uint32_t line_length2 = 0; 
-    ogg_uint32_t line_length_score = 0; 
-    ogg_uint32_t tmp_line_length = 0; 
-    ogg_uint32_t tmp_line_length2 = 0;  
-    
+static unsigned char LineSearchScorePixel( PP_INSTANCE *ppi,
+                                           unsigned char * ChangedLocalsPtr,
+                                           ogg_int32_t RowNumber,
+                                           ogg_int32_t ColNumber ){
+    ogg_uint32_t line_length = 0;
+    ogg_uint32_t line_length2 = 0;
+    ogg_uint32_t line_length_score = 0;
+    ogg_uint32_t tmp_line_length = 0;
+    ogg_uint32_t tmp_line_length2 = 0;
+
     /* Look UP and Down */
-    PixelLineSearch( ppi, ChangedLocalsPtr, RowNumber, 
-		     ColNumber, UP, &tmp_line_length );
+    PixelLineSearch( ppi, ChangedLocalsPtr, RowNumber,
+                     ColNumber, UP, &tmp_line_length );
 
     if (tmp_line_length < ppi->MaxLineSearchLen) {
       /* Look DOWN */
-      PixelLineSearch( ppi, ChangedLocalsPtr, RowNumber, 
-		       ColNumber, DOWN, &tmp_line_length2 );
-      line_length = tmp_line_length + tmp_line_length2 - 1; 
-      
+      PixelLineSearch( ppi, ChangedLocalsPtr, RowNumber,
+                       ColNumber, DOWN, &tmp_line_length2 );
+      line_length = tmp_line_length + tmp_line_length2 - 1;
+
       if ( line_length > ppi->MaxLineSearchLen )
-	line_length = ppi->MaxLineSearchLen;
+        line_length = ppi->MaxLineSearchLen;
     }else
-      line_length = tmp_line_length; 
-    
+      line_length = tmp_line_length;
+
     /* If no max length line found then look left and right */
-    if ( line_length < ppi->MaxLineSearchLen ){   
+    if ( line_length < ppi->MaxLineSearchLen ){
       tmp_line_length = 0;
       tmp_line_length2 = 0;
-      
-      PixelLineSearch( ppi, ChangedLocalsPtr, RowNumber, 
-		       ColNumber, LEFT,  &tmp_line_length );
+
+      PixelLineSearch( ppi, ChangedLocalsPtr, RowNumber,
+                       ColNumber, LEFT,  &tmp_line_length );
       if (tmp_line_length < ppi->MaxLineSearchLen){
-	PixelLineSearch( ppi, ChangedLocalsPtr, RowNumber, 
-			 ColNumber, RIGHT,  &tmp_line_length2 ); 
-	line_length2 = tmp_line_length + tmp_line_length2 - 1; 
-	
-	if ( line_length2 > ppi->MaxLineSearchLen )
-	  line_length2 = ppi->MaxLineSearchLen;
+        PixelLineSearch( ppi, ChangedLocalsPtr, RowNumber,
+                         ColNumber, RIGHT,  &tmp_line_length2 );
+        line_length2 = tmp_line_length + tmp_line_length2 - 1;
+
+        if ( line_length2 > ppi->MaxLineSearchLen )
+          line_length2 = ppi->MaxLineSearchLen;
       }else
-	line_length2 = tmp_line_length; 
-      
+        line_length2 = tmp_line_length;
+
     }
-    
+
     /* Take the largest line length */
     if ( line_length2 > line_length )
       line_length = line_length2;
-    
+
     /* Create line length score */
     line_length_score = LineLengthScores[line_length];
-    
+
     return (unsigned char)line_length_score;
 }
 
-static void LineSearchScoreRow( PP_INSTANCE *ppi, 
-				unsigned char * ChangedLocalsPtr, 
-				ogg_int16_t   * YUVDiffsPtr, 
-				unsigned char * PixelNoiseScorePtr, 
-				ogg_uint32_t  * FragScorePtr, 
-				signed char   * DispFragPtr,
-				ogg_int32_t     RowNumber ){ 
+static void LineSearchScoreRow( PP_INSTANCE *ppi,
+                                unsigned char * ChangedLocalsPtr,
+                                ogg_int16_t   * YUVDiffsPtr,
+                                unsigned char * PixelNoiseScorePtr,
+                                ogg_uint32_t  * FragScorePtr,
+                                signed char   * DispFragPtr,
+                                ogg_int32_t     RowNumber ){
   ogg_uint32_t AbsDiff;
-  unsigned char  changed_locals = 0; 
+  unsigned char  changed_locals = 0;
   ogg_int32_t  Score;
   ogg_uint32_t FragScore;
   ogg_int32_t  i,j;
-  
+
   /* The defining rule used here is as follows. */
   /* An edge pixels has 2-5 changed locals. */
   /* And one or more of these changed locals has itself got 7-8
      changed locals. */
-  
+
   /* Loop for all pixels in the row. */
   for ( i = 0; i < ppi->PlaneWidth; i += HFRAGPIXELS ){
     /* Does the fragment contain anything interesting to work with. */
     if ( *DispFragPtr == CANDIDATE_BLOCK ){
       /* Reset the cumulative fragment score. */
       FragScore = 0;
-      
+
       /* Pixels grouped along the row into fragments */
       for ( j = 0; j < HFRAGPIXELS; j++ ){
-	/* How many changed locals has the current pixel got. */
-	changed_locals = ChangedLocalsPtr[j];
-	
-	/* Is the pixel a suitable candidate for edge enhancement */
-	if ( (changed_locals > 1) && (changed_locals < 6) &&
-	     (PixelNoiseScorePtr[j] < ppi->LineSearchTripTresh) ) {
-	  Score = (ogg_int32_t)
-	    LineSearchScorePixel( ppi, &ChangedLocalsPtr[j], RowNumber, i+j );
-	  
-	  if ( Score ){
-	    AbsDiff = abs( YUVDiffsPtr[j] );
-	    Score = (ogg_int32_t)
-	      ( (double)Score * ppi->AbsDiff_ScoreMultiplierTable[AbsDiff] );
-	    if ( Score < 1 )
-	      Score = 1;
-	    
-	    PixelNoiseScorePtr[j] += (unsigned char)Score;  
-	    FragScore += (ogg_uint32_t)Score;
-	  }
-	}
+        /* How many changed locals has the current pixel got. */
+        changed_locals = ChangedLocalsPtr[j];
+
+        /* Is the pixel a suitable candidate for edge enhancement */
+        if ( (changed_locals > 1) && (changed_locals < 6) &&
+             (PixelNoiseScorePtr[j] < ppi->LineSearchTripTresh) ) {
+          Score = (ogg_int32_t)
+            LineSearchScorePixel( ppi, &ChangedLocalsPtr[j], RowNumber, i+j );
+
+          if ( Score ){
+            AbsDiff = abs( YUVDiffsPtr[j] );
+            Score = (ogg_int32_t)
+              ( (double)Score * ppi->AbsDiff_ScoreMultiplierTable[AbsDiff] );
+            if ( Score < 1 )
+              Score = 1;
+
+            PixelNoiseScorePtr[j] += (unsigned char)Score;
+            FragScore += (ogg_uint32_t)Score;
+          }
+        }
       }
-      
+
       /* Add fragment score (with plane correction factor) into main
          data structure */
-      *FragScorePtr += 
-	(ogg_int32_t)(FragScore * ppi->YUVPlaneCorrectionFactor);
-      
+      *FragScorePtr +=
+        (ogg_int32_t)(FragScore * ppi->YUVPlaneCorrectionFactor);
+
       /* If score is greater than trip threshold then mark blcok for update. */
       if ( *FragScorePtr > ppi->BlockThreshold ){
-	*DispFragPtr = BLOCK_CODED_LOW;
+        *DispFragPtr = BLOCK_CODED_LOW;
       }
     }
-    
+
     /* Increment the various pointers */
     FragScorePtr++;
     DispFragPtr++;
     PixelNoiseScorePtr += HFRAGPIXELS;
     ChangedLocalsPtr += HFRAGPIXELS;
     YUVDiffsPtr += HFRAGPIXELS;
-    
+
   }
 }
 
 static void RowCopy( PP_INSTANCE *ppi, ogg_uint32_t BlockMapIndex ){
 
   ogg_uint32_t   i,j;
-  
+
   ogg_uint32_t   PixelIndex = ppi->ScanPixelIndexTable[BlockMapIndex];
   signed char   * BlockMapPtr = &ppi->ScanDisplayFragments[BlockMapIndex];
   signed char   * PrevFragmentsPtr = &ppi->PrevFragments[0][BlockMapIndex];
-  
+
   unsigned char  * SourcePtr;
   unsigned char  * DestPtr;
-  
+
   /* Copy pixels from changed blocks back to reference frame. */
   for ( i = 0; i < (ogg_uint32_t)ppi->PlaneHFragments; i ++ ){
     /* If the fragement is marked for update or was recently marked
        for update (PrevFragmentsPtr[i]) */
-    if ( (BlockMapPtr[i] > BLOCK_NOT_CODED) || 
-	 (PrevFragmentsPtr[i] == BLOCK_CODED) ){
+    if ( (BlockMapPtr[i] > BLOCK_NOT_CODED) ||
+         (PrevFragmentsPtr[i] == BLOCK_CODED) ){
       /* Set up the various pointers required. */
       SourcePtr = &ppi->ScanConfig.Yuv1ptr[PixelIndex];
       DestPtr = &ppi->ScanConfig.SrfWorkSpcPtr[PixelIndex];
-      
+
       /* For each row of the block */
       for ( j = 0; j < VFRAGPIXELS; j++ ){
-	/* Copy the data unaltered from source to destination */
-	memcpy(DestPtr,SourcePtr,8);
+        /* Copy the data unaltered from source to destination */
+        memcpy(DestPtr,SourcePtr,8);
 
-	/* Increment pointers for next line in the block */
-	SourcePtr += ppi->PlaneWidth;
-	DestPtr += ppi->PlaneWidth;
+        /* Increment pointers for next line in the block */
+        SourcePtr += ppi->PlaneWidth;
+        DestPtr += ppi->PlaneWidth;
       }
     }
-    
+
     /* Increment pixel index for next block. */
     PixelIndex += HFRAGPIXELS;
   }
 }
 
-static void RowBarEnhBlockMap( PP_INSTANCE *ppi, 
-			       signed char   * UpdatedBlockMapPtr,
-			       signed char   * BarBlockMapPtr,
-			       ogg_uint32_t RowNumber ){
+static void RowBarEnhBlockMap( PP_INSTANCE *ppi,
+                               signed char   * UpdatedBlockMapPtr,
+                               signed char   * BarBlockMapPtr,
+                               ogg_uint32_t RowNumber ){
   int i;
-  
+
   /* Start by blanking the row in the bar block map structure. */
   memset( BarBlockMapPtr, BLOCK_NOT_CODED, ppi->PlaneHFragments );
 
   /* First row */
   if ( RowNumber == 0 ){
-    
+
     /* For each fragment in the row. */
     for ( i = 0; i < ppi->PlaneHFragments; i ++ ){
       /* Test for CANDIDATE_BLOCK or CANDIDATE_BLOCK_LOW. Uncoded or
-	 coded blocks will be ignored. */
+         coded blocks will be ignored. */
       if ( UpdatedBlockMapPtr[i] <= CANDIDATE_BLOCK ){
-	/* Is one of the immediate neighbours updated in the main map. */
-	/* Note special cases for blocks at the start and end of rows. */
-	if ( i == 0 ){
-	  
-	  if ((UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
-	      (UpdatedBlockMapPtr[i+ppi->PlaneHFragments]>BLOCK_NOT_CODED ) ||
-	      (UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1]>BLOCK_NOT_CODED ) )
-	    BarBlockMapPtr[i] = BLOCK_CODED_BAR;
-	  
-	  
-	}else if ( i == (ppi->PlaneHFragments - 1) ){
-                    
-	  if ((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
-	      (UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1]>BLOCK_NOT_CODED) ||
-	       (UpdatedBlockMapPtr[i+ppi->PlaneHFragments]>BLOCK_NOT_CODED) )
-	      BarBlockMapPtr[i] = BLOCK_CODED_BAR;
-                    
-	}else{
-	  if((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
-	     (UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1] > BLOCK_NOT_CODED) )
-	      BarBlockMapPtr[i] = BLOCK_CODED_BAR;
-	}
+        /* Is one of the immediate neighbours updated in the main map. */
+        /* Note special cases for blocks at the start and end of rows. */
+        if ( i == 0 ){
+
+          if ((UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
+              (UpdatedBlockMapPtr[i+ppi->PlaneHFragments]>BLOCK_NOT_CODED ) ||
+              (UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1]>BLOCK_NOT_CODED ) )
+            BarBlockMapPtr[i] = BLOCK_CODED_BAR;
+
+
+        }else if ( i == (ppi->PlaneHFragments - 1) ){
+
+          if ((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
+              (UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1]>BLOCK_NOT_CODED) ||
+               (UpdatedBlockMapPtr[i+ppi->PlaneHFragments]>BLOCK_NOT_CODED) )
+              BarBlockMapPtr[i] = BLOCK_CODED_BAR;
+
+        }else{
+          if((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
+             (UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1] > BLOCK_NOT_CODED) )
+              BarBlockMapPtr[i] = BLOCK_CODED_BAR;
+        }
       }
     }
-    
+
   } else if ( RowNumber == (ogg_uint32_t)(ppi->PlaneVFragments-1)) {
-    
+
     /* Last row */
     /* Used to read PlaneHFragments */
-    
+
     /* For each fragment in the row. */
     for ( i = 0; i < ppi->PlaneHFragments; i ++ ){
       /* Test for CANDIDATE_BLOCK or CANDIDATE_BLOCK_LOW
-	 Uncoded or coded blocks will be ignored. */
+         Uncoded or coded blocks will be ignored. */
       if ( UpdatedBlockMapPtr[i] <= CANDIDATE_BLOCK ){
-	/* Is one of the immediate neighbours updated in the main map. */
-	/* Note special cases for blocks at the start and end of rows. */
-	if ( i == 0 ){
-	  if((UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ))
-	    BarBlockMapPtr[i] = BLOCK_CODED_BAR;
-                
-	}else if ( i == (ppi->PlaneHFragments - 1) ){
-	  if((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) )
-	    BarBlockMapPtr[i] = BLOCK_CODED_BAR;
-	}else{
-	  if((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED) )
-	    BarBlockMapPtr[i] = BLOCK_CODED_BAR;
-	}
+        /* Is one of the immediate neighbours updated in the main map. */
+        /* Note special cases for blocks at the start and end of rows. */
+        if ( i == 0 ){
+          if((UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ))
+            BarBlockMapPtr[i] = BLOCK_CODED_BAR;
+
+        }else if ( i == (ppi->PlaneHFragments - 1) ){
+          if((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) )
+            BarBlockMapPtr[i] = BLOCK_CODED_BAR;
+        }else{
+          if((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED) )
+            BarBlockMapPtr[i] = BLOCK_CODED_BAR;
+        }
       }
     }
-    
+
   }else{
     /* All other rows */
     /* For each fragment in the row. */
@@ -1871,47 +1872,47 @@
       /* Test for CANDIDATE_BLOCK or CANDIDATE_BLOCK_LOW */
       /* Uncoded or coded blocks will be ignored. */
       if ( UpdatedBlockMapPtr[i] <= CANDIDATE_BLOCK ){
-	/* Is one of the immediate neighbours updated in the main map. */
-	/* Note special cases for blocks at the start and end of rows. */
-	if ( i == 0 ){
-	  
-	  if((UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED)||
-	     (UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1] > BLOCK_NOT_CODED) )
-	    BarBlockMapPtr[i] = BLOCK_CODED_BAR;
-	  
-	}else if ( i == (ppi->PlaneHFragments - 1) ){
-                    
-	  if((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
-	     (UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) )
-	    BarBlockMapPtr[i] = BLOCK_CODED_BAR;
-	  
-	}else{
-	  if((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED)||
-	     (UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
-	     (UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
-	     (UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ))
-	    BarBlockMapPtr[i] = BLOCK_CODED_BAR;
-	}
+        /* Is one of the immediate neighbours updated in the main map. */
+        /* Note special cases for blocks at the start and end of rows. */
+        if ( i == 0 ){
+
+          if((UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED)||
+             (UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1] > BLOCK_NOT_CODED) )
+            BarBlockMapPtr[i] = BLOCK_CODED_BAR;
+
+        }else if ( i == (ppi->PlaneHFragments - 1) ){
+
+          if((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
+             (UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) )
+            BarBlockMapPtr[i] = BLOCK_CODED_BAR;
+
+        }else{
+          if((UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED)||
+             (UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1] > BLOCK_NOT_CODED)||
+             (UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
+             (UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ))
+            BarBlockMapPtr[i] = BLOCK_CODED_BAR;
+        }
       }
     }
   }
 }
 
-static void BarCopyBack( PP_INSTANCE *ppi, 
-			 signed char  * UpdatedBlockMapPtr,
-			 signed char  * BarBlockMapPtr ){
+static void BarCopyBack( PP_INSTANCE *ppi,
+                         signed char  * UpdatedBlockMapPtr,
+                         signed char  * BarBlockMapPtr ){
   ogg_int32_t i;
-  
+
   /* For each fragment in the row. */
   for ( i = 0; i < ppi->PlaneHFragments; i ++ ){
     if ( BarBlockMapPtr[i] > BLOCK_NOT_CODED ){
@@ -1920,107 +1921,107 @@
   }
 }
 
-static void AnalysePlane( PP_INSTANCE *ppi, 
-			  unsigned char * PlanePtr0, 
-			  unsigned char * PlanePtr1, 
-			  ogg_uint32_t FragArrayOffset, 
-			  ogg_uint32_t PWidth, 
-			  ogg_uint32_t PHeight, 
-			  ogg_uint32_t PStride ) {
+static void AnalysePlane( PP_INSTANCE *ppi,
+                          unsigned char * PlanePtr0,
+                          unsigned char * PlanePtr1,
+                          ogg_uint32_t FragArrayOffset,
+                          ogg_uint32_t PWidth,
+                          ogg_uint32_t PHeight,
+                          ogg_uint32_t PStride ) {
   unsigned char  * RawPlanePtr0;
   unsigned char  * RawPlanePtr1;
-  
+
   ogg_int16_t  * YUVDiffsPtr;
   ogg_int16_t  * YUVDiffsPtr1;
   ogg_int16_t  * YUVDiffsPtr2;
-  
+
   ogg_uint32_t FragIndex;
   ogg_uint32_t ScoreFragIndex1;
   ogg_uint32_t ScoreFragIndex2;
   ogg_uint32_t ScoreFragIndex3;
   ogg_uint32_t ScoreFragIndex4;
-  
+
   int   UpdatedOrCandidateBlocks = 0;
-  
+
   unsigned char  * ChLocalsPtr0;
   unsigned char  * ChLocalsPtr1;
   unsigned char  * ChLocalsPtr2;
-  
+
   unsigned char  * PixelsChangedPtr0;
   unsigned char  * PixelsChangedPtr1;
-  
+
   unsigned char  * PixelScoresPtr1;
   unsigned char  * PixelScoresPtr2;
-  
+
   signed char   * DispFragPtr0;
   signed char   * DispFragPtr1;
   signed char   * DispFragPtr2;
-  
+
   ogg_uint32_t * FragScoresPtr1;
   ogg_uint32_t * FragScoresPtr2;
-  
+
   ogg_int32_t  * RowDiffsPtr;
   ogg_int32_t  * RowDiffsPtr1;
   ogg_int32_t  * RowDiffsPtr2;
-  
-  ogg_int32_t  i,j; 
-  
+
+  ogg_int32_t  i,j;
+
   ogg_int32_t  RowNumber1;
   ogg_int32_t  RowNumber2;
   ogg_int32_t  RowNumber3;
   ogg_int32_t  RowNumber4;
-  
+
   int   EdgeRow;
   ogg_int32_t  LineSearchRowNumber = 0;
-        
+
   /* Variables used as temporary stores for frequently used values. */
   ogg_int32_t  Row0Mod3;
   ogg_int32_t  Row1Mod3;
   ogg_int32_t  Row2Mod3;
   ogg_int32_t  BlockRowPixels;
-  
+
   /* Set pixel difference threshold */
   if ( FragArrayOffset == 0 ){
     /* Luminance */
     ppi->LevelThresh = (int)ppi->SgcLevelThresh;
     ppi->NegLevelThresh = -ppi->LevelThresh;
-    
+
     ppi->SrfThresh = (int)ppi->SRFGreyThresh;
     ppi->NegSrfThresh = -ppi->SrfThresh;
-    
+
     /* Scores correction for Y pixels. */
     ppi->YUVPlaneCorrectionFactor = 1.0;
-    
+
     ppi->BlockThreshold = ppi->PrimaryBlockThreshold;
     ppi->BlockSgcThresh = ppi->SgcThresh;
   }else{
     /* Chrominance */
     ppi->LevelThresh = (int)ppi->SuvcLevelThresh;
     ppi->NegLevelThresh = -ppi->LevelThresh;
-    
+
     ppi->SrfThresh = (int)ppi->SRFColThresh;
     ppi->NegSrfThresh = -ppi->SrfThresh;
-    
+
     /* Scores correction for UV pixels. */
     ppi->YUVPlaneCorrectionFactor = 1.5;
-    
+
     /* Block threholds different for subsampled U and V blocks */
-    ppi->BlockThreshold = 
+    ppi->BlockThreshold =
       (ppi->PrimaryBlockThreshold / ppi->UVBlockThreshCorrection);
-    ppi->BlockSgcThresh = 
+    ppi->BlockSgcThresh =
       (ppi->SgcThresh / ppi->UVSgcCorrection);
   }
-  
+
   /* Initialise the SRF thresh table and pointer. */
   memset( ppi->SrfThreshTable, 1, 512 );
   for ( i = ppi->NegSrfThresh; i <= ppi->SrfThresh; i++ )
     ppi->SrfThreshTable[i+255] = 0;
-  
+
   /* Initialise the PAK thresh table. */
   for ( i = -255; i <= 255; i++ )
-    if ( ppi->SrfThreshTable[i+255] && 
-	 (i <= ppi->HighChange) && 
-	 (i >= ppi->NegHighChange) )
+    if ( ppi->SrfThreshTable[i+255] &&
+         (i <= ppi->HighChange) &&
+         (i >= ppi->NegHighChange) )
       ppi->SrfPakThreshTable[i+255] = 1;
     else
       ppi->SrfPakThreshTable[i+255] = 0;
@@ -2034,248 +2035,248 @@
     else
       ppi->SgcThreshTable[i+255] = 0;
   }
-  
+
   /* Set up plane dimension variables */
   ppi->PlaneHFragments = PWidth / HFRAGPIXELS;
   ppi->PlaneVFragments = PHeight / VFRAGPIXELS;
   ppi->PlaneWidth = PWidth;
   ppi->PlaneHeight = PHeight;
   ppi->PlaneStride = PStride;
-  
+
   /* Set up local pointers into the raw image data. */
   RawPlanePtr0 = PlanePtr0;
   RawPlanePtr1 = PlanePtr1;
-  
+
   /* Note size and endo points for circular buffers. */
   ppi->YuvDiffsCircularBufferSize = YDIFF_CB_ROWS * ppi->PlaneWidth;
   ppi->ChLocalsCircularBufferSize = CHLOCALS_CB_ROWS * ppi->PlaneWidth;
   ppi->PixelMapCircularBufferSize = PMAP_CB_ROWS * ppi->PlaneWidth;
-  
+
   /* Set high change thresh where PAK not needed */
   ppi->HighChange = ppi->SrfThresh * 4;
   ppi->NegHighChange = -ppi->HighChange;
-  
+
   /* Set up row difference pointers. */
   RowDiffsPtr = ppi->RowChangedPixels;
   RowDiffsPtr1 = ppi->RowChangedPixels;
   RowDiffsPtr2 = ppi->RowChangedPixels;
-  
+
   BlockRowPixels = ppi->PlaneWidth * VFRAGPIXELS;
-  
+
   for ( i = 0; i < (ppi->PlaneVFragments + 4); i++ ){
     RowNumber1 = (i - 1);
     RowNumber2 = (i - 2);
     RowNumber3 = (i - 3);
     RowNumber4 = (i - 4);
-    
+
     /* Pre calculate some frequently used values */
     Row0Mod3 = i % 3;
     Row1Mod3 = RowNumber1 % 3;
     Row2Mod3 = RowNumber2 % 3;
-    
+
     /*  For row diff scan last two iterations are invalid */
     if ( i < ppi->PlaneVFragments ){
       FragIndex = (i * ppi->PlaneHFragments) + FragArrayOffset;
       YUVDiffsPtr = &ppi->yuv_differences[Row0Mod3 * BlockRowPixels];
-      
+
       PixelsChangedPtr0 = (&ppi->PixelChangedMap[Row0Mod3 * BlockRowPixels]);
       DispFragPtr0 =  &ppi->ScanDisplayFragments[FragIndex];
-      
+
       ChLocalsPtr0 = (&ppi->ChLocals[Row0Mod3 * BlockRowPixels]);
-      
+
     }
-    
+
     /* Set up the changed locals pointer to trail behind by one row of
        fragments. */
     if ( i > 0 ){
       /* For last iteration the ch locals and noise scans are invalid */
       if ( RowNumber1 < ppi->PlaneVFragments ){
-	ScoreFragIndex1 = (RowNumber1 * ppi->PlaneHFragments) + 
-	  FragArrayOffset;
-	
-	ChLocalsPtr1 = &ppi->ChLocals[Row1Mod3 * BlockRowPixels];
-	PixelsChangedPtr1 = 
-	  &ppi->PixelChangedMap[(Row1Mod3) * BlockRowPixels];
-      
-	PixelScoresPtr1 = &ppi->PixelScores[(RowNumber1 % 4) * BlockRowPixels];
-	
-	YUVDiffsPtr1 = &ppi->yuv_differences[Row1Mod3 * BlockRowPixels];
-	FragScoresPtr1 = &ppi->FragScores[ScoreFragIndex1];
-	DispFragPtr1 = &ppi->ScanDisplayFragments[ScoreFragIndex1];
-	
+        ScoreFragIndex1 = (RowNumber1 * ppi->PlaneHFragments) +
+          FragArrayOffset;
+
+        ChLocalsPtr1 = &ppi->ChLocals[Row1Mod3 * BlockRowPixels];
+        PixelsChangedPtr1 =
+          &ppi->PixelChangedMap[(Row1Mod3) * BlockRowPixels];
+
+        PixelScoresPtr1 = &ppi->PixelScores[(RowNumber1 % 4) * BlockRowPixels];
+
+        YUVDiffsPtr1 = &ppi->yuv_differences[Row1Mod3 * BlockRowPixels];
+        FragScoresPtr1 = &ppi->FragScores[ScoreFragIndex1];
+        DispFragPtr1 = &ppi->ScanDisplayFragments[ScoreFragIndex1];
+
       }
-      
+
       if ( RowNumber2 >= 0 ){
-	ScoreFragIndex2 = (RowNumber2 * ppi->PlaneHFragments) +
-	  FragArrayOffset;
-	ChLocalsPtr2 = (&ppi->ChLocals[Row2Mod3 * BlockRowPixels]);
-	YUVDiffsPtr2 = &ppi->yuv_differences[Row2Mod3 * BlockRowPixels];
-	
-	PixelScoresPtr2 = &ppi->PixelScores[(RowNumber2 % 4) * BlockRowPixels];
-	
-	FragScoresPtr2 =  &ppi->FragScores[ScoreFragIndex2];
-	DispFragPtr2 = &ppi->ScanDisplayFragments[ScoreFragIndex2];
+        ScoreFragIndex2 = (RowNumber2 * ppi->PlaneHFragments) +
+          FragArrayOffset;
+        ChLocalsPtr2 = (&ppi->ChLocals[Row2Mod3 * BlockRowPixels]);
+        YUVDiffsPtr2 = &ppi->yuv_differences[Row2Mod3 * BlockRowPixels];
+
+        PixelScoresPtr2 = &ppi->PixelScores[(RowNumber2 % 4) * BlockRowPixels];
+
+        FragScoresPtr2 =  &ppi->FragScores[ScoreFragIndex2];
+        DispFragPtr2 = &ppi->ScanDisplayFragments[ScoreFragIndex2];
       }else{
-	ChLocalsPtr2 = NULL;
+        ChLocalsPtr2 = NULL;
       }
     }else{
       ChLocalsPtr1 = NULL;
       ChLocalsPtr2 = NULL;
     }
-    
+
     /* Fast break out test for obvious yes and no cases in this row of
        blocks */
     if ( i < ppi->PlaneVFragments ){
-      UpdatedOrCandidateBlocks = 
-	RowSadScan( ppi, RawPlanePtr0, RawPlanePtr1, DispFragPtr0 );
+      UpdatedOrCandidateBlocks =
+        RowSadScan( ppi, RawPlanePtr0, RawPlanePtr1, DispFragPtr0 );
       if( ColSadScan( ppi, RawPlanePtr0, RawPlanePtr1, DispFragPtr0 ) )
-	UpdatedOrCandidateBlocks = 1;
+        UpdatedOrCandidateBlocks = 1;
     }else{
       /* Make sure we still call other functions if RowSadScan() disabled */
       UpdatedOrCandidateBlocks = 1;
     }
-    
+
     /* Consolidation and fast break ot tests at Row 1 level */
     if ( (i > 0) && (RowNumber1 < ppi->PlaneVFragments) ){
       /* Mark as coded any candidate block that lies adjacent to a
          coded block. */
       SadPass2( ppi, RowNumber1, DispFragPtr1 );
-      
+
       /* Check results of diff scan in last set of blocks. */
       /* Eliminate NO cases and add in +SGC cases */
-      ConsolidateDiffScanResults( ppi, &ppi->FragDiffPixels[ScoreFragIndex1], 
-				  &ppi->SameGreyDirPixels[ScoreFragIndex1], 
-				  DispFragPtr1 
-				  );
+      ConsolidateDiffScanResults( ppi, &ppi->FragDiffPixels[ScoreFragIndex1],
+                                  &ppi->SameGreyDirPixels[ScoreFragIndex1],
+                                  DispFragPtr1
+                                  );
     }
-    
+
     for ( j = 0; j < VFRAGPIXELS; j++ ){
       /* Last two iterations do not apply */
       if ( i < ppi->PlaneVFragments ){
-	/* Is the current fragment at an edge. */
-	EdgeRow = ( ( (i == 0) && (j == 0) ) ||
-		    ( (i == (ppi->PlaneVFragments - 1)) && 
-		      (j == (VFRAGPIXELS - 1)) ) );
-	
-	/* Clear the arrays that will be used for the changed pixels maps */
-	memset( PixelsChangedPtr0, 0, ppi->PlaneWidth );
-	
-	/* Difference scan and map each row */
-	if ( UpdatedOrCandidateBlocks ){
-	  /* Scan the row for interesting differences */
-	  /* Also clear the array that will be used for changed locals map */
-	  RowDiffScan( ppi, RawPlanePtr0, RawPlanePtr1, 
-		       YUVDiffsPtr, PixelsChangedPtr0, 
-		       &ppi->SameGreyDirPixels[FragIndex], 
-		       DispFragPtr0, &ppi->FragDiffPixels[FragIndex], 
-		       RowDiffsPtr, ChLocalsPtr0, EdgeRow);
-	}else{
-	  /* Clear the array that will be used for changed locals map */
-	  memset( ChLocalsPtr0, 0, ppi->PlaneWidth );
-	}
-	
-	/* The actual image plane pointers must be incremented by
-	   stride as this may be different (more) than the plane
-	   width. Our own internal buffers use ppi->PlaneWidth. */
-	RawPlanePtr0 += ppi->PlaneStride;
-	RawPlanePtr1 += ppi->PlaneStride;
-	PixelsChangedPtr0 += ppi->PlaneWidth;
-	ChLocalsPtr0 += ppi->PlaneWidth;
-	YUVDiffsPtr += ppi->PlaneWidth;
-	RowDiffsPtr++;
+        /* Is the current fragment at an edge. */
+        EdgeRow = ( ( (i == 0) && (j == 0) ) ||
+                    ( (i == (ppi->PlaneVFragments - 1)) &&
+                      (j == (VFRAGPIXELS - 1)) ) );
+
+        /* Clear the arrays that will be used for the changed pixels maps */
+        memset( PixelsChangedPtr0, 0, ppi->PlaneWidth );
+
+        /* Difference scan and map each row */
+        if ( UpdatedOrCandidateBlocks ){
+          /* Scan the row for interesting differences */
+          /* Also clear the array that will be used for changed locals map */
+          RowDiffScan( ppi, RawPlanePtr0, RawPlanePtr1,
+                       YUVDiffsPtr, PixelsChangedPtr0,
+                       &ppi->SameGreyDirPixels[FragIndex],
+                       DispFragPtr0, &ppi->FragDiffPixels[FragIndex],
+                       RowDiffsPtr, ChLocalsPtr0, EdgeRow);
+        }else{
+          /* Clear the array that will be used for changed locals map */
+          memset( ChLocalsPtr0, 0, ppi->PlaneWidth );
+        }
+
+        /* The actual image plane pointers must be incremented by
+           stride as this may be different (more) than the plane
+           width. Our own internal buffers use ppi->PlaneWidth. */
+        RawPlanePtr0 += ppi->PlaneStride;
+        RawPlanePtr1 += ppi->PlaneStride;
+        PixelsChangedPtr0 += ppi->PlaneWidth;
+        ChLocalsPtr0 += ppi->PlaneWidth;
+        YUVDiffsPtr += ppi->PlaneWidth;
+        RowDiffsPtr++;
       }
-      
+
       /* Run behind calculating the changed locals data and noise scores. */
       if ( ChLocalsPtr1 != NULL ){
-	/* Last few iterations do not apply */
-	if ( RowNumber1 < ppi->PlaneVFragments ){
-	  /* Blank the next row in the pixel scores data structure. */
-	  memset( PixelScoresPtr1, 0, ppi->PlaneWidth );
-	  
-	  /* Don't bother doing anything if there are no changed
+        /* Last few iterations do not apply */
+        if ( RowNumber1 < ppi->PlaneVFragments ){
+          /* Blank the next row in the pixel scores data structure. */
+          memset( PixelScoresPtr1, 0, ppi->PlaneWidth );
+
+          /* Don't bother doing anything if there are no changed
              pixels in this row */
-	  if ( *RowDiffsPtr1 ){
-	    /* Last valid row is a special case */
-	    if ( i < ppi->PlaneVFragments )
-	      RowChangedLocalsScan( ppi, PixelsChangedPtr1, ChLocalsPtr1, 
-				    DispFragPtr1, 
-				    ( (((i-1)==0) && (j==0)) ? 
-				      FIRST_ROW : NOT_EDGE_ROW) );
-	    else    
-	      RowChangedLocalsScan( ppi, PixelsChangedPtr1, ChLocalsPtr1, 
-				    DispFragPtr1, 
-				    ((j==(VFRAGPIXELS-1)) ? 
-				     LAST_ROW : NOT_EDGE_ROW) );
-
-	    NoiseScoreRow( ppi, PixelsChangedPtr1, ChLocalsPtr1, YUVDiffsPtr1,
-			   PixelScoresPtr1, FragScoresPtr1, DispFragPtr1, 
-			   RowDiffsPtr1 );
-	  }
-	  
-	  ChLocalsPtr1 += ppi->PlaneWidth;
-	  PixelsChangedPtr1 += ppi->PlaneWidth;
-	  YUVDiffsPtr1 += ppi->PlaneWidth;
-	  PixelScoresPtr1 += ppi->PlaneWidth;
-	  RowDiffsPtr1 ++;
-	}
-	
-	/* Run edge enhancement algorithms */
-	if ( RowNumber2 < ppi->PlaneVFragments ){
-	  if ( ChLocalsPtr2 != NULL ){
-	    /* Don't bother doing anything if there are no changed
+          if ( *RowDiffsPtr1 ){
+            /* Last valid row is a special case */
+            if ( i < ppi->PlaneVFragments )
+              RowChangedLocalsScan( ppi, PixelsChangedPtr1, ChLocalsPtr1,
+                                    DispFragPtr1,
+                                    ( (((i-1)==0) && (j==0)) ?
+                                      FIRST_ROW : NOT_EDGE_ROW) );
+            else
+              RowChangedLocalsScan( ppi, PixelsChangedPtr1, ChLocalsPtr1,
+                                    DispFragPtr1,
+                                    ((j==(VFRAGPIXELS-1)) ?
+                                     LAST_ROW : NOT_EDGE_ROW) );
+
+            NoiseScoreRow( ppi, PixelsChangedPtr1, ChLocalsPtr1, YUVDiffsPtr1,
+                           PixelScoresPtr1, FragScoresPtr1, DispFragPtr1,
+                           RowDiffsPtr1 );
+          }
+
+          ChLocalsPtr1 += ppi->PlaneWidth;
+          PixelsChangedPtr1 += ppi->PlaneWidth;
+          YUVDiffsPtr1 += ppi->PlaneWidth;
+          PixelScoresPtr1 += ppi->PlaneWidth;
+          RowDiffsPtr1 ++;
+        }
+
+        /* Run edge enhancement algorithms */
+        if ( RowNumber2 < ppi->PlaneVFragments ){
+          if ( ChLocalsPtr2 != NULL ){
+            /* Don't bother doing anything if there are no changed
                pixels in this row */
-	    if ( *RowDiffsPtr2 ){
-	      if ( RowNumber1 < ppi->PlaneVFragments ){
-		PrimaryEdgeScoreRow( ppi, ChLocalsPtr2, YUVDiffsPtr2,
-				     PixelScoresPtr2, FragScoresPtr2, 
-				     DispFragPtr2,
-				     ( (((i-2)==0) && (j==0)) ? 
-				       FIRST_ROW : NOT_EDGE_ROW)  );
-	      }else{
-		/* Edge enhancement */
-		PrimaryEdgeScoreRow( ppi, ChLocalsPtr2, YUVDiffsPtr2,
-				     PixelScoresPtr2, FragScoresPtr2, 
-				     DispFragPtr2,
-				     ((j==(VFRAGPIXELS-1)) ? 
-				      LAST_ROW : NOT_EDGE_ROW) );
-	      }
-	      
-	      /* Recursive line search */
-	      LineSearchScoreRow( ppi, ChLocalsPtr2, YUVDiffsPtr2,
-				  PixelScoresPtr2, FragScoresPtr2, 
-				  DispFragPtr2,
-				  LineSearchRowNumber );
-	    }
-	    
-	    ChLocalsPtr2 += ppi->PlaneWidth;
-	    YUVDiffsPtr2 += ppi->PlaneWidth;
-	    PixelScoresPtr2 += ppi->PlaneWidth;
-	    LineSearchRowNumber += 1;
-	    RowDiffsPtr2 ++;
-	  }
-	}
+            if ( *RowDiffsPtr2 ){
+              if ( RowNumber1 < ppi->PlaneVFragments ){
+                PrimaryEdgeScoreRow( ppi, ChLocalsPtr2, YUVDiffsPtr2,
+                                     PixelScoresPtr2, FragScoresPtr2,
+                                     DispFragPtr2,
+                                     ( (((i-2)==0) && (j==0)) ?
+                                       FIRST_ROW : NOT_EDGE_ROW)  );
+              }else{
+                /* Edge enhancement */
+                PrimaryEdgeScoreRow( ppi, ChLocalsPtr2, YUVDiffsPtr2,
+                                     PixelScoresPtr2, FragScoresPtr2,
+                                     DispFragPtr2,
+                                     ((j==(VFRAGPIXELS-1)) ?
+                                      LAST_ROW : NOT_EDGE_ROW) );
+              }
+
+              /* Recursive line search */
+              LineSearchScoreRow( ppi, ChLocalsPtr2, YUVDiffsPtr2,
+                                  PixelScoresPtr2, FragScoresPtr2,
+                                  DispFragPtr2,
+                                  LineSearchRowNumber );
+            }
+
+            ChLocalsPtr2 += ppi->PlaneWidth;
+            YUVDiffsPtr2 += ppi->PlaneWidth;
+            PixelScoresPtr2 += ppi->PlaneWidth;
+            LineSearchRowNumber += 1;
+            RowDiffsPtr2 ++;
+          }
+        }
       }
     }
-    
+
     /* BAR algorithm */
     if ( (RowNumber3 >= 0) && (RowNumber3 < ppi->PlaneVFragments) ){
       ScoreFragIndex3 = (RowNumber3 * ppi->PlaneHFragments) + FragArrayOffset;
       RowBarEnhBlockMap(ppi,
-			&ppi->ScanDisplayFragments[ScoreFragIndex3],
-			&ppi->BarBlockMap[(RowNumber3 % 3) * 
-					 ppi->PlaneHFragments],
-			RowNumber3 );
+                        &ppi->ScanDisplayFragments[ScoreFragIndex3],
+                        &ppi->BarBlockMap[(RowNumber3 % 3) *
+                                         ppi->PlaneHFragments],
+                        RowNumber3 );
     }
-    
+
     /* BAR copy back and "ppi->SRF filtering" or "pixel copy back" */
     if ( (RowNumber4 >= 0) && (RowNumber4 < ppi->PlaneVFragments) ){
       /* BAR copy back stage must lag by one more row to avoid BAR blocks
-	 being used in BAR descisions. */
+         being used in BAR descisions. */
       ScoreFragIndex4 = (RowNumber4 * ppi->PlaneHFragments) + FragArrayOffset;
-      
+
       BarCopyBack(ppi, &ppi->ScanDisplayFragments[ScoreFragIndex4],
-		  &ppi->BarBlockMap[(RowNumber4 % 3) * ppi->PlaneHFragments]);
-      
+                  &ppi->BarBlockMap[(RowNumber4 % 3) * ppi->PlaneHFragments]);
+
       /* Copy over the data from any blocks marked for update into the
          output buffer. */
       RowCopy(ppi, ScoreFragIndex4);
@@ -2284,66 +2285,66 @@
 }
 
 ogg_uint32_t YUVAnalyseFrame( PP_INSTANCE *ppi, ogg_uint32_t * KFIndicator ){
- 
+
   /* Initialise the map arrays. */
   InitScanMapArrays(ppi);
-  
+
   /* If the motion level in the previous frame was high then adjust
      the high and low SAD thresholds to speed things up. */
   ppi->ModifiedGrpLowSadThresh = ppi->GrpLowSadThresh;
   ppi->ModifiedGrpHighSadThresh = ppi->GrpHighSadThresh;
-  
-  
+
+
   /* Set up the internal plane height and width variables. */
   ppi->VideoYPlaneWidth = ppi->ScanConfig.VideoFrameWidth;
   ppi->VideoYPlaneHeight = ppi->ScanConfig.VideoFrameHeight;
   ppi->VideoUVPlaneWidth = ppi->ScanConfig.VideoFrameWidth / 2;
   ppi->VideoUVPlaneHeight = ppi->ScanConfig.VideoFrameHeight / 2;
-  
+
   /* To start with the strides will be set from the widths */
   ppi->VideoYPlaneStride = ppi->VideoYPlaneWidth;
   ppi->VideoUPlaneStride = ppi->VideoUVPlaneWidth;
   ppi->VideoVPlaneStride = ppi->VideoUVPlaneWidth;
-  
+
   /* Set up the plane pointers */
   ppi->YPlanePtr0 = ppi->ScanConfig.Yuv0ptr;
   ppi->YPlanePtr1 = ppi->ScanConfig.Yuv1ptr;
   ppi->UPlanePtr0 = (ppi->ScanConfig.Yuv0ptr + ppi->YFramePixels);
   ppi->UPlanePtr1 = (ppi->ScanConfig.Yuv1ptr + ppi->YFramePixels);
-  ppi->VPlanePtr0 = (ppi->ScanConfig.Yuv0ptr + ppi->YFramePixels + 
-		     ppi->UVFramePixels);
-  ppi->VPlanePtr1 = (ppi->ScanConfig.Yuv1ptr + ppi->YFramePixels + 
-		     ppi->UVFramePixels);
-  
+  ppi->VPlanePtr0 = (ppi->ScanConfig.Yuv0ptr + ppi->YFramePixels +
+                     ppi->UVFramePixels);
+  ppi->VPlanePtr1 = (ppi->ScanConfig.Yuv1ptr + ppi->YFramePixels +
+                     ppi->UVFramePixels);
+
   /* Check previous frame lists and if necessary mark extra blocks for
      update. */
   SetFromPrevious(ppi);
-  
+
   /* Ananlyse the U and V palnes. */
-  AnalysePlane( ppi, ppi->UPlanePtr0, ppi->UPlanePtr1, 
-		ppi->ScanYPlaneFragments, ppi->VideoUVPlaneWidth, 
-		ppi->VideoUVPlaneHeight, ppi->VideoUPlaneStride );
-  AnalysePlane( ppi, ppi->VPlanePtr0, ppi->VPlanePtr1, 
-		(ppi->ScanYPlaneFragments + ppi->ScanUVPlaneFragments), 
-		ppi->VideoUVPlaneWidth, ppi->VideoUVPlaneHeight, 
-		ppi->VideoVPlaneStride );
+  AnalysePlane( ppi, ppi->UPlanePtr0, ppi->UPlanePtr1,
+                ppi->ScanYPlaneFragments, ppi->VideoUVPlaneWidth,
+                ppi->VideoUVPlaneHeight, ppi->VideoUPlaneStride );
+  AnalysePlane( ppi, ppi->VPlanePtr0, ppi->VPlanePtr1,
+                (ppi->ScanYPlaneFragments + ppi->ScanUVPlaneFragments),
+                ppi->VideoUVPlaneWidth, ppi->VideoUVPlaneHeight,
+                ppi->VideoVPlaneStride );
 
   /* Now analyse the Y plane. */
-  AnalysePlane( ppi, ppi->YPlanePtr0, ppi->YPlanePtr1, 0, 
-		ppi->VideoYPlaneWidth, ppi->VideoYPlaneHeight,
-		ppi->VideoYPlaneStride );
+  AnalysePlane( ppi, ppi->YPlanePtr0, ppi->YPlanePtr1, 0,
+                ppi->VideoYPlaneWidth, ppi->VideoYPlaneHeight,
+                ppi->VideoYPlaneStride );
 
   /* Update the list of previous frame block updates. */
   UpdatePreviousBlockLists(ppi);
-    
+
   /* Create an output block map for the calling process. */
-  CreateOutputDisplayMap( ppi, ppi->ScanDisplayFragments, 
-			  ppi->PrevFragments[0],
-			  ppi->ScanConfig.disp_fragments );
-  
+  CreateOutputDisplayMap( ppi, ppi->ScanDisplayFragments,
+                          ppi->PrevFragments[0],
+                          ppi->ScanConfig.disp_fragments );
+
   /* Set the candidate key frame indicator (0-100) */
   *KFIndicator = ppi->KFIndicator;
-  
+
   /* Return the normalised block count (this is actually a motion
      level weighting not a true block count). */
   return ppi->OutputBlocksUpdated;

<p><p>1.26      +343 -344  theora/lib/toplevel.c

Index: toplevel.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/toplevel.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- toplevel.c	9 Jun 2003 12:39:24 -0000	1.25
+++ toplevel.c	10 Jun 2003 01:31:33 -0000	1.26
@@ -10,8 +10,8 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: toplevel.c,v 1.25 2003/06/09 12:39:24 giles Exp $
+  function:
+  last mod: $Id: toplevel.c,v 1.26 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
@@ -21,7 +21,6 @@
 #include <theora/theora.h>
 #include "encoder_internal.h"
 #include "toplevel_lookup.h"
-#include "toplevel.h"
 
 #define VERSION_MAJOR 3
 #define VERSION_MINOR 2
@@ -29,7 +28,7 @@
 
 #define VENDOR_STRING "Xiph.Org libTheora I 20030609 3 2 0"
 
-#define A_TABLE_SIZE	    29
+#define A_TABLE_SIZE        29
 #define DF_CANDIDATE_WINDOW 5
 
 static void EClearFragmentInfo(CP_INSTANCE * cpi){
@@ -63,10 +62,10 @@
     _ogg_free(cpi->PartiallyCodedMbPatterns);
   if(cpi->UncodedMbFlags)
     _ogg_free(cpi->UncodedMbFlags);
-  
+
   if(cpi->BlockCodedFlags)
     _ogg_free(cpi->BlockCodedFlags);
-  
+
   cpi->extra_fragments = 0;
   cpi->FragmentLastQ = 0;
   cpi->FragTokens = 0;
@@ -83,14 +82,14 @@
 }
 
 static void EInitFragmentInfo(CP_INSTANCE * cpi){
-  
+
   /* clear any existing info */
   EClearFragmentInfo(cpi);
-  
+
   /* Perform Fragment Allocations */
-  cpi->extra_fragments =  
+  cpi->extra_fragments =
     _ogg_malloc(cpi->pb.UnitFragments*sizeof(unsigned char));
-  
+
   /* A note to people reading and wondering why malloc returns aren't
      checked:
 
@@ -105,58 +104,58 @@
      strategy is only to allocate virtual pages, which are not mapped
      until the memory on that page is touched.  At *that* point, if
      the machine is out of heap, the page fails to be mapped and a
-     SEGV is generated.  
+     SEGV is generated.
 
      That means that is we want to deal with out of memory conditions,
      we *must* be prepared to process a SEGV.  If we implement the
      SEGV handler, there's no reason to to check malloc return; it is
      a waste of code. */
 
-  cpi->FragmentLastQ = 
+  cpi->FragmentLastQ =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->FragmentLastQ));
-  cpi->FragTokens =  
+                sizeof(*cpi->FragmentLastQ));
+  cpi->FragTokens =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->FragTokens));
+                sizeof(*cpi->FragTokens));
   cpi->OriginalDC =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->OriginalDC));
-  cpi->FragTokenCounts =  
-    _ogg_malloc(cpi->pb.UnitFragments* 
-		sizeof(*cpi->FragTokenCounts));
-  cpi->RunHuffIndices =  
+                sizeof(*cpi->OriginalDC));
+  cpi->FragTokenCounts =
+    _ogg_malloc(cpi->pb.UnitFragments*
+                sizeof(*cpi->FragTokenCounts));
+  cpi->RunHuffIndices =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->RunHuffIndices));
-  cpi->LastCodedErrorScore =  
+                sizeof(*cpi->RunHuffIndices));
+  cpi->LastCodedErrorScore =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->LastCodedErrorScore));
-  cpi->BlockCodedFlags =  
+                sizeof(*cpi->LastCodedErrorScore));
+  cpi->BlockCodedFlags =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->BlockCodedFlags));
-  cpi->ModeList =  
+                sizeof(*cpi->BlockCodedFlags));
+  cpi->ModeList =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->ModeList));
-  cpi->MVList =  
-    _ogg_malloc(cpi->pb.UnitFragments* 
-		sizeof(cpi->MVList));
+                sizeof(*cpi->ModeList));
+  cpi->MVList =
+    _ogg_malloc(cpi->pb.UnitFragments*
+                sizeof(cpi->MVList));
   cpi->DCT_codes =
     _ogg_malloc(64*
-		sizeof(*cpi->DCT_codes));
+                sizeof(*cpi->DCT_codes));
   cpi->DCTDataBuffer =
     _ogg_malloc(64*
-		sizeof(*cpi->DCTDataBuffer));
+                sizeof(*cpi->DCTDataBuffer));
   cpi->quantized_list =
     _ogg_malloc(64*
-		sizeof(*cpi->quantized_list));
-  cpi->PartiallyCodedFlags = 
-    _ogg_malloc(cpi->pb.MacroBlocks* 
-		sizeof(*cpi->PartiallyCodedFlags));
-  cpi->PartiallyCodedMbPatterns = 
-    _ogg_malloc(cpi->pb.MacroBlocks* 
-		sizeof(*cpi->PartiallyCodedMbPatterns));
-  cpi->UncodedMbFlags = 
-    _ogg_malloc(cpi->pb.MacroBlocks* 
-		sizeof(*cpi->UncodedMbFlags));
+                sizeof(*cpi->quantized_list));
+  cpi->PartiallyCodedFlags =
+    _ogg_malloc(cpi->pb.MacroBlocks*
+                sizeof(*cpi->PartiallyCodedFlags));
+  cpi->PartiallyCodedMbPatterns =
+    _ogg_malloc(cpi->pb.MacroBlocks*
+                sizeof(*cpi->PartiallyCodedMbPatterns));
+  cpi->UncodedMbFlags =
+    _ogg_malloc(cpi->pb.MacroBlocks*
+                sizeof(*cpi->UncodedMbFlags));
 
 }
 
@@ -164,7 +163,7 @@
   if(cpi->ConvDestBuffer )
     _ogg_free(cpi->ConvDestBuffer );
   cpi->ConvDestBuffer = 0;
-  
+
   if(cpi->yuv0ptr)
     _ogg_free(cpi->yuv0ptr);
   cpi->yuv0ptr = 0;
@@ -176,7 +175,7 @@
   if(cpi->OptimisedTokenListEb )
     _ogg_free(cpi->OptimisedTokenListEb);
   cpi->OptimisedTokenListEb = 0;
-  
+
   if(cpi->OptimisedTokenList )
     _ogg_free(cpi->OptimisedTokenList);
   cpi->OptimisedTokenList = 0;
@@ -188,7 +187,7 @@
   if(cpi->OptimisedTokenListPl )
     _ogg_free(cpi->OptimisedTokenListPl);
   cpi->OptimisedTokenListPl = 0;
-  
+
 }
 
 void EInitFrameInfo(CP_INSTANCE * cpi){
@@ -198,57 +197,57 @@
   EClearFrameInfo(cpi);
 
   /* allocate frames */
-  cpi->ConvDestBuffer = 
+  cpi->ConvDestBuffer =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->ConvDestBuffer));
-  cpi->yuv0ptr = 
+                sizeof(*cpi->ConvDestBuffer));
+  cpi->yuv0ptr =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->yuv0ptr));
-  cpi->yuv1ptr = 
+                sizeof(*cpi->yuv0ptr));
+  cpi->yuv1ptr =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->yuv1ptr));
-  cpi->OptimisedTokenListEb = 
+                sizeof(*cpi->yuv1ptr));
+  cpi->OptimisedTokenListEb =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->OptimisedTokenListEb));
-  cpi->OptimisedTokenList = 
+                sizeof(*cpi->OptimisedTokenListEb));
+  cpi->OptimisedTokenList =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->OptimisedTokenList));
-  cpi->OptimisedTokenListHi = 
+                sizeof(*cpi->OptimisedTokenList));
+  cpi->OptimisedTokenListHi =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->OptimisedTokenListHi));
-  cpi->OptimisedTokenListPl = 
+                sizeof(*cpi->OptimisedTokenListHi));
+  cpi->OptimisedTokenListPl =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->OptimisedTokenListPl));
+                sizeof(*cpi->OptimisedTokenListPl));
 }
 
 static void SetupKeyFrame(CP_INSTANCE *cpi) {
   /* Make sure the "last frame" buffer contains the first frame data
      as well. */
-  memcpy ( cpi->yuv0ptr, cpi->yuv1ptr, 
-	   cpi->pb.ReconYPlaneSize + 2 * cpi->pb.ReconUVPlaneSize );
+  memcpy ( cpi->yuv0ptr, cpi->yuv1ptr,
+           cpi->pb.ReconYPlaneSize + 2 * cpi->pb.ReconUVPlaneSize );
 
   /* Initialise the cpi->pb.display_fragments and other fragment
      structures for the first frame. */
   memset( cpi->pb.display_fragments, 1, cpi->pb.UnitFragments );
   memset( cpi->extra_fragments, 1, cpi->pb.UnitFragments );
-  
+
   /* Set up for a BASE/KEY FRAME */
   SetFrameType( &cpi->pb,BASE_FRAME );
 }
 
 static void AdjustKeyFrameContext(CP_INSTANCE *cpi) {
   ogg_uint32_t i;
-  ogg_uint32_t  AvKeyFrameFrequency = 
-    (ogg_uint32_t) (cpi->CurrentFrame / cpi->KeyFrameCount);  
-  ogg_uint32_t  AvKeyFrameBytes = 
+  ogg_uint32_t  AvKeyFrameFrequency =
+    (ogg_uint32_t) (cpi->CurrentFrame / cpi->KeyFrameCount);
+  ogg_uint32_t  AvKeyFrameBytes =
     (ogg_uint32_t) (cpi->TotKeyFrameBytes / cpi->KeyFrameCount);
   ogg_uint32_t TotalWeight=0;
   ogg_int32_t AvKeyFramesPerSecond;
   ogg_int32_t MinFrameTargetRate;
-  
+
   /* Update the frame carry over. */
   cpi->TotKeyFrameBytes += oggpackB_bytes(&cpi->oggbuffer);
-  
+
   /* reset keyframe context and calculate weighted average of last
      KEY_FRAME_CONTEXT keyframes */
   for( i = 0 ; i < KEY_FRAME_CONTEXT ; i ++ ) {
@@ -256,31 +255,31 @@
       cpi->PriorKeyFrameSize[i] = cpi->PriorKeyFrameSize[i+1];
       cpi->PriorKeyFrameDistance[i] = cpi->PriorKeyFrameDistance[i+1];
     } else {
-      cpi->PriorKeyFrameSize[KEY_FRAME_CONTEXT - 1] = 
-	oggpackB_bytes(&cpi->oggbuffer);
-      cpi->PriorKeyFrameDistance[KEY_FRAME_CONTEXT - 1] = 
-	cpi->LastKeyFrame;
+      cpi->PriorKeyFrameSize[KEY_FRAME_CONTEXT - 1] =
+        oggpackB_bytes(&cpi->oggbuffer);
+      cpi->PriorKeyFrameDistance[KEY_FRAME_CONTEXT - 1] =
+        cpi->LastKeyFrame;
     }
-    
-    AvKeyFrameBytes += PriorKeyFrameWeight[i] * 
+
+    AvKeyFrameBytes += PriorKeyFrameWeight[i] *
       cpi->PriorKeyFrameSize[i];
-    AvKeyFrameFrequency += PriorKeyFrameWeight[i] * 
+    AvKeyFrameFrequency += PriorKeyFrameWeight[i] *
       cpi->PriorKeyFrameDistance[i];
     TotalWeight += PriorKeyFrameWeight[i];
   }
   AvKeyFrameBytes /= TotalWeight;
   AvKeyFrameFrequency /= TotalWeight;
-  AvKeyFramesPerSecond =  100 * cpi->Configuration.OutputFrameRate / 
+  AvKeyFramesPerSecond =  100 * cpi->Configuration.OutputFrameRate /
     AvKeyFrameFrequency ;
 
   /* Calculate a new target rate per frame allowing for average key
      frame frequency over newest frames . */
-  if ( 100 * cpi->Configuration.TargetBandwidth > 
+  if ( 100 * cpi->Configuration.TargetBandwidth >
        AvKeyFrameBytes * AvKeyFramesPerSecond &&
        (100 * cpi->Configuration.OutputFrameRate - AvKeyFramesPerSecond )){
-    cpi->frame_target_rate =  
-      (ogg_int32_t)(100* cpi->Configuration.TargetBandwidth - 
-		    AvKeyFrameBytes * AvKeyFramesPerSecond ) / 
+    cpi->frame_target_rate =
+      (ogg_int32_t)(100* cpi->Configuration.TargetBandwidth -
+                    AvKeyFrameBytes * AvKeyFramesPerSecond ) /
       ( (100 * cpi->Configuration.OutputFrameRate - AvKeyFramesPerSecond ) );
   } else {
     /* don't let this number get too small!!! */
@@ -288,9 +287,9 @@
   }
 
   /* minimum allowable frame_target_rate */
-  MinFrameTargetRate = (cpi->Configuration.TargetBandwidth / 
-			cpi->Configuration.OutputFrameRate) / 3;
-  
+  MinFrameTargetRate = (cpi->Configuration.TargetBandwidth /
+                        cpi->Configuration.OutputFrameRate) / 3;
+
   if(cpi->frame_target_rate < MinFrameTargetRate ) {
     cpi->frame_target_rate = MinFrameTargetRate;
   }
@@ -301,42 +300,42 @@
 }
 
 void UpdateFrame(CP_INSTANCE *cpi){
-  
+
   double CorrectionFactor;
-  
+
   /* Reset the DC predictors. */
   cpi->pb.LastIntraDC = 0;
   cpi->pb.InvLastIntraDC = 0;
   cpi->pb.LastInterDC = 0;
   cpi->pb.InvLastInterDC = 0;
-    
+
   /* Initialise bit packing mechanism. */
   oggpackB_reset(&cpi->oggbuffer);
 
   /* mark as video frame */
   oggpackB_write(&cpi->oggbuffer,0,1);
-  
+
   /* Write out the frame header information including size. */
   WriteFrameHeader(cpi);
-  
-  /* Copy back any extra frags that are to be updated by the codec 
+
+  /* Copy back any extra frags that are to be updated by the codec
      as part of the background cleanup task */
   CopyBackExtraFrags(cpi);
-  
+
   /* Encode the data.  */
-  EncodeData(cpi); 
+  EncodeData(cpi);
 
   /* Adjust drop frame trigger. */
   if ( GetFrameType(&cpi->pb) != BASE_FRAME ) {
     /* Apply decay factor then add in the last frame size. */
-    cpi->DropFrameTriggerBytes = 
-      ((cpi->DropFrameTriggerBytes * (DF_CANDIDATE_WINDOW-1)) / 
+    cpi->DropFrameTriggerBytes =
+      ((cpi->DropFrameTriggerBytes * (DF_CANDIDATE_WINDOW-1)) /
        DF_CANDIDATE_WINDOW) + oggpackB_bytes(&cpi->oggbuffer);
   }else{
     /* Increase cpi->DropFrameTriggerBytes a little. Just after a key
        frame may actually be a good time to drop a frame. */
-    cpi->DropFrameTriggerBytes = 
-      (cpi->DropFrameTriggerBytes * DF_CANDIDATE_WINDOW) / 
+    cpi->DropFrameTriggerBytes =
+      (cpi->DropFrameTriggerBytes * DF_CANDIDATE_WINDOW) /
       (DF_CANDIDATE_WINDOW-1);
   }
 
@@ -345,49 +344,49 @@
      previous frame was not dropped then the threshold for continuing
      to allow dropped frames is reduced. */
   if ( cpi->DropFrameCandidate ) {
-    if ( cpi->DropFrameTriggerBytes > 
-	 (cpi->frame_target_rate * (DF_CANDIDATE_WINDOW+1)) )
+    if ( cpi->DropFrameTriggerBytes >
+         (cpi->frame_target_rate * (DF_CANDIDATE_WINDOW+1)) )
       cpi->DropFrameCandidate = 1;
     else
       cpi->DropFrameCandidate = 0;
   } else {
-    if ( cpi->DropFrameTriggerBytes > 
-	 (cpi->frame_target_rate * ((DF_CANDIDATE_WINDOW*2)-2)) )
+    if ( cpi->DropFrameTriggerBytes >
+         (cpi->frame_target_rate * ((DF_CANDIDATE_WINDOW*2)-2)) )
       cpi->DropFrameCandidate = 1;
     else
       cpi->DropFrameCandidate = 0;
   }
-  
+
   /* Update the BpbCorrectionFactor variable according to whether or
      not we were close enough with our selection of DCT quantiser.  */
   if ( GetFrameType(&cpi->pb) != BASE_FRAME ) {
     /* Work out a size correction factor. */
-    CorrectionFactor = (double)oggpackB_bytes(&cpi->oggbuffer) / 
+    CorrectionFactor = (double)oggpackB_bytes(&cpi->oggbuffer) /
       (double)cpi->ThisFrameTargetBytes;
-  
-    if ( (CorrectionFactor > 1.05) && 
-	 (cpi->pb.ThisFrameQualityValue < 
-	  cpi->pb.QThreshTable[cpi->Configuration.ActiveMaxQ]) ) {
+
+    if ( (CorrectionFactor > 1.05) &&
+         (cpi->pb.ThisFrameQualityValue <
+          cpi->pb.QThreshTable[cpi->Configuration.ActiveMaxQ]) ) {
       CorrectionFactor = 1.0 + ((CorrectionFactor - 1.0)/2);
       if ( CorrectionFactor > 1.5 )
-	cpi->BpbCorrectionFactor *= 1.5;
+        cpi->BpbCorrectionFactor *= 1.5;
       else
-	cpi->BpbCorrectionFactor *= CorrectionFactor;
-      
+        cpi->BpbCorrectionFactor *= CorrectionFactor;
+
       /* Keep BpbCorrectionFactor within limits */
       if ( cpi->BpbCorrectionFactor > MAX_BPB_FACTOR )
-	cpi->BpbCorrectionFactor = MAX_BPB_FACTOR;
+        cpi->BpbCorrectionFactor = MAX_BPB_FACTOR;
     } else if ( (CorrectionFactor < 0.95) &&
-		(cpi->pb.ThisFrameQualityValue > VERY_BEST_Q) ){
+                (cpi->pb.ThisFrameQualityValue > VERY_BEST_Q) ){
       CorrectionFactor = 1.0 - ((1.0 - CorrectionFactor)/2);
       if ( CorrectionFactor < 0.75 )
-	cpi->BpbCorrectionFactor *= 0.75;
+        cpi->BpbCorrectionFactor *= 0.75;
       else
-	cpi->BpbCorrectionFactor *= CorrectionFactor;
-      
+        cpi->BpbCorrectionFactor *= CorrectionFactor;
+
       /* Keep BpbCorrectionFactor within limits */
       if ( cpi->BpbCorrectionFactor < MIN_BPB_FACTOR )
-	cpi->BpbCorrectionFactor = MIN_BPB_FACTOR;
+        cpi->BpbCorrectionFactor = MIN_BPB_FACTOR;
     }
   }
 
@@ -397,14 +396,14 @@
     AdjustKeyFrameContext(cpi);
   } else {
     /* Update the frame carry over */
-    cpi->CarryOver += ((ogg_int32_t)cpi->frame_target_rate - 
-		       (ogg_int32_t)oggpackB_bytes(&cpi->oggbuffer));
+    cpi->CarryOver += ((ogg_int32_t)cpi->frame_target_rate -
+                       (ogg_int32_t)oggpackB_bytes(&cpi->oggbuffer));
   }
   cpi->TotalByteCount += oggpackB_bytes(&cpi->oggbuffer);
 }
 
-static void CompressFirstFrame(CP_INSTANCE *cpi) {                  
-  ogg_uint32_t i; 
+static void CompressFirstFrame(CP_INSTANCE *cpi) {
+  ogg_uint32_t i;
 
   /* set up context of key frame sizes and distances for more local
      datarate control */
@@ -412,156 +411,156 @@
     cpi->PriorKeyFrameSize[i] = cpi->Configuration.KeyFrameDataTarget;
     cpi->PriorKeyFrameDistance[i] = cpi->pb.info.keyframe_frequency_force;
   }
-  
+
   /* Keep track of the total number of Key Frames Coded. */
   cpi->KeyFrameCount = 1;
   cpi->LastKeyFrame = 1;
   cpi->TotKeyFrameBytes = 0;
-  
+
   /* A key frame is not a dropped frame there for reset the count of
      consequative dropped frames. */
-  cpi->DropCount = 0;     
-    
+  cpi->DropCount = 0;
+
   SetupKeyFrame(cpi);
 
   /* Calculate a new target rate per frame allowing for average key
      frame frequency and size thus far. */
-  if ( cpi->Configuration.TargetBandwidth > 
-       ((cpi->Configuration.KeyFrameDataTarget * 
-	 cpi->Configuration.OutputFrameRate)/
-	cpi->pb.info.keyframe_frequency) ) {
-
-    cpi->frame_target_rate =  
-      (ogg_int32_t)((cpi->Configuration.TargetBandwidth - 
-		     ((cpi->Configuration.KeyFrameDataTarget * 
-		       cpi->Configuration.OutputFrameRate)/
-		      cpi->pb.info.keyframe_frequency)) / 
-		    cpi->Configuration.OutputFrameRate);
-  }else 
+  if ( cpi->Configuration.TargetBandwidth >
+       ((cpi->Configuration.KeyFrameDataTarget *
+         cpi->Configuration.OutputFrameRate)/
+        cpi->pb.info.keyframe_frequency) ) {
+
+    cpi->frame_target_rate =
+      (ogg_int32_t)((cpi->Configuration.TargetBandwidth -
+                     ((cpi->Configuration.KeyFrameDataTarget *
+                       cpi->Configuration.OutputFrameRate)/
+                      cpi->pb.info.keyframe_frequency)) /
+                    cpi->Configuration.OutputFrameRate);
+  }else
     cpi->frame_target_rate = 1;
 
   /* Set baseline frame target rate. */
   cpi->BaseLineFrameTargetRate = cpi->frame_target_rate;
 
-  /* A key frame is not a dropped frame there for reset the count of 
+  /* A key frame is not a dropped frame there for reset the count of
      consequative dropped frames. */
-  cpi->DropCount = 0;     
-  
+  cpi->DropCount = 0;
+
   /* Initialise drop frame trigger to 5 frames worth of data. */
   cpi->DropFrameTriggerBytes = cpi->frame_target_rate * DF_CANDIDATE_WINDOW;
 
   /* Set a target size for this key frame based upon the baseline
      target and frequency */
   cpi->ThisFrameTargetBytes = cpi->Configuration.KeyFrameDataTarget;
-  
+
   /* Get a DCT quantizer level for the key frame. */
   cpi->MotionScore = cpi->pb.UnitFragments;
-  
+
   RegulateQ(cpi, cpi->pb.UnitFragments);
-  
+
   cpi->pb.LastFrameQualityValue = cpi->pb.ThisFrameQualityValue;
-  
+
   /* Initialise quantizer. */
-  UpdateQC(cpi, cpi->pb.ThisFrameQualityValue );  
-  
+  UpdateQC(cpi, cpi->pb.ThisFrameQualityValue );
+
   /* Initialise the cpi->pb.display_fragments and other fragment
      structures for the first frame. */
-  for ( i = 0; i < cpi->pb.UnitFragments; i ++ ) 
+  for ( i = 0; i < cpi->pb.UnitFragments; i ++ )
     cpi->FragmentLastQ[i] = cpi->pb.ThisFrameQualityValue;
 
   /* Compress and output the frist frame. */
   PickIntra( cpi,
-	     cpi->pb.YSBRows, cpi->pb.YSBCols);
-  UpdateFrame(cpi);  
-  
+             cpi->pb.YSBRows, cpi->pb.YSBCols);
+  UpdateFrame(cpi);
+
   /* Initialise the carry over rate targeting variables. */
   cpi->CarryOver = 0;
-  
+
 }
 
-static void CompressKeyFrame(CP_INSTANCE *cpi){                  
-  ogg_uint32_t  i;   
-  
+static void CompressKeyFrame(CP_INSTANCE *cpi){
+  ogg_uint32_t  i;
+
   /* Before we compress reset the carry over to the actual frame carry over */
-  cpi->CarryOver = cpi->Configuration.TargetBandwidth * cpi->CurrentFrame  / 
+  cpi->CarryOver = cpi->Configuration.TargetBandwidth * cpi->CurrentFrame  /
     cpi->Configuration.OutputFrameRate - cpi->TotalByteCount;
-  
+
   /* Keep track of the total number of Key Frames Coded */
   cpi->KeyFrameCount += 1;
-  
-  /* A key frame is not a dropped frame there for reset the count of  
+
+  /* A key frame is not a dropped frame there for reset the count of
      consequative dropped frames. */
-  cpi->DropCount = 0;     
-  
+  cpi->DropCount = 0;
+
   SetupKeyFrame(cpi);
-  
+
   /* set a target size for this frame */
-  cpi->ThisFrameTargetBytes = (ogg_int32_t) cpi->frame_target_rate + 
-    ( (cpi->Configuration.KeyFrameDataTarget - cpi->frame_target_rate) * 
+  cpi->ThisFrameTargetBytes = (ogg_int32_t) cpi->frame_target_rate +
+    ( (cpi->Configuration.KeyFrameDataTarget - cpi->frame_target_rate) *
       cpi->LastKeyFrame / cpi->pb.info.keyframe_frequency_force );
-   
+
   if ( cpi->ThisFrameTargetBytes > cpi->Configuration.KeyFrameDataTarget )
     cpi->ThisFrameTargetBytes = cpi->Configuration.KeyFrameDataTarget;
-  
+
   /* Get a DCT quantizer level for the key frame. */
   cpi->MotionScore = cpi->pb.UnitFragments;
-  
+
   RegulateQ(cpi, cpi->pb.UnitFragments);
-  
+
   cpi->pb.LastFrameQualityValue = cpi->pb.ThisFrameQualityValue;
-  
+
   /* Initialise DCT tables. */
-  UpdateQC(cpi, cpi->pb.ThisFrameQualityValue );  
-  
+  UpdateQC(cpi, cpi->pb.ThisFrameQualityValue );
+
   /* Initialise the cpi->pb.display_fragments and other fragment
      structures for the first frame. */
   for ( i = 0; i < cpi->pb.UnitFragments; i ++ )
     cpi->FragmentLastQ[i] = cpi->pb.ThisFrameQualityValue;
-  
-  
+
+
   /* Compress and output the frist frame. */
   PickIntra( cpi,
-	     cpi->pb.YSBRows, cpi->pb.YSBCols);
-  UpdateFrame(cpi);  
-  
+             cpi->pb.YSBRows, cpi->pb.YSBCols);
+  UpdateFrame(cpi);
+
 }
 
 static void CompressFrame( CP_INSTANCE *cpi) {
   ogg_int32_t min_blocks_per_frame;
-  ogg_uint32_t	i; 
+  ogg_uint32_t  i;
   int DropFrame = 0;
   ogg_uint32_t  ResidueBlocksAdded=0;
   ogg_uint32_t  KFIndicator = 0;
-  
+
   double QModStep;
   double QModifier = 1.0;
-  
+
   /* Clear down the macro block level mode and MV arrays. */
   for ( i = 0; i < cpi->pb.UnitFragments; i++ ) {
     cpi->pb.FragCodingMethod[i] = CODE_INTER_NO_MV;  /* Default coding mode */
     cpi->pb.FragMVect[i].x = 0;
     cpi->pb.FragMVect[i].y = 0;
   }
-  
+
   /* Default to normal frames. */
-  SetFrameType( &cpi->pb, NORMAL_FRAME );  
-  
-  /* Clear down the difference arrays for the current frame. */                     
+  SetFrameType( &cpi->pb, NORMAL_FRAME );
+
+  /* Clear down the difference arrays for the current frame. */
   memset( cpi->pb.display_fragments, 0, cpi->pb.UnitFragments );
   memset( cpi->extra_fragments, 0, cpi->pb.UnitFragments );
-  
-  /* Calculate the target bytes for this frame. */ 
+
+  /* Calculate the target bytes for this frame. */
   cpi->ThisFrameTargetBytes = cpi->frame_target_rate;
-  
+
   /* Correct target to try and compensate for any overall rate error
      that is developing */
-  
+
   /* Set the max allowed Q for this frame based upon carry over
      history.  First set baseline worst Q for this frame */
   cpi->Configuration.ActiveMaxQ = cpi->Configuration.MaxQ + 10;
   if ( cpi->Configuration.ActiveMaxQ >= Q_TABLE_SIZE )
     cpi->Configuration.ActiveMaxQ = Q_TABLE_SIZE - 1;
-  
+
   /* Make a further adjustment based upon the carry over and recent
    history..  cpi->Configuration.ActiveMaxQ reduced by 1 for each 1/2
    seconds worth of -ve carry over up to a limit of 6.  Also
@@ -572,15 +571,15 @@
     if ( cpi->DropFrameCandidate ) {
       cpi->Configuration.ActiveMaxQ -= 4;
     }
-    
-    if ( cpi->CarryOver < 
-	 -((ogg_int32_t)cpi->Configuration.TargetBandwidth*3) )
+
+    if ( cpi->CarryOver <
+         -((ogg_int32_t)cpi->Configuration.TargetBandwidth*3) )
       cpi->Configuration.ActiveMaxQ -= 6;
     else
-      cpi->Configuration.ActiveMaxQ += 
-	(ogg_int32_t) ((cpi->CarryOver*2) / 
-		       (ogg_int32_t)cpi->Configuration.TargetBandwidth);
-    
+      cpi->Configuration.ActiveMaxQ +=
+        (ogg_int32_t) ((cpi->CarryOver*2) /
+                       (ogg_int32_t)cpi->Configuration.TargetBandwidth);
+
     /* Check that we have not dropped quality too far */
     if ( cpi->Configuration.ActiveMaxQ < cpi->Configuration.MaxQ )
       cpi->Configuration.ActiveMaxQ = cpi->Configuration.MaxQ;
@@ -589,104 +588,104 @@
   /* Calculate the Q Modifier step size required to cause a step down
      from full target bandwidth to 40% of target between max Q and
      best Q */
-  QModStep = 0.5 / (double)((Q_TABLE_SIZE - 1) - 
-			    cpi->Configuration.ActiveMaxQ); 
+  QModStep = 0.5 / (double)((Q_TABLE_SIZE - 1) -
+                            cpi->Configuration.ActiveMaxQ);
 
   /* Set up the cpi->QTargetModifier[] table. */
   for ( i = 0; i < cpi->Configuration.ActiveMaxQ; i++ ) {
     cpi->QTargetModifier[i] = QModifier;
-  } 
+  }
   for ( i = cpi->Configuration.ActiveMaxQ; i < Q_TABLE_SIZE; i++ ) {
     cpi->QTargetModifier[i] = QModifier;
     QModifier -= QModStep;
   }
-  
+
   /* if we are allowed to drop frames and are falling behind (eg more
      than x frames worth of bandwidth) */
-  if ( cpi->pb.info.dropframes_p && 
-       ( cpi->DropCount < cpi->MaxConsDroppedFrames) && 
-       ( cpi->CarryOver < 
-	 -((ogg_int32_t)cpi->Configuration.TargetBandwidth)) &&
+  if ( cpi->pb.info.dropframes_p &&
+       ( cpi->DropCount < cpi->MaxConsDroppedFrames) &&
+       ( cpi->CarryOver <
+         -((ogg_int32_t)cpi->Configuration.TargetBandwidth)) &&
        ( cpi->DropFrameCandidate) ) {
     /* (we didn't do this frame so we should have some left over for
        the next frame) */
     cpi->CarryOver += cpi->frame_target_rate;
     DropFrame = 1;
     cpi->DropCount ++;
-    
+
     /* Adjust DropFrameTriggerBytes to account for the saving achieved. */
-    cpi->DropFrameTriggerBytes = 
-      (cpi->DropFrameTriggerBytes * 
-       (DF_CANDIDATE_WINDOW-1))/DF_CANDIDATE_WINDOW;        
+    cpi->DropFrameTriggerBytes =
+      (cpi->DropFrameTriggerBytes *
+       (DF_CANDIDATE_WINDOW-1))/DF_CANDIDATE_WINDOW;
 
     /* Even if we drop a frame we should account for it when
         considering key frame seperation. */
-    cpi->LastKeyFrame++;                                    
-  } else if ( cpi->CarryOver < 
-	      -((ogg_int32_t)cpi->Configuration.TargetBandwidth * 2) ) {
+    cpi->LastKeyFrame++;
+  } else if ( cpi->CarryOver <
+              -((ogg_int32_t)cpi->Configuration.TargetBandwidth * 2) ) {
     /* Reduce frame bit target by 1.75% for each 1/10th of a seconds
        worth of -ve carry over down to a minimum of 65% of its
        un-modified value. */
 
-    cpi->ThisFrameTargetBytes = 
-      (ogg_uint32_t)(cpi->ThisFrameTargetBytes * 0.65); 
+    cpi->ThisFrameTargetBytes =
+      (ogg_uint32_t)(cpi->ThisFrameTargetBytes * 0.65);
   } else if ( cpi->CarryOver < 0 ) {
     /* Note that cpi->CarryOver is a -ve here hence 1.0 "+" ... */
-    cpi->ThisFrameTargetBytes = 
-      (ogg_uint32_t)(cpi->ThisFrameTargetBytes * 
-		     (1.0 + ( ((cpi->CarryOver * 10)/
-			       ((ogg_int32_t)cpi->
-				Configuration.TargetBandwidth)) * 0.0175) ));
+    cpi->ThisFrameTargetBytes =
+      (ogg_uint32_t)(cpi->ThisFrameTargetBytes *
+                     (1.0 + ( ((cpi->CarryOver * 10)/
+                               ((ogg_int32_t)cpi->
+                                Configuration.TargetBandwidth)) * 0.0175) ));
   }
 
   if ( !DropFrame ) {
     /*  pick all the macroblock modes and motion vectors */
     ogg_uint32_t InterError;
     ogg_uint32_t IntraError;
-    
-    
+
+
     /* Set Baseline filter level. */
     ConfigurePP( &cpi->pp, cpi->pb.info.noise_sensitivity);
-    
-    /* Score / analyses the fragments. */ 
+
+    /* Score / analyses the fragments. */
     cpi->MotionScore = YUVAnalyseFrame(&cpi->pp, &KFIndicator );
-    
+
     /* Get the baseline Q value */
     RegulateQ( cpi, cpi->MotionScore );
-    
+
     /* Recode blocks if the error score in last frame was high. */
     ResidueBlocksAdded  = 0;
     for ( i = 0; i < cpi->pb.UnitFragments; i++ ){
       if ( !cpi->pb.display_fragments[i] ){
-	if ( cpi->LastCodedErrorScore[i] >= 
-	     ResidueErrorThresh[cpi->pb.FrameQIndex] ) {
-	  cpi->pb.display_fragments[i] = 1; /* Force block update */
-	  cpi->extra_fragments[i] = 1;      /* Insures up to date
+        if ( cpi->LastCodedErrorScore[i] >=
+             ResidueErrorThresh[cpi->pb.FrameQIndex] ) {
+          cpi->pb.display_fragments[i] = 1; /* Force block update */
+          cpi->extra_fragments[i] = 1;      /* Insures up to date
                                                pixel data is used. */
-	  ResidueBlocksAdded ++;
-	}
+          ResidueBlocksAdded ++;
+        }
       }
     }
-    
+
     /* Adjust the motion score to allow for residue blocks
        added. These are assumed to have below average impact on
        bitrate (Hence ResidueBlockFactor). */
-    cpi->MotionScore = cpi->MotionScore + 
+    cpi->MotionScore = cpi->MotionScore +
       (ResidueBlocksAdded / ResidueBlockFactor[cpi->pb.FrameQIndex]);
-    
+
     /* Estimate the min number of blocks at best Q */
-    min_blocks_per_frame = 
-      (ogg_int32_t)(cpi->ThisFrameTargetBytes / 
-		    GetEstimatedBpb( cpi, VERY_BEST_Q ));
+    min_blocks_per_frame =
+      (ogg_int32_t)(cpi->ThisFrameTargetBytes /
+                    GetEstimatedBpb( cpi, VERY_BEST_Q ));
     if ( min_blocks_per_frame == 0 )
       min_blocks_per_frame = 1;
-    
+
     /* If we have less than this number then consider adding in some
        extra blocks */
     if ( cpi->MotionScore < min_blocks_per_frame ) {
-      min_blocks_per_frame = 
-	cpi->MotionScore + 
-	(ogg_int32_t)(((min_blocks_per_frame - cpi->MotionScore) * 4) / 3 );
+      min_blocks_per_frame =
+        cpi->MotionScore +
+        (ogg_int32_t)(((min_blocks_per_frame - cpi->MotionScore) * 4) / 3 );
       UpRegulateDataStream( cpi, VERY_BEST_Q, min_blocks_per_frame );
     }else{
       /* Reset control variable for best quality final pass. */
@@ -695,19 +694,19 @@
 
     /* Get the modified Q prediction taking into account extra blocks added. */
     RegulateQ( cpi, cpi->MotionScore );
-    
+
     /* Unless we are already well ahead (4 seconds of data) of the
        projected bitrate */
-    if ( cpi->CarryOver < 
-	 (ogg_int32_t)(cpi->Configuration.TargetBandwidth * 4) ){
+    if ( cpi->CarryOver <
+         (ogg_int32_t)(cpi->Configuration.TargetBandwidth * 4) ){
       /* Look at the predicted Q (pbi->FrameQIndex).  Adjust the
-	 target bits for this frame based upon projected Q and
-	 re-calculate.  The idea is that if the Q is better than a
-	 given (good enough) level then we will try and save some bits
-	 for use in more difficult segments. */
-      cpi->ThisFrameTargetBytes = 
-	(ogg_int32_t) (cpi->ThisFrameTargetBytes * 
-		       cpi->QTargetModifier[cpi->pb.FrameQIndex]);
+         target bits for this frame based upon projected Q and
+         re-calculate.  The idea is that if the Q is better than a
+         given (good enough) level then we will try and save some bits
+         for use in more difficult segments. */
+      cpi->ThisFrameTargetBytes =
+        (ogg_int32_t) (cpi->ThisFrameTargetBytes *
+                       cpi->QTargetModifier[cpi->pb.FrameQIndex]);
 
       /* Recalculate Q again */
       RegulateQ( cpi, cpi->MotionScore );
@@ -716,43 +715,43 @@
 
     /* Select modes and motion vectors for each of the blocks : return
        an error score for inter and intra */
-    PickModes( cpi, cpi->pb.YSBRows, cpi->pb.YSBCols, 
-	       cpi->pb.info.width, 
-	       &InterError, &IntraError );
+    PickModes( cpi, cpi->pb.YSBRows, cpi->pb.YSBCols,
+               cpi->pb.info.width,
+               &InterError, &IntraError );
 
     /* decide whether we really should have made this frame a key frame */
 
     if( cpi->pb.info.keyframe_auto_p){
-      if( ( ( 2* IntraError < 5 * InterError ) 
-	    && ( KFIndicator >= (ogg_uint32_t) 
-		 cpi->pb.info.keyframe_auto_threshold)
-	    && ( cpi->LastKeyFrame > cpi->pb.info.keyframe_mindistance)
-	    ) ||
-	  (cpi->LastKeyFrame >= (ogg_uint32_t)
-	   cpi->pb.info.keyframe_frequency_force) ){
-	
-	CompressKeyFrame(cpi);  /* Code a key frame */
-	return;
+      if( ( ( 2* IntraError < 5 * InterError )
+            && ( KFIndicator >= (ogg_uint32_t)
+                 cpi->pb.info.keyframe_auto_threshold)
+            && ( cpi->LastKeyFrame > cpi->pb.info.keyframe_mindistance)
+            ) ||
+          (cpi->LastKeyFrame >= (ogg_uint32_t)
+           cpi->pb.info.keyframe_frequency_force) ){
+
+        CompressKeyFrame(cpi);  /* Code a key frame */
+        return;
       }
-      
+
     }
-    
+
     /* Increment the frames since last key frame count */
     cpi->LastKeyFrame++;
-    
+
     if ( cpi->MotionScore > 0 ){
       cpi->DropCount = 0;
-      
+
       /* Proceed with the frame update. */
-      UpdateFrame(cpi);  
-      
+      UpdateFrame(cpi);
+
       /* Note the Quantizer used for each block coded. */
       for ( i = 0; i < cpi->pb.UnitFragments; i++ ){
-	if ( cpi->pb.display_fragments[i] ){
-	  cpi->FragmentLastQ[i] = cpi->pb.ThisFrameQualityValue;
-	}
+        if ( cpi->pb.display_fragments[i] ){
+          cpi->FragmentLastQ[i] = cpi->pb.ThisFrameQualityValue;
+        }
       }
-      
+
     }
   }else{
     /* even if we 'drop' a frame, a placeholder must be written as we
@@ -761,7 +760,7 @@
     UpdateFrame(cpi);
   }
 }
- 
+
 static int _ilog(unsigned int v){
   int ret=0;
   while(v){
@@ -771,7 +770,7 @@
   return(ret);
 }
 
- 
+
 /********************** The toplevel: encode ***********************/
 
 const char *theora_version_string(void){
@@ -784,12 +783,12 @@
 
 int theora_encode_init(theora_state *th, theora_info *c){
   int i;
-  
+
   CP_INSTANCE *cpi;
 
   memset(th, 0, sizeof(*th));
   th->internal_encode=cpi=_ogg_calloc(1,sizeof(*cpi));
-  
+
   c->version_major=VERSION_MAJOR;
   c->version_minor=VERSION_MINOR;
   c->version_subminor=VERSION_SUB;
@@ -804,14 +803,14 @@
   cpi->Configuration.FirstFrameQ = c->quality;
   cpi->Configuration.MaxQ = c->quality;
   cpi->Configuration.ActiveMaxQ = c->quality;
-  
-  cpi->MVChangeFactor    =    14;     
-  cpi->FourMvChangeFactor =   8;           
-  cpi->MinImprovementForNewMV = 25;   
+
+  cpi->MVChangeFactor    =    14;
+  cpi->FourMvChangeFactor =   8;
+  cpi->MinImprovementForNewMV = 25;
   cpi->ExhaustiveSearchThresh = 2500;
-  cpi->MinImprovementForFourMV = 100;   
+  cpi->MinImprovementForFourMV = 100;
   cpi->FourMVThreshold = 10000;
-  cpi->BitRateCapFactor = 1.50;    
+  cpi->BitRateCapFactor = 1.50;
   cpi->InterTripOutThresh = 5000;
   cpi->MVEnabled = 1;
   cpi->InterCodeCount = 127;
@@ -847,26 +846,26 @@
   th->granulepos=-1;
 
   /* Set up default values for QTargetModifier[Q_TABLE_SIZE] table */
-  for ( i = 0; i < Q_TABLE_SIZE; i++ ) 
+  for ( i = 0; i < Q_TABLE_SIZE; i++ )
     cpi->QTargetModifier[i] = 1.0;
- 
+
   /* Set up an encode buffer */
-  oggpackB_writeinit(&cpi->oggbuffer);  
+  oggpackB_writeinit(&cpi->oggbuffer);
 
   /* Set data rate related variables. */
   cpi->Configuration.TargetBandwidth = (c->target_bitrate) / 8;
-  
+
   cpi->Configuration.OutputFrameRate =
     (double)( c->fps_numerator /
-	      c->fps_denominator );
+              c->fps_denominator );
 
   cpi->frame_target_rate = cpi->Configuration.TargetBandwidth /
-    cpi->Configuration.OutputFrameRate; 
-  
+    cpi->Configuration.OutputFrameRate;
+
   /* Set key frame data rate target; this is nominal keyframe size */
-  cpi->Configuration.KeyFrameDataTarget = (c->keyframe_data_target_bitrate * 
-					   c->fps_numerator /
-					   c->fps_denominator ) / 8;
+  cpi->Configuration.KeyFrameDataTarget = (c->keyframe_data_target_bitrate *
+                                           c->fps_numerator /
+                                           c->fps_denominator ) / 8;
 
   /* Note the height and width in the pre-processor control structure. */
   cpi->ScanConfig.VideoFrameHeight = cpi->pb.info.height;
@@ -888,38 +887,38 @@
 
   /* Initialise Motion compensation */
   InitMotionCompensation(cpi);
-  
+
   /* Initialise the compression process. */
-  /* We always start at frame 1 */                 
-  cpi->CurrentFrame = 1;   
-  
+  /* We always start at frame 1 */
+  cpi->CurrentFrame = 1;
+
   /* Reset the rate targeting correction factor. */
   cpi->BpbCorrectionFactor = 1.0;
-  
+
   cpi->TotalByteCount = 0;
   cpi->TotalMotionScore = 0;
-  
+
   /* Up regulation variables. */
   cpi->FinalPassLastPos = 0;  /* Used to regulate a final unrestricted pass. */
-  cpi->LastEndSB = 0;	      /* Where we were in the loop last time.  */
+  cpi->LastEndSB = 0;         /* Where we were in the loop last time.  */
   cpi->ResidueLastEndSB = 0;  /* Where we were in the residue update
                                  loop last time. */
-  
+
   InitHuffmanSet(&cpi->pb);
 
   /* This makes sure encoder version specific tables are initialised */
-  InitQTables(&cpi->pb);  
-  
+  InitQTables(&cpi->pb);
+
   /* Indicate that the next frame to be compressed is the first in the
      current clip. */
   cpi->ThisIsFirstFrame = 1;
   cpi->readyflag = 1;
-  
+
   return 0;
 }
 
-int theora_encode_YUVin(theora_state *t, 
-			 yuv_buffer *yuv){
+int theora_encode_YUVin(theora_state *t,
+                         yuv_buffer *yuv){
   ogg_int32_t i;
   unsigned char *LocalDataPtr;
   unsigned char *InputDataPtr;
@@ -934,7 +933,7 @@
     return(-1);
 
 
-  /* Copy over input YUV to internal YUV buffers. */  
+  /* Copy over input YUV to internal YUV buffers. */
   /* First copy over the Y data */
   LocalDataPtr = cpi->yuv1ptr;
   InputDataPtr = yuv->y;
@@ -952,9 +951,9 @@
     LocalDataPtr += yuv->uv_width;
     InputDataPtr += yuv->uv_stride;
   }
-  
+
   /* Now copy over the V data */
-  LocalDataPtr = 
+  LocalDataPtr =
     &cpi->yuv1ptr[((yuv->y_height*yuv->y_width)*5)/4];
   InputDataPtr = yuv->v;
   for ( i = 0; i < yuv->uv_height; i++ ){
@@ -982,16 +981,16 @@
   cpi->packetflag=1;
 
   t->granulepos=
-    ((cpi->CurrentFrame-cpi->LastKeyFrame-1)<<cpi->pb.keyframe_granule_shift)+ 
+    ((cpi->CurrentFrame-cpi->LastKeyFrame-1)<<cpi->pb.keyframe_granule_shift)+
     cpi->LastKeyFrame-1;
-  
+
   return 0;
 }
 
 int theora_encode_packetout( theora_state *t, int last_p, ogg_packet *op){
   CP_INSTANCE *cpi=(CP_INSTANCE *)(t->internal_encode);
   long bytes=oggpackB_bytes(&cpi->oggbuffer);
-  
+
   if(!bytes)return(0);
   if(!cpi->packetflag)return(0);
   if(cpi->doneflag)return(-1);
@@ -1000,7 +999,7 @@
   op->bytes=bytes;
   op->b_o_s=0;
   op->e_o_s=last_p;
-  
+
   op->packetno=cpi->CurrentFrame;
   op->granulepos=t->granulepos;
 
@@ -1013,19 +1012,19 @@
 static void _tp_readbuffer(oggpack_buffer *opb, char *buf, const long len)
 {
   long i;
-  
+
   for (i = 0; i < len; i++)
-    *buf++=oggpack_read(opb,8);
+    *buf++=(char)oggpack_read(opb,8);
 }
 
 static void _tp_writebuffer(oggpack_buffer *opb, const char *buf, const long len)
 {
   long i;
-  
+
   for (i = 0; i < len; i++)
     oggpack_write(opb, *buf++, 8);
 }
- 
+
 /* build the initial short header for stream recognition and format */
 int theora_encode_header(theora_state *t, ogg_packet *op){
   CP_INSTANCE *cpi=(CP_INSTANCE *)(t->internal_encode);
@@ -1033,7 +1032,7 @@
   oggpackB_reset(&cpi->oggbuffer);
   oggpackB_write(&cpi->oggbuffer,0x80,8);
   _tp_writebuffer(&cpi->oggbuffer, "theora", 6);
-  
+
   oggpackB_write(&cpi->oggbuffer,VERSION_MAJOR,8);
   oggpackB_write(&cpi->oggbuffer,VERSION_MINOR,8);
   oggpackB_write(&cpi->oggbuffer,VERSION_SUB,8);
@@ -1061,9 +1060,9 @@
 
   op->b_o_s=1;
   op->e_o_s=0;
-  
+
   op->packetno=0;
-  
+
   op->granulepos=0;
   cpi->packetflag=0;
 
@@ -1080,10 +1079,10 @@
   oggpack_writeinit(&opb);
   oggpack_write(&opb, 0x81, 8);
   _tp_writebuffer(&opb, "theora", 6);
-  
+
   oggpack_write(&opb, vendor_length, 32);
   _tp_writebuffer(&opb, vendor, vendor_length);
-  
+
   oggpack_write(&opb, tc->comments, 32);
   if(tc->comments){
     int i;
@@ -1106,10 +1105,10 @@
 
   op->b_o_s=0;
   op->e_o_s=0;
-  
+
   op->packetno=0;
   op->granulepos=0;
-  
+
   return (0);
 }
 
@@ -1121,7 +1120,7 @@
   oggpackB_reset(&cpi->oggbuffer);
   oggpackB_write(&cpi->oggbuffer,0x82,8);
   _tp_writebuffer(&cpi->oggbuffer,"theora",6);
-  
+
   WriteQTables(&cpi->pb,&cpi->oggbuffer);
   WriteHuffmanTrees(cpi->pb.HuffRoot_VP3x,&cpi->oggbuffer);
 
@@ -1130,9 +1129,9 @@
 
   op->b_o_s=0;
   op->e_o_s=0;
-  
+
   op->packetno=0;
-  
+
   op->granulepos=0;
   cpi->packetflag=0;
 
@@ -1157,19 +1156,19 @@
   if(t){
     CP_INSTANCE *cpi=(CP_INSTANCE *)(t->internal_encode);
     PB_INSTANCE *pbi=(PB_INSTANCE *)(t->internal_decode);
-    
+
     if(cpi){
-      
+
       ClearHuffmanSet(&cpi->pb);
       ClearFragmentInfo(&cpi->pb);
       ClearFrameInfo(&cpi->pb);
       EClearFragmentInfo(cpi);
-      EClearFrameInfo(cpi);		
+      EClearFrameInfo(cpi);
       ClearTmpBuffers(&cpi->pb);
       ClearPPInstance(&cpi->pp);
 
-	  _ogg_free(t->internal_encode);
-      
+          _ogg_free(t->internal_encode);
+
     }
 
     if(pbi){
@@ -1191,9 +1190,9 @@
 static int _theora_unpack_info(theora_info *ci, oggpack_buffer *opb){
   long ret;
 
-  ci->version_major=oggpackB_read(opb,8);
-  ci->version_minor=oggpackB_read(opb,8);
-  ci->version_subminor=oggpackB_read(opb,8);
+  ci->version_major=(unsigned char)oggpackB_read(opb,8);
+  ci->version_minor=(unsigned char)oggpackB_read(opb,8);
+  ci->version_subminor=(unsigned char)oggpackB_read(opb,8);
 
   if(ci->version_major!=VERSION_MAJOR)return(OC_VERSION);
   if(ci->version_minor>VERSION_MINOR)return(OC_VERSION);
@@ -1313,7 +1312,7 @@
 
   ci=(codec_setup_info *)c->codec_setup;
   th->internal_decode=pbi=_ogg_calloc(1,sizeof(*pbi));
-  
+
   InitPBInstance(pbi);
   memcpy(&pbi->info,c,sizeof(*c));
   pbi->info.codec_setup=NULL;
@@ -1343,7 +1342,7 @@
 int theora_decode_packetin(theora_state *th,ogg_packet *op){
   int ret;
   PB_INSTANCE *pbi=(PB_INSTANCE *)(th->internal_decode);
-  
+
   pbi->DecoderErrorCode = 0;
   oggpackB_readinit(&pbi->opb,op->packet,op->bytes);
 
@@ -1352,7 +1351,7 @@
     ret=LoadAndDecode(pbi);
 
     if(ret)return ret;
-    
+
     if(pbi->PostProcessingLevel)
       PostProcess(pbi);
 
@@ -1360,18 +1359,18 @@
       th->granulepos=op->granulepos;
     else{
       if(th->granulepos==-1){
-	th->granulepos=0;
+        th->granulepos=0;
       }else{
-	if(pbi->FrameType==BASE_FRAME){
-	  long frames= th->granulepos & ((1<<pbi->keyframe_granule_shift)-1);
-	  th->granulepos>>=pbi->keyframe_granule_shift;
-	  th->granulepos+=frames+1;
-	  th->granulepos<<=pbi->keyframe_granule_shift;
-	}else
-	  th->granulepos++;
+        if(pbi->FrameType==BASE_FRAME){
+          long frames= th->granulepos & ((1<<pbi->keyframe_granule_shift)-1);
+          th->granulepos>>=pbi->keyframe_granule_shift;
+          th->granulepos+=frames+1;
+          th->granulepos<<=pbi->keyframe_granule_shift;
+        }else
+          th->granulepos++;
       }
     }
-           
+
     return(0);
   }
 
@@ -1384,11 +1383,11 @@
   yuv->y_width = pbi->info.width;
   yuv->y_height = pbi->info.height;
   yuv->y_stride = pbi->YStride;
-  
+
   yuv->uv_width = pbi->info.width / 2;
   yuv->uv_height = pbi->info.height / 2;
   yuv->uv_stride = pbi->UVStride;
-  
+
   if(pbi->PostProcessingLevel){
     yuv->y = &pbi->PostProcessBuffer[pbi->ReconYDataOffset];
     yuv->u = &pbi->PostProcessBuffer[pbi->ReconUDataOffset];
@@ -1407,7 +1406,7 @@
 double theora_granule_time(theora_state *th,ogg_int64_t granulepos){
   CP_INSTANCE *cpi=(CP_INSTANCE *)(th->internal_encode);
   PB_INSTANCE *pbi=(PB_INSTANCE *)(th->internal_decode);
-  
+
   if(cpi)pbi=&cpi->pb;
 
   if(granulepos>=0){

<p><p>1.3       +10 -11    theora/lib/toplevel_lookup.h

Index: toplevel_lookup.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/toplevel_lookup.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- toplevel_lookup.h	8 Jun 2003 00:08:38 -0000	1.2
+++ toplevel_lookup.h	10 Jun 2003 01:31:33 -0000	1.3
@@ -10,24 +10,24 @@
  *                                                                  *
  ********************************************************************
 
-  function: 
-  last mod: $Id: toplevel_lookup.h,v 1.2 2003/06/08 00:08:38 giles Exp $
+  function:
+  last mod: $Id: toplevel_lookup.h,v 1.3 2003/06/10 01:31:33 tterribe Exp $
 
  ********************************************************************/
 
 ogg_uint32_t PriorKeyFrameWeight[KEY_FRAME_CONTEXT] = { 1,2,3,4,5 };
 
 /* Data structures controlling addition of residue blocks */
-ogg_uint32_t ResidueErrorThresh[Q_TABLE_SIZE] =  {    
-  750, 700, 650, 600, 590, 580, 570, 560, 
-  550, 540, 530, 520, 510, 500, 490, 480,  
-  470, 460, 450, 440, 430, 420, 410, 400, 
-  390, 380, 370, 360, 350, 340, 330, 320, 
-  310, 300, 290, 280, 270, 260, 250, 245, 
-  240, 235, 230, 225, 220, 215, 210, 205, 
+ogg_uint32_t ResidueErrorThresh[Q_TABLE_SIZE] =  {
+  750, 700, 650, 600, 590, 580, 570, 560,
+  550, 540, 530, 520, 510, 500, 490, 480,
+  470, 460, 450, 440, 430, 420, 410, 400,
+  390, 380, 370, 360, 350, 340, 330, 320,
+  310, 300, 290, 280, 270, 260, 250, 245,
+  240, 235, 230, 225, 220, 215, 210, 205,
   200, 195, 190, 185, 180, 175, 170, 165,
   160, 155, 150, 145, 140, 135, 130, 130 };
-ogg_uint32_t ResidueBlockFactor[Q_TABLE_SIZE] =  {    
+ogg_uint32_t ResidueBlockFactor[Q_TABLE_SIZE] =  {
   3,   3,   3,   3,   3,   3,   3,   3,
   3,   3,   3,   3,   3,   3,   3,   3,
   3,   3,   3,   3,   3,   3,   3,   3,
@@ -36,4 +36,3 @@
   2,   2,   2,   2,   2,   2,   2,   2,
   2,   2,   2,   2,   2,   2,   2,   2,
   2,   2,   2,   2,   2,   2,   2,   2 };
-

<p><p>1.8       +175 -177  theora/win32/experimental/splayer/splayer.c

Index: splayer.c
===================================================================
RCS file: /usr/local/cvsroot/theora/win32/experimental/splayer/splayer.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- splayer.c	9 Jun 2003 15:42:07 -0000	1.7
+++ splayer.c	10 Jun 2003 01:31:34 -0000	1.8
@@ -13,7 +13,7 @@
   function: example SDL player application; plays Ogg Theora files (with
             optional Vorbis audio second stream)
  * Modified by M. Piacentini http://www.tabuleiro.com
- * from the original Theora Alpha player_sample files 
+ * from the original Theora Alpha player_sample files
  *
  * Modified to build on Windows and use PortAudio as the audio
  * and synchronization layer, calculating license.
@@ -45,7 +45,7 @@
 
 
 /* Ogg and codec state for demux/decode */
-ogg_sync_state   oy; 
+ogg_sync_state   oy;
 ogg_page         og;
 ogg_stream_state vo;
 ogg_stream_state to;
@@ -102,73 +102,73 @@
 
 static void usage(void){
   printf("Usage: splayer ogg_file\n\n"
-	  "or drag and drop an ogg file over the .exe\n\n");
+	 "or drag and drop an ogg file over the .exe\n\n");
   exit(1);
 }
 
 static int open_audio(){
-	/* this will open one circular audio stream*/
-	/*build on top of portaudio routines*/
-	/*implementation on fille pastreamio.c*/
+  /* this will open one circular audio stream*/
+  /*build on top of portaudio routines*/
+  /*implementation on fille pastreamio.c*/
 
-	int        numSamples;
-    int        numBytes;
+  int        numSamples;
+  int        numBytes;
 
-	int minNumBuffers;
-	int numFrames;
+  int minNumBuffers;
+  int numFrames;
 
-	minNumBuffers = 2 * Pa_GetMinNumBuffers( FRAMES_PER_BUFFER, vi.rate );
-    numFrames = minNumBuffers * FRAMES_PER_BUFFER;
-    numFrames = RoundUpToNextPowerOf2( numFrames );
+  minNumBuffers = 2 * Pa_GetMinNumBuffers( FRAMES_PER_BUFFER, vi.rate );
+  numFrames = minNumBuffers * FRAMES_PER_BUFFER;
+  numFrames = RoundUpToNextPowerOf2( numFrames );
 
-    numSamples = numFrames * vi.channels;
-    numBytes = numSamples * sizeof(SAMPLE);
+  numSamples = numFrames * vi.channels;
+  numBytes = numSamples * sizeof(SAMPLE);
 
-    samples = (SAMPLE *) malloc( numBytes );
+  samples = (SAMPLE *) malloc( numBytes );
 
-	/*store our latency calculation here*/
-	latency_sec =  (double) numFrames / vi.rate / vi.channels;
-	printf( "Latency: %.04f\n", latency_sec );
+  /*store our latency calculation here*/
+  latency_sec =  (double) numFrames / vi.rate / vi.channels;
+  printf( "Latency: %.04f\n", latency_sec );
 
-	err = OpenAudioStream( &aOutStream, vi.rate, PA_SAMPLE_TYPE,
-                           (PASTREAMIO_WRITE | PASTREAMIO_STEREO) );
-    if( err != paNoError ) goto error;
-    return err;
+  err = OpenAudioStream( &aOutStream, vi.rate, PA_SAMPLE_TYPE,
+                        (PASTREAMIO_WRITE | PASTREAMIO_STEREO) );
+  if( err != paNoError ) goto error;
+  return err;
 error:
-	CloseAudioStream( aOutStream );
-    printf( "An error occured while opening the portaudio stream\n" );
-    printf( "Error number: %d\n", err );
-    printf( "Error message: %s\n", Pa_GetErrorText( err ) );
-    return err;
-	
+  CloseAudioStream( aOutStream );
+  printf( "An error occured while opening the portaudio stream\n" );
+  printf( "Error number: %d\n", err );
+  printf( "Error message: %s\n", Pa_GetErrorText( err ) );
+  return err;
+
 }
 
 static int start_audio(){
-	err = StartAudioStream(aOutStream);
-    if( err != paNoError ) goto error;
-	
-    return err;
+  err = StartAudioStream(aOutStream);
+  if( err != paNoError ) goto error;
+
+  return err;
 error:
-	CloseAudioStream( aOutStream );
-    printf( "An error occured while opening the portaudio stream\n" );
-    printf( "Error number: %d\n", err );
-    printf( "Error message: %s\n", Pa_GetErrorText( err ) );
-    return err;
+  CloseAudioStream( aOutStream );
+  printf( "An error occured while opening the portaudio stream\n" );
+  printf( "Error number: %d\n", err );
+  printf( "Error message: %s\n", Pa_GetErrorText( err ) );
+  return err;
 }
 
 static int audio_close(void){
-	err = CloseAudioStream( aOutStream );
-	if( err != paNoError ) goto error;
-	
-	free(samples);
-    return err;
+  err = CloseAudioStream( aOutStream );
+  if( err != paNoError ) goto error;
+
+  free(samples);
+  return err;
 
 error:
-    Pa_Terminate();
-    printf( "An error occured while closing the portaudio stream\n" );
-    printf( "Error number: %d\n", err );
-    printf( "Error message: %s\n", Pa_GetErrorText( err ) );
-    return err;
+  Pa_Terminate();
+  printf( "An error occured while closing the portaudio stream\n" );
+  printf( "Error number: %d\n", err );
+  printf( "Error message: %s\n", Pa_GetErrorText( err ) );
+  return err;
 }
 
 
@@ -183,65 +183,65 @@
 
 
 static void open_video(void){
-	/*taken from player_sample.c test file for theora alpha*/
+  /*taken from player_sample.c test file for theora alpha*/
 
   if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
     printf("Unable to init SDL: %s\n", SDL_GetError());
     exit(1);
   }
-  
+
   screen = SDL_SetVideoMode(ti.frame_width, ti.frame_height, 0, SDL_SWSURFACE);
   if ( screen == NULL ) {
-    printf("Unable to set %dx%d video: %s\n", 
+    printf("Unable to set %dx%d video: %s\n",
             ti.frame_width,ti.frame_height,SDL_GetError());
     exit(1);
   }
-  
+
   yuv_overlay = SDL_CreateYUVOverlay(ti.frame_width, ti.frame_height,
                                      SDL_YV12_OVERLAY,
                                      screen);
   if ( yuv_overlay == NULL ) {
-    printf("SDL: Couldn't create SDL_yuv_overlay: %s\n", 
+    printf("SDL: Couldn't create SDL_yuv_overlay: %s\n",
             SDL_GetError());
     exit(1);
   }
   rect.x = 0;
   rect.y = 0;
-  rect.w = ti.frame_width;
-  rect.h = ti.frame_height;
+  rect.w = (Uint16)ti.frame_width;
+  rect.h = (Uint16)ti.frame_height;
 
   SDL_DisplayYUVOverlay(yuv_overlay, &rect);
 }
 
 static void video_write(void){
-	/*taken from player_sample.c test file for theora alpha*/
+  /*taken from player_sample.c test file for theora alpha*/
   int i;
   yuv_buffer yuv;
   int crop_offset;
   theora_decode_YUVout(&td,&yuv);
-  
+
   /* Lock SDL_yuv_overlay */
   if ( SDL_MUSTLOCK(screen) ) {
     if ( SDL_LockSurface(screen) < 0 ) return;
   }
   if (SDL_LockYUVOverlay(yuv_overlay) < 0) return;
-  
+
   /* let's draw the data (*yuv[3]) on a SDL screen (*screen) */
   /* deal with border stride */
   /* reverse u and v for SDL */
   /* and crop input properly, respecting the encoded frame rect */
   crop_offset=ti.offset_x+yuv.y_stride*ti.offset_y;
   for(i=0;i<yuv_overlay->h;i++)
-    memcpy(yuv_overlay->pixels[0]+yuv_overlay->pitches[0]*i, 
-	   yuv.y+crop_offset+yuv.y_stride*i, 
+    memcpy(yuv_overlay->pixels[0]+yuv_overlay->pitches[0]*i,
+	   yuv.y+crop_offset+yuv.y_stride*i,
            yuv_overlay->w);
   crop_offset=(ti.offset_x/2)+(yuv.uv_stride)*(ti.offset_y/2);
   for(i=0;i<yuv_overlay->h/2;i++){
-    memcpy(yuv_overlay->pixels[1]+yuv_overlay->pitches[1]*i, 
-	   yuv.v+crop_offset+yuv.uv_stride*i, 
+    memcpy(yuv_overlay->pixels[1]+yuv_overlay->pitches[1]*i,
+	   yuv.v+crop_offset+yuv.uv_stride*i,
            yuv_overlay->w/2);
-    memcpy(yuv_overlay->pixels[2]+yuv_overlay->pitches[2]*i, 
-	   yuv.u+crop_offset+yuv.uv_stride*i, 
+    memcpy(yuv_overlay->pixels[2]+yuv_overlay->pitches[2]*i,
+	   yuv.u+crop_offset+yuv.uv_stride*i,
            yuv_overlay->w/2);
   }
 
@@ -254,14 +254,14 @@
 
   /* Show, baby, show! */
   SDL_DisplayYUVOverlay(yuv_overlay, &rect);
-  
+
 }
 
 /* dump the theora (or vorbis) comment header */
 static int dump_comments(theora_comment *tc){
   int i, len;
   char *value;
-  
+
   printf("Encoded by %s\n",tc->vendor);
   if(tc->comments){
     printf("theora comment header:\n");
@@ -285,21 +285,21 @@
    whatever display device it supports. */
 static void report_colorspace(theora_info *ti)
 {
-    switch(ti->colorspace){
-      case not_specified:
-        /* nothing to report */
-        break;;
-      case ITU_Rec_601:
-        fprintf(stderr,"  encoder specified ITU Rec 601 color.\n");
-        break;;
-      case CIE_Rec_709:
-        fprintf(stderr,"  encoder specified CIE Rec 709 color.\n");
-        break;;
-      default:
-        fprintf(stderr,"warning: encoder specified unknown colorspace (%d).\n",
+  switch(ti->colorspace){
+  case not_specified:
+    /* nothing to report */
+    break;
+  case ITU_Rec_601:
+    fprintf(stderr,"  encoder specified ITU Rec 601 color.\n");
+    break;
+  case CIE_Rec_709:
+    fprintf(stderr,"  encoder specified CIE Rec 709 color.\n");
+    break;
+  default:
+    fprintf(stderr,"warning: encoder specified unknown colorspace (%d).\n",
             ti->colorspace);
-        break;;
-    }
+    break;
+  }
 }
 
 /* helper: push a page into the appropriate steam */
@@ -309,7 +309,7 @@
   if(theora_p)ogg_stream_pagein(&to,&og);
   if(vorbis_p)ogg_stream_pagein(&vo,&og);
   return 0;
-}                                   
+}
 
 
 void parseHeaders(){
@@ -322,7 +322,7 @@
     if(ret==0)break;
     while(ogg_sync_pageout(&oy,&og)>0){
       ogg_stream_state test;
-      
+
       /* is this a mandated initial header? If not, stop parsing */
       if(!ogg_page_bos(&og)){
         /* don't leak the page; get it into the appropriate stream */
@@ -330,11 +330,11 @@
         stateflag=1;
         break;
       }
-      
+
       ogg_stream_init(&test,ogg_page_serialno(&og));
       ogg_stream_pagein(&test,&og);
       ogg_stream_packetout(&test,&op);
-      
+
       /* identify the codec: try theora */
       if(!theora_p && theora_decode_header(&ti,&tc,&op)>=0){
         /* it is theora */
@@ -351,11 +351,11 @@
       }
     }
   }
-  
+
   /* we're expecting more header packets. */
   while((theora_p && theora_p<3) || (vorbis_p && vorbis_p<3)){
     int ret;
-    
+
     /* look for further theora headers */
     while(theora_p && (theora_p<3) && (ret=ogg_stream_packetout(&to,&op))){
       if(ret<0){
@@ -370,7 +370,7 @@
       if(theora_p==3)break;
     }
 
-    /* look for more vorbis header packets */  
+    /* look for more vorbis header packets */
     while(vorbis_p && (vorbis_p<3) && (ret=ogg_stream_packetout(&vo,&op))){
       if(ret<0){
         printf("Error parsing Vorbis stream headers; corrupt stream?\n");
@@ -383,10 +383,10 @@
       vorbis_p++;
       if(vorbis_p==3)break;
     }
-    
+
     /* The header pages/packets will arrive before anything else we
        care about, or the stream is not obeying spec */
-    
+
     if(ogg_sync_pageout(&oy,&og)>0){
       queue_page(&og); /* demux into the appropriate stream */
     }else{
@@ -401,7 +401,7 @@
 }
 
 int main( int argc, char* argv[] ){
-  
+
   int i,j;
   ogg_packet op;
   SDL_Event event;
@@ -416,8 +416,8 @@
 
   if( argc != 2 )
   {
-	usage();
-	exit(0);
+    usage();
+    exit(0);
   }
 
   infile  = fopen( argv[1], "rb" );
@@ -440,8 +440,8 @@
     theora_decode_init(&td,&ti);
     printf("Ogg logical stream %x is Theora %dx%d %.02f fps video\n"
            "  Frame content is %dx%d with offset (%d,%d).\n",
-	    to.serialno,ti.width,ti.height, (double)ti.fps_numerator/ti.fps_denominator,
-		ti.frame_width, ti.frame_height, ti.offset_x, ti.offset_y);
+           to.serialno,ti.width,ti.height, (double)ti.fps_numerator/ti.fps_denominator,
+           ti.frame_width, ti.frame_height, ti.offset_x, ti.offset_y);
     report_colorspace(&ti);
     dump_comments(&tc);
   }else{
@@ -451,9 +451,9 @@
   }
   if(vorbis_p){
     vorbis_synthesis_init(&vd,&vi);
-    vorbis_block_init(&vd,&vb);  
+    vorbis_block_init(&vd,&vb);
     printf("Ogg logical stream %x is Vorbis %d channel %d Hz audio.\n",
-	    vo.serialno,vi.channels,vi.rate);
+	   vo.serialno,vi.channels,vi.rate);
   }else{
     /* tear down the partial vorbis setup */
     vorbis_info_clear(&vi);
@@ -468,126 +468,124 @@
   /*our main loop*/
   while(1){
 
-	SDL_Delay(5);
+    SDL_Delay(5);
 
-	if (playbackdone == 1 ) break;
+    if (playbackdone == 1 ) break;
 
-	/*break out on SDL quit event*/
+    /*break out on SDL quit event*/
     if ( SDL_PollEvent ( &event ) )
     {
       if ( event.type == SDL_QUIT ) break ;
-	  
+
     }
 
-	/*get some audio data*/
+    /*get some audio data*/
     while(vorbis_p){
       int ret;
       float **pcm;
-	  int count = 0;
-	  int maxBytesToWrite;
+      int count = 0;
+      int maxBytesToWrite;
 
-	  /* is there pending audio? does it fit our circular buffer without blocking?*/
-	  ret=vorbis_synthesis_pcmout(&vd,&pcm);
-	  maxBytesToWrite = GetAudioStreamWriteable(aOutStream);
-
-	  if (maxBytesToWrite<=FRAMES_PER_BUFFER)
-	  {
-		  /*break out until there is a significant amount of
-		  data to avoid a series of small write operations*/
-		  break;
+      /* is there pending audio? does it fit our circular buffer without blocking?*/
+      ret=vorbis_synthesis_pcmout(&vd,&pcm);
+      maxBytesToWrite = GetAudioStreamWriteable(aOutStream);
+
+      if (maxBytesToWrite<=FRAMES_PER_BUFFER)
+      {
+          /*break out until there is a significant amount of
+	  data to avoid a series of small write operations*/
+	  break;
       }
       /* if there's pending, decoded audio, grab it */
       if((ret>0)&&(maxBytesToWrite>0)){
-	
-	  for(i=0;i<ret && i<(maxBytesToWrite/vi.channels);i++)
-	   for(j=0;j<vi.channels;j++){
-		int val=(int)(pcm[j][i]*32767.f);
+
+	for(i=0;i<ret && i<(maxBytesToWrite/vi.channels);i++)
+	  for(j=0;j<vi.channels;j++){
+	    int val=(int)(pcm[j][i]*32767.f);
             if(val>32767)val=32767;
             if(val<-32768)val=-32768;
-		samples[count]=val;
-		count++;
-	   }
-	  WriteAudioStream( aOutStream, samples, i );
-      vorbis_synthesis_read(&vd,i);
-
-	  if(vd.granulepos>=0)
-	   audiobuf_granulepos=vd.granulepos-ret+i;
-	  else
-	   audiobuf_granulepos+=i;
+	    samples[count]=val;
+	    count++;
+	  }
+        WriteAudioStream( aOutStream, samples, i );
+        vorbis_synthesis_read(&vd,i);
+
+        if(vd.granulepos>=0)
+          audiobuf_granulepos=vd.granulepos-ret+i;
+        else
+          audiobuf_granulepos+=i;
 
       }else{
-	
-	 /* no pending audio; is there a pending packet to decode? */
-	  if(ogg_stream_packetout(&vo,&op)>0){
-	    if(vorbis_synthesis(&vb,&op)==0) /* test for success! */
-	     vorbis_synthesis_blockin(&vd,&vb);
-	  }else	/* we need more data; break out to suck in another page */
+
+	/* no pending audio; is there a pending packet to decode? */
+	if(ogg_stream_packetout(&vo,&op)>0){
+	  if(vorbis_synthesis(&vb,&op)==0) /* test for success! */
+	   vorbis_synthesis_blockin(&vd,&vb);
+	}else	/* we need more data; break out to suck in another page */
            break;
       }
     }/*end audio cycle*/
-      
+
     while(theora_p && !videobuf_ready){
       /* get one video packet... */
       if(ogg_stream_packetout(&to,&op)>0){
-	  theora_decode_packetin(&td,&op);
+        theora_decode_packetin(&td,&op);
 
-	  videobuf_granulepos=td.granulepos;
-	  videobuf_time=theora_granule_time(&td,videobuf_granulepos);
-	  /*update the frame counter*/
-	  //printf("Frame\n");
-	  frameNum++;
+        videobuf_granulepos=td.granulepos;
+        videobuf_time=theora_granule_time(&td,videobuf_granulepos);
+        /*update the frame counter*/
+        frameNum++;
 
-	  /*check if this frame time has not passed yet.
+        /*check if this frame time has not passed yet.
           If the frame is late we need to decode additonal
           ones and keep looping, since theora at
           this stage needs to decode all frames*/
 
-	   if(videobuf_time>= get_time())
-		/*got a good frame, not late, ready to break out*/
-		videobuf_ready=1;
+        if(videobuf_time>= get_time())
+	  /*got a good frame, not late, ready to break out*/
+	  videobuf_ready=1;
 
       }else
-	  /*already have a good frame in the buffer*/
-	  {
-		if (isPlaying == 1)
-		{
-	    printf("end\n");
-	  	endticks = GetTickCount();
-		isPlaying = 0;
-		playbackdone = 1;
-		}
+      /*already have a good frame in the buffer*/
+      {
+        if (isPlaying == 1)
+	{
+	  printf("end\n");
+	  endticks = GetTickCount();
+	  isPlaying = 0;
+	  playbackdone = 1;
+	}
         break;
-	  }
+      }
     }
- 
+
     if(stateflag && videobuf_ready && (videobuf_time<= get_time())){
-		/*time to write our cached frame*/
-	    video_write();
-		videobuf_ready=0;
-
-		/*if audio has not started (first frame) then start it*/
-		if ((!isPlaying)&&(vorbis_p)){
-			start_audio();
-			isPlaying = 1;
-		}
+      /*time to write our cached frame*/
+      video_write();
+      videobuf_ready=0;
+
+      /*if audio has not started (first frame) then start it*/
+      if ((!isPlaying)&&(vorbis_p)){
+        start_audio();
+        isPlaying = 1;
+      }
     }
 
-	/*buffer compressed data every loop */
-	//buffer_data(&oy);
-	if (hasdatatobuffer)
-	{
-	  hasdatatobuffer=buffer_data(&oy);
+    /*buffer compressed data every loop */
+    if (hasdatatobuffer)
+    {
+      hasdatatobuffer=buffer_data(&oy);
       if(hasdatatobuffer==0){
-		printf("Ogg buffering stopped, end of file reached.\n");
+        printf("Ogg buffering stopped, end of file reached.\n");
 
       }
-	}
+    }
 
 
-	if (ogg_sync_pageout(&oy,&og)>0){
-		if(theora_p)ogg_stream_pagein(&to,&og);
-  	    if(vorbis_p)ogg_stream_pagein(&vo,&og);
-	}
+    if (ogg_sync_pageout(&oy,&og)>0){
+      if(theora_p)ogg_stream_pagein(&to,&og);
+      if(vorbis_p)ogg_stream_pagein(&vo,&og);
+    }
 
   }
 
@@ -602,13 +600,13 @@
   SDL_Quit();
 
   if(vorbis_p){
-	audio_close();
+    audio_close();
 
     ogg_stream_clear(&vo);
     vorbis_block_clear(&vb);
     vorbis_dsp_clear(&vd);
     vorbis_comment_clear(&vc);
-    vorbis_info_clear(&vi); 
+    vorbis_info_clear(&vi);
   }
   if(theora_p){
     ogg_stream_clear(&to);
@@ -619,7 +617,7 @@
   ogg_sync_clear(&oy);
 
   printf("\r                                                              "
-	  "\nDone.\n");
+	 "\nDone.\n");
   return(0);
 
 }

<p><p>1.2       +2 -2      theora/win32/experimental/wincompat/getopt.c

Index: getopt.c
===================================================================
RCS file: /usr/local/cvsroot/theora/win32/experimental/wincompat/getopt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- getopt.c	30 May 2003 20:40:16 -0000	1.1
+++ getopt.c	10 Jun 2003 01:31:34 -0000	1.2
@@ -41,9 +41,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-//#include "un-namespace.h"
+/*#include "un-namespace.h"*/
 
-//#include "libc_private.h"
+/*#include "libc_private.h"*/
 
 int	opterr = 1,		/* if error message should be printed */
         optind = 1,		/* index into parent argv vector */

<p><p>1.2       +1 -1      theora/win32/experimental/wincompat/getopt_long.c

Index: getopt_long.c
===================================================================
RCS file: /usr/local/cvsroot/theora/win32/experimental/wincompat/getopt_long.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- getopt_long.c	30 May 2003 20:40:16 -0000	1.1
+++ getopt_long.c	10 Jun 2003 01:31:34 -0000	1.2
@@ -72,7 +72,7 @@
         }
 }
 
-#endif //_WIN32
+#endif /*_WIN32*/
 
 /* not part of the original file */
 #ifndef _DIAGASSERT

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list