[xiph-cvs] cvs commit: theora/lib toplevel.c

Ralph Giles giles at xiph.org
Tue Jun 3 17:04:29 PDT 2003



giles       03/06/03 20:04:29

  Modified:    examples encoder_example.c player_example.c
               include/theora theora.h
               lib      toplevel.c
  Log:
  Add an 8-bit field to the header to allow the encoder to specify a
  colorspace for the compressed video. The idea is to allow a only
  a handful of settings here; the encoder should do the best conversion it
  can to one of the supported options, and the decoder should do the best
  it can to reproduce that on its display device.
  
  Currectly only three are supported: ITU 601, CIE 709, and 'not
  specified'. The field is represented by an enum in the theora_info
  struct.
  
  Also adds an informational display of this field to the example player;
  it doesn't actually try to do any color correction.

Revision  Changes    Path
1.15      +2 -1      theora/examples/encoder_example.c

Index: encoder_example.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/encoder_example.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- encoder_example.c	3 Jun 2003 22:39:26 -0000	1.14
+++ encoder_example.c	4 Jun 2003 00:04:28 -0000	1.15
@@ -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.14 2003/06/03 22:39:26 giles Exp $
+  last mod: $Id: encoder_example.c,v 1.15 2003/06/04 00:04:28 giles Exp $
 
  ********************************************************************/
 
@@ -585,6 +585,7 @@
   ti.fps_denominator=video_hzd;
   ti.aspect_numerator=video_an;
   ti.aspect_denominator=video_ad;
+  ti.colorspace=not_specified;
   ti.target_bitrate=video_r;
   ti.quality=video_q;
   

<p><p>1.16      +25 -1     theora/examples/player_example.c

Index: player_example.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/player_example.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- player_example.c	21 May 2003 18:36:00 -0000	1.15
+++ player_example.c	4 Jun 2003 00:04:28 -0000	1.16
@@ -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.15 2003/05/21 18:36:00 giles Exp $
+  last mod: $Id: player_example.c,v 1.16 2003/06/04 00:04:28 giles Exp $
 
  ********************************************************************/
 
@@ -378,6 +378,29 @@
   return(0);
 }
 
+/* Report the encoder-specified colorspace for the video, if any.
+   We don't actually make use of the information in this example;
+   a real player should attempt to perform color correction for
+   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",
+            ti->colorspace);
+        break;;
+    }
+}
+
 /* 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 */
@@ -531,6 +554,7 @@
     fprintf(stderr,"Ogg logical stream %x is Theora %dx%d %.02f fps video.\n",
             to.serialno,ti.width,ti.height,
             (double)ti.fps_numerator/ti.fps_denominator);
+    report_colorspace(&ti);
   }
   if(vorbis_p){
     vorbis_synthesis_init(&vd,&vi);

<p><p>1.9       +9 -3      theora/include/theora/theora.h

Index: theora.h
===================================================================
RCS file: /usr/local/cvsroot/theora/include/theora/theora.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- theora.h	3 Jun 2003 22:39:26 -0000	1.8
+++ theora.h	4 Jun 2003 00:04:29 -0000	1.9
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function: 
-  last mod: $Id: theora.h,v 1.8 2003/06/03 22:39:26 giles Exp $
+  last mod: $Id: theora.h,v 1.9 2003/06/04 00:04:29 giles Exp $
 
  ********************************************************************/
 
@@ -28,14 +28,19 @@
     int   uv_width;
     int   uv_height;
     int   uv_stride;
-
     char *y;
     char *u;
     char *v;
 
 } yuv_buffer;
 
-typedef struct{
+typedef enum {
+    not_specified = 0,
+    ITU_Rec_601 = 1,
+    CIE_Rec_709 = 2
+} theora_colorspace;
+
+typedef struct {
   ogg_uint32_t  width;
   ogg_uint32_t  height;
   ogg_uint32_t  frame_width;
@@ -46,6 +51,7 @@
   ogg_uint32_t  fps_denominator;
   ogg_uint32_t  aspect_numerator;
   ogg_uint32_t  aspect_denominator;
+  theora_colorspace colorspace;
   int           target_bitrate;
   int           quality;
   int           quick_p;  /* quick encode/decode */

<p><p>1.21      +3 -1      theora/lib/toplevel.c

Index: toplevel.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/toplevel.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- toplevel.c	3 Jun 2003 22:39:26 -0000	1.20
+++ toplevel.c	4 Jun 2003 00:04:29 -0000	1.21
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function: 
-  last mod: $Id: toplevel.c,v 1.20 2003/06/03 22:39:26 giles Exp $
+  last mod: $Id: toplevel.c,v 1.21 2003/06/04 00:04:29 giles Exp $
 
  ********************************************************************/
 
@@ -1050,6 +1050,7 @@
 
   oggpackB_write(&cpi->oggbuffer,cpi->pb.keyframe_granule_shift,5);
 
+  oggpackB_write(&cpi->oggbuffer,cpi->pb.info.colorspace,8);
   oggpackB_write(&cpi->oggbuffer,cpi->pb.info.target_bitrate,24);
   oggpackB_write(&cpi->oggbuffer,cpi->pb.info.quality,6);
 
@@ -1212,6 +1213,7 @@
 
   c->keyframe_frequency_force=1<<oggpackB_read(&opb,5);
 
+  c->colorspace=oggpackB_read(&opb,8);
   c->target_bitrate=oggpackB_read(&opb,24);
   c->quality=ret=oggpackB_read(&opb,6);
 

<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