[xiph-commits] r9839 - in trunk/theora-tools: . theora123 theora_dumpvideo theora_splayer theoraenc

j at svn.xiph.org j at svn.xiph.org
Wed Aug 24 05:39:36 PDT 2005


Author: j
Date: 2005-08-24 05:39:29 -0700 (Wed, 24 Aug 2005)
New Revision: 9839

Modified:
   trunk/theora-tools/configure.ac
   trunk/theora-tools/theora123/Makefile.am
   trunk/theora-tools/theora123/theora123.c
   trunk/theora-tools/theora_dumpvideo/Makefile.am
   trunk/theora-tools/theora_dumpvideo/theora_dumpvideo.c
   trunk/theora-tools/theora_splayer/Makefile.am
   trunk/theora-tools/theoraenc/Makefile.am
Log:
just in case someone is still using this,
- update autotools buildsystem a bit.
- copy changes from trunk in dumpvideo and player_example



Modified: trunk/theora-tools/configure.ac
===================================================================
--- trunk/theora-tools/configure.ac	2005-08-24 11:56:30 UTC (rev 9838)
+++ trunk/theora-tools/configure.ac	2005-08-24 12:39:29 UTC (rev 9839)
@@ -74,34 +74,21 @@
 AC_CHECK_FUNC(getopt_long, [GETOPT_OBJS=''], [GETOPT_OBJS='getopt.$(OBJEXT) getopt1.$(OBJEXT)'])
 AC_SUBST(GETOPT_OBJS)
 
-XIPH_PATH_OGG(, AC_MSG_ERROR([
-    libogg is required to build this package!
-    please see http://www.xiph.org/ for how to
-    obtain a copy.
-]))
-CFLAGS="$CFLAGS $OGG_CFLAGS"
-LIBS="$LIBS $OGG_LIBS"
-AC_CHECK_FUNC(oggpackB_read, , [
-  AC_MSG_ERROR([newer libogg version (>1.0) required])
-])
+PKG_CHECK_MODULES(XIPH,ogg >= 1.1 vorbis theora)
+CFLAGS="$CFLGS $XIPH_CFLAGS"
+LIBS="$LIBS $XIPH_LIBS"
 
-AC_CHECK_LIB(theora, theora_version_string, [
-  AC_CHECK_HEADER(theora/theora.h, [HAVE_THEORA=yes])
-  ],,[-ltheora]
-)
-if test "x$HAVE_THEORA" != xyes; then
-	AC_MSG_ERROR([
-    	libtheora is required to build this package!
-    	please see http://www.xiph.org/ for how to
-    	obtain a copy.
-	])
-fi
+PKG_CHECK_MODULES(VORBISENC,vorbisenc)
+AC_SUBST(VORBISENC_CFLAGS)
+AC_SUBST(VORBISENC_LIBS)
 
-
 AM_PATH_SDL(,[
 	HAVE_SDL=yes
 	SDL_LIBS=`$SDL_CONFIG --libs`
+	SDL_CFLGAS=`$SDL_CONFIG --cflags`
 ],AC_MSG_WARN([*** Unable to find SDL -- Not compiling example players ***]))
+AC_SUBST(SDL_CFLAGS)
+AC_SUBST(SDL_LIBS)
 
 AC_CHECK_HEADERS([sys/soundcard.h soundcard.h machine/soundcard.h],[
   HAVE_OSS=yes
@@ -114,7 +101,10 @@
 )
 if test "x$HAVE_PORTAUDIO" != xyes; then
   AC_MSG_WARN([portaudio not found -- not compiling splayer example])
+else
+PORTAUDIO_LIBS="-lportaudio -lpthread"
 fi
+AC_SUBST(PORTAUDIO_LIBS)
 
 if test x$HAVE_SDL = xyes -a x$HAVE_OSS = xyes; then
   THEORA123="theora123"

Modified: trunk/theora-tools/theora123/Makefile.am
===================================================================
--- trunk/theora-tools/theora123/Makefile.am	2005-08-24 11:56:30 UTC (rev 9838)
+++ trunk/theora-tools/theora123/Makefile.am	2005-08-24 12:39:29 UTC (rev 9839)
@@ -9,8 +9,6 @@
 # possible contents of BUILDABLE_PLAYERS:
 EXTRA_PROGRAMS = theora123
 
-CFLAGS = $(SDL_CFLAGS)
-LDADD = -ltheora -logg -lvorbis -lm
-
 theora123_SOURCES = theora123.c
+theora123_CFLAGS  = $(SDL_CFLAGS)
 theora123_LDADD = $(LDADD) $(SDL_LIBS)

Modified: trunk/theora-tools/theora123/theora123.c
===================================================================
--- trunk/theora-tools/theora123/theora123.c	2005-08-24 11:56:30 UTC (rev 9838)
+++ trunk/theora-tools/theora123/theora123.c	2005-08-24 12:39:29 UTC (rev 9839)
@@ -552,9 +552,18 @@
   /* and now we have it all.  initialize decoders */
   if(theora_p){
     theora_decode_init(&td,&ti);
-    printf("Ogg logical stream %x is Theora %dx%d %.02f fps video\n",
-           to.serialno,ti.width,ti.height, 
+    printf("Ogg logical stream %x is Theora %dx%d %.02f fps",
+           (unsigned int)to.serialno,ti.width,ti.height, 
            (double)ti.fps_numerator/ti.fps_denominator);
+    switch(ti.pixelformat){
+      case OC_PF_420: printf(" 4:2:0 video\n"); break;
+      case OC_PF_422: printf(" 4:2:2 video\n"); break;
+      case OC_PF_444: printf(" 4:4:4 video\n"); break;
+      case OC_PF_RSVD:
+      default:
+	printf(" video\n  (UNKNOWN Chroma sampling!)\n");
+	break;
+    }
     if(ti.width!=ti.frame_width || ti.height!=ti.frame_height)
       printf("  Frame content is %dx%d with offset (%d,%d).\n",
            ti.frame_width, ti.frame_height, ti.offset_x, ti.offset_y);
@@ -569,7 +578,7 @@
     vorbis_synthesis_init(&vd,&vi);
     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);
+            (unsigned int)vo.serialno,vi.channels,(int)vi.rate);
   }else{
     /* tear down the partial vorbis setup */
     vorbis_info_clear(&vi);
@@ -657,7 +666,7 @@
 
     if(!videobuf_ready || !audiobuf_ready){
       /* no data yet for somebody.  Grab another page */
-      int ret=buffer_data(infile,&oy);
+      int bytes=buffer_data(infile,&oy);
       while(ogg_sync_pageout(&oy,&og)>0){
         queue_page(&og);
       }

Modified: trunk/theora-tools/theora_dumpvideo/Makefile.am
===================================================================
--- trunk/theora-tools/theora_dumpvideo/Makefile.am	2005-08-24 11:56:30 UTC (rev 9838)
+++ trunk/theora-tools/theora_dumpvideo/Makefile.am	2005-08-24 12:39:29 UTC (rev 9839)
@@ -4,8 +4,4 @@
 
 bin_PROGRAMS = theora_dumpvideo
 
-CFLAGS = $(SDL_CFLAGS)
-LDADD = -ltheora -logg -lvorbis -lm
-
 theora_dumpvideo_SOURCES = theora_dumpvideo.c
-theora_dumpvideo_LDADD = $(LDADD)

Modified: trunk/theora-tools/theora_dumpvideo/theora_dumpvideo.c
===================================================================
--- trunk/theora-tools/theora_dumpvideo/theora_dumpvideo.c	2005-08-24 11:56:30 UTC (rev 9838)
+++ trunk/theora-tools/theora_dumpvideo/theora_dumpvideo.c	2005-08-24 12:39:29 UTC (rev 9839)
@@ -5,7 +5,7 @@
  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003                *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2004                *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
@@ -31,24 +31,26 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-/*#include <sys/time.h>*/
 #include <sys/types.h>
 #include <sys/stat.h>
-/*Yes, yes, we're going to hell.*/
+
 #if defined(_WIN32)
 #include <io.h>
 #endif
+
 #include <fcntl.h>
 #include <math.h>
 #include <signal.h>
+
 #include "getopt.h"
 #include "theora/theora.h"
 
 
 
-const char *optstring = "o:";
+const char *optstring = "o:r";
 struct option options [] = {
   {"output",required_argument,NULL,'o'},
+  {"raw",no_argument, NULL, 'r'}, /* Disable YUV4MPEG2 headers if set */
   {NULL,0,NULL,0}
 };
 
@@ -78,6 +80,7 @@
 int          videobuf_ready=0;
 ogg_int64_t  videobuf_granulepos=-1;
 double       videobuf_time=0;
+int          raw = 0;
 
 FILE* outfile = NULL;
 
@@ -86,25 +89,30 @@
   got_sigint = 1;
 }
 
+/* this is a nop in the current implementation. we could
+   open a file here or something if so moved. */
 static void open_video(void){
-
+   return;
 }
 
+/* write out the planar YUV frame, uncropped */
 static void video_write(void){
   int i;
 
   yuv_buffer yuv;
   theora_decode_YUVout(&td,&yuv);
 
+  if(!raw)
+    fprintf(outfile, "FRAME\n");
   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.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);
-  for(i=0;i<yuv.uv_height;i++)
-    fwrite(yuv.u+yuv.uv_stride*i, 1, yuv.uv_width, outfile);
 
 }
-/* dump the theora (or vorbis) comment header */
+/* dump the theora comment header */
 static int dump_comments(theora_comment *tc){
   int i, len;
   char *value;
@@ -127,9 +135,7 @@
   return(0);
 }
 
-/* helper: push a page into the appropriate steam */
-/* this can be done blindly; a stream won't accept a page
-                that doesn't belong to it */
+/* helper: push a page into the steam for packetization */
 static int queue_page(ogg_page *page){
   if(theora_p)ogg_stream_pagein(&to,&og);
   return 0;
@@ -154,7 +160,7 @@
   outfile = stdout;
 
 
-#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
+#ifdef _WIN32 /* We need to set stdin/stdout to binary mode on windows. */
   /* 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 );
@@ -172,6 +178,10 @@
       }
       break;
 
+      case 'r':
+      raw = 1;
+      break;
+
       default:
         usage();
     }
@@ -188,19 +198,34 @@
     }
   }
 
+
+  /*
+     Ok, Ogg parsing. The idea here is we have a bitstream
+     that is made up of Ogg pages. The libogg sync layer will
+     find them for us. There may be pages from several logical
+     streams interleaved; we find the first theora stream and
+     ignore any others.
+
+     Then we pass the pages for our stream to the libogg stream
+     layer which assembles our original set of packets out of
+     them. It's the packets that libtheora actually knows how
+     to handle.
+  */
+
   /* start up Ogg stream synchronization layer */
   ogg_sync_init(&oy);
 
-  /* init supporting Vorbis structures needed in header parsing */
-  /*vorbis_info_init(&vi);*/
-  /*vorbis_comment_init(&vc);*/
-
   /* init supporting Theora structures needed in header parsing */
   theora_comment_init(&tc);
   theora_info_init(&ti);
 
   /* Ogg file open; parse the headers */
-  /* Only interested in Vorbis/Theora streams */
+
+  /* Vorbis and Theora both depend on some initial header packets
+     for decoder setup and initialization. We retrieve these first
+     before entering the main decode loop. */
+
+  /* Only interested in Theora streams */
   while(!stateflag){
     int ret=buffer_data(infile,&oy);
     if(ret==0)break;
@@ -221,7 +246,7 @@
 
       /* identify the codec: try theora */
       if(!theora_p && theora_decode_header(&ti,&tc,&op)>=0){
-        /* it is theora */
+        /* it is theora -- save this stream state */
         memcpy(&to,&test,sizeof(test));
         theora_p=1;
       }else{
@@ -229,7 +254,7 @@
         ogg_stream_clear(&test);
       }
     }
-    /* fall through to non-bos page parsing */
+    /* fall through to non-initial page parsing */
   }
 
   /* we're expecting more header packets. */
@@ -255,9 +280,9 @@
        care about, or the stream is not obeying spec */
 
     if(ogg_sync_pageout(&oy,&og)>0){
-      queue_page(&og); /* demux into the appropriate stream */
+      queue_page(&og); /* demux into the stream state */
     }else{
-      int ret=buffer_data(infile,&oy); /* someone needs more data */
+      int ret=buffer_data(infile,&oy); /* need more data */
       if(ret==0){
         fprintf(stderr,"End of file while searching for codec headers.\n");
         exit(1);
@@ -265,11 +290,12 @@
     }
   }
 
-  /* and now we have it all.  initialize decoders */
+  /* Now we have all the required headers. initialize the decoder. */
   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,
+            (unsigned int)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 */
@@ -280,11 +306,35 @@
   /* open video */
   if(theora_p)open_video();
 
+  if(!raw)
+    fprintf(outfile, "YUV4MPEG2 W%d H%d F%d:%d I%c A%d:%d\n",
+          ti.width, ti.height, ti.fps_numerator, ti.fps_denominator, 'p', 
+          ti.aspect_numerator, ti.aspect_denominator);
+
   /* install signal handler */
   signal (SIGINT, sigint_handler);
 
-  /* on to the main decode loop.*/
+  /* Finally the main decode loop. 
 
+     It's one Theora packet per frame, so this is pretty 
+     straightforward if we're not trying to maintain sync
+     with other multiplexed streams.
+
+     the videobuf_ready flag is used to maintain the input
+     buffer in the libogg stream state. If there's no output
+     frame available at the end of the decode step, we must
+     need more input data. We could simplify this by just 
+     using the return code on ogg_page_packetout(), but the
+     flag system extends easily to the case were you care
+     about more than one multiplexed stream (like with audio
+     playback). In that case, just maintain a flag for each
+     decoder you care about, and pull data when any one of
+     them stalls.
+
+     videobuf_time holds the presentation time of the currently
+     buffered video frame. We ignore this value.
+  */
+
   stateflag=0; /* playback has not begun */
   /* queue any remaining pages from data we buffered but that did not
       contain headers */
@@ -306,11 +356,11 @@
         break;
     }
 
-    if(!videobuf_ready  && feof(infile))break;
+    if(!videobuf_ready && feof(infile))break;
 
-    if(!videobuf_ready ){
+    if(!videobuf_ready){
       /* no data yet for somebody.  Grab another page */
-      int ret=buffer_data(infile,&oy);
+      buffer_data(infile,&oy);
       while(ogg_sync_pageout(&oy,&og)>0){
         queue_page(&og);
       }
@@ -321,7 +371,7 @@
     videobuf_ready=0;
   }
 
-  /* close everything */
+  /* end of decoder loop -- close everything */
 
   if(theora_p){
     ogg_stream_clear(&to);

Modified: trunk/theora-tools/theora_splayer/Makefile.am
===================================================================
--- trunk/theora-tools/theora_splayer/Makefile.am	2005-08-24 11:56:30 UTC (rev 9838)
+++ trunk/theora-tools/theora_splayer/Makefile.am	2005-08-24 12:39:29 UTC (rev 9839)
@@ -7,8 +7,6 @@
 # possible contents of BUILDABLE_PLAYERS:
 EXTRA_PROGRAMS = theora_splayer
 
-CFLAGS = $(SDL_CFLAGS)
-LDADD = -ltheora -logg -lvorbis -lm
-
 theora_splayer_SOURCES = theora_splayer.c
-theora_splayer_LDADD = $(LDADD) $(SDL_LIBS) -lportaudio -lpthread
+theora_splayer_LDADD = $(SDL_LIBS) @PORTAUDIO_LIBS@
+theora_splayer_CFLAGS = $(CFLAGS) $(SDL_CFLAGS)

Modified: trunk/theora-tools/theoraenc/Makefile.am
===================================================================
--- trunk/theora-tools/theoraenc/Makefile.am	2005-08-24 11:56:30 UTC (rev 9838)
+++ trunk/theora-tools/theoraenc/Makefile.am	2005-08-24 12:39:29 UTC (rev 9839)
@@ -4,10 +4,8 @@
 
 bin_PROGRAMS = theoraenc
 
-CFLAGS = $(SDL_CFLAGS)
-LDADD = -ltheora -logg -lvorbis -lm
-
 theoraenc_SOURCES = theoraenc.c
 EXTRA_theoraenc_SOURCES = getopt.c getopt1.c getopt.h
-theoraenc_LDADD = $(GETOPT_OBJS) $(LDADD) -lvorbisenc
+theoraenc_LDADD  = $(GETOPT_OBJS)  @VORBISENC_LIBS@
+theoraenc_CFLAGS = $(CFLGAS) @VORBISENC_CFLAGS@
 theoraenc_DEPENDENCIES = $(GETOPT_OBJS)



More information about the commits mailing list