[xiph-commits] r13911 - in trunk/theora/lib: . dec
tterribe at svn.xiph.org
tterribe at svn.xiph.org
Thu Sep 27 18:39:26 PDT 2007
Author: tterribe
Date: 2007-09-27 18:39:26 -0700 (Thu, 27 Sep 2007)
New Revision: 13911
Modified:
trunk/theora/lib/dec/decode.c
trunk/theora/lib/dec/internal.c
trunk/theora/lib/dec/state.c
trunk/theora/lib/internal.h
Log:
Make mv's use signed chars explicitly.
Hopefully this should fix the crash on PowerPC, though it's something we should
be doing anyway.
Modified: trunk/theora/lib/dec/decode.c
===================================================================
--- trunk/theora/lib/dec/decode.c 2007-09-28 01:37:19 UTC (rev 13910)
+++ trunk/theora/lib/dec/decode.c 2007-09-28 01:39:26 UTC (rev 13911)
@@ -602,8 +602,8 @@
const int *map_idxs;
long val;
int map_nidxs;
- char last_mv[2][2];
- char cbmvs[4][2];
+ oc_mv last_mv[2];
+ oc_mv cbmvs[4];
set_chroma_mvs=OC_SET_CHROMA_MVS_TABLE[_dec->state.info.pixel_fmt];
theora_read1(&_dec->opb,&val);
mv_comp_unpack=val?oc_clc_mv_comp_unpack:oc_vlc_mv_comp_unpack;
@@ -614,7 +614,7 @@
mb_end=mb+_dec->state.nmbs;
for(;mb<mb_end;mb++)if(mb->mode!=OC_MODE_INVALID){
oc_fragment *frag;
- char mbmv[2];
+ oc_mv mbmv;
int coded[13];
int codedi;
int ncoded;
@@ -634,8 +634,8 @@
mb_mode=mb->mode;
switch(mb_mode){
case OC_MODE_INTER_MV_FOUR:{
- char lbmvs[4][2];
- int bi;
+ oc_mv lbmvs[4];
+ int bi;
/*Mark the tail of the list, so we don't accidentally go past it.*/
coded[ncoded]=-1;
for(bi=codedi=0;bi<4;bi++){
@@ -643,8 +643,8 @@
codedi++;
frag=_dec->state.frags+mb->map[0][bi];
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);
+ frag->mv[0]=lbmvs[bi][0]=(signed char)(*mv_comp_unpack)(&_dec->opb);
+ frag->mv[1]=lbmvs[bi][1]=(signed char)(*mv_comp_unpack)(&_dec->opb);
}
else lbmvs[bi][0]=lbmvs[bi][1]=0;
}
@@ -655,7 +655,7 @@
last_mv[0][1]=lbmvs[coded[codedi-1]][1];
}
if(codedi<ncoded){
- (*set_chroma_mvs)(cbmvs,lbmvs);
+ (*set_chroma_mvs)(cbmvs,(const oc_mv *)lbmvs);
for(;codedi<ncoded;codedi++){
mapi=coded[codedi];
bi=mapi&3;
@@ -669,8 +669,8 @@
case OC_MODE_INTER_MV:{
last_mv[1][0]=last_mv[0][0];
last_mv[1][1]=last_mv[0][1];
- mbmv[0]=last_mv[0][0]=(char)(*mv_comp_unpack)(&_dec->opb);
- mbmv[1]=last_mv[0][1]=(char)(*mv_comp_unpack)(&_dec->opb);
+ mbmv[0]=last_mv[0][0]=(signed char)(*mv_comp_unpack)(&_dec->opb);
+ mbmv[1]=last_mv[0][1]=(signed char)(*mv_comp_unpack)(&_dec->opb);
}break;
case OC_MODE_INTER_MV_LAST:{
mbmv[0]=last_mv[0][0];
@@ -685,8 +685,8 @@
last_mv[0][1]=mbmv[1];
}break;
case OC_MODE_GOLDEN_MV:{
- mbmv[0]=(char)(*mv_comp_unpack)(&_dec->opb);
- mbmv[1]=(char)(*mv_comp_unpack)(&_dec->opb);
+ mbmv[0]=(signed char)(*mv_comp_unpack)(&_dec->opb);
+ mbmv[1]=(signed char)(*mv_comp_unpack)(&_dec->opb);
}break;
default:mbmv[0]=mbmv[1]=0;break;
}
@@ -925,12 +925,12 @@
run_counts[63]+=eobs;
token=oc_huff_token_decode(&_dec->opb,
_dec->huff_tables[_huff_idxs[pli]]);
- _dec->dct_tokens[0][ti++]=(char)token;
+ _dec->dct_tokens[0][ti++]=(unsigned char)token;
neb=OC_DCT_TOKEN_EXTRA_BITS[token];
if(neb){
theora_read(&_dec->opb,neb,&val);
eb=(int)val;
- _dec->extra_bits[0][ebi++]=(ogg_int16_t)eb;
+ _dec->extra_bits[0][ebi++]=(ogg_uint16_t)eb;
}
else eb=0;
skip=oc_dct_token_skip(token,eb);
@@ -997,12 +997,12 @@
run_counts[63]+=_eobs;
token=oc_huff_token_decode(&_dec->opb,
_dec->huff_tables[_huff_idxs[pli]]);
- _dec->dct_tokens[_zzi][ti++]=(char)token;
+ _dec->dct_tokens[_zzi][ti++]=(unsigned char)token;
neb=OC_DCT_TOKEN_EXTRA_BITS[token];
if(neb){
theora_read(&_dec->opb,neb,&val);
eb=(int)val;
- _dec->extra_bits[_zzi][ebi++]=(ogg_int16_t)eb;
+ _dec->extra_bits[_zzi][ebi++]=(ogg_uint16_t)eb;
}
else eb=0;
skip=oc_dct_token_skip(token,eb);
Modified: trunk/theora/lib/dec/internal.c
===================================================================
--- trunk/theora/lib/dec/internal.c 2007-09-28 01:37:19 UTC (rev 13910)
+++ trunk/theora/lib/dec/internal.c 2007-09-28 01:39:26 UTC (rev 13911)
@@ -227,13 +227,13 @@
This version is for use with chroma decimated in the X and Y directions.
_cbmvs: The chroma block-level motion vectors to fill in.
_lbmvs: The luma block-level motion vectors.*/
-static void oc_set_chroma_mvs00(char _cbmvs[4][2],const char _lbmvs[4][2]){
+static void oc_set_chroma_mvs00(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){
int dx;
int dy;
dx=_lbmvs[0][0]+_lbmvs[1][0]+_lbmvs[2][0]+_lbmvs[3][0];
dy=_lbmvs[0][1]+_lbmvs[1][1]+_lbmvs[2][1]+_lbmvs[3][1];
- _cbmvs[0][0]=(char)OC_DIV_ROUND_POW2(dx,2,2);
- _cbmvs[0][1]=(char)OC_DIV_ROUND_POW2(dy,2,2);
+ _cbmvs[0][0]=(signed char)OC_DIV_ROUND_POW2(dx,2,2);
+ _cbmvs[0][1]=(signed char)OC_DIV_ROUND_POW2(dy,2,2);
}
/*The function used to fill in the chroma plane motion vectors for a macro
@@ -241,17 +241,17 @@
This version is for use with chroma decimated in the Y direction.
_cbmvs: The chroma block-level motion vectors to fill in.
_lbmvs: The luma block-level motion vectors.*/
-static void oc_set_chroma_mvs01(char _cbmvs[4][2],const char _lbmvs[4][2]){
+static void oc_set_chroma_mvs01(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){
int dx;
int dy;
dx=_lbmvs[0][0]+_lbmvs[2][0];
dy=_lbmvs[0][1]+_lbmvs[2][1];
- _cbmvs[0][0]=(char)OC_DIV_ROUND_POW2(dx,1,1);
- _cbmvs[0][1]=(char)OC_DIV_ROUND_POW2(dy,1,1);
+ _cbmvs[0][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1);
+ _cbmvs[0][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1);
dx=_lbmvs[1][0]+_lbmvs[3][0];
dy=_lbmvs[1][1]+_lbmvs[3][1];
- _cbmvs[1][0]=(char)OC_DIV_ROUND_POW2(dx,1,1);
- _cbmvs[1][1]=(char)OC_DIV_ROUND_POW2(dy,1,1);
+ _cbmvs[1][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1);
+ _cbmvs[1][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1);
}
/*The function used to fill in the chroma plane motion vectors for a macro
@@ -259,17 +259,17 @@
This version is for use with chroma decimated in the X direction.
_cbmvs: The chroma block-level motion vectors to fill in.
_lbmvs: The luma block-level motion vectors.*/
-static void oc_set_chroma_mvs10(char _cbmvs[4][2],const char _lbmvs[4][2]){
+static void oc_set_chroma_mvs10(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){
int dx;
int dy;
dx=_lbmvs[0][0]+_lbmvs[1][0];
dy=_lbmvs[0][1]+_lbmvs[1][1];
- _cbmvs[0][0]=(char)OC_DIV_ROUND_POW2(dx,1,1);
- _cbmvs[0][1]=(char)OC_DIV_ROUND_POW2(dy,1,1);
+ _cbmvs[0][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1);
+ _cbmvs[0][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1);
dx=_lbmvs[2][0]+_lbmvs[3][0];
dy=_lbmvs[2][1]+_lbmvs[3][1];
- _cbmvs[2][0]=(char)OC_DIV_ROUND_POW2(dx,1,1);
- _cbmvs[2][1]=(char)OC_DIV_ROUND_POW2(dy,1,1);
+ _cbmvs[2][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1);
+ _cbmvs[2][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1);
}
/*The function used to fill in the chroma plane motion vectors for a macro
@@ -279,7 +279,7 @@
_lmbmv: The luma macro-block level motion vector to fill in for use in
prediction.
_lbmvs: The luma block-level motion vectors.*/
-static void oc_set_chroma_mvs11(char _cbmvs[4][2],const char _lbmvs[4][2]){
+static void oc_set_chroma_mvs11(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){
memcpy(_cbmvs,_lbmvs,4*sizeof(_lbmvs[0]));
}
Modified: trunk/theora/lib/dec/state.c
===================================================================
--- trunk/theora/lib/dec/state.c 2007-09-28 01:37:19 UTC (rev 13910)
+++ trunk/theora/lib/dec/state.c 2007-09-28 01:39:26 UTC (rev 13911)
@@ -723,12 +723,10 @@
Return: The number of offsets returned: 1 or 2.*/
int oc_state_get_mv_offsets(oc_theora_state *_state,int *_offset0,
int *_offset1,int _dx,int _dy,int _ystride,int _pli){
- static const int MV_SHIFT[6]={1,2};
- static const int MV_MASK[6]={1,3};
int offset0;
int offset1;
- int xtype;
- int ytype;
+ int xprec;
+ int yprec;
int xsign;
int ysign;
int xfrac;
@@ -749,35 +747,35 @@
appropriate amount, always truncating _away_ from zero.*/
/*These two variables decide whether we are in half- or quarter-pixel
precision in each component.*/
- xtype=!(_state->info.pixel_fmt&1)&!!_pli;
- ytype=!(_state->info.pixel_fmt&2)&!!_pli;
+ xprec=1+(!(_state->info.pixel_fmt&1)&!!_pli);
+ yprec=1+(!(_state->info.pixel_fmt&2)&!!_pli);
/*These two variables are either 0 for a non-negative vector or all 1's for
a negative one.*/
- xsign=_dx>>6;
- ysign=_dy>>6;
+ xsign=-(_dx<0);
+ ysign=-(_dy<0);
/*These two variables are either 0 if all the fractional bits are 0 or 1 if
any of them are non-zero.*/
- xfrac=!!(_dx&MV_MASK[xtype]);
- yfrac=!!(_dy&MV_MASK[ytype]);
+ xfrac=!!(_dx&(1<<xprec)-1);
+ yfrac=!!(_dy&(1<<yprec)-1);
/*This branchless code is equivalent to:
if(_dx<0){
if(_dy<0){
- offset0=-(-_dx>>MV_SHIFT[xtype])-(-_dy>>MV_SHIFT[ytype])*_ystride;
+ offset0=-(-_dx>>xprec)-(-_dy>>yprec)*_ystride;
}
else{
- offset0=-(-_dx>>MV_SHIFT[xtype])+(_dy>>MV_SHIFT[ytype])*_ystride;
+ offset0=-(-_dx>>xprec)+(_dy>>yprec)*_ystride;
}
}
else{
if(_dy<0){
- offset0=(_dx>>MV_SHIFT[xtype])-(-_dy>>MV_SHIFT[ytype])*_ystride;
+ offset0=(_dx>>xprec)-(-_dy>>yprec)*_ystride;
}
else{
- offset0=(_dx>>MV_SHIFT[xtype])+(_dy>>MV_SHIFT[ytype])*_ystride;
+ offset0=(_dx>>xprec)+(_dy>>yprec)*_ystride;
}
}*/
- *_offset0=offset0=(_dx>>MV_SHIFT[xtype])+(xfrac&xsign)+
- ((_dy>>MV_SHIFT[ytype])+(yfrac&ysign))*_ystride;
+ *_offset0=offset0=(_dx>>xprec)+(xfrac&xsign)+
+ ((_dy>>yprec)+(yfrac&ysign))*_ystride;
if(xfrac||yfrac){
int o[2];
/*This branchless code is equivalent to:
Modified: trunk/theora/lib/internal.h
===================================================================
--- trunk/theora/lib/internal.h 2007-09-28 01:37:19 UTC (rev 13910)
+++ trunk/theora/lib/internal.h 2007-09-28 01:39:26 UTC (rev 13911)
@@ -131,9 +131,11 @@
/*A map from a super block to fragment numbers.*/
-typedef int oc_sb_map[4][4];
+typedef int oc_sb_map[4][4];
/*A map from a macro block to fragment numbers.*/
-typedef int oc_mb_map[3][4];
+typedef int oc_mb_map[3][4];
+/*A motion vector.*/
+typedef signed char oc_mv[2];
@@ -228,7 +230,7 @@
For fragments completely inside or outside this region, this is NULL.*/
oc_border_info *border;
/*The motion vector used for this fragment.*/
- char mv[2];
+ oc_mv mv;
}oc_fragment;
@@ -361,8 +363,7 @@
_lmbmv: The luma macro-block level motion vector to fill in for use in
prediction.
_lbmvs: The luma block-level motion vectors.*/
-typedef void (*oc_set_chroma_mvs_func)(char _cbmvs[4][2],
- /*const*/ char _lbmvs[4][2]);
+typedef void (*oc_set_chroma_mvs_func)(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]);
@@ -427,11 +428,13 @@
#endif
/*Shared accelerated functions.*/
-void oc_frag_recon_intra(const oc_theora_state *_state,unsigned char *_dst,int _dst_ystride,
- const ogg_int16_t *_residue);
-void oc_frag_recon_inter(const oc_theora_state *_state,unsigned char *_dst,int _dst_ystride,
+void oc_frag_recon_intra(const oc_theora_state *_state,
+ unsigned char *_dst,int _dst_ystride,const ogg_int16_t *_residue);
+void oc_frag_recon_inter(const oc_theora_state *_state,
+ unsigned char *_dst,int _dst_ystride,
const unsigned char *_src,int _src_ystride,const ogg_int16_t *_residue);
-void oc_frag_recon_inter2(const oc_theora_state *_state,unsigned char *_dst,int _dst_ystride,
+void oc_frag_recon_inter2(const oc_theora_state *_state,
+ unsigned char *_dst,int _dst_ystride,
const unsigned char *_src1,int _src1_ystride,const unsigned char *_src2,
int _src2_ystride,const ogg_int16_t *_residue);
void oc_state_frag_copy(const oc_theora_state *_state,const int *_fragis,
More information about the commits
mailing list