[xiph-commits] r14310 - branches/theora-thusnelda/lib/enc
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Tue Dec 18 00:43:34 PST 2007
Author: xiphmont
Date: 2007-12-18 00:43:32 -0800 (Tue, 18 Dec 2007)
New Revision: 14310
Modified:
branches/theora-thusnelda/lib/enc/codec_internal.h
branches/theora-thusnelda/lib/enc/encode.c
branches/theora-thusnelda/lib/enc/frarray.c
branches/theora-thusnelda/lib/enc/frinit.c
branches/theora-thusnelda/lib/enc/mcomp.c
Log:
Move MB/SB aggregation from pointer to index
Modified: branches/theora-thusnelda/lib/enc/codec_internal.h
===================================================================
--- branches/theora-thusnelda/lib/enc/codec_internal.h 2007-12-18 07:46:54 UTC (rev 14309)
+++ branches/theora-thusnelda/lib/enc/codec_internal.h 2007-12-18 08:43:32 UTC (rev 14310)
@@ -119,15 +119,15 @@
};
typedef struct macroblock {
- fragment_t *y[4]; // MV (raster) order
- fragment_t *u;
- fragment_t *v;
+ int y[4]; // raster order
+ int u;
+ int v;
} macroblock_t;
#define SB_MB_BLFRAG(sb,mbnum) ((sb).f[ ((mbnum)<2? ((mbnum)==0?0:4) : ((mbnum)==2?8:14)) ])
typedef struct superblock {
- fragment_t *f[16]; // hilbert order
- macroblock_t *m[4]; // hilbert order
+ int f[16]; // hilbert order
+ int m[4]; // hilbert order
} superblock_t;
typedef ogg_int16_t quant_table[64];
Modified: branches/theora-thusnelda/lib/enc/encode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encode.c 2007-12-18 07:46:54 UTC (rev 14309)
+++ branches/theora-thusnelda/lib/enc/encode.c 2007-12-18 08:43:32 UTC (rev 14310)
@@ -163,10 +163,10 @@
int mode = 0;
for ( B=0; B<4; B++, frag++ ) {
- fragment_t *fp = sp->f[frag];
- int fi = fp - cpi->frag[0];
+ int fi = sp->f[frag];
+ fragment_t *fp = &cpi->frag[0][fi];
- if ( fp && cp[fi] ) {
+ if ( cp[fi] ) {
/* transform and quantize block */
TransformQuantizeBlock( cpi, fi );
@@ -389,20 +389,12 @@
for ( SB=0 ; SB < cpi->super_n[0]; SB++ ){
superblock_t *sp = &cpi->super[0][SB];
for ( MB=0; MB<4; MB++ ) {
- macroblock_t *mbp = sp->m[MB];
- fragment_t *fp;
- int fi;
+ macroblock_t *mbp = &cpi->macro[sp->m[MB]];
+ int fi = mbp->y[0];
- if(!mbp) continue;
-
- fp = mbp->y[0];
- fi = (fp ? fp - cpi->frag[0] : -1);
-
- for(B=1; (!fp || !cp[fi]) && B<4; B++ ){
- fp = mbp->y[B];
- fi = (fp ? fp - cpi->frag[0] : -1);
- }
- if(fp && cp[fi]){
+ for(B=1; !cp[fi] && B<4; B++ ) fi = mbp->y[B];
+
+ if(cp[fi]){
/* Add the appropriate mode entropy token. */
int index = ModeScheme[mp[fi]];
oggpackB_write( opb, ModeWords[index],
@@ -438,30 +430,24 @@
for ( SB=0 ; SB < cpi->super_n[0]; SB++ ){
superblock_t *sp = &cpi->super[0][SB];
for ( MB=0; MB<4; MB++ ) {
- macroblock_t *mbp = sp->m[MB];
- fragment_t *fp;
- int fi;
+ macroblock_t *mbp = &cpi->macro[sp->m[MB]];
+ int fi = mbp->y[0];
+
+ for(B=1; !cp[fi] && B<4; B++ ) fi = mbp->y[B];
+ if(B==4) continue;
- if(!mbp) continue;
-
- fp = mbp->y[0];
- fi = (fp ? fp - cpi->frag[0] : -1);
- for(B=1; !fp && !cp[fi] && B<4; B++ ){
- fp = mbp->y[B];
- fi = (fp ? fp - cpi->frag[0] : -1);
- }
-
- if(!fp || !cp[fi]) continue;
if(mp[fi]==CODE_INTER_PLUS_MV || mp[fi]==CODE_GOLDEN_MV){
+ fragment_t *fp = &cpi->frag[0][fi];
+
/* One MV for the macroblock */
oggpackB_write( opb, MvPatternPtr[fp->mv.x], MvBitsPtr[fp->mv.x] );
oggpackB_write( opb, MvPatternPtr[fp->mv.y], MvBitsPtr[fp->mv.y] );
}else if (mp[fi] == CODE_INTER_FOURMV){
/* MV for each codedblock */
for(B=0; B<4; B++ ){
- fp = mbp->y[B];
- fi = (fp ? fp - cpi->frag[0] : -1);
- if(fp && cp[fi]){
+ fi = mbp->y[B];
+ if(cp[fi]){
+ fragment_t *fp = &cpi->frag[0][fi];
oggpackB_write( opb, MvPatternPtr[fp->mv.x], MvBitsPtr[fp->mv.x] );
oggpackB_write( opb, MvPatternPtr[fp->mv.y], MvBitsPtr[fp->mv.y] );
}
@@ -537,13 +523,12 @@
macroblock_t *mp,
mv_t *mv,
int mode){
- fragment_t *fp0 = cpi->frag[0];
- SetFragMotionVectorAndMode(cpi, mp->y[0] - fp0, mv, mode);
- SetFragMotionVectorAndMode(cpi, mp->y[1] - fp0, mv, mode);
- SetFragMotionVectorAndMode(cpi, mp->y[2] - fp0, mv, mode);
- SetFragMotionVectorAndMode(cpi, mp->y[3] - fp0, mv, mode);
- SetFragMotionVectorAndMode(cpi, mp->u - fp0, mv, mode);
- SetFragMotionVectorAndMode(cpi, mp->v - fp0, mv, mode);
+ SetFragMotionVectorAndMode(cpi, mp->y[0], mv, mode);
+ SetFragMotionVectorAndMode(cpi, mp->y[1], mv, mode);
+ SetFragMotionVectorAndMode(cpi, mp->y[2], mv, mode);
+ SetFragMotionVectorAndMode(cpi, mp->y[3], mv, mode);
+ SetFragMotionVectorAndMode(cpi, mp->u, mv, mode);
+ SetFragMotionVectorAndMode(cpi, mp->v, mv, mode);
}
ogg_uint32_t PickModes(CP_INSTANCE *cpi,
@@ -577,7 +562,6 @@
mv_t GFMVect = {0,0};
mv_t ZeroVect = {0,0};
- int MBCodedFlag;
unsigned char QIndex = cpi->BaseQ; // temporary
unsigned char *cp = cpi->frag_coded[0];
@@ -613,23 +597,13 @@
superblock_t *sp = &cpi->super[0][SB];
/* Check its four Macro-Blocks */
for ( MB=0; MB<4; MB++ ) {
- macroblock_t *mp = sp->m[MB];
+ macroblock_t *mbp = &cpi->macro[sp->m[MB]];
+ int fi = mbp->y[0];
+
+ for ( B=1; !cp[fi] && B<4; B++ ) fi = mbp->y[B];
- if(!mp) continue;
-
- /* Is the current macro block coded (in part or in whole) */
- MBCodedFlag = 0;
- for ( B=0; B<4; B++ ) {
- fragment_t *fp = mp->y[B];
- int fi = (fp ? fp - cpi->frag[0] : -1);
- if ( fp && cp[fi] ){
- MBCodedFlag = 1;
- break;
- }
- }
-
/* This one isn't coded go to the next one */
- if(!MBCodedFlag) continue;
+ if(!cp[fi]) continue;
/**************************************************************
Find the block choice with the lowest error
@@ -643,24 +617,24 @@
/* Look at the intra coding error. */
- MBIntraError = GetMBIntraError( cpi, mp );
+ MBIntraError = GetMBIntraError( cpi, mbp );
BestError = (BestError > MBIntraError) ? MBIntraError : BestError;
/* Get the golden frame error */
MBGFError = GetMBInterError( cpi, cpi->frame, cpi->golden,
- mp, 0, 0 );
+ mbp, 0, 0 );
BestError = (BestError > MBGFError) ? MBGFError : BestError;
/* Calculate the 0,0 case. */
MBInterError = GetMBInterError( cpi, cpi->frame,
cpi->lastrecon,
- mp, 0, 0 );
+ mbp, 0, 0 );
BestError = (BestError > MBInterError) ? MBInterError : BestError;
/* Measure error for last MV */
MBLastInterError = GetMBInterError( cpi, cpi->frame,
cpi->lastrecon,
- mp, LastInterMVect.x,
+ mbp, LastInterMVect.x,
LastInterMVect.y );
BestError = (BestError > MBLastInterError) ?
MBLastInterError : BestError;
@@ -668,7 +642,7 @@
/* Measure error for prior last MV */
MBPriorLastInterError = GetMBInterError( cpi, cpi->frame,
cpi->lastrecon,
- mp, PriorLastInterMVect.x,
+ mbp, PriorLastInterMVect.x,
PriorLastInterMVect.y );
BestError = (BestError > MBPriorLastInterError) ?
MBPriorLastInterError : BestError;
@@ -685,7 +659,7 @@
quick mode. */
if ( cpi->info.quick_p ) {
MBInterMVError = GetMBMVInterError( cpi, cpi->lastrecon,
- mp,
+ mbp,
cpi->MVPixelOffsetY,
&InterMVect );
@@ -696,7 +670,7 @@
MBInterMVExError =
GetMBMVExhaustiveSearch( cpi, cpi->lastrecon,
- mp,
+ mbp,
&InterMVectEx );
/* Is the Variance measure for the EX search
@@ -711,7 +685,7 @@
/* Use an exhaustive search */
MBInterMVError =
GetMBMVExhaustiveSearch( cpi, cpi->lastrecon,
- mp,
+ mbp,
&InterMVect );
}
@@ -732,13 +706,13 @@
if ( BestError > cpi->MinImprovementForNewMV && cpi->MotionCompensation) {
/* Do an MV search in the golden reference frame */
MBGF_MVError = GetMBMVInterError( cpi, cpi->golden,
- mp,
+ mbp,
cpi->MVPixelOffsetY, &GFMVect );
/* Measure error for last GFMV */
LastMBGF_MVError = GetMBInterError( cpi, cpi->frame,
cpi->golden,
- mp,
+ mbp,
LastGFMVect.x,
LastGFMVect.y );
@@ -767,7 +741,7 @@
/* Get the 4MV error. */
MBInterFOURMVError =
GetFOURMVExhaustiveSearch( cpi, cpi->lastrecon,
- mp,
+ mbp,
FourMVect );
/* If the improvement is great enough then use the four MV mode */
@@ -789,15 +763,15 @@
if ( (BestError > cpi->InterTripOutThresh) &&
(10 * BestError > MBIntraError * 7 ) ) {
- SetMBMotionVectorsAndMode(cpi,mp,&ZeroVect,CODE_INTRA);
+ SetMBMotionVectorsAndMode(cpi,mbp,&ZeroVect,CODE_INTRA);
} else if ( BestError == MBInterError ) {
- SetMBMotionVectorsAndMode(cpi,mp,&ZeroVect,CODE_INTER_NO_MV);
+ SetMBMotionVectorsAndMode(cpi,mbp,&ZeroVect,CODE_INTER_NO_MV);
} else if ( BestError == MBGFError ) {
- SetMBMotionVectorsAndMode(cpi,mp,&ZeroVect,CODE_USING_GOLDEN);
+ SetMBMotionVectorsAndMode(cpi,mbp,&ZeroVect,CODE_USING_GOLDEN);
} else if ( BestError == MBLastInterError ) {
- SetMBMotionVectorsAndMode(cpi,mp,&LastInterMVect,CODE_INTER_LAST_MV);
+ SetMBMotionVectorsAndMode(cpi,mbp,&LastInterMVect,CODE_INTER_LAST_MV);
} else if ( BestError == MBPriorLastInterError ) {
- SetMBMotionVectorsAndMode(cpi,mp,&PriorLastInterMVect,CODE_INTER_PRIOR_LAST);
+ SetMBMotionVectorsAndMode(cpi,mbp,&PriorLastInterMVect,CODE_INTER_PRIOR_LAST);
/* Swap the prior and last MV cases over */
TmpMVect = PriorLastInterMVect;
@@ -806,7 +780,7 @@
} else if ( BestError == MBInterMVError ) {
- SetMBMotionVectorsAndMode(cpi,mp,&InterMVect,CODE_INTER_PLUS_MV);
+ SetMBMotionVectorsAndMode(cpi,mbp,&InterMVect,CODE_INTER_PLUS_MV);
/* Update Prior last mv with last mv */
PriorLastInterMVect.x = LastInterMVect.x;
@@ -820,7 +794,7 @@
} else if ( BestError == MBGF_MVError ) {
- SetMBMotionVectorsAndMode(cpi,mp,&GFMVect,CODE_GOLDEN_MV);
+ SetMBMotionVectorsAndMode(cpi,mbp,&GFMVect,CODE_GOLDEN_MV);
/* Note last inter GF MV for future use */
LastGFMVect.x = GFMVect.x;
@@ -850,12 +824,12 @@
{
fragment_t *f0 = cpi->frag[0];
- SetFragMotionVectorAndMode(cpi,mp->y[0]-f0, &FourMVect[0],CODE_INTER_FOURMV);
- SetFragMotionVectorAndMode(cpi,mp->y[1]-f0, &FourMVect[1],CODE_INTER_FOURMV);
- SetFragMotionVectorAndMode(cpi,mp->y[2]-f0, &FourMVect[2],CODE_INTER_FOURMV);
- SetFragMotionVectorAndMode(cpi,mp->y[3]-f0, &FourMVect[3],CODE_INTER_FOURMV);
- SetFragMotionVectorAndMode(cpi,mp->u-f0, &FourMVect[4],CODE_INTER_FOURMV);
- SetFragMotionVectorAndMode(cpi,mp->v-f0, &FourMVect[5],CODE_INTER_FOURMV);
+ SetFragMotionVectorAndMode(cpi,mbp->y[0], &FourMVect[0],CODE_INTER_FOURMV);
+ SetFragMotionVectorAndMode(cpi,mbp->y[1], &FourMVect[1],CODE_INTER_FOURMV);
+ SetFragMotionVectorAndMode(cpi,mbp->y[2], &FourMVect[2],CODE_INTER_FOURMV);
+ SetFragMotionVectorAndMode(cpi,mbp->y[3], &FourMVect[3],CODE_INTER_FOURMV);
+ SetFragMotionVectorAndMode(cpi,mbp->u, &FourMVect[4],CODE_INTER_FOURMV);
+ SetFragMotionVectorAndMode(cpi,mbp->v, &FourMVect[5],CODE_INTER_FOURMV);
}
/* Note the four MVs values for current macro-block. */
@@ -872,7 +846,7 @@
} else {
- SetMBMotionVectorsAndMode(cpi, mp,&ZeroVect,CODE_INTRA);
+ SetMBMotionVectorsAndMode(cpi, mbp,&ZeroVect,CODE_INTRA);
}
Modified: branches/theora-thusnelda/lib/enc/frarray.c
===================================================================
--- branches/theora-thusnelda/lib/enc/frarray.c 2007-12-18 07:46:54 UTC (rev 14309)
+++ branches/theora-thusnelda/lib/enc/frarray.c 2007-12-18 08:43:32 UTC (rev 14310)
@@ -114,6 +114,7 @@
int run_break = 0;
int partial=0;
int fully = 1;
+ int invalid_fi = cpi->frag_total;
unsigned char *cp = cpi->frag_coded[0];
/* code the partially coded SB flags */
@@ -123,10 +124,9 @@
fully = 1;
for ( B=0; B<16; B++ ) {
- fragment_t *fp = sp->f[B];
- int fi = (fp ? fp-cpi->frag[0] : -1);
+ int fi = sp->f[B];
- if ( fp ) {
+ if ( fi != invalid_fi ){
if ( cp[fi] ) {
coded = 1; /* SB at least partly coded */
}else{
@@ -170,9 +170,8 @@
fully = 1;
for ( B=0; B<16; B++ ) {
- fragment_t *fp = sp->f[B];
- int fi = (fp ? fp-cpi->frag[0] : -1);
- if ( fp ) {
+ int fi = sp->f[B];
+ if ( fi != invalid_fi ) {
if ( cp[fi] ) {
coded = 1;
}else{
@@ -215,9 +214,8 @@
fully = 1;
for ( B=0; B<16; B++ ) {
- fragment_t *fp = sp->f[B];
- int fi = (fp ? fp-cpi->frag[0] : -1);
- if ( fp ) {
+ int fi = sp->f[B];
+ if ( fi != invalid_fi ) {
if ( cp[fi] ) {
coded = 1;
}else{
@@ -229,9 +227,8 @@
if(fully || !coded) continue;
for ( B=0; B<16; B++ ) {
- fragment_t *fp = sp->f[B];
- int fi = (fp ? fp-cpi->frag[0] : -1);
- if(fp){
+ int fi = sp->f[B];
+ if(fi != invalid_fi){
if(run_last == -1){
oggpackB_write( cpi->oggbuffer, cp[fi], 1);
run_last = cp[fi];
Modified: branches/theora-thusnelda/lib/enc/frinit.c
===================================================================
--- branches/theora-thusnelda/lib/enc/frinit.c 2007-12-18 07:46:54 UTC (rev 14309)
+++ branches/theora-thusnelda/lib/enc/frinit.c 2007-12-18 08:43:32 UTC (rev 14310)
@@ -131,19 +131,21 @@
cpi->super_n[2] = cpi->super_h[2] * cpi->super_v[2];
cpi->super_total = cpi->super_n[0] + cpi->super_n[1] + cpi->super_n[2];
- cpi->frag[0] = calloc(cpi->frag_total, sizeof(**cpi->frag));
+ cpi->frag[0] = calloc(cpi->frag_total+1, sizeof(**cpi->frag));
cpi->frag[1] = cpi->frag[0] + cpi->frag_n[0];
cpi->frag[2] = cpi->frag[1] + cpi->frag_n[1];
- cpi->frag_coded[0] = calloc(cpi->frag_total, sizeof(**cpi->frag_coded));
+ /* +1; the last entry is the 'invalid' frag, which is always set to not coded as it doesn't really exist */
+ cpi->frag_coded[0] = calloc(cpi->frag_total+1, sizeof(**cpi->frag_coded));
cpi->frag_coded[1] = cpi->frag_coded[0] + cpi->frag_n[0];
cpi->frag_coded[2] = cpi->frag_coded[1] + cpi->frag_n[1];
- cpi->frag_mode[0] = calloc(cpi->frag_total, sizeof(**cpi->frag_mode));
+ cpi->frag_mode[0] = calloc(cpi->frag_total+1, sizeof(**cpi->frag_mode));
cpi->frag_mode[1] = cpi->frag_mode[0] + cpi->frag_n[0];
cpi->frag_mode[2] = cpi->frag_mode[1] + cpi->frag_n[1];
- cpi->macro = calloc(cpi->macro_total, sizeof(*cpi->macro));
+ /* +1; the last entry is the 'invalid' mb, which contains only 'invalid' frags */
+ cpi->macro = calloc(cpi->macro_total+1, sizeof(*cpi->macro));
cpi->super[0] = calloc(cpi->super_total, sizeof(**cpi->super));
cpi->super[1] = cpi->super[0] + cpi->super_n[0];
@@ -169,8 +171,9 @@
int fcol = col*4 + fhilbertx[frag];
if(frow<cpi->frag_v[plane] && fcol<cpi->frag_h[plane]){
int fragindex = frow*cpi->frag_h[plane] + fcol;
- cpi->super[plane][superindex].f[frag] = &cpi->frag[plane][fragindex];
- }
+ cpi->super[plane][superindex].f[frag] = &cpi->frag[plane][fragindex] - cpi->frag[0];
+ }else
+ cpi->super[plane][superindex].f[frag] = cpi->frag_total; /* 'invalid' */
}
}
}
@@ -185,8 +188,10 @@
int mcol = col*2 + mhilbertx[mb];
if(mrow<cpi->macro_v && mcol<cpi->macro_h){
int macroindex = mrow*cpi->macro_h + mcol;
- cpi->super[0][superindex].m[mb] = &cpi->macro[macroindex];
- }
+ cpi->super[0][superindex].m[mb] = &cpi->macro[macroindex] - cpi->macro;
+ }else
+ cpi->super[0][superindex].m[mb] = cpi->macro_total;
+
}
}
}
@@ -209,19 +214,33 @@
int fcol = basecol + scanx[frag];
if(frow<cpi->frag_v[0] && fcol<cpi->frag_h[0]){
int fragindex = frow*cpi->frag_h[0] + fcol;
- cpi->macro[macroindex].y[frag] = &cpi->frag[0][fragindex];
- }
+ cpi->macro[macroindex].y[frag] = fragindex;
+ }else
+ cpi->macro[macroindex].y[frag] = cpi->frag_total;
}
-
+
if(row<cpi->frag_v[1] && col<cpi->frag_h[1])
- cpi->macro[macroindex].u = &cpi->frag[1][macroindex];
+ cpi->macro[macroindex].u = &cpi->frag[1][macroindex]-cpi->frag[0];
+ else
+ cpi->macro[macroindex].u = cpi->frag_total;
if(row<cpi->frag_v[2] && col<cpi->frag_h[2])
- cpi->macro[macroindex].v = &cpi->frag[2][macroindex];
-
+ cpi->macro[macroindex].v = &cpi->frag[2][macroindex]-cpi->frag[0];
+ else
+ cpi->macro[macroindex].v = cpi->frag_total;
}
}
}
+ /* fill in 'invalid' macroblock */
+ {
+ cpi->macro[cpi->macro_total].y[0] = cpi->frag_total;
+ cpi->macro[cpi->macro_total].y[1] = cpi->frag_total;
+ cpi->macro[cpi->macro_total].y[2] = cpi->frag_total;
+ cpi->macro[cpi->macro_total].y[3] = cpi->frag_total;
+ cpi->macro[cpi->macro_total].u = cpi->frag_total;
+ cpi->macro[cpi->macro_total].v = cpi->frag_total;
+ }
+
/* allocate frames */
cpi->frame = _ogg_malloc(cpi->frame_size*sizeof(*cpi->frame));
cpi->lastrecon = _ogg_malloc(cpi->frame_size*sizeof(*cpi->lastrecon));
Modified: branches/theora-thusnelda/lib/enc/mcomp.c
===================================================================
--- branches/theora-thusnelda/lib/enc/mcomp.c 2007-12-18 07:46:54 UTC (rev 14309)
+++ branches/theora-thusnelda/lib/enc/mcomp.c 2007-12-18 08:43:32 UTC (rev 14310)
@@ -148,19 +148,18 @@
ogg_uint32_t IntraError = 0;
dsp_save_fpu (cpi->dsp);
unsigned char *cp = cpi->frag_coded[0];
-
- fragment_t *f0 = cpi->frag[0];
+ fragment_t *fp = cpi->frag[0];
/* Add together the intra errors for those blocks in the macro block
that are coded (Y only) */
- if ( mp->y[0] && cp[mp->y[0]-f0] )
- IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[mp->y[0]->buffer_index],cpi->stride[0]);
- if ( mp->y[1] && cp[mp->y[1]-f0] )
- IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[mp->y[1]->buffer_index],cpi->stride[0]);
- if ( mp->y[2] && cp[mp->y[2]-f0] )
- IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[mp->y[2]->buffer_index],cpi->stride[0]);
- if ( mp->y[3] && cp[mp->y[3]-f0] )
- IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[mp->y[3]->buffer_index],cpi->stride[0]);
+ if ( cp[mp->y[0]] )
+ IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[fp[mp->y[0]].buffer_index],cpi->stride[0]);
+ if ( cp[mp->y[1]] )
+ IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[fp[mp->y[1]].buffer_index],cpi->stride[0]);
+ if ( cp[mp->y[2]] )
+ IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[fp[mp->y[2]].buffer_index],cpi->stride[0]);
+ if ( cp[mp->y[3]] )
+ IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[fp[mp->y[3]].buffer_index],cpi->stride[0]);
dsp_restore_fpu (cpi->dsp);
return IntraError;
@@ -181,9 +180,8 @@
unsigned char * SrcPtr1;
unsigned char * RefPtr1;
unsigned char *cp = cpi->frag_coded[0];
+ fragment_t *fp = cpi->frag[0];
- fragment_t *f0 = cpi->frag[0];
-
dsp_save_fpu (cpi->dsp);
/* Work out the second reference pointer offset. */
@@ -202,28 +200,28 @@
/* Add together the errors for those blocks in the macro block that
are coded (Y only) */
- if ( mp->y[0] && cp[mp->y[0]-f0] ) {
- SrcPtr1 = &SrcPtr[mp->y[0]->buffer_index];
- RefPtr1 = &RefPtr[mp->y[0]->buffer_index + RefPixelOffset];
+ if ( cp[mp->y[0]] ) {
+ SrcPtr1 = &SrcPtr[fp[mp->y[0]].buffer_index];
+ RefPtr1 = &RefPtr[fp[mp->y[0]].buffer_index + RefPixelOffset];
InterError += GetInterErr(cpi, SrcPtr1, RefPtr1, &RefPtr1[RefPtr2Offset] );
}
- if ( mp->y[1] && cp[mp->y[1]-f0] ) {
- SrcPtr1 = &SrcPtr[mp->y[1]->buffer_index];
- RefPtr1 = &RefPtr[mp->y[1]->buffer_index + RefPixelOffset];
+ if ( cp[mp->y[1]] ) {
+ SrcPtr1 = &SrcPtr[fp[mp->y[1]].buffer_index];
+ RefPtr1 = &RefPtr[fp[mp->y[1]].buffer_index + RefPixelOffset];
InterError += GetInterErr(cpi, SrcPtr1, RefPtr1, &RefPtr1[RefPtr2Offset] );
}
- if ( mp->y[2] && cp[mp->y[2]-f0] ) {
- SrcPtr1 = &SrcPtr[mp->y[2]->buffer_index];
- RefPtr1 = &RefPtr[mp->y[2]->buffer_index + RefPixelOffset];
+ if ( cp[mp->y[2]] ) {
+ SrcPtr1 = &SrcPtr[fp[mp->y[2]].buffer_index];
+ RefPtr1 = &RefPtr[fp[mp->y[2]].buffer_index + RefPixelOffset];
InterError += GetInterErr(cpi, SrcPtr1, RefPtr1, &RefPtr1[RefPtr2Offset] );
}
- if ( mp->y[3] && cp[mp->y[3]-f0] ) {
- SrcPtr1 = &SrcPtr[mp->y[3]->buffer_index];
- RefPtr1 = &RefPtr[mp->y[3]->buffer_index + RefPixelOffset];
+ if ( cp[mp->y[3]] ) {
+ SrcPtr1 = &SrcPtr[fp[mp->y[3]].buffer_index];
+ RefPtr1 = &RefPtr[fp[mp->y[3]].buffer_index + RefPixelOffset];
InterError += GetInterErr(cpi, SrcPtr1, RefPtr1, &RefPtr1[RefPtr2Offset] );
}
@@ -259,39 +257,38 @@
unsigned char * RefDataPtr1;
unsigned char * RefDataPtr2;
unsigned char *cp = cpi->frag_coded[0];
+ fragment_t *fp = cpi->frag[0];
- fragment_t *f0 = cpi->frag[0];
-
dsp_save_fpu (cpi->dsp);
/* Note which of the four blocks in the macro block are to be
included in the search. */
- disp[0] = (mp->y[0] && cp[mp->y[0]-f0]);
- disp[1] = (mp->y[1] && cp[mp->y[1]-f0]);
- disp[2] = (mp->y[2] && cp[mp->y[2]-f0]);
- disp[3] = (mp->y[3] && cp[mp->y[3]-f0]);
+ disp[0] = cp[mp->y[0]];
+ disp[1] = cp[mp->y[1]];
+ disp[2] = cp[mp->y[2]];
+ disp[3] = cp[mp->y[3]];
if(disp[0]){
- SrcPtr[0] = &cpi->frame[mp->y[0]->buffer_index];
- RefPtr[0] = &RefFramePtr[mp->y[0]->buffer_index];
+ SrcPtr[0] = &cpi->frame[fp[mp->y[0]].buffer_index];
+ RefPtr[0] = &RefFramePtr[fp[mp->y[0]].buffer_index];
Error += dsp_sad8x8 (cpi->dsp, SrcPtr[0], RefPtr[0],
cpi->stride[0]);
}
if(disp[1]){
- SrcPtr[1] = &cpi->frame[mp->y[1]->buffer_index];
- RefPtr[1] = &RefFramePtr[mp->y[1]->buffer_index];
+ SrcPtr[1] = &cpi->frame[fp[mp->y[1]].buffer_index];
+ RefPtr[1] = &RefFramePtr[fp[mp->y[1]].buffer_index];
Error += dsp_sad8x8 (cpi->dsp, SrcPtr[1], RefPtr[1],
cpi->stride[0]);
}
if(disp[2]){
- SrcPtr[2] = &cpi->frame[mp->y[2]->buffer_index];
- RefPtr[2] = &RefFramePtr[mp->y[2]->buffer_index];
+ SrcPtr[2] = &cpi->frame[fp[mp->y[2]].buffer_index];
+ RefPtr[2] = &RefFramePtr[fp[mp->y[2]].buffer_index];
Error += dsp_sad8x8 (cpi->dsp, SrcPtr[2], RefPtr[2],
cpi->stride[0]);
}
if(disp[3]){
- SrcPtr[3] = &cpi->frame[mp->y[3]->buffer_index];
- RefPtr[3] = &RefFramePtr[mp->y[3]->buffer_index];
+ SrcPtr[3] = &cpi->frame[fp[mp->y[3]].buffer_index];
+ RefPtr[3] = &RefFramePtr[fp[mp->y[3]].buffer_index];
Error += dsp_sad8x8 (cpi->dsp, SrcPtr[3], RefPtr[3],
cpi->stride[0]);
}
@@ -438,33 +435,32 @@
unsigned char * RefDataPtr2;
int off;
unsigned char *cp = cpi->frag_coded[0];
+ fragment_t *fp = cpi->frag[0];
- fragment_t *f0 = cpi->frag[0];
-
dsp_save_fpu (cpi->dsp);
/* Note which of the four blocks in the macro block are to be
included in the search. */
- disp[0] = (mp->y[0] && cp[mp->y[0]-f0]);
- disp[1] = (mp->y[1] && cp[mp->y[1]-f0]);
- disp[2] = (mp->y[2] && cp[mp->y[2]-f0]);
- disp[3] = (mp->y[3] && cp[mp->y[3]-f0]);
+ disp[0] = cp[mp->y[0]];
+ disp[1] = cp[mp->y[1]];
+ disp[2] = cp[mp->y[2]];
+ disp[3] = cp[mp->y[3]];
if(disp[0]){
- SrcPtr[0] = &cpi->frame[mp->y[0]->buffer_index];
- RefPtr[0] = &RefFramePtr[mp->y[0]->buffer_index];
+ SrcPtr[0] = &cpi->frame[fp[mp->y[0]].buffer_index];
+ RefPtr[0] = &RefFramePtr[fp[mp->y[0]].buffer_index];
}
if(disp[1]){
- SrcPtr[1] = &cpi->frame[mp->y[1]->buffer_index];
- RefPtr[1] = &RefFramePtr[mp->y[1]->buffer_index];
+ SrcPtr[1] = &cpi->frame[fp[mp->y[1]].buffer_index];
+ RefPtr[1] = &RefFramePtr[fp[mp->y[1]].buffer_index];
}
if(disp[2]){
- SrcPtr[2] = &cpi->frame[mp->y[2]->buffer_index];
- RefPtr[2] = &RefFramePtr[mp->y[2]->buffer_index];
+ SrcPtr[2] = &cpi->frame[fp[mp->y[2]].buffer_index];
+ RefPtr[2] = &RefFramePtr[fp[mp->y[2]].buffer_index];
}
if(disp[3]){
- SrcPtr[3] = &cpi->frame[mp->y[3]->buffer_index];
- RefPtr[3] = &RefFramePtr[mp->y[3]->buffer_index];
+ SrcPtr[3] = &cpi->frame[fp[mp->y[3]].buffer_index];
+ RefPtr[3] = &RefFramePtr[fp[mp->y[3]].buffer_index];
}
off = - ((MAX_MV_EXTENT/2) * cpi->stride[0]) - (MAX_MV_EXTENT/2);
@@ -570,7 +566,7 @@
static ogg_uint32_t GetBMVExhaustiveSearch (CP_INSTANCE *cpi,
unsigned char *RefFramePtr,
- fragment_t *fp,
+ int fi,
mv_t *MV ) {
ogg_uint32_t Error = 0;
ogg_uint32_t MinError = HUGE_ERROR;
@@ -589,6 +585,7 @@
ogg_int32_t BestHalfPixelError;
unsigned char BestHalfOffset;
unsigned char * RefDataPtr2;
+ fragment_t *fp = &cpi->frag[0][fi];
/* Set up the source pointer for the block. */
SrcPtr = &cpi->frame[fp->buffer_index];
@@ -662,17 +659,15 @@
ogg_uint32_t InterMVError;
unsigned char *cp = cpi->frag_coded[0];
- fragment_t *f0 = cpi->frag[0];
-
dsp_save_fpu (cpi->dsp);
/* For the moment the 4MV mode is only deemed to be valid
if all four Y blocks are to be updated */
/* This may be adapted later. */
- if ( mp->y[0] && cp[mp->y[0]-f0] &&
- mp->y[1] && cp[mp->y[1]-f0] &&
- mp->y[2] && cp[mp->y[2]-f0] &&
- mp->y[3] && cp[mp->y[3]-f0] ) {
+ if ( cp[mp->y[0]] &&
+ cp[mp->y[1]] &&
+ cp[mp->y[2]] &&
+ cp[mp->y[3]] ) {
/* Reset the error score. */
InterMVError = 0;
More information about the commits
mailing list