[xiph-commits] r13596 - in trunk/theora/lib: . dec dec/x86 enc
enc/x86_32 enc/x86_64
tterribe at svn.xiph.org
tterribe at svn.xiph.org
Thu Aug 23 13:05:38 PDT 2007
Author: tterribe
Date: 2007-08-23 13:05:38 -0700 (Thu, 23 Aug 2007)
New Revision: 13596
Modified:
trunk/theora/lib/Version_script.in
trunk/theora/lib/cpu.h
trunk/theora/lib/dec/apiwrapper.c
trunk/theora/lib/dec/decint.h
trunk/theora/lib/dec/decode.c
trunk/theora/lib/dec/dequant.c
trunk/theora/lib/dec/fragment.c
trunk/theora/lib/dec/huffdec.c
trunk/theora/lib/dec/huffdec.h
trunk/theora/lib/dec/info.c
trunk/theora/lib/dec/internal.c
trunk/theora/lib/dec/ocintrin.h
trunk/theora/lib/dec/state.c
trunk/theora/lib/dec/x86/mmxstate.c
trunk/theora/lib/dec/x86/x86int.h
trunk/theora/lib/dec/x86/x86state.c
trunk/theora/lib/enc/codec_internal.h
trunk/theora/lib/enc/dct.c
trunk/theora/lib/enc/dsp.h
trunk/theora/lib/enc/encoder_toplevel.c
trunk/theora/lib/enc/hufftables.h
trunk/theora/lib/enc/x86_32/dct_decode_mmx.c
trunk/theora/lib/enc/x86_32/dsp_mmx.c
trunk/theora/lib/enc/x86_32/dsp_mmxext.c
trunk/theora/lib/enc/x86_32/fdct_mmx.c
trunk/theora/lib/enc/x86_32/idct_mmx.c
trunk/theora/lib/enc/x86_32/recon_mmx.c
trunk/theora/lib/enc/x86_64/fdct_mmx.c
trunk/theora/lib/internal.h
Log:
Various clean-ups in preparation for release.
Fix theora_clear() so it actually clears an encoder instance.
Remove link-time dependencies of the decoder code on the encoder code.
This allows the separation of the two libraries, but requires a virtual
function table of entry points into the encoder in order to work with the old
libtheora API functions that don't distinguish between encoder and decoder
objects.
Future upgrades will need to be careful of this bit to retain ABI
compatibility.
Fix up #include directives to point directly to the project-local files they
are including.
General warning clean-up.
Minor updates to the version script; this still needs to be fixed to use the
proper version macros from configure.ac.
Modified: trunk/theora/lib/Version_script.in
===================================================================
--- trunk/theora/lib/Version_script.in 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/Version_script.in 2007-08-23 20:05:38 UTC (rev 13596)
@@ -44,14 +44,16 @@
theora_comment_query_count;
theora_comment_clear;
- th_version_number;
th_version_string;
-
+ th_version_number;
+
+ th_decode_headerin;
th_decode_alloc;
+ th_setup_free;
th_decode_ctl;
- th_decode_headerin;
th_decode_packetin;
th_decode_ycbcr_out;
+ th_decode_free;
th_packet_isheader;
th_packet_iskeyframe;
@@ -59,12 +61,9 @@
th_granule_frame;
th_granule_time;
- th_setup_free;
- th_decode_free;
-
th_info_init;
th_info_clear;
-
+
th_comment_init;
th_comment_add;
th_comment_add_tag;
Modified: trunk/theora/lib/cpu.h
===================================================================
--- trunk/theora/lib/cpu.h 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/cpu.h 2007-08-23 20:05:38 UTC (rev 13596)
@@ -17,7 +17,6 @@
#if !defined(_x86_cpu_H)
# define _x86_cpu_H (1)
#include "internal.h"
-#include "codec_internal.h"
#define OC_CPU_X86_MMX (1<<0)
#define OC_CPU_X86_3DNOW (1<<1)
Modified: trunk/theora/lib/dec/apiwrapper.c
===================================================================
--- trunk/theora/lib/dec/apiwrapper.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/apiwrapper.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -24,7 +24,7 @@
/*theora-exp header.*/
#include "theora/theoradec.h"
/*For oc_ilog et al.*/
-#include "internal.h"
+#include "../internal.h"
typedef struct th_api_wrapper th_api_wrapper;
@@ -65,15 +65,14 @@
}
void theora_clear(theora_state *_td){
- if(_td->i!=NULL)
- if(_td->internal_encode==NULL) {
- theora_info_clear(_td->i);
- _ogg_free(_td->i);
- _td->i=NULL;
- }
- else {
- //FIXME: what needs to be freed if theora_state was created by encoder
- }
+ if(_td->internal_encode!=NULL){
+ (*((oc_enc_dispatch_vtbl *)_td->internal_encode)->clear)(_td);
+ }
+ else if(_td->i!=NULL){
+ theora_info_clear(_td->i);
+ _ogg_free(_td->i);
+ _td->i=NULL;
+ }
}
static void theora_info2th_info(th_info *_info,const theora_info *_ci){
@@ -132,8 +131,7 @@
/*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);
+ return 0;
}
static void th_info2theora_info(theora_info *_ci,const th_info *_info){
@@ -222,6 +220,15 @@
return ret;
}
+int theora_control(theora_state *_td,int _req,void *_buf,size_t _buf_sz){
+ if(_td->internal_encode!=NULL){
+ return (*((oc_enc_dispatch_vtbl *)_td->internal_encode)->control)(_td,
+ _req,_buf,_buf_sz);
+ }
+ return th_decode_ctl(((th_api_wrapper *)_td->i->codec_setup)->decode,
+ _req,_buf,_buf_sz);
+}
+
int theora_packet_isheader(ogg_packet *_op){
return th_packet_isheader(_op);
}
@@ -238,16 +245,21 @@
}
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);
+ if(_td->internal_encode!=NULL){
+ return
+ (*((oc_enc_dispatch_vtbl *)_td->internal_encode)->granule_frame)(_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);
+ if(_td->internal_encode!=NULL){
+ return
+ (*((oc_enc_dispatch_vtbl *)_td->internal_encode)->granule_time)(_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);
}
@@ -270,4 +282,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
+}
Modified: trunk/theora/lib/dec/decint.h
===================================================================
--- trunk/theora/lib/dec/decint.h 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/decint.h 2007-08-23 20:05:38 UTC (rev 13596)
@@ -19,7 +19,7 @@
#if !defined(_decint_H)
# define _decint_H (1)
# include "theora/theoradec.h"
-# include "internal.h"
+# include "../internal.h"
typedef struct th_setup_info oc_setup_info;
typedef struct th_dec_ctx oc_dec_ctx;
Modified: trunk/theora/lib/dec/decode.c
===================================================================
--- trunk/theora/lib/dec/decode.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/decode.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -621,6 +621,7 @@
int mapi;
int mapii;
int fragi;
+ int mb_mode;
/*Search for at least one coded fragment.*/
ncoded=mapii=0;
do{
@@ -630,7 +631,8 @@
}
while(++mapii<map_nidxs);
if(ncoded<=0)continue;
- switch(mb->mode){
+ mb_mode=mb->mode;
+ switch(mb_mode){
case OC_MODE_INTER_MV_FOUR:{
char lbmvs[4][2];
int bi;
@@ -640,7 +642,7 @@
if(coded[codedi]==bi){
codedi++;
frag=_dec->state.frags+mb->map[0][bi];
- frag->mbmode=mb->mode;
+ frag->mbmode=mb_mode;
frag->mv[0]=lbmvs[bi][0]=(char)(*mv_comp_unpack)(&_dec->opb);
frag->mv[1]=lbmvs[bi][1]=(char)(*mv_comp_unpack)(&_dec->opb);
}
@@ -658,7 +660,7 @@
mapi=coded[codedi];
bi=mapi&3;
frag=_dec->state.frags+mb->map[mapi>>2][bi];
- frag->mbmode=mb->mode;
+ frag->mbmode=mb_mode;
frag->mv[0]=cbmvs[bi][0];
frag->mv[1]=cbmvs[bi][1];
}
@@ -690,12 +692,12 @@
}
/*4MV mode fills in the fragments itself.
For all other modes we can use this common code.*/
- if(mb->mode!=OC_MODE_INTER_MV_FOUR){
+ if(mb_mode!=OC_MODE_INTER_MV_FOUR){
for(codedi=0;codedi<ncoded;codedi++){
mapi=coded[codedi];
fragi=mb->map[mapi>>2][mapi&3];
frag=_dec->state.frags+fragi;
- frag->mbmode=mb->mode;
+ frag->mbmode=mb_mode;
frag->mv[0]=mbmv[0];
frag->mv[1]=mbmv[1];
}
Modified: trunk/theora/lib/dec/dequant.c
===================================================================
--- trunk/theora/lib/dec/dequant.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/dequant.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -26,18 +26,18 @@
int oc_quant_params_unpack(oggpack_buffer *_opb,
th_quant_info *_qinfo){
th_quant_base *base_mats;
- long val;
- int nbase_mats;
- int sizes[64];
- int indices[64];
- int nbits;
- int bmi;
- int ci;
- int qti;
- int pli;
- int qri;
- int qi;
- int i;
+ long val;
+ int nbase_mats;
+ int sizes[64];
+ int indices[64];
+ int nbits;
+ int bmi;
+ int ci;
+ int qti;
+ int pli;
+ int qri;
+ int qi;
+ int i;
theora_read(_opb,3,&val);
nbits=(int)val;
for(qi=0;qi<64;qi++){
@@ -69,7 +69,7 @@
for(i=0;i<6;i++){
th_quant_ranges *qranges;
th_quant_base *qrbms;
- int *qrsizes;
+ int *qrsizes;
qti=i/3;
pli=i%3;
qranges=_qinfo->qi_ranges[qti]+pli;
@@ -115,8 +115,8 @@
qranges->nranges=qri;
qranges->sizes=qrsizes=(int *)_ogg_malloc(qri*sizeof(qrsizes[0]));
memcpy(qrsizes,sizes,qri*sizeof(qrsizes[0]));
- qranges->base_matrices=qrbms=(th_quant_base *)_ogg_malloc(
- (qri+1)*sizeof(qrbms[0]));
+ qrbms=(th_quant_base *)_ogg_malloc((qri+1)*sizeof(qrbms[0]));
+ qranges->base_matrices=(const th_quant_base *)qrbms;
do{
bmi=indices[qri];
/*Note: The caller is responsible for cleaning up any partially
Modified: trunk/theora/lib/dec/fragment.c
===================================================================
--- trunk/theora/lib/dec/fragment.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/fragment.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -15,7 +15,7 @@
********************************************************************/
-#include "internal.h"
+#include "../internal.h"
void oc_frag_recon_intra(const oc_theora_state *_state,unsigned char *_dst,
int _dst_ystride,const ogg_int16_t *_residue){
@@ -27,7 +27,11 @@
int i;
for(i=0;i<8;i++){
int j;
- for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(*_residue+++128);
+ for(j=0;j<8;j++){
+ int res;
+ res=*_residue++;
+ _dst[j]=OC_CLAMP255(res+128);
+ }
_dst+=_dst_ystride;
}
}
@@ -44,7 +48,11 @@
int i;
for(i=0;i<8;i++){
int j;
- for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(*_residue+++_src[j]);
+ for(j=0;j<8;j++){
+ int res;
+ res=*_residue++;
+ _dst[j]=OC_CLAMP255(res+_src[j]);
+ }
_dst+=_dst_ystride;
_src+=_src_ystride;
}
@@ -64,7 +72,9 @@
for(i=0;i<8;i++){
int j;
for(j=0;j<8;j++){
- _dst[j]=OC_CLAMP255(*_residue+++((int)_src1[j]+_src2[j]>>1));
+ int res;
+ res=*_residue++;
+ _dst[j]=OC_CLAMP255(res+((int)_src1[j]+_src2[j]>>1));
}
_dst+=_dst_ystride;
_src1+=_src1_ystride;
Modified: trunk/theora/lib/dec/huffdec.c
===================================================================
--- trunk/theora/lib/dec/huffdec.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/huffdec.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -251,7 +251,7 @@
_dst: The array to store the copy in.
_src: The array of trees to copy.*/
void oc_huff_trees_copy(oc_huff_node *_dst[TH_NHUFFMAN_TABLES],
- const oc_huff_node *const _src[TH_NHUFFMAN_TABLES]){
+ /*const*/ oc_huff_node *const _src[TH_NHUFFMAN_TABLES]){
int i;
for(i=0;i<TH_NHUFFMAN_TABLES;i++)_dst[i]=oc_huff_tree_copy(_src[i]);
}
Modified: trunk/theora/lib/dec/huffdec.h
===================================================================
--- trunk/theora/lib/dec/huffdec.h 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/huffdec.h 2007-08-23 20:05:38 UTC (rev 13596)
@@ -61,7 +61,7 @@
int oc_huff_trees_unpack(oggpack_buffer *_opb,
oc_huff_node *_nodes[TH_NHUFFMAN_TABLES]);
void oc_huff_trees_copy(oc_huff_node *_dst[TH_NHUFFMAN_TABLES],
- const oc_huff_node *const _src[TH_NHUFFMAN_TABLES]);
+ /*const*/ oc_huff_node *const _src[TH_NHUFFMAN_TABLES]);
void oc_huff_trees_clear(oc_huff_node *_nodes[TH_NHUFFMAN_TABLES]);
int oc_huff_token_decode(oggpack_buffer *_opb,const oc_huff_node *_node);
Modified: trunk/theora/lib/dec/info.c
===================================================================
--- trunk/theora/lib/dec/info.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/info.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -18,7 +18,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
-#include "internal.h"
+#include "../internal.h"
Modified: trunk/theora/lib/dec/internal.c
===================================================================
--- trunk/theora/lib/dec/internal.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/internal.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -18,7 +18,7 @@
#include <stdlib.h>
#include <limits.h>
#include <string.h>
-#include "internal.h"
+#include "../internal.h"
#include "idct.h"
@@ -287,10 +287,10 @@
macro block when 4 different motion vectors are specified in the luma
plane.*/
const oc_set_chroma_mvs_func OC_SET_CHROMA_MVS_TABLE[TH_PF_NFORMATS]={
- oc_set_chroma_mvs00,
- oc_set_chroma_mvs01,
- oc_set_chroma_mvs10,
- oc_set_chroma_mvs11
+ (oc_set_chroma_mvs_func)oc_set_chroma_mvs00,
+ (oc_set_chroma_mvs_func)oc_set_chroma_mvs01,
+ (oc_set_chroma_mvs_func)oc_set_chroma_mvs10,
+ (oc_set_chroma_mvs_func)oc_set_chroma_mvs11
};
@@ -339,7 +339,7 @@
return (void **)ret;
}
-void oc_free_2d(void **_ptr){
+void oc_free_2d(void *_ptr){
_ogg_free(_ptr);
}
Modified: trunk/theora/lib/dec/ocintrin.h
===================================================================
--- trunk/theora/lib/dec/ocintrin.h 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/ocintrin.h 2007-08-23 20:05:38 UTC (rev 13596)
@@ -32,9 +32,6 @@
return (_a&~ambsign)+(_b&ambsign);
}*/
-static unsigned char oc_clamp255(int _x){
- return (unsigned char)(((_x<0)-1)&(_x|-(_x>255)));
-}
#define OC_MAXI(_a,_b) ((_a)<(_b)?(_b):(_a))
#define OC_MINI(_a,_b) ((_a)>(_b)?(_b):(_a))
@@ -45,7 +42,7 @@
_b: The value to clamp.
_c: The upper boud.*/
#define OC_CLAMPI(_a,_b,_c) (OC_MAXI(_a,OC_MINI(_b,_c)))
-#define OC_CLAMP255(_x) (oc_clamp255(_x))
+#define OC_CLAMP255(_x) ((unsigned char)((((_x)<0)-1)&((_x)|-((_x)>255))))
/*Divides an integer by a power of two, truncating towards 0.
_dividend: The integer to divide.
_shift: The non-negative power of two to divide by.
Modified: trunk/theora/lib/dec/state.c
===================================================================
--- trunk/theora/lib/dec/state.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/state.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -17,9 +17,9 @@
#include <stdlib.h>
#include <string.h>
-#include "internal.h"
+#include "../internal.h"
#include "idct.h"
-#if defined(OC_X86ASM)
+#if defined(USE_ASM)
# include "x86/x86int.h"
#endif
#if defined(OC_DUMP_IMAGES)
@@ -535,7 +535,7 @@
/*Initialize the accelerated function pointers.*/
void oc_state_vtable_init(oc_theora_state *_state){
-#if defined(OC_X86ASM)
+#if defined(USE_ASM)
oc_state_vtable_init_x86(_state);
#else
oc_state_vtable_init_c(_state);
Modified: trunk/theora/lib/dec/x86/mmxstate.c
===================================================================
--- trunk/theora/lib/dec/x86/mmxstate.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/x86/mmxstate.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -18,7 +18,7 @@
/*MMX acceleration of complete fragment reconstruction algorithm.
Originally written by Rudolf Marek.*/
#include "x86int.h"
-#include "../internal.h"
+#include "../../internal.h"
#if defined(USE_ASM)
Modified: trunk/theora/lib/dec/x86/x86int.h
===================================================================
--- trunk/theora/lib/dec/x86/x86int.h 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/x86/x86int.h 2007-08-23 20:05:38 UTC (rev 13596)
@@ -17,7 +17,7 @@
#if !defined(_x86_x86int_H)
# define _x86_x86int_H (1)
-# include "internal.h"
+# include "../../internal.h"
void oc_state_vtable_init_x86(oc_theora_state *_state);
Modified: trunk/theora/lib/dec/x86/x86state.c
===================================================================
--- trunk/theora/lib/dec/x86/x86state.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/dec/x86/x86state.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -19,7 +19,7 @@
#if defined(USE_ASM)
-#include "cpu.h"
+#include "../../cpu.h"
void oc_state_vtable_init_x86(oc_theora_state *_state){
_state->cpu_flags=oc_cpu_flags_get();
Modified: trunk/theora/lib/enc/codec_internal.h
===================================================================
--- trunk/theora/lib/enc/codec_internal.h 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/codec_internal.h 2007-08-23 20:05:38 UTC (rev 13596)
@@ -535,6 +535,10 @@
/* Encoder (Compressor) instance -- installed in a theora_state */
typedef struct CP_INSTANCE {
+ /*This structure must be first.
+ It contains entry points accessed by the decoder library's API wrapper, and
+ is the only assumption that library makes about our internal format.*/
+ oc_enc_dispatch_vtbl dispatch_vtbl;
/* Compressor Configuration */
SCAN_CONFIG_DATA ScanConfig;
Modified: trunk/theora/lib/enc/dct.c
===================================================================
--- trunk/theora/lib/enc/dct.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/dct.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -17,7 +17,7 @@
#include "codec_internal.h"
#include "dsp.h"
-#include "cpu.h"
+#include "../cpu.h"
static ogg_int32_t xC1S7 = 64277;
static ogg_int32_t xC2S6 = 60547;
Modified: trunk/theora/lib/enc/dsp.h
===================================================================
--- trunk/theora/lib/enc/dsp.h 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/dsp.h 2007-08-23 20:05:38 UTC (rev 13596)
@@ -19,7 +19,7 @@
#define DSP_H
#include "theora/theora.h"
-#include "cpu.h"
+#include "../cpu.h"
typedef struct
{
Modified: trunk/theora/lib/enc/encoder_toplevel.c
===================================================================
--- trunk/theora/lib/enc/encoder_toplevel.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/encoder_toplevel.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include "toplevel_lookup.h"
-#include "internal.h"
+#include "../internal.h"
#include "dsp.h"
#include "codec_internal.h"
@@ -888,6 +888,8 @@
return(ret);
}
+static void theora_encode_dispatch_init(CP_INSTANCE *cpi);
+
int theora_encode_init(theora_state *th, theora_info *c){
int i;
@@ -897,6 +899,7 @@
/*Currently only the 4:2:0 format is supported.*/
if(c->pixelformat!=OC_PF_420)return OC_IMPL;
th->internal_encode=cpi=_ogg_calloc(1,sizeof(*cpi));
+ theora_encode_dispatch_init(cpi);
dsp_static_init (&cpi->dsp);
memcpy (&cpi->pb.dsp, &cpi->dsp, sizeof(DspFunctions));
@@ -1325,7 +1328,9 @@
return(0);
}
-void theora_encoder_clear (CP_INSTANCE * cpi){
+static void theora_encode_clear (theora_state *th){
+ CP_INSTANCE *cpi;
+ cpi=(CP_INSTANCE *)th->internal_encode;
if(cpi){
ClearHuffmanSet(&cpi->pb);
@@ -1340,11 +1345,13 @@
_ogg_free(cpi->oggbuffer);
_ogg_free(cpi);
}
+ th->internal_encode=NULL;
}
/* returns, in seconds, absolute time of current packet in given
logical stream */
-double theora_granule_time_enc(theora_state *th,ogg_int64_t granulepos){
+static double theora_encode_granule_time(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);
@@ -1365,7 +1372,8 @@
}
/* returns frame number of current packet in given logical stream */
-ogg_int64_t theora_granule_frame_enc(theora_state *th,ogg_int64_t granulepos){
+static ogg_int64_t theora_encode_granule_frame(theora_state *th,
+ ogg_int64_t granulepos){
CP_INSTANCE *cpi=(CP_INSTANCE *)(th->internal_encode);
PB_INSTANCE *pbi=(PB_INSTANCE *)(th->internal_decode);
@@ -1382,7 +1390,8 @@
}
-int theora_control(theora_state *th,int req,void *buf,size_t buf_sz) {
+static int theora_encode_control(theora_state *th,int req,
+ void *buf,size_t buf_sz) {
int value;
@@ -1447,3 +1456,10 @@
return TH_EIMPL;
}
}
+
+static void theora_encode_dispatch_init(CP_INSTANCE *cpi){
+ cpi->dispatch_vtbl.clear=theora_encode_clear;
+ cpi->dispatch_vtbl.control=theora_encode_control;
+ cpi->dispatch_vtbl.granule_frame=theora_encode_granule_frame;
+ cpi->dispatch_vtbl.granule_time=theora_encode_granule_time;
+}
Modified: trunk/theora/lib/enc/hufftables.h
===================================================================
--- trunk/theora/lib/enc/hufftables.h 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/hufftables.h 2007-08-23 20:05:38 UTC (rev 13596)
@@ -15,7 +15,7 @@
********************************************************************/
-#include "huffman.h"
+#include "../dec/huffman.h"
#include "codec_internal.h"
const unsigned char ExtraBitLengths_VP31[MAX_ENTROPY_TOKENS] = {
Modified: trunk/theora/lib/enc/x86_32/dct_decode_mmx.c
===================================================================
--- trunk/theora/lib/enc/x86_32/dct_decode_mmx.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/x86_32/dct_decode_mmx.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -17,7 +17,7 @@
#include <stdlib.h>
-#include "codec_internal.h"
+#include "../codec_internal.h"
#if defined(USE_ASM)
Modified: trunk/theora/lib/enc/x86_32/dsp_mmx.c
===================================================================
--- trunk/theora/lib/enc/x86_32/dsp_mmx.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/x86_32/dsp_mmx.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -17,8 +17,8 @@
#include <stdlib.h>
-#include "codec_internal.h"
-#include "dsp.h"
+#include "../codec_internal.h"
+#include "../dsp.h"
#if defined(USE_ASM)
Modified: trunk/theora/lib/enc/x86_32/dsp_mmxext.c
===================================================================
--- trunk/theora/lib/enc/x86_32/dsp_mmxext.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/x86_32/dsp_mmxext.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -17,8 +17,8 @@
#include <stdlib.h>
-#include "codec_internal.h"
-#include "dsp.h"
+#include "../codec_internal.h"
+#include "../dsp.h"
#if defined(USE_ASM)
Modified: trunk/theora/lib/enc/x86_32/fdct_mmx.c
===================================================================
--- trunk/theora/lib/enc/x86_32/fdct_mmx.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/x86_32/fdct_mmx.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -18,8 +18,8 @@
/* mmx fdct implementation */
#include "theora/theora.h"
-#include "codec_internal.h"
-#include "dsp.h"
+#include "../codec_internal.h"
+#include "../dsp.h"
#if defined(USE_ASM)
@@ -290,8 +290,7 @@
version. */
static void fdct_short__mmx ( ogg_int16_t *InputData, ogg_int16_t *OutputData)
{
- ogg_int64_t __attribute__((aligned(8))) align_tmp[16];
- ogg_int16_t *const temp= (ogg_int16_t*)align_tmp;
+ ogg_int16_t __attribute__((aligned(8))) temp[8*8];
__asm__ __volatile__ (
" .p2align 4 \n\t"
Modified: trunk/theora/lib/enc/x86_32/idct_mmx.c
===================================================================
--- trunk/theora/lib/enc/x86_32/idct_mmx.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/x86_32/idct_mmx.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -15,7 +15,7 @@
********************************************************************/
-#include "codec_internal.h"
+#include "../codec_internal.h"
#if defined(USE_ASM)
Modified: trunk/theora/lib/enc/x86_32/recon_mmx.c
===================================================================
--- trunk/theora/lib/enc/x86_32/recon_mmx.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/x86_32/recon_mmx.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -15,7 +15,7 @@
********************************************************************/
-#include "codec_internal.h"
+#include "../codec_internal.h"
#if defined(USE_ASM)
Modified: trunk/theora/lib/enc/x86_64/fdct_mmx.c
===================================================================
--- trunk/theora/lib/enc/x86_64/fdct_mmx.c 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/enc/x86_64/fdct_mmx.c 2007-08-23 20:05:38 UTC (rev 13596)
@@ -291,8 +291,7 @@
version. */
static void fdct_short__mmx ( ogg_int16_t *InputData, ogg_int16_t *OutputData)
{
- ogg_int64_t __attribute__((aligned(8))) align_tmp[16];
- ogg_int16_t *const temp= (ogg_int16_t*)align_tmp;
+ ogg_int16_t __attribute__((aligned(8))) temp[8*8];
__asm__ __volatile__ (
" .balign 16 \n\t"
Modified: trunk/theora/lib/internal.h
===================================================================
--- trunk/theora/lib/internal.h 2007-08-23 16:58:18 UTC (rev 13595)
+++ trunk/theora/lib/internal.h 2007-08-23 20:05:38 UTC (rev 13596)
@@ -23,12 +23,14 @@
# endif
# include "theora/codec.h"
# include "theora/theora.h"
-# include "ocintrin.h"
-# include "huffman.h"
-# include "quant.h"
+# include "dec/ocintrin.h"
+# include "dec/huffman.h"
+# include "dec/quant.h"
/*Thank you Microsoft, I know the order of operations.*/
-#pragma warning(disable:4554)
+# if defined(_MSC_VER)
+# pragma warning(disable:4554)
+# endif
/*This library's version.*/
# define OC_VENDOR_STRING "Xiph.Org libTheora I 20060526 3 2 0"
@@ -352,7 +354,7 @@
prediction.
_lbmvs: The luma block-level motion vectors.*/
typedef void (*oc_set_chroma_mvs_func)(char _cbmvs[4][2],
- const char _lbmvs[4][2]);
+ /*const*/ char _lbmvs[4][2]);
@@ -386,7 +388,7 @@
int oc_ilog(unsigned _v);
void **oc_malloc_2d(size_t _height,size_t _width,size_t _sz);
void **oc_calloc_2d(size_t _height,size_t _width,size_t _sz);
-void oc_free_2d(void **_ptr);
+void oc_free_2d(void *_ptr);
void oc_ycbcr_buffer_flip(th_ycbcr_buffer _dst,
const th_ycbcr_buffer _src);
@@ -450,7 +452,26 @@
int _refi,int _pli,int _fragy0,int _fragy_end);
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);
+/*We need a way to call a few enocder functions without introducing a link-time
+ dependency into the decoder, while still allowing the old alpha API which
+ does not distinguish between encoder and decoder objects to be used.
+ We do this by placing a function table at the start of the encoder object
+ which can dispatch into the encoder library.*/
+typedef void (*oc_enc_clear_func)(theora_state *_th);
+typedef int (*oc_enc_control_func)(theora_state *th,int req,
+ void *buf,size_t buf_sz);
+typedef ogg_int64_t (*oc_enc_granule_frame_func)(theora_state *_th,
+ ogg_int64_t _granulepos);
+typedef double (*oc_enc_granule_time_func)(theora_state *_th,
+ ogg_int64_t _granulepos);
+typedef struct oc_enc_dispatch_vtbl oc_enc_dispatch_vtbl;
+
+struct oc_enc_dispatch_vtbl{
+ oc_enc_clear_func clear;
+ oc_enc_control_func control;
+ oc_enc_granule_frame_func granule_frame;
+ oc_enc_granule_time_func granule_time;
+};
+
#endif
More information about the commits
mailing list