[xiph-cvs] cvs commit: writ/src encode.c Makefile.am format.c

Arc arc at xiph.org
Mon Dec 8 22:38:44 PST 2003



arc         03/12/09 01:38:44

  Modified:    include/writ writ.h
               src      Makefile.am format.c
  Added:       src      encode.c
  Log:
  Started work on the encode side of the library.
  Still need help with autotools...

Revision  Changes    Path
1.6       +47 -24    writ/include/writ/writ.h

Index: writ.h
===================================================================
RCS file: /usr/local/cvsroot/writ/include/writ/writ.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- writ.h	2 Dec 2003 07:54:12 -0000	1.5
+++ writ.h	9 Dec 2003 06:38:43 -0000	1.6
@@ -11,20 +11,21 @@
  ********************************************************************
 
  function: toplevel libwrit include
- last mod: $Id: writ.h,v 1.5 2003/12/02 07:54:12 arc Exp $
+ last mod: $Id: writ.h,v 1.6 2003/12/09 06:38:43 arc Exp $
 
  ********************************************************************/
 
 #include <ogg2/ogg.h>
 
+
+/* These structs should all be abstracted for internal use only */
   
 typedef struct writ_text {
   int    length;
   char  *string;
 } writ_text;
 
-
-typedef struct writ_langdef {
+typedef struct writ_language {
   writ_text language_name;
   writ_text language_desc;
 } writ_langdef;
@@ -35,53 +36,75 @@
   ogg_uint16_t  location_y;
   ogg_uint16_t  location_width;
   ogg_uint16_t  location_height;
-  int	        alignment_x; 		/* 0=left, 1=right, 2=center, 3=full */
-  int           alignment_y;		/* 0=top, 1=bottom, 2=middle, 3=full */
+  int	        alignment_x; 	 /* 0=left, 1=right, 2=center, 3=full */
+  int           alignment_y;	 /* 0=top, 1=bottom, 2=middle, 3=full */
 } writ_window;
 
 
-typedef struct writ_wininfo {
-  ogg_uint16_t  location_scale_x;
-  ogg_uint16_t  location_scale_y;
-
-  int           num_windows;
-  writ_window  *windows;   
-} writ_wininfo;
-
-
 typedef struct writ_info {
-  int            subver;
-  int            subver_bytes;
+  int            subversion;
   
   ogg_uint32_t   granulerate_numerator;
   ogg_uint32_t   granulerate_denominator;
   
+  /* Subversion 1+ */
   int            num_languages;
-  writ_langdef  *languages;
+  writ_language *languages;
   
-  writ_wininfo  *window_info; /* Used with subversion 1+ only */
-  /* Future subversion structs go here */
+  /* Subversion 2+ */
+  ogg_uint16_t  location_scale_x;
+  ogg_uint16_t  location_scale_y;
+  int           num_windows;
+  writ_window  *windows;   
 } writ_info;
 
 
 typedef struct writ_phrase {
   ogg_int64_t    start;
   ogg_uint32_t   duration;
-  char         **text;
-
-  int            win_id;
-  /* Future subversion fields go here */
+  writ_text    **text;
+  int            window_id;
 } writ_phrase;  
 
 
 typedef struct writ_state {
   writ_info   *wi;
   
+  ogg_int64_t  granulepos;
+
   int          num_phrases;
+  int          skip_phrases;
   writ_phrase *phrase_buffer;
   
-  ogg_int64_t granulepos;
 } writ_state;
 
 
+/* OggWrit Encoding Methods ******************************************/
+
+extern int writ_encode_init(writ_state *ws, ogg_uint32_t granule_num,
+                            ogg_uint32_t granule_den);
+extern int writ_encode_clear(writ_state *ws);
+
+extern int writ_encode_lang_add(writ_state *ws, char *name, char *desc);
+extern int writ_encode_wind_init(writ_state *ws, 
+                                 int scale_x, int scale_y);
+extern int writ_encode_wind_add(writ_state *ws, int left, int top, 
+                                int width, int height, 
+                                int align_x, int align_y);
+extern int writ_encode_get_header(writ_state *ws, int packets,
+                                  **ogg_packet);
+
+/* A different call for each subversion, the best way? */
+extern int writ_encode_phrase0(writ_state *ws, ogg_packet *ogg_packet,
+                               ogg_int64_t start, ogg_uint32_t duration, 
+                               *text);
+extern int writ_encode_phrase1(writ_state *ws, ogg_packet *ogg_packet,
+                               ogg_int64_t start, ogg_uint32_t duration, 
+                               **text);
+extern int writ_encode_phrase2(writ_state *ws, ogg_packet *ogg_packet,
+                               ogg_int64_t start, ogg_uint32_t duration, 
+                               **text, int window_id);
+
+
 extern int ilog(unsigned int v);	/* src/format.c */
+

<p><p>1.2       +1 -1      writ/src/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/writ/src/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile.am	17 Aug 2003 21:16:14 -0000	1.1
+++ Makefile.am	9 Dec 2003 06:38:44 -0000	1.2
@@ -6,7 +6,7 @@
 
 lib_LTLIBRARIES = libwrit.la
 
-libwrit_la_SOURCES = format.c 
+libwrit_la_SOURCES = format.c encode.c
 libwrit_la_LDFLAGS = -no-undefined -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
 
 debug:

<p><p>1.3       +4 -7      writ/src/format.c

Index: format.c
===================================================================
RCS file: /usr/local/cvsroot/writ/src/format.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- format.c	17 Aug 2003 08:34:49 -0000	1.2
+++ format.c	9 Dec 2003 06:38:44 -0000	1.3
@@ -1,17 +1,17 @@
 /********************************************************************
  *                                                                  *
- * THIS FILE IS PART OF THE Ogg Writ SOFTWARE CODEC SOURCE CODE.    *
+ * THIS FILE IS PART OF THE OggWrit SOFTWARE CODEC SOURCE CODE.     *
  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
- * THE Ogg Writ SOURCE CODE IS (C) COPYRIGHT 2003                   *
+ * THE OggWrit SOURCE CODE IS (C) COPYRIGHT 2003                    *
  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
- format: Writ data formatting
- last mod: $Id: format.c,v 1.2 2003/08/17 08:34:49 arc Exp $
+ format.c: Writ formatting functions
+ last mod: $Id: format.c,v 1.3 2003/12/09 06:38:44 arc Exp $
 
  ********************************************************************/
 
@@ -27,6 +27,3 @@
   return(ret);
 }
 
-/* this is undocumented in libogg, and very needed here
-void oggpack_writealign(oggpack_buffer *b);
-*/

<p><p>1.1                  writ/src/encode.c

Index: encode.c
===================================================================
/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggWrit SOFTWARE CODEC SOURCE CODE.     *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
 *                                                                  *
 * THE OggWrit SOURCE CODE IS (C) COPYRIGHT 2003                    *
 * by the XIPHOPHORUS Company http://www.xiph.org/                  *
 *                                                                  *
 ********************************************************************

 encode.c: Writ stream encoding
 last mod: $Id: encode.c,v 1.1 2003/12/09 06:38:44 arc Exp $

 ********************************************************************/

#include <writ/writ.h>

int writ_encode_init(writ_state *ws, ogg_uint32_t granule_num, 
                     ogg_uint32_t granule_den) {
  ws = _ogg_malloc(sizeof(writ_state));
  ws->granulepos = 0;
  ws->num_phrases = 0;
  ws->skip_phrases = 0;

  ws->wi = _ogg_malloc(sizeof(writ_info));
  ws->wi->subversion = 0;
  ws->wi->granulerate_numerator = granule_num;
  ws->wi->granulerate_denominator = granule_den;
   
  return OGG_SUCCESS;
}

int writ_encode_clear(writ_state *ws) {
  _ogg_free(ws->wi);
  _ogg_free(ws);

  return OGG_SUCCESS;
}

int writ_encode_lang_add(writ_state *ws, char *name, char *desc) {
  writ_language *new_lang;
  int name_length = strlen(name);
  int desc_length = strlen(desc);

  if (ws->wi->subversion == 0) {
    ws->wi->subversion = 1;
    ws->wi->num_languages = 0;
    ws->wi->languages = malloc(sizeof(writ_language)*16);
  } else {
    if (ws->wi->num_languages == 15) 
      ws->wi->languages = realloc(ws->wi->languages, 
                                  sizeof(writ_language)*256);
    ws->wi->num_languages++;
  }
  new_lang = ws->wi->languages + ws->wi->num_languages;
  new_lang->language_name.length = name_length;
  new_lang->language_name.string = malloc(name_length+desc_length);
  memcpy(new_lang->language_name.string, name, name_length); 
  new_lang->language_desc.length = desc_length;
  new_lang->language_desc.string = new_lang->language_name.string +
                                   name_length;
  memcpy(new_lang->language_desc.string, desc, desc_length); 

  return ws->wi->num_languages;
}

<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