[xiph-commits] r9527 - trunk/theora/lib

giles at svn.xiph.org giles at svn.xiph.org
Mon Jun 27 03:47:59 PDT 2005


Author: giles
Date: 2005-06-27 03:47:51 -0700 (Mon, 27 Jun 2005)
New Revision: 9527

Modified:
   trunk/theora/lib/dct_decode.c
   trunk/theora/lib/dct_encode.c
   trunk/theora/lib/decode.c
   trunk/theora/lib/encode.c
   trunk/theora/lib/encoder_internal.h
   trunk/theora/lib/encoder_toplevel.c
   trunk/theora/lib/frarray.c
   trunk/theora/lib/misc_common.c
   trunk/theora/lib/toplevel.c
Log:
Code cleanup. Define frame types as KEY_FRAME and DELTA_FRAME instead of
BASE_FRAME and NORMAL_FRAME, which terms aren't used anywhere else. The
spec uses 'intra' and 'inter' but those are hard to distinguish 
visually.


Modified: trunk/theora/lib/dct_decode.c
===================================================================
--- trunk/theora/lib/dct_decode.c	2005-06-27 10:11:14 UTC (rev 9526)
+++ trunk/theora/lib/dct_decode.c	2005-06-27 10:47:51 UTC (rev 9527)
@@ -183,7 +183,7 @@
                                         pixel is used */
 
   /* Get coding mode for this block */
-  if ( GetFrameType(pbi) == BASE_FRAME ){
+  if ( GetFrameType(pbi) == KEY_FRAME ){
     pbi->CodingMode = CODE_INTRA;
   }else{
     /* Get Motion vector and mode for this block. */
@@ -1083,7 +1083,7 @@
 
   void (*ExpandBlockA) ( PB_INSTANCE *pbi, ogg_int32_t FragmentNumber );
 
-  if ( GetFrameType(pbi) == BASE_FRAME )
+  if ( GetFrameType(pbi) == KEY_FRAME )
     ExpandBlockA=ExpandKFBlock;
   else
     ExpandBlockA=ExpandBlock;
@@ -1127,7 +1127,7 @@
 
         /* only do 2 prediction if fragment coded and on non intra or
            if all fragments are intra */
-        if( pbi->display_fragments[i] || (GetFrameType(pbi) == BASE_FRAME) ){
+        if( pbi->display_fragments[i] || (GetFrameType(pbi) == KEY_FRAME) ){
           /* Type of Fragment */
           WhichFrame = Mode2Frame[pbi->FragCodingMethod[i]];
 
@@ -1220,7 +1220,7 @@
 
   /* Reconstruct the golden frame if necessary.
      For VFW codec only on key frames */
-  if ( GetFrameType(pbi) == BASE_FRAME ){
+  if ( GetFrameType(pbi) == KEY_FRAME ){
     CopyRecon( pbi, pbi->GoldenFrame, pbi->LastFrameRecon );
     /* We may need to update the UMV border */
     UpdateUMVBorder(pbi, pbi->GoldenFrame);

Modified: trunk/theora/lib/dct_encode.c
===================================================================
--- trunk/theora/lib/dct_encode.c	2005-06-27 10:11:14 UTC (rev 9526)
+++ trunk/theora/lib/dct_encode.c	2005-06-27 10:47:51 UTC (rev 9527)
@@ -348,7 +348,7 @@
                                 ogg_int32_t FragIndex){
   ogg_uint32_t  token_count;
 
-  if ( GetFrameType(&cpi->pb) == BASE_FRAME ){
+  if ( GetFrameType(&cpi->pb) == KEY_FRAME ){
     /* Key frame so code block in INTRA mode. */
     cpi->pb.CodingMode = CODE_INTRA;
   }else{
@@ -491,7 +491,7 @@
   /* adjusted / filtered pointers */
   FiltPtr = &cpi->ConvDestBuffer[cpi->pb.pixel_index_table[FragIndex]];
 
-  if ( GetFrameType(&cpi->pb) == BASE_FRAME ) {
+  if ( GetFrameType(&cpi->pb) == KEY_FRAME ) {
     /* Key frame so code block in INTRA mode. */
     cpi->pb.CodingMode = CODE_INTRA;
   }else{

Modified: trunk/theora/lib/decode.c
===================================================================
--- trunk/theora/lib/decode.c	2005-06-27 10:11:14 UTC (rev 9526)
+++ trunk/theora/lib/decode.c	2005-06-27 10:47:51 UTC (rev 9527)
@@ -76,7 +76,7 @@
   theora_read(pbi->opb,1,&ret);
   SpareBits = (unsigned char)ret;
 
-  if ( (pbi->FrameType == BASE_FRAME) ){
+  if ( (pbi->FrameType == KEY_FRAME) ){
     /* Read the type / coding method for the key frame. */
     theora_read(pbi->opb,1,&ret);
     pbi->KeyFrameType = (unsigned char)ret;
@@ -96,7 +96,7 @@
   /* Set the appropriate frame type according to the request. */
   switch ( FrType ){
 
-  case BASE_FRAME:
+  case KEY_FRAME:
     pbi->FrameType = FrType;
     break;
 
@@ -140,7 +140,7 @@
   ogg_uint32_t  i;
 
   /* If the frame is an intra frame then all blocks have mode intra. */
-  if ( GetFrameType(pbi) == BASE_FRAME ){
+  if ( GetFrameType(pbi) == KEY_FRAME ){
     for ( i = 0; i < pbi->UnitFragments; i++ ){
       pbi->FragCodingMethod[i] = CODE_INTRA;
     }
@@ -322,7 +322,7 @@
   ogg_uint32_t  MBListIndex = 0;
 
   /* Should not be decoding motion vectors if in INTRA only mode. */
-  if ( GetFrameType(pbi) == BASE_FRAME ){
+  if ( GetFrameType(pbi) == KEY_FRAME ){
     return;
   }
 

Modified: trunk/theora/lib/encode.c
===================================================================
--- trunk/theora/lib/encode.c	2005-06-27 10:11:14 UTC (rev 9526)
+++ trunk/theora/lib/encode.c	2005-06-27 10:47:51 UTC (rev 9527)
@@ -592,7 +592,7 @@
   ClearDownQFragData(&cpi->pb);
 
   /* The tree is not needed (implicit) for key frames */
-  if ( GetFrameType(&cpi->pb) != BASE_FRAME ){
+  if ( GetFrameType(&cpi->pb) != KEY_FRAME ){
     /* Pack the quad tree fragment mapping. */
     PackAndWriteDFArray( cpi );
   }
@@ -601,7 +601,7 @@
   cpi->FrameBitCount = oggpackB_bytes(cpi->oggbuffer) << 3;
 
   /* Mode and MV data not needed for key frames. */
-  if ( GetFrameType(&cpi->pb) != BASE_FRAME ){
+  if ( GetFrameType(&cpi->pb) != KEY_FRAME ){
     /* Pack and code the mode list. */
     PackModes(cpi);
     /* Pack the motion vectors */
@@ -815,7 +815,7 @@
         /* only do 2 prediction if fragment coded and on non intra or
            if all fragments are intra */
         if( cpi->pb.display_fragments[i] ||
-            (GetFrameType(&cpi->pb) == BASE_FRAME) ) {
+            (GetFrameType(&cpi->pb) == KEY_FRAME) ) {
           /* Type of Fragment */
           WhichFrame = Mode2Frame[cpi->pb.FragCodingMethod[i]];
 
@@ -1481,7 +1481,7 @@
   oggpackB_write( opb, 0, 1 );
 
   /* If the frame was a base frame then write out the frame dimensions. */
-  if ( cpi->pb.FrameType == BASE_FRAME ) {
+  if ( cpi->pb.FrameType == KEY_FRAME ) {
     /* Key frame type / method */
     oggpackB_write( opb, cpi->pb.KeyFrameType, 1 );
 

Modified: trunk/theora/lib/encoder_internal.h
===================================================================
--- trunk/theora/lib/encoder_internal.h	2005-06-27 10:11:14 UTC (rev 9526)
+++ trunk/theora/lib/encoder_internal.h	2005-06-27 10:47:51 UTC (rev 9527)
@@ -48,8 +48,8 @@
 
 #define Q_TABLE_SIZE            64
 
-#define BASE_FRAME              0
-#define NORMAL_FRAME            1
+#define KEY_FRAME              0
+#define DELTA_FRAME            1
 
 #define MAX_MODES               8
 #define MODE_BITS               3
@@ -253,7 +253,7 @@
 
 typedef struct qmat_range_table {
   int startq, startqi; /* index where this range starts */
-  Q_LIST_ENTRY *qmat;  /* qmat at each this range boundary */
+  Q_LIST_ENTRY *qmat;  /* qmat at this range boundary */
 } qmat_range_table;
 
 typedef struct codec_setup_info {
@@ -622,7 +622,7 @@
 
   ogg_uint32_t      RunLength;
   ogg_uint32_t      MaxBitTarget;     /* Cut off target for rate capping */
-  double            BitRateCapFactor; /* Factor relating normal frame target
+  double            BitRateCapFactor; /* Factor relating delta frame target
                                          to cut off target. */
 
   unsigned char     MBCodingMode;     /* Coding mode flags */

Modified: trunk/theora/lib/encoder_toplevel.c
===================================================================
--- trunk/theora/lib/encoder_toplevel.c	2005-06-27 10:11:14 UTC (rev 9526)
+++ trunk/theora/lib/encoder_toplevel.c	2005-06-27 10:47:51 UTC (rev 9527)
@@ -228,8 +228,8 @@
   memset( cpi->pb.display_fragments, 1, cpi->pb.UnitFragments );
   memset( cpi->extra_fragments, 1, cpi->pb.UnitFragments );
 
-  /* Set up for a BASE/KEY FRAME */
-  SetFrameType( &cpi->pb,BASE_FRAME );
+  /* Set up for a KEY FRAME */
+  SetFrameType( &cpi->pb,KEY_FRAME );
 }
 
 static void AdjustKeyFrameContext(CP_INSTANCE *cpi) {
@@ -326,7 +326,7 @@
   EncodeData(cpi);
 
   /* Adjust drop frame trigger. */
-  if ( GetFrameType(&cpi->pb) != BASE_FRAME ) {
+  if ( GetFrameType(&cpi->pb) != KEY_FRAME ) {
     /* Apply decay factor then add in the last frame size. */
     cpi->DropFrameTriggerBytes =
       ((cpi->DropFrameTriggerBytes * (DF_CANDIDATE_WINDOW-1)) /
@@ -359,7 +359,7 @@
 
   /* Update the BpbCorrectionFactor variable according to whether or
      not we were close enough with our selection of DCT quantiser.  */
-  if ( GetFrameType(&cpi->pb) != BASE_FRAME ) {
+  if ( GetFrameType(&cpi->pb) != KEY_FRAME ) {
     /* Work out a size correction factor. */
     CorrectionFactor = (double)oggpackB_bytes(cpi->oggbuffer) /
       (double)cpi->ThisFrameTargetBytes;
@@ -391,7 +391,7 @@
   }
 
   /* Adjust carry over and or key frame context. */
-  if ( GetFrameType(&cpi->pb) == BASE_FRAME ) {
+  if ( GetFrameType(&cpi->pb) == KEY_FRAME ) {
     /* Adjust the key frame context unless the key frame was very small */
     AdjustKeyFrameContext(cpi);
   } else {
@@ -542,8 +542,8 @@
     cpi->pb.FragMVect[i].y = 0;
   }
 
-  /* Default to normal frames. */
-  SetFrameType( &cpi->pb, NORMAL_FRAME );
+  /* Default to delta frames. */
+  SetFrameType( &cpi->pb, DELTA_FRAME );
 
   /* Clear down the difference arrays for the current frame. */
   memset( cpi->pb.display_fragments, 0, cpi->pb.UnitFragments );

Modified: trunk/theora/lib/frarray.c
===================================================================
--- trunk/theora/lib/frarray.c	2005-06-27 10:11:14 UTC (rev 9526)
+++ trunk/theora/lib/frarray.c	2005-06-27 10:47:51 UTC (rev 9527)
@@ -456,7 +456,7 @@
 
   /* For "Key frames" mark all blocks as coded and return. */
   /* Else initialise the ArrayPtr array to 0 (all blocks uncoded by default) */
-  if ( GetFrameType(pbi) == BASE_FRAME ) {
+  if ( GetFrameType(pbi) == KEY_FRAME ) {
     memset( pbi->SBFullyFlags, 1, pbi->SuperBlocks );
     memset( pbi->SBCodedFlags, 1, pbi->SuperBlocks );
         memset( pbi->MBCodedFlags, 0, pbi->MacroBlocks );

Modified: trunk/theora/lib/misc_common.c
===================================================================
--- trunk/theora/lib/misc_common.c	2005-06-27 10:11:14 UTC (rev 9526)
+++ trunk/theora/lib/misc_common.c	2005-06-27 10:47:51 UTC (rev 9527)
@@ -59,7 +59,7 @@
   }
 
   /* Adjust according to Q shift and type of frame */
-  if ( GetFrameType(&cpi->pb) == BASE_FRAME ) {
+  if ( GetFrameType(&cpi->pb) == KEY_FRAME ) {
     /* Get primary prediction */
     BytesPerBlock = KfBpbTable[ThreshTableIndex];
   } else {
@@ -258,7 +258,7 @@
   cpi->pb.ThisFrameQualityValue = cpi->pb.QThreshTable[QIndex];
 
   /* Apply range restrictions for key frames. */
-  if ( GetFrameType(&cpi->pb) == BASE_FRAME ) {
+  if ( GetFrameType(&cpi->pb) == KEY_FRAME ) {
     if ( cpi->pb.ThisFrameQualityValue > cpi->pb.QThreshTable[20] )
       cpi->pb.ThisFrameQualityValue = cpi->pb.QThreshTable[20];
     else if ( cpi->pb.ThisFrameQualityValue < cpi->pb.QThreshTable[50] )
@@ -273,7 +273,7 @@
   }
 
   if(cpi->FixedQ) {
-    if ( GetFrameType(&cpi->pb) == BASE_FRAME ) {
+    if ( GetFrameType(&cpi->pb) == KEY_FRAME ) {
       cpi->pb.ThisFrameQualityValue = cpi->pb.QThreshTable[43];
       cpi->pb.ThisFrameQualityValue = cpi->FixedQ;
     } else {

Modified: trunk/theora/lib/toplevel.c
===================================================================
--- trunk/theora/lib/toplevel.c	2005-06-27 10:11:14 UTC (rev 9526)
+++ trunk/theora/lib/toplevel.c	2005-06-27 10:47:51 UTC (rev 9527)
@@ -357,7 +357,7 @@
       if(th->granulepos==-1){
         th->granulepos=0;
       }else{
-        if(pbi->FrameType==BASE_FRAME){
+        if(pbi->FrameType==KEY_FRAME){
           long frames= th->granulepos & ((1<<pbi->keyframe_granule_shift)-1);
           th->granulepos>>=pbi->keyframe_granule_shift;
           th->granulepos+=frames+1;



More information about the commits mailing list