[xiph-cvs] cvs commit: theora/examples encoder_example.c

Ralph Giles giles at xiph.org
Fri Jun 13 18:08:11 PDT 2003



giles       03/06/13 21:08:10

  Modified:    examples encoder_example.c
  Log:
  Liberalize the YUV4MPEG frame header parsing. The spec allows for some
  informational tags separated by spaces between the 'FRAME' magic and the
  '\n'. Also ffmpeg apparently always inserts a space based on incorrect
  documentation shipped with the mjpegtools, so we need to handle that.
  
  This code just scans for the first newline within 79 bytes of the magic
  string, ignoring anything in between. According the mjpegtools source,
  the maximum allowed header line is 256 bytes, but I stuck with the more
  conservative value monty used for the file header.

Revision  Changes    Path
1.23      +13 -3     theora/examples/encoder_example.c

Index: encoder_example.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/encoder_example.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- encoder_example.c	10 Jun 2003 11:42:45 -0000	1.22
+++ encoder_example.c	14 Jun 2003 01:08:10 -0000	1.23
@@ -12,7 +12,7 @@
 
   function: example encoder application; makes an Ogg Theora/Vorbis
             file from YUV4MPEG2 and WAV input
-  last mod: $Id: encoder_example.c,v 1.22 2003/06/10 11:42:45 giles Exp $
+  last mod: $Id: encoder_example.c,v 1.23 2003/06/14 01:08:10 giles Exp $
 
  ********************************************************************/
 
@@ -372,13 +372,23 @@
          always be full when we get here */
 
       for(i=state;i<2;i++){
-        char frame[6];
+        char c,frame[6];
         int ret=fread(frame,1,6,video);
         
+	/* match and skip the frame header */
         if(ret<6)break;
-        if(memcmp(frame,"FRAME\n",6)){
+        if(memcmp(frame,"FRAME",5)){
           fprintf(stderr,"Loss of framing in YUV input data\n");
           exit(1);
+        }
+        if(frame[5]!='\n'){
+          int j;
+          for(j=0;j<79;j++)
+            if(fread(&c,1,1,video)&&c=='\n')break;
+          if(j==79){
+            fprintf(stderr,"Error parsing YUV frame header\n");
+            exit(1);
+          }
         }
 
         /* read the Y plane into our frame buffer with centering */

<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