[xiph-commits] r8555 - in trunk/theora: examples include/theora lib

giles at motherfish-iii.xiph.org giles at motherfish-iii.xiph.org
Wed Dec 29 12:42:31 PST 2004


Author: giles
Date: 2004-12-29 12:42:30 -0800 (Wed, 29 Dec 2004)
New Revision: 8555

Modified:
   trunk/theora/examples/encoder_example.c
   trunk/theora/examples/player_example.c
   trunk/theora/include/theora/theora.h
   trunk/theora/lib/encoder_toplevel.c
   trunk/theora/lib/toplevel.c
Log:
Add support for the pixel format field in the theora info header.
The codec still only handles 4:2:0.


Modified: trunk/theora/examples/encoder_example.c
===================================================================
--- trunk/theora/examples/encoder_example.c	2004-12-29 19:50:51 UTC (rev 8554)
+++ trunk/theora/examples/encoder_example.c	2004-12-29 20:42:30 UTC (rev 8555)
@@ -660,6 +660,7 @@
   ti.aspect_numerator=video_an;
   ti.aspect_denominator=video_ad;
   ti.colorspace=OC_CS_UNSPECIFIED;
+  ti.pixelformat=OC_PF_420;
   ti.target_bitrate=video_r;
   ti.quality=video_q;
 

Modified: trunk/theora/examples/player_example.c
===================================================================
--- trunk/theora/examples/player_example.c	2004-12-29 19:50:51 UTC (rev 8554)
+++ trunk/theora/examples/player_example.c	2004-12-29 20:42:30 UTC (rev 8555)
@@ -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",
+    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);

Modified: trunk/theora/include/theora/theora.h
===================================================================
--- trunk/theora/include/theora/theora.h	2004-12-29 19:50:51 UTC (rev 8554)
+++ trunk/theora/include/theora/theora.h	2004-12-29 20:42:30 UTC (rev 8555)
@@ -78,9 +78,24 @@
   OC_CS_UNSPECIFIED,	/**< the colorspace is unknown or unspecified */
   OC_CS_ITU_REC_470M,	/**< best option for 'NTSC' content */
   OC_CS_ITU_REC_470BG,	/**< best option for 'PAL' content */
+  OC_CS_NSPACES		/* mark the end of the defined colorspaces */
 } theora_colorspace;
 
 /**
+ * A Chroma subsampling
+ *
+ * These enumerate the available chroma subsampling options supported
+ * by the theora format. See Section 4.4 of the specification for
+ * exact definitions.
+ */
+typedef enum {
+  OC_PF_420,	/**< Chroma subsampling by 2 in each direction (4:2:0) */
+  OC_PF_RSVD,	/**< reserved value */
+  OC_PF_422,	/**< Horizonatal chroma subsampling by 2 (4:2:2) */
+  OC_PF_444,	/**< No chroma subsampling at all (4:4:4) */
+} theora_pixelformat;
+
+/**
  * Theora bitstream info.
  * Contains the basic playback parameters for a stream,
  * corresponds to the initial 'info' header packet.
@@ -135,6 +150,8 @@
   ogg_int32_t   noise_sensitivity;
   ogg_int32_t   sharpness;
 
+  theora_pixelformat pixelformat;
+
 } theora_info;
 
 /** Codec internal state and context.

Modified: trunk/theora/lib/encoder_toplevel.c
===================================================================
--- trunk/theora/lib/encoder_toplevel.c	2004-12-29 19:50:51 UTC (rev 8554)
+++ trunk/theora/lib/encoder_toplevel.c	2004-12-29 20:42:30 UTC (rev 8555)
@@ -1065,8 +1065,10 @@
 
   oggpackB_write(cpi->oggbuffer,cpi->pb.keyframe_granule_shift,5);
 
-  oggpackB_write(cpi->oggbuffer,0,5); /* spare config bits */
+  oggpackB_write(cpi->oggbuffer,cpi->pb.info.pixelformat,2);
 
+  oggpackB_write(cpi->oggbuffer,0,3); /* spare config bits */
+
 #ifndef LIBOGG2
   op->packet=oggpackB_get_buffer(cpi->oggbuffer);
 #else

Modified: trunk/theora/lib/toplevel.c
===================================================================
--- trunk/theora/lib/toplevel.c	2004-12-29 19:50:51 UTC (rev 8554)
+++ trunk/theora/lib/toplevel.c	2004-12-29 20:42:30 UTC (rev 8555)
@@ -144,13 +144,16 @@
   theora_read(opb,24,&ret);
   ci->target_bitrate=ret;
   theora_read(opb,6,&ret);
-  ci->quality=ret=ret;
+  ci->quality=ret;
 
   theora_read(opb,5,&ret);
   ci->keyframe_frequency_force=1<<ret;
 
+  theora_read(opb,2,&ret);
+  ci->pixelformat=ret;
+
   /* spare configuration bits */
-  if ( theora_read(opb,5,&ret) == -1 )
+  if ( theora_read(opb,3,&ret) == -1 )
     return (OC_BADHEADER);
 
   return(0);



More information about the commits mailing list