[xiph-commits] r14387 - in branches/theora-thusnelda/lib: . enc
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Thu Jan 10 01:52:16 PST 2008
Author: xiphmont
Date: 2008-01-10 01:52:15 -0800 (Thu, 10 Jan 2008)
New Revision: 14387
Modified:
branches/theora-thusnelda/lib/Makefile.am
branches/theora-thusnelda/lib/enc/codec_internal.h
branches/theora-thusnelda/lib/enc/encode.c
branches/theora-thusnelda/lib/enc/encoder_lookup.h
branches/theora-thusnelda/lib/enc/encoder_toplevel.c
branches/theora-thusnelda/lib/enc/frinit.c
branches/theora-thusnelda/lib/enc/mcenc.c
Log:
Ongoing debugging work
Modified: branches/theora-thusnelda/lib/Makefile.am
===================================================================
--- branches/theora-thusnelda/lib/Makefile.am 2008-01-10 02:06:49 UTC (rev 14386)
+++ branches/theora-thusnelda/lib/Makefile.am 2008-01-10 09:52:15 UTC (rev 14387)
@@ -38,7 +38,8 @@
enc/dct_decode.c \
enc/frarray.c \
enc/frinit.c \
- enc/mcomp.c \
+ enc/mcenc.c \
+ enc/mode.c \
enc/reconstruct.c \
enc/dsp.c
@@ -103,6 +104,7 @@
enc/encoder_huffman.h \
enc/hufftables.h \
enc/quant_lookup.h \
+ enc/mode_select.h \
enc/toplevel_lookup.h \
enc/dsp.h \
dec/apiwrapper.h \
Modified: branches/theora-thusnelda/lib/enc/codec_internal.h
===================================================================
--- branches/theora-thusnelda/lib/enc/codec_internal.h 2008-01-10 02:06:49 UTC (rev 14386)
+++ branches/theora-thusnelda/lib/enc/codec_internal.h 2008-01-10 09:52:15 UTC (rev 14387)
@@ -110,6 +110,14 @@
ogg_int32_t y;
} mv_t;
+typedef struct {
+ mv_t candidates[12];
+ int setb0;
+ int ncandidates;
+ ogg_int32_t mvapw1[2];
+ ogg_int32_t mvapw2[2];
+} mc_state;
+
typedef struct macroblock {
/* the blocks comprising this macroblock */
int yuv[3][4]; /* [Y,U,V][raster order] */
@@ -151,26 +159,26 @@
typedef ogg_int32_t iquant_table[64];
typedef iquant_table iquant_tables[64];
-struct oc_mode_scheme_chooser{
- const int *mode_bits[8];
+typedef struct {
+ const int *mode_bits[8];
/*Pointers to the a list containing the index of each mode in the mode
alphabet used by each scheme.
The first entry points to the dynamic scheme0_ranks, while the remaining
7 point to the constant entries stored in OC_MODE_SCHEMES.*/
- const int *mode_ranks[8];
+ const unsigned char *mode_ranks[8];
/*The ranks for each mode when coded with scheme 0.
These are optimized so that the more frequent modes have lower ranks.*/
- int scheme0_ranks[OC_NMODES];
+ unsigned char scheme0_ranks[OC_NMODES];
/*The list of modes, sorted in descending order of frequency, that
corresponds to the ranks above.*/
- int scheme0_list[OC_NMODES];
+ unsigned char scheme0_list[OC_NMODES];
/*The number of times each mode has been chosen so far.*/
- int mode_counts[OC_NMODES];
+ int mode_counts[OC_NMODES];
/*The list of mode coding schemes, sorted in ascending order of bit cost.*/
- int scheme_list[8];
+ unsigned char scheme_list[8];
/*The number of bits used by each mode coding scheme.*/
- int scheme_bits[8];
-};
+ int scheme_bits[8];
+} oc_mode_scheme_chooser;
/* Encoder (Compressor) instance -- installed in a theora_state */
typedef struct CP_INSTANCE {
@@ -314,4 +322,11 @@
extern void ClearFrameInfo (CP_INSTANCE *cpi);
+extern void oc_mode_unset(CP_INSTANCE *cpi,
+ macroblock_t *mb);
+
+extern void oc_mcenc_start(CP_INSTANCE *cpi,
+ mc_state *_mcenc);
+
+
#endif /* ENCODER_INTERNAL_H */
Modified: branches/theora-thusnelda/lib/enc/encode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encode.c 2008-01-10 02:06:49 UTC (rev 14386)
+++ branches/theora-thusnelda/lib/enc/encode.c 2008-01-10 09:52:15 UTC (rev 14387)
@@ -171,7 +171,7 @@
TransformQuantizeBlock( cpi, mp->mode, fi, mp->mv[B] );
if(!cp[fi] && plane == 0){
mp->coded &= ~(1<<B);
- if(!mp->coded) oc_unset_mode(cpi,mp);
+ if(!mp->coded) oc_mode_unset(cpi,mp);
}
}
}
@@ -298,16 +298,16 @@
}
-static const ogg_uint32_t NoOpModeWords[8] = {0,1,2,3,4,5,6,7};
-static const ogg_int32_t NoOpModeBits[8] = {3,3,3,3,3,3,3,3};
+static const unsigned char NoOpModeWords[8] = {0,1,2,3,4,5,6,7};
+static const unsigned char NoOpModeBits[8] = {3,3,3,3,3,3,3,3};
static const unsigned char NoOpScheme[8] = {0,1,2,3,4,5,6,7};
static void PackModes (CP_INSTANCE *cpi) {
- ogg_uint32_t i,j;
+ ogg_uint32_t j;
ogg_uint32_t BestScheme = cpi->chooser.scheme_list[0];
- const ogg_uint32_t *ModeWords;
- const ogg_int32_t *ModeBits;
+ const unsigned char *ModeWords;
+ const unsigned char *ModeBits;
const unsigned char *ModeScheme;
int SB,MB;
@@ -321,7 +321,7 @@
if ( BestScheme == 0 ) {
for ( j = 0; j < MAX_MODES; j++ ){
/* Note that the last two entries are implicit */
- oggpackB_write( opb, cpi->chooser.scheme0_ranks, (ogg_uint32_t)MODE_BITS );
+ oggpackB_write( opb, cpi->chooser.scheme0_ranks[j], (ogg_uint32_t)MODE_BITS );
}
ModeScheme = cpi->chooser.scheme0_ranks;
ModeWords = ModeBitPatterns;
@@ -398,9 +398,6 @@
void EncodeData(CP_INSTANCE *cpi){
- /* reset all coding metadata */
- memset(cpi->ModeCount, 0, MAX_MODES*sizeof(*cpi->ModeCount));
-
dsp_save_fpu (cpi->dsp);
/* Encode and tokenise the Y, U and V components */
Modified: branches/theora-thusnelda/lib/enc/encoder_lookup.h
===================================================================
--- branches/theora-thusnelda/lib/enc/encoder_lookup.h 2008-01-10 02:06:49 UTC (rev 14386)
+++ branches/theora-thusnelda/lib/enc/encoder_lookup.h 2008-01-10 09:52:15 UTC (rev 14387)
@@ -77,13 +77,13 @@
6, 6, 6, 6, 6, 6, 6,
};
-static const ogg_uint32_t ModeBitPatterns[MAX_MODES] = {
+static const unsigned char ModeBitPatterns[MAX_MODES] = {
0x00, 0x02, 0x06, 0x0E, 0x1E, 0x3E, 0x7E, 0x7F };
-static const int ModeBitLengths[MAX_MODES] = {
+static const unsigned char ModeBitLengths[MAX_MODES] = {
1, 2, 3, 4, 5, 6, 7, 7 };
-static const int ModeBitLengthsD[MAX_MODES] = {
+static const unsigned char ModeBitLengthsD[MAX_MODES] = {
3, 3, 3, 3, 3, 3, 3, 3 };
static const unsigned char ModeSchemes[MODE_METHODS-1][MAX_MODES] = {
Modified: branches/theora-thusnelda/lib/enc/encoder_toplevel.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encoder_toplevel.c 2008-01-10 02:06:49 UTC (rev 14386)
+++ branches/theora-thusnelda/lib/enc/encoder_toplevel.c 2008-01-10 09:52:15 UTC (rev 14387)
@@ -27,6 +27,7 @@
#include "codec_internal.h"
static void CompressKeyFrame(CP_INSTANCE *cpi){
+ int j;
oggpackB_reset(cpi->oggbuffer);
cpi->FrameType = KEY_FRAME;
@@ -57,7 +58,7 @@
oggpackB_reset(cpi->oggbuffer);
cpi->FrameType = DELTA_FRAME;
- for ( i = 0; i < cpi->frag_total; i++, fi++ )
+ for ( i = 0; i < cpi->frag_total; i++ )
cpi->frag_coded[i] = 1; /* TEMPORARY */
/* mark as video frame */
@@ -115,18 +116,6 @@
if(c->target_bitrate<0)c->target_bitrate=0;
cpi->BaseQ = c->quality;
- cpi->MVChangeFactor = 14;
- cpi->FourMvChangeFactor = 8;
- cpi->MinImprovementForNewMV = 25;
- cpi->ExhaustiveSearchThresh = 2500;
- cpi->MinImprovementForFourMV = 100;
- cpi->FourMVThreshold = 10000;
- cpi->InterTripOutThresh = 5000;
- cpi->MVEnabled = 1;
- cpi->GoldenFrameEnabled = 1;
- cpi->InterPrediction = 1;
- cpi->MotionCompensation = 1;
-
/* Set encoder flags. */
/* if not AutoKeyframing cpi->ForceKeyFrameEvery = is frequency */
if(!c->keyframe_auto_p)
Modified: branches/theora-thusnelda/lib/enc/frinit.c
===================================================================
--- branches/theora-thusnelda/lib/enc/frinit.c 2008-01-10 02:06:49 UTC (rev 14386)
+++ branches/theora-thusnelda/lib/enc/frinit.c 2008-01-10 09:52:15 UTC (rev 14387)
@@ -268,9 +268,7 @@
/* fill in macroblock neighbor information for MC analysis */
{
- int row,col,frag;
- int scanx[4] = {0,1,0,1};
- int scany[4] = {0,0,1,1};
+ int row,col;
for(row=0;row<cpi->macro_v;row++){
for(col=0;col<cpi->macro_h;col++){
@@ -281,11 +279,11 @@
if(col)
cpi->macro[macroindex].cneighbors[count++]=macroindex-1;
if(col && row)
- cpi->macro[macroindex].cneighbors[count++]=macroindex-macro_h-1;
+ cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h-1;
if(row)
- cpi->macro[macroindex].cneighbors[count++]=macroindex-macro_h;
- if(row && col+1<macro_h)
- cpi->macro[macroindex].cneighbors[count++]=macroindex-macro_h+1;
+ cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h;
+ if(row && col+1<cpi->macro_h)
+ cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h+1;
cpi->macro[macroindex].ncneighbors=count;
/* pneighbors are of the four possible direct neighbors (plus pattern), not the same as cneighbors */
@@ -293,11 +291,11 @@
if(col)
cpi->macro[macroindex].pneighbors[count++]=macroindex-1;
if(row)
- cpi->macro[macroindex].pneighbors[count++]=macroindex-macro_h;
- if(col+1<macro_h)
+ cpi->macro[macroindex].pneighbors[count++]=macroindex-cpi->macro_h;
+ if(col+1<cpi->macro_h)
cpi->macro[macroindex].pneighbors[count++]=macroindex+1;
- if(row+1<macro_v)
- cpi->macro[macroindex].pneighbors[count++]=macroindex+macro_h;
+ if(row+1<cpi->macro_v)
+ cpi->macro[macroindex].pneighbors[count++]=macroindex+cpi->macro_h;
cpi->macro[macroindex].npneighbors=count;
}
}
Modified: branches/theora-thusnelda/lib/enc/mcenc.c
===================================================================
--- branches/theora-thusnelda/lib/enc/mcenc.c 2008-01-10 02:06:49 UTC (rev 14386)
+++ branches/theora-thusnelda/lib/enc/mcenc.c 2008-01-10 09:52:15 UTC (rev 14387)
@@ -20,14 +20,6 @@
#include <string.h>
#include "codec_internal.h"
-typedef struct {
- int candidates[12][2];
- int setb0;
- int ncandidates;
- ogg_int32_t mvapw1[2];
- ogg_int32_t mvapw2[2];
-} mc_state;
-
/*The maximum Y plane SAD value for accepting the median predictor.*/
#define OC_YSAD_THRESH1 (256)
/*The amount to right shift the minimum error by when inflating it for
@@ -127,16 +119,16 @@
mv_t a[3];
int ncandidates;
int i;
- emb=_mcenc->enc->mbinfo+_mbi;
+ emb = &cpi->macro[_mbi];
if(emb->ncneighbors>0){
/*Fill in the first part of set A: the last motion vectors used and the
vectors from adjacent blocks.*/
/*Skip a position to store the median predictor in.*/
ncandidates=1;
for(i=0;i<emb->ncneighbors;i++){
- nemb=cpi->macro[emb->cneighbors[i]];
- _mcenc->candidates[ncandidates].x=nemb->analysis_mv[0][_which_frame].x;
- _mcenc->candidates[ncandidates].y=nemb->analysis_mv[0][_which_frame].y;
+ nemb=&cpi->macro[emb->cneighbors[i]];
+ _mcenc->candidates[ncandidates].x = nemb->analysis_mv[0][_which_frame].x;
+ _mcenc->candidates[ncandidates].y = nemb->analysis_mv[0][_which_frame].y;
ncandidates++;
}
/*Add a few additional vectors to set A: the vector used in the previous
@@ -187,7 +179,7 @@
_mcenc->candidates[ncandidates].y = OC_CLAMPI(-31,_mcenc->candidates[ncandidates].y,31);
ncandidates++;
if(i>=emb->npneighbors)break;
- nemb=cpi->macro[emb->pneighbors[i]];
+ nemb=&cpi->macro[emb->pneighbors[i]];
}
/*Truncate to full-pel positions.*/
for(i=0;i<ncandidates;i++){
@@ -237,12 +229,12 @@
int _mvoffset1,
int _goldenp){
- macroblock_t *mbi = cpi->macro[mbi];
+ macroblock_t *mb = &cpi->macro[mbi];
int err;
int i;
err=0;
for(i=0;i<4;i++){
- int fi = mbi->y[i];
+ int fi = mb->yuv[0][i];
if(fi < cpi->frag_total){ /* last fragment is the 'invalid fragment' */
ogg_uint32_t base_offset = cpi->frag_buffer_index[fi];
const unsigned char *cur = cpi->frame + base_offset;
@@ -272,7 +264,7 @@
mvoffset=_delta.x+_delta.y*stride;
err=0;
for(bi=0;bi<4;bi++){
- int fi = mbi->y[i];
+ int fi = mb->yuv[0][bi];
if(fi < cpi->frag_total){ /* last fragment is the 'invalid fragment' */
ogg_uint32_t base_offset = cpi->frag_buffer_index[fi];
const unsigned char *cur = cpi->frame + base_offset;
@@ -342,24 +334,24 @@
mc_state *_mcenc,
int _mbi,
int _bi,
- mv *_vec,
+ mv_t *_vec,
int _best_err,
int _goldenp){
- macroblock_t *mb = &cpi->macro[mbi];
+ macroblock_t *mb = &cpi->macro[_mbi];
int offset_y[9];
int stride = cpi->stride[0];
int mvoffset_base;
int best_site;
int sitei;
int err;
- int fi = mb->y[bi];
+ int fi = mb->yuv[0][_bi];
- if(fi == frag_total) return _best_err;
+ if(fi == cpi->frag_total) return _best_err;
mvoffset_base=_vec->x+_vec->y*stride;
- offset_y[0]=offset_y[1]=offset_y[2]=-ref_ystride;
+ offset_y[0]=offset_y[1]=offset_y[2]=-stride;
offset_y[3]=offset_y[5]=0;
- offset_y[6]=offset_y[7]=offset_y[8]=ref_ystride;
+ offset_y[6]=offset_y[7]=offset_y[8]=stride;
err=_best_err;
best_site=4;
@@ -413,7 +405,7 @@
_mcenc: The motion compensation context.
_mbi: The macro block index.
_frame: The frame to search, either OC_FRAME_PREV or OC_FRAME_GOLD.
- _bmvs: Returns the individual block motion vectors.
+ _bmvs: Returns the individual block motion vectors. */
void oc_mcenc_search(CP_INSTANCE *cpi,
mc_state *_mcenc,
@@ -626,8 +618,8 @@
}
-static void oc_mcenc_start(CP_INSTANCE *cpi,
- mc_state *_mcenc){
+void oc_mcenc_start(CP_INSTANCE *cpi,
+ mc_state *mcenc){
ogg_int64_t nframes;
@@ -642,51 +634,3 @@
mcenc->mvapw2[OC_FRAME_GOLD]=(ogg_int32_t)(nframes!=2?(nframes<<16)/(nframes-2):0);
}
-
-static int oc_mcenc_pipe_process(oc_enc_pipe_stage *_stage,int _y_avail[3]){
- oc_mcenc_ctx *mcenc;
- int pli;
- mcenc=_stage->enc->mcenc;
- /*For now we ignore the chroma planes.*/
- for(pli=1;pli<3;pli++)_stage->y_procd[pli]=_y_avail[pli];
- /*Only do motion analysis if there is a previous frame; otherwise every
- vector has already been initialized to (0,0).*/
- if(mcenc->enc->state.ref_frame_idx[OC_FRAME_PREV]>=0){
- int y_avail;
- y_avail=_y_avail[0];
- /*Round to a super-block row, except for the last one, which may be
- incomplete.*/
- if(y_avail<(int)mcenc->enc->state.info.frame_height)y_avail&=~31;
- while(_stage->y_procd[0]<y_avail){
- oc_mb_enc_info *embs;
- oc_mb *mbs;
- int mbi;
- int mbi_end;
- mbi=(_stage->y_procd[0]>>4)*mcenc->enc->state.fplanes[0].nhsbs;
- mbi_end=mbi+mcenc->enc->state.fplanes[0].nhsbs<<1;
- mbs=mcenc->enc->state.mbs;
- embs=mcenc->enc->mbinfo;
- for(;mbi<mbi_end;mbi++)if(mbs[mbi].mode!=OC_MODE_INVALID){
- oc_mb_enc_info *emb;
- emb=embs+mbi;
- oc_mcenc_search(mcenc,mbi,OC_FRAME_PREV,emb->bmvs,&emb->aerror,
- &emb->aerror4mv);
- }
- /*Chain to the next stage.*/
- _stage->y_procd[0]=OC_MINI(_stage->y_procd[0]+32,y_avail);
- if(_stage->next!=NULL){
- int ret;
- ret=_stage->next->pipe_proc(_stage->next,_stage->y_procd);
- if(ret<0)return ret;
- }
- }
- }
- else{
- _stage->y_procd[0]=_y_avail[0];
- if(_stage->next!=NULL){
- return _stage->next->pipe_proc(_stage->next,_stage->y_procd);
- }
- }
- return 0;
-}
-
More information about the commits
mailing list