[xiph-commits] r12742 - in experimental/j/theora-mashup/lib: dec enc
j at svn.xiph.org
j at svn.xiph.org
Mon Mar 12 15:08:52 PDT 2007
Author: j
Date: 2007-03-12 15:08:49 -0700 (Mon, 12 Mar 2007)
New Revision: 12742
Modified:
experimental/j/theora-mashup/lib/dec/apiwrapper.c
experimental/j/theora-mashup/lib/dec/internal.h
experimental/j/theora-mashup/lib/enc/encoder_toplevel.c
Log:
- add theora_granule_time and theora_granule_frame from trunk
use those if encoder was initialized
Modified: experimental/j/theora-mashup/lib/dec/apiwrapper.c
===================================================================
--- experimental/j/theora-mashup/lib/dec/apiwrapper.c 2007-03-12 21:58:47 UTC (rev 12741)
+++ experimental/j/theora-mashup/lib/dec/apiwrapper.c 2007-03-12 22:08:49 UTC (rev 12742)
@@ -111,6 +111,8 @@
/*Don't bother to copy the setup info; th_decode_alloc() makes its own copy
of the stuff it needs.*/
dapi->decode=th_decode_alloc(&info,api->setup);
+
+ return(0);
}
static void th_info2theora_info(theora_info *_ci,const th_info *_info){
@@ -215,10 +217,14 @@
}
ogg_int64_t theora_granule_frame(theora_state *_td,ogg_int64_t _gp){
+ if(_td->internal_encode!=NULL)
+ return theora_granule_time_enc(_td, _gp);
return th_granule_frame(((th_api_wrapper *)_td->i->codec_setup)->decode,_gp);
}
double theora_granule_time(theora_state *_td, ogg_int64_t _gp){
+ if(_td->internal_encode!=NULL)
+ return theora_granule_time_enc(_td, _gp);
return th_granule_time(((th_api_wrapper *)_td->i->codec_setup)->decode,_gp);
}
Modified: experimental/j/theora-mashup/lib/dec/internal.h
===================================================================
--- experimental/j/theora-mashup/lib/dec/internal.h 2007-03-12 21:58:47 UTC (rev 12741)
+++ experimental/j/theora-mashup/lib/dec/internal.h 2007-03-12 22:08:49 UTC (rev 12742)
@@ -5,6 +5,7 @@
# include <config.h>
# endif
# include "theora/codec.h"
+# include "theora/theora.h"
# include "ocintrin.h"
# include "huffman.h"
# include "quant.h"
@@ -428,4 +429,7 @@
ogg_uint16_t _dc_iquant,const ogg_uint16_t _ac_iquant[64]);
void oc_restore_fpu_c(void);
+extern double theora_granule_time_enc(theora_state *th,ogg_int64_t granulepos);
+extern ogg_int64_t theora_granule_frame_enc(theora_state *th,ogg_int64_t granulepos);
+
#endif
Modified: experimental/j/theora-mashup/lib/enc/encoder_toplevel.c
===================================================================
--- experimental/j/theora-mashup/lib/enc/encoder_toplevel.c 2007-03-12 21:58:47 UTC (rev 12741)
+++ experimental/j/theora-mashup/lib/enc/encoder_toplevel.c 2007-03-12 22:08:49 UTC (rev 12742)
@@ -1219,3 +1219,42 @@
_ogg_free(cpi);
}
}
+
+/* returns, in seconds, absolute time of current packet in given
+ logical stream */
+double theora_granule_time_enc(theora_state *th,ogg_int64_t granulepos){
+#ifndef THEORA_DISABLE_FLOAT
+ CP_INSTANCE *cpi=(CP_INSTANCE *)(th->internal_encode);
+ PB_INSTANCE *pbi=(PB_INSTANCE *)(th->internal_decode);
+
+ if(cpi)pbi=&cpi->pb;
+
+ if(granulepos>=0){
+ ogg_int64_t iframe=granulepos>>pbi->keyframe_granule_shift;
+ ogg_int64_t pframe=granulepos-(iframe<<pbi->keyframe_granule_shift);
+
+ return (iframe+pframe)*
+ ((double)pbi->info.fps_denominator/pbi->info.fps_numerator);
+
+ }
+#endif
+
+ return(-1); /* negative granulepos or float calculations disabled */
+}
+
+/* returns frame number of current packet in given logical stream */
+ogg_int64_t theora_granule_frame_enc(theora_state *th,ogg_int64_t granulepos){
+ CP_INSTANCE *cpi=(CP_INSTANCE *)(th->internal_encode);
+ PB_INSTANCE *pbi=(PB_INSTANCE *)(th->internal_decode);
+
+ if(cpi)pbi=&cpi->pb;
+
+ if(granulepos>=0){
+ ogg_int64_t iframe=granulepos>>pbi->keyframe_granule_shift;
+ ogg_int64_t pframe=granulepos-(iframe<<pbi->keyframe_granule_shift);
+
+ return (iframe+pframe);
+ }
+
+ return(-1);
+}
More information about the commits
mailing list