[xiph-commits] r12838 - in experimental/j/theora-mashup/lib: . dec enc

j at svn.xiph.org j at svn.xiph.org
Mon Apr 9 10:13:33 PDT 2007


Author: j
Date: 2007-04-09 10:13:28 -0700 (Mon, 09 Apr 2007)
New Revision: 12838

Removed:
   experimental/j/theora-mashup/lib/enc/comment.c
Modified:
   experimental/j/theora-mashup/lib/Makefile.am
   experimental/j/theora-mashup/lib/dec/apiwrapper.c
   experimental/j/theora-mashup/lib/dec/info.c
Log:
port comment fix from theora-exp and add to apiwrapper



Modified: experimental/j/theora-mashup/lib/Makefile.am
===================================================================
--- experimental/j/theora-mashup/lib/Makefile.am	2007-04-09 16:55:47 UTC (rev 12837)
+++ experimental/j/theora-mashup/lib/Makefile.am	2007-04-09 17:13:28 UTC (rev 12838)
@@ -20,7 +20,6 @@
 
 if THEORA_DISABLE_ENCODE
 encoder_sources = \
-	enc/comment.c \
 	enc/encoder_disabled.c
 else
 encoder_sources = \
@@ -31,7 +30,6 @@
 	enc/encoder_quant.c \
 	enc/blockmap.c \
 	enc/common.c \
-	enc/comment.c \
 	enc/dct.c \
 	enc/dct_decode.c \
 	enc/frarray.c \

Modified: experimental/j/theora-mashup/lib/dec/apiwrapper.c
===================================================================
--- experimental/j/theora-mashup/lib/dec/apiwrapper.c	2007-04-09 16:55:47 UTC (rev 12837)
+++ experimental/j/theora-mashup/lib/dec/apiwrapper.c	2007-04-09 17:13:28 UTC (rev 12838)
@@ -231,7 +231,6 @@
     return theora_granule_time_enc(_td, _gp);
   return th_granule_time(((th_api_wrapper *)_td->i->codec_setup)->decode,_gp);
 }
-/*
 void theora_comment_init(theora_comment *_tc){
   th_comment_init((th_comment *)_tc);
 }
@@ -254,5 +253,4 @@
 
 void theora_comment_add_tag(theora_comment *_tc, char *_tag, char *_value){
   th_comment_add_tag((th_comment *)_tc,_tag,_value);
-}
-*/
\ No newline at end of file
+}
\ No newline at end of file

Modified: experimental/j/theora-mashup/lib/dec/info.c
===================================================================
--- experimental/j/theora-mashup/lib/dec/info.c	2007-04-09 16:55:47 UTC (rev 12837)
+++ experimental/j/theora-mashup/lib/dec/info.c	2007-04-09 17:13:28 UTC (rev 12838)
@@ -70,13 +70,12 @@
   long i;
   int  found;
   int  tag_len;
-  /*+1 for the '=' we append.*/
-  tag_len=strlen(_tag)+1;
+  tag_len=strlen(_tag);
   found=0;
   for(i=0;i<_tc->comments;i++){
     if(!oc_tagcompare(_tc->user_comments[i],_tag,tag_len)){
       /*We return a pointer to the data, not a copy.*/
-      if(_count==found++)return _tc->user_comments[i]+tag_len;
+      if(_count==found++)return _tc->user_comments[i]+tag_len+1;
     }
   }
   /*Didn't find anything.*/
@@ -87,8 +86,7 @@
   long i;
   int  tag_len;
   int  count;
-  /*+1 for the '=' we append.*/
-  tag_len=strlen(_tag)+1;
+  tag_len=strlen(_tag);
   count=0;
   for(i=0;i<_tc->comments;i++){
     if(!oc_tagcompare(_tc->user_comments[i],_tag,tag_len))count++;

Deleted: experimental/j/theora-mashup/lib/enc/comment.c
===================================================================
--- experimental/j/theora-mashup/lib/enc/comment.c	2007-04-09 16:55:47 UTC (rev 12837)
+++ experimental/j/theora-mashup/lib/enc/comment.c	2007-04-09 17:13:28 UTC (rev 12838)
@@ -1,109 +0,0 @@
-/********************************************************************
- *                                                                  *
- * THIS FILE IS PART OF THE OggTheora 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 Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003                *
- * by the Xiph.Org Foundation http://www.xiph.org/                  *
- *                                                                  *
- ********************************************************************
-
-  function: read/write and client interface for comment header packet
-  last mod: $Id$
-
- ********************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include "codec_internal.h"
-
-void theora_comment_init(theora_comment *tc){
-  memset(tc,0,sizeof(*tc));
-}
-
-void theora_comment_add(theora_comment *tc,char *comment){
-  tc->user_comments=_ogg_realloc(tc->user_comments,
-                            (tc->comments+2)*sizeof(*tc->user_comments));
-  tc->comment_lengths=_ogg_realloc(tc->comment_lengths,
-                            (tc->comments+2)*sizeof(*tc->comment_lengths));
-  tc->comment_lengths[tc->comments]=strlen(comment);
-  tc->user_comments[tc->comments]=_ogg_malloc(tc->comment_lengths[tc->comments]+1);
-  strcpy(tc->user_comments[tc->comments], comment);
-  tc->comments++;
-  tc->user_comments[tc->comments]=NULL;
-}
-
-void theora_comment_add_tag(theora_comment *tc, char *tag, char *value){
-  char *comment=_ogg_malloc(strlen(tag)+strlen(value)+2); /* +2 for = and \0 */
-  strcpy(comment, tag);
-  strcat(comment, "=");
-  strcat(comment, value);
-  theora_comment_add(tc, comment);
-  _ogg_free(comment);
-}
-
-/* This is more or less the same as strncasecmp - but that doesn't exist
- * everywhere, and this is a fairly trivial function, so we include it */
-static int tagcompare(const char *s1, const char *s2, int n){
-  int c=0;
-  while(c < n){
-    if(toupper(s1[c]) != toupper(s2[c]))
-      return !0;
-    c++;
-  }
-  return 0;
-}
-
-char *theora_comment_query(theora_comment *tc, char *tag, int count){
-  long i;
-  int found = 0;
-  int taglen = strlen(tag)+1; /* +1 for the = we append */
-  char *fulltag = _ogg_malloc(taglen+ 1);
-
-  strcpy(fulltag, tag);
-  strcat(fulltag, "=");
-
-  for(i=0;i<tc->comments;i++){
-    if(!tagcompare(tc->user_comments[i], fulltag, taglen)){
-      if(count == found){
-        _ogg_free(fulltag);
-        /* We return a pointer to the data, not a copy */
-        return tc->user_comments[i] + taglen;
-      }
-      else
-        found++;
-    }
-  }
-  _ogg_free(fulltag);
-  return NULL; /* didn't find anything */
-}
-
-int theora_comment_query_count(theora_comment *tc, char *tag){
-  int i,count=0;
-  int taglen = strlen(tag)+1; /* +1 for the = we append */
-  char *fulltag = _ogg_malloc(taglen+1);
-  strcpy(fulltag,tag);
-  strcat(fulltag, "=");
-
-  for(i=0;i<tc->comments;i++){
-    if(!tagcompare(tc->user_comments[i], fulltag, taglen))
-      count++;
-  }
-  _ogg_free(fulltag);
-  return count;
-}
-
-void theora_comment_clear(theora_comment *tc){
-  if(tc){
-    long i;
-    for(i=0;i<tc->comments;i++)
-      if(tc->user_comments[i])_ogg_free(tc->user_comments[i]);
-    if(tc->user_comments)_ogg_free(tc->user_comments);
-    if(tc->comment_lengths)_ogg_free(tc->comment_lengths);
-    if(tc->vendor)_ogg_free(tc->vendor);
-    memset(tc,0,sizeof(*tc));
-  }
-}



More information about the commits mailing list