[xiph-commits] r11142 - in branches/theora-mmx: . doc/spec include/theora lib

j at svn.xiph.org j at svn.xiph.org
Sat Apr 15 13:53:23 PDT 2006


Author: j
Date: 2006-04-15 13:53:14 -0700 (Sat, 15 Apr 2006)
New Revision: 11142

Modified:
   branches/theora-mmx/
   branches/theora-mmx/CHANGES
   branches/theora-mmx/doc/spec/spec.tex
   branches/theora-mmx/include/theora/theora.h
   branches/theora-mmx/lib/codec_internal.h
   branches/theora-mmx/lib/compglobals.c
   branches/theora-mmx/lib/dct_decode.c
   branches/theora-mmx/lib/decode.c
   branches/theora-mmx/lib/encoder_toplevel.c
   branches/theora-mmx/lib/quant.c
   branches/theora-mmx/lib/scan.c
   branches/theora-mmx/lib/toplevel.c
Log:
merge changes from trunk


Property changes on: branches/theora-mmx
___________________________________________________________________
Name: branch-point
   - 10957
   + 11141

Modified: branches/theora-mmx/CHANGES
===================================================================
--- branches/theora-mmx/CHANGES	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/CHANGES	2006-04-15 20:53:14 UTC (rev 11142)
@@ -1,6 +1,11 @@
 libtheora 1.0alph6 (unreleased)
 
- * no changes yet
+ * Major RTP payload specification update
+ * Minor format specification updates
+ * Fix some spurious calls to free() instead of _ogg_free()
+ * Fix invalid array indexing in PixelLineSearch()
+ * Improve robustness against invalid input
+ * General warning cleanup
 
 libtheora 1.0alpha5 (2005 August 20)
 

Modified: branches/theora-mmx/doc/spec/spec.tex
===================================================================
--- branches/theora-mmx/doc/spec/spec.tex	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/doc/spec/spec.tex	2006-04-15 20:53:14 UTC (rev 11142)
@@ -160,7 +160,7 @@
 \item[$a\%b$]
 The remainder from the integer division of $a$ by $b$.
 \begin{align*}
-a\%b & = |a|-|b|*|a//b|
+a\%b & = a-|b|*\left\lfloor\frac{a}{|b|}\right\rfloor
 \end{align*}
 Note that with this definition, the result is always non-negative and less than
  $|b|$.
@@ -206,7 +206,7 @@
 \begin{align*}
 \ilog(a) = \left\{\begin{array}{ll}
 0, & a \le 0 \\
-\left\lceil\log_2{a}\right\rceil, & a > 0
+\left\lfloor\log_2{a}\right\rfloor+1, & a > 0
 \end{array}\right.
 \end{align*}
 
@@ -975,6 +975,9 @@
 All other packet types are reserved; packets marked with a reserved type should
  be ignored.
 
+Additionally, zero-length packets are treated as if they were an inter 
+frame with no blocks coded. That is, as a duplicate frame.
+
 \paragraph{Frame Header Decode}
 
 The frame header contains some global information about the current frame.
@@ -2056,8 +2059,11 @@
 This stream is not decodable according to this specification.
 \item
 Read an 8-bit unsigned integer as \bitvar{VREV}.
-If \bitvar{VREV} is not $0$, then stop.
-This stream is not decodable according to this specification.
+If \bitvar{VREV} is greater than $0$, then this stream
+may contain optional features or interpretational changes 
+documented in a future version of this specification.
+Regardless of the value of \bitvar{VREV}, the stream is decodable 
+according to this specification.
 \item
 Read a 16-bit unsigned integer as \bitvar{FMBW}.
 This MUST be greater than zero.
@@ -7535,12 +7541,12 @@
 
 This procedure uses all the procedures defined in the previous section of this
  chapter to decode and reconstruct a complete frame.
-As a special case, a 0-byte packet is treated exactly like an inter frame with
- no coded blocks.
 It takes as input values decoded from the headers, as well as the current
  reference frames.
 As output, it gives the uncropped, reconstructed frame.
 This should be cropped to picture region before display.
+As a special case, a 0-byte packet is treated exactly like an inter frame with
+ no coded blocks.
 
 \begin{enumerate}
 \item

Modified: branches/theora-mmx/include/theora/theora.h
===================================================================
--- branches/theora-mmx/include/theora/theora.h	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/include/theora/theora.h	2006-04-15 20:53:14 UTC (rev 11142)
@@ -58,16 +58,16 @@
  * All samples are 8 bits.
  */
 typedef struct {
-    int   y_width;	/**< Width of the Y' luminance plane */
-    int   y_height;	/**< Height of the luminance plane */
-    int   y_stride;	/**< Offset in bytes between successive rows */
+    int   y_width;      /**< Width of the Y' luminance plane */
+    int   y_height;     /**< Height of the luminance plane */
+    int   y_stride;     /**< Offset in bytes between successive rows */
 
-    int   uv_width;	/**< Height of the Cb and Cr chroma planes */
-    int   uv_height;	/**< Width of the chroma planes */
-    int   uv_stride;	/**< Offset between successive chroma rows */
-    unsigned char *y;	/**< Pointer to start of luminance data */
-    unsigned char *u;	/**< Pointer to start of Cb data */
-    unsigned char *v;	/**< Pointer to start of Cr data */
+    int   uv_width;     /**< Height of the Cb and Cr chroma planes */
+    int   uv_height;    /**< Width of the chroma planes */
+    int   uv_stride;    /**< Offset between successive chroma rows */
+    unsigned char *y;   /**< Pointer to start of luminance data */
+    unsigned char *u;   /**< Pointer to start of Cb data */
+    unsigned char *v;   /**< Pointer to start of Cr data */
 
 } yuv_buffer;
 
@@ -75,10 +75,10 @@
  * A Colorspace.
  */
 typedef enum {
-  OC_CS_UNSPECIFIED,	/**< The colorspace is unknown or unspecified */
-  OC_CS_ITU_REC_470M,	/**< This is the best option for 'NTSC' content */
-  OC_CS_ITU_REC_470BG,	/**< This is the best option for 'PAL' content */
-  OC_CS_NSPACES		/**< This marks the end of the defined colorspaces */
+  OC_CS_UNSPECIFIED,    /**< The colorspace is unknown or unspecified */
+  OC_CS_ITU_REC_470M,   /**< This is the best option for 'NTSC' content */
+  OC_CS_ITU_REC_470BG,  /**< This is the best option for 'PAL' content */
+  OC_CS_NSPACES         /**< This marks the end of the defined colorspaces */
 } theora_colorspace;
 
 /**
@@ -89,10 +89,10 @@
  * exact definitions.
  */
 typedef enum {
-  OC_PF_420,	/**< Chroma subsampling by 2 in each direction (4:2:0) */
-  OC_PF_RSVD,	/**< Reserved value */
-  OC_PF_422,	/**< Horizonatal chroma subsampling by 2 (4:2:2) */
-  OC_PF_444,	/**< No chroma subsampling at all (4:4:4) */
+  OC_PF_420,    /**< Chroma subsampling by 2 in each direction (4:2:0) */
+  OC_PF_RSVD,   /**< Reserved value */
+  OC_PF_422,    /**< Horizonatal chroma subsampling by 2 (4:2:2) */
+  OC_PF_444,    /**< No chroma subsampling at all (4:4:4) */
 } theora_pixelformat;
 
 /**
@@ -185,22 +185,23 @@
  * for their length.
  */
 typedef struct theora_comment{
-  char **user_comments;		/**< An array of comment string vectors */
-  int   *comment_lengths;	/**< An array of corresponding string vector lengths in bytes */
-  int    comments;		/**< The total number of comment string vectors */
-  char  *vendor;		/**< The vendor string identifying the encoder, null terminated */
+  char **user_comments;         /**< An array of comment string vectors */
+  int   *comment_lengths;       /**< An array of corresponding string vector lengths in bytes */
+  int    comments;              /**< The total number of comment string vectors */
+  char  *vendor;                /**< The vendor string identifying the encoder, null terminated */
 
 } theora_comment;
 
-#define OC_FAULT       -1	/**< General failure */
-#define OC_EINVAL      -10	/**< Library encountered invalid internal data */
-#define OC_DISABLED    -11	/**< Requested action is disabled */
-#define OC_BADHEADER   -20	/**< Header packet was corrupt/invalid */
-#define OC_NOTFORMAT   -21	/**< Packet is not a theora packet */
-#define OC_VERSION     -22	/**< Bitstream version is not handled */
-#define OC_IMPL        -23	/**< Feature or action not implemented */
-#define OC_BADPACKET   -24	/**< Packet is corrupt */
-#define OC_NEWPACKET   -25	/**< Packet is an (ignorable) unhandled extension */
+#define OC_FAULT       -1       /**< General failure */
+#define OC_EINVAL      -10      /**< Library encountered invalid internal data */
+#define OC_DISABLED    -11      /**< Requested action is disabled */
+#define OC_BADHEADER   -20      /**< Header packet was corrupt/invalid */
+#define OC_NOTFORMAT   -21      /**< Packet is not a theora packet */
+#define OC_VERSION     -22      /**< Bitstream version is not handled */
+#define OC_IMPL        -23      /**< Feature or action not implemented */
+#define OC_BADPACKET   -24      /**< Packet is corrupt */
+#define OC_NEWPACKET   -25      /**< Packet is an (ignorable) unhandled extension */
+#define OC_DUPFRAME    1        /**< Packet is a dropped frame */
 
 /** 
  * Retrieve a human-readable string to identify the encoder vendor and version.
@@ -434,7 +435,7 @@
  * \returns The absolute time in seconds corresponding to \a granulepos.
  * \retval -1. The given granulepos is undefined (i.e. negative), or
  * \retval -1. The function has been disabled because floating 
- *		point support is not available.
+ *              point support is not available.
  */
 extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
 

Modified: branches/theora-mmx/lib/codec_internal.h
===================================================================
--- branches/theora-mmx/lib/codec_internal.h	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/lib/codec_internal.h	2006-04-15 20:53:14 UTC (rev 11142)
@@ -461,7 +461,7 @@
   Q_LIST_ENTRY  *dequant_InterY_coeffs;
   Q_LIST_ENTRY  *dequant_InterU_coeffs;
   Q_LIST_ENTRY  *dequant_InterV_coeffs;
-  Q_LIST_ENTRY  *dequant_coeffs;	/* currently active quantizer */
+  Q_LIST_ENTRY  *dequant_coeffs;        /* currently active quantizer */
   unsigned int   zigzag_index[64];
   ogg_int32_t    quant_Y_coeffs[64];
   ogg_int32_t    quant_UV_coeffs[64];

Modified: branches/theora-mmx/lib/compglobals.c
===================================================================
--- branches/theora-mmx/lib/compglobals.c	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/lib/compglobals.c	2006-04-15 20:53:14 UTC (rev 11142)
@@ -121,49 +121,49 @@
 
   cpi->FragmentLastQ =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->FragmentLastQAlloc));
+                sizeof(*cpi->FragmentLastQAlloc));
   cpi->FragTokens =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->FragTokensAlloc));
+                sizeof(*cpi->FragTokensAlloc));
   cpi->OriginalDC =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->OriginalDCAlloc));
+                sizeof(*cpi->OriginalDCAlloc));
   cpi->FragTokenCounts =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->FragTokenCountsAlloc));
+                sizeof(*cpi->FragTokenCountsAlloc));
   cpi->RunHuffIndices =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->RunHuffIndicesAlloc));
+                sizeof(*cpi->RunHuffIndicesAlloc));
   cpi->LastCodedErrorScore =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->LastCodedErrorScoreAlloc));
+                sizeof(*cpi->LastCodedErrorScoreAlloc));
   cpi->BlockCodedFlags =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->BlockCodedFlagsAlloc));
+                sizeof(*cpi->BlockCodedFlagsAlloc));
   cpi->ModeList =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(*cpi->ModeListAlloc));
+                sizeof(*cpi->ModeListAlloc));
   cpi->MVList =
     _ogg_malloc(cpi->pb.UnitFragments*
-		sizeof(cpi->MVListAlloc));
+                sizeof(cpi->MVListAlloc));
   cpi->DCT_codes =
     _ogg_malloc(64*
-		sizeof(*cpi->DCT_codesAlloc));
+                sizeof(*cpi->DCT_codesAlloc));
   cpi->DCTDataBuffer =
     _ogg_malloc(64*
-		sizeof(*cpi->DCTDataBufferAlloc));
+                sizeof(*cpi->DCTDataBufferAlloc));
   cpi->quantized_list =
     _ogg_malloc(64*
-		sizeof(*cpi->quantized_listAlloc));
+                sizeof(*cpi->quantized_listAlloc));
   cpi->PartiallyCodedFlags =
     _ogg_malloc(cpi->pb.MacroBlocks*
-		sizeof(*cpi->PartiallyCodedFlags));
+                sizeof(*cpi->PartiallyCodedFlags));
   cpi->PartiallyCodedMbPatterns =
     _ogg_malloc(cpi->pb.MacroBlocks*
-		sizeof(*cpi->PartiallyCodedMbPatterns));
+                sizeof(*cpi->PartiallyCodedMbPatterns));
   cpi->UncodedMbFlags =
     _ogg_malloc(cpi->pb.MacroBlocks*
-		sizeof(*cpi->UncodedMbFlags));
+                sizeof(*cpi->UncodedMbFlags));
 
 }
 
@@ -214,25 +214,25 @@
   /* allocate frames */
   cpi->ConvDestBuffer =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->ConvDestBuffer));
+                sizeof(*cpi->ConvDestBuffer));
   cpi->yuv0ptr =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->yuv0ptr));
+                sizeof(*cpi->yuv0ptr));
   cpi->yuv1ptr =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->yuv1ptr));
+                sizeof(*cpi->yuv1ptr));
   cpi->OptimisedTokenListEb =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->OptimisedTokenListEb));
+                sizeof(*cpi->OptimisedTokenListEb));
   cpi->OptimisedTokenList =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->OptimisedTokenList));
+                sizeof(*cpi->OptimisedTokenList));
   cpi->OptimisedTokenListHi =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->OptimisedTokenListHi));
+                sizeof(*cpi->OptimisedTokenListHi));
   cpi->OptimisedTokenListPl =
     _ogg_malloc(FrameSize*
-		sizeof(*cpi->OptimisedTokenListPl));
+                sizeof(*cpi->OptimisedTokenListPl));
 }
 
 void ClearCPInstance(CP_INSTANCE *cpi){

Modified: branches/theora-mmx/lib/dct_decode.c
===================================================================
--- branches/theora-mmx/lib/dct_decode.c	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/lib/dct_decode.c	2006-04-15 20:53:14 UTC (rev 11142)
@@ -197,13 +197,13 @@
     /* Select appropriate dequantiser matrix. */
     if ( pbi->CodingMode == CODE_INTRA )
       if ( FragmentNumber < 
-		(ogg_int32_t)(pbi->YPlaneFragments + pbi->UVPlaneFragments) )
+                (ogg_int32_t)(pbi->YPlaneFragments + pbi->UVPlaneFragments) )
         pbi->dequant_coeffs = pbi->dequant_U_coeffs;
       else
         pbi->dequant_coeffs = pbi->dequant_V_coeffs;
     else
       if ( FragmentNumber < 
-		(ogg_int32_t)(pbi->YPlaneFragments + pbi->UVPlaneFragments) )
+                (ogg_int32_t)(pbi->YPlaneFragments + pbi->UVPlaneFragments) )
         pbi->dequant_coeffs = pbi->dequant_InterU_coeffs;
       else
         pbi->dequant_coeffs = pbi->dequant_InterV_coeffs;

Modified: branches/theora-mmx/lib/decode.c
===================================================================
--- branches/theora-mmx/lib/decode.c	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/lib/decode.c	2006-04-15 20:53:14 UTC (rev 11142)
@@ -5,7 +5,7 @@
  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003                *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2006                *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
@@ -72,17 +72,29 @@
   /* Quality (Q) index */
   NQIndex = 0;
   theora_read(pbi->opb,6,&ret);
+  if (ret < 0 || ret >= 64) {   /* range check */
+    ret = 0;
+    pbi->DecoderErrorCode = 1;
+  }
   DctQIndex[NQIndex++] = (unsigned char)ret;
 
   theora_read(pbi->opb,1,&ret);
   SpareBits = (unsigned char)ret;
   if (SpareBits) {
     theora_read(pbi->opb,6,&ret);
+    if (ret < 0 || ret >= 64) { /* range check */
+      ret = 0;
+      pbi->DecoderErrorCode = 1;
+    }
     DctQIndex[NQIndex++] = (unsigned char)ret;
     theora_read(pbi->opb,1,&ret);
     SpareBits = (unsigned char)ret;
     if (SpareBits) {
       theora_read(pbi->opb,6,&ret);
+      if (ret < 0 || ret >= 64) {       /* range check */
+        ret = 0;
+        pbi->DecoderErrorCode = 1;
+      }
       DctQIndex[NQIndex++] = (unsigned char)ret;
     }
   }
@@ -103,7 +115,7 @@
   /* Set this frame quality value and tables from the coded Q Index */
   UpdateQ(pbi, DctQIndex[0]);
 
-  return 1;
+  return pbi->DecoderErrorCode;
 }
 
 void SetFrameType( PB_INSTANCE *pbi,unsigned char FrType ){
@@ -123,13 +135,13 @@
 static int LoadFrame(PB_INSTANCE *pbi){
 
   /* Load the frame header (including the frame size). */
-  if ( LoadFrameHeader(pbi) ){
+  if ( LoadFrameHeader(pbi) == 0 ){
     /* Read in the updated block map */
     QuadDecodeDisplayFragments( pbi );
-    return 1;
+    return 0;
   }
 
-  return 0;
+  return pbi->DecoderErrorCode;
 }
 
 static void DecodeModes (PB_INSTANCE *pbi,
@@ -293,6 +305,9 @@
     if (ret)
       MVectComponent = -MVectComponent;
     break;
+  default:
+    /* occurs if there is a read error */
+    MVectComponent = 0;
   }
 
   return MVectComponent;
@@ -340,9 +355,19 @@
     return;
   }
 
-  /* set the default motion vector to 0,0 */
+  /* set the default motion vectors to 0,0 */
   MVect[0].x = 0;
   MVect[0].y = 0;
+  MVect[1].x = 0;
+  MVect[1].y = 0;
+  MVect[2].x = 0;
+  MVect[2].y = 0;
+  MVect[3].x = 0;
+  MVect[3].y = 0;
+  MVect[4].x = 0;
+  MVect[4].y = 0;
+  MVect[5].x = 0;
+  MVect[5].y = 0;
   LastInterMV.x = 0;
   LastInterMV.y = 0;
   PriorLastInterMV.x = 0;
@@ -518,7 +543,8 @@
   /* until it hits a leaf at which point we have decoded a token */
   while ( CurrentRoot->Value < 0 ){
 
-    theora_read(opb, 1, &ret);  
+    theora_read(opb, 1, &ret);
+    if (ret < 0) break; /* out of packet data! */
     if (ret)
       CurrentRoot = CurrentRoot->OneChild;
     else
@@ -532,7 +558,7 @@
 static void UnpackAndExpandDcToken( PB_INSTANCE *pbi,
                                     Q_LIST_ENTRY *ExpandedBlock,
                                     unsigned char * CoeffIndex ){
-  long			ret;
+  long                  ret;
   ogg_int32_t           ExtraBits = 0;
   ogg_uint32_t          Token;
 
@@ -691,8 +717,16 @@
   /* Get the DC huffman table choice for Y and then UV */
   theora_read(pbi->opb,DC_HUFF_CHOICE_BITS,&ret); 
   DcHuffChoice1 = ret + DC_HUFF_OFFSET;
+  if (ret < 0 || DcHuffChoice1 >= NUM_HUFF_TABLES) {
+    DcHuffChoice1 = DC_HUFF_OFFSET;
+    pbi->DecoderErrorCode = 1;
+  }
   theora_read(pbi->opb,DC_HUFF_CHOICE_BITS,&ret); 
   DcHuffChoice2 = ret + DC_HUFF_OFFSET;
+  if (ret < 0 || DcHuffChoice2 >= NUM_HUFF_TABLES) {
+    DcHuffChoice2 = DC_HUFF_OFFSET;
+    pbi->DecoderErrorCode = 1;
+  }
 
   /* UnPack DC coefficients / tokens */
   CodedBlockListPtr = pbi->CodedBlockList;
@@ -729,8 +763,16 @@
 
   theora_read(pbi->opb,AC_HUFF_CHOICE_BITS,&ret); 
   AcHuffIndex1 = ret + AC_HUFF_OFFSET;
+  if (ret < 0 || AcHuffIndex1 >= NUM_HUFF_TABLES) {
+    AcHuffIndex1 = AC_HUFF_OFFSET;
+    pbi->DecoderErrorCode = 1;
+  }
   theora_read(pbi->opb,AC_HUFF_CHOICE_BITS,&ret); 
   AcHuffIndex2 = ret + AC_HUFF_OFFSET;
+  if (ret < 0 || AcHuffIndex2 >= NUM_HUFF_TABLES) {
+    AcHuffIndex2 = AC_HUFF_OFFSET;
+    pbi->DecoderErrorCode = 1;
+  }
 
   /* Unpack Lower AC coefficients. */
   while ( EncodedCoeffs < 64 ) {
@@ -812,12 +854,15 @@
 
   /* Decode the modes data */
   DecodeModes( pbi, pbi->YSBRows, pbi->YSBCols);
+  if (pbi->DecoderErrorCode) return;
 
   /* Unpack and decode the motion vectors. */
   DecodeMVectors ( pbi, pbi->YSBRows, pbi->YSBCols);
+  if (pbi->DecoderErrorCode) return;
 
   /* Unpack and decode the actual video data. */
   UnPackVideo(pbi);
+  if (pbi->DecoderErrorCode) return;
 
   /* Reconstruct and display the frame */
   dsp_static_save_fpu ();
@@ -828,22 +873,18 @@
 
 
 int LoadAndDecode(PB_INSTANCE *pbi){
-  int    LoadFrameOK;
 
   /* Reset the DC predictors. */
   pbi->InvLastIntraDC = 0;
   pbi->InvLastInterDC = 0;
 
-  /* Load the next frame. */
-  LoadFrameOK = LoadFrame(pbi);
-
-  if ( LoadFrameOK ){
+  if ( LoadFrame(pbi) == 0 ){
     pbi->LastFrameQualityValue = pbi->ThisFrameQualityValue;
 
     /* Decode the data into the fragment buffer. */
     DecodeData(pbi);
-    return(0);
+    if (pbi->DecoderErrorCode == 0) return 0;
   }
 
-  return(OC_BADPACKET);
+  return OC_BADPACKET;
 }

Modified: branches/theora-mmx/lib/encoder_toplevel.c
===================================================================
--- branches/theora-mmx/lib/encoder_toplevel.c	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/lib/encoder_toplevel.c	2006-04-15 20:53:14 UTC (rev 11142)
@@ -723,10 +723,10 @@
     /* forcing out a keyframe if the max interval is up is done at a higher level */
     if( cpi->pb.info.keyframe_auto_p){
       if( ( 2* IntraError < 5 * InterError )
-	  && ( KFIndicator >= (ogg_uint32_t)
-	       cpi->pb.info.keyframe_auto_threshold)
-	  && ( cpi->LastKeyFrame > cpi->pb.info.keyframe_mindistance)
-	  ){
+          && ( KFIndicator >= (ogg_uint32_t)
+               cpi->pb.info.keyframe_auto_threshold)
+          && ( cpi->LastKeyFrame > cpi->pb.info.keyframe_mindistance)
+          ){
         CompressKeyFrame(cpi);  /* Code a key frame */
         return;
       }

Modified: branches/theora-mmx/lib/quant.c
===================================================================
--- branches/theora-mmx/lib/quant.c	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/lib/quant.c	2006-04-15 20:53:14 UTC (rev 11142)
@@ -168,7 +168,7 @@
 }
 
 static int _read_qtable_range(codec_setup_info *ci, oggpack_buffer* opb,
-	 int N, int type) 
+         int N, int type) 
 {
   int index, range;
   int qi = 0;

Modified: branches/theora-mmx/lib/scan.c
===================================================================
--- branches/theora-mmx/lib/scan.c	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/lib/scan.c	2006-04-15 20:53:14 UTC (rev 11142)
@@ -1427,12 +1427,12 @@
                              ogg_uint32_t * line_length ){
   /* Exit if the pixel does not qualify or we have fallen off the edge
      of either the image plane or the row. */
-  if ( ((*ChangedLocalsPtr) <= 1) ||
-       ((*ChangedLocalsPtr) >= 6) ||
-       (RowNumber < 0) ||
+  if ( (RowNumber < 0) ||
        (RowNumber >= ppi->PlaneHeight) ||
        (ColNumber < 0) ||
-       (ColNumber >= ppi->PlaneWidth) ){
+       (ColNumber >= ppi->PlaneWidth) ||
+       ((*ChangedLocalsPtr) <= 1) ||
+       ((*ChangedLocalsPtr) >= 6) ){
     /* If not then it isn't part of any line. */
     return;
   }

Modified: branches/theora-mmx/lib/toplevel.c
===================================================================
--- branches/theora-mmx/lib/toplevel.c	2006-04-14 13:23:45 UTC (rev 11141)
+++ branches/theora-mmx/lib/toplevel.c	2006-04-15 20:53:14 UTC (rev 11142)
@@ -227,13 +227,13 @@
     theora_read(opb,8,&ret);
     typeflag = ret;
     if(!(typeflag&0x80)) {
-      free(opb);
+      _ogg_free(opb);
       return(OC_NOTFORMAT);
     }
 
     _tp_readbuffer(opb,id,6);
     if(memcmp(id,"theora",6)) {
-      free(opb);
+      _ogg_free(opb);
       return(OC_NOTFORMAT);
     }
 
@@ -241,43 +241,43 @@
     case 0x80:
       if(!op->b_o_s){
         /* Not the initial packet */
-        free(opb);
+        _ogg_free(opb);
         return(OC_BADHEADER);
       }
       if(ci->version_major!=0){
         /* previously initialized info header */
-        free(opb);
+        _ogg_free(opb);
         return OC_BADHEADER;
       }
 
       ret = _theora_unpack_info(ci,opb);
-      free(opb);
+      _ogg_free(opb);
       return(ret);
 
     case 0x81:
       if(ci->version_major==0){
         /* um... we didn't get the initial header */
-        free(opb);
+        _ogg_free(opb);
         return(OC_BADHEADER);
       }
 
       ret = _theora_unpack_comment(cc,opb);
-      free(opb);
+      _ogg_free(opb);
       return(ret);
 
     case 0x82:
       if(ci->version_major==0 || cc->vendor==NULL){
         /* um... we didn't get the initial header or comments yet */
-        free(opb);
+        _ogg_free(opb);
         return(OC_BADHEADER);
       }
 
       ret = _theora_unpack_tables(ci,opb);
-      free(opb);
+      _ogg_free(opb);
       return(ret);
     
     default:
-      free(opb);
+      _ogg_free(opb);
       if(ci->version_major==0 || cc->vendor==NULL || 
          ((codec_setup_info *)ci->codec_setup)->HuffRoot[0]==NULL){
         /* we haven't gotten the three required headers */
@@ -288,7 +288,7 @@
     }
   }
   /* I don't think it's possible to get this far, but better safe.. */
-  free(opb);
+  _ogg_free(opb);
   return(OC_BADHEADER);
 }
 
@@ -342,34 +342,39 @@
   oggpackB_readinit(pbi->opb,op->packet);
 #endif
 
-  /* verify that this is a video frame */
-  theora_read(pbi->opb,1,&ret);
+  if(op->bytes!=0){
+    /* verify that this is a video frame */
+    theora_read(pbi->opb,1,&ret);
 
-  if (ret==0) {
-    ret=LoadAndDecode(pbi);
+    if (ret==0) {
+      ret=LoadAndDecode(pbi);
 
-    if(ret)return ret;
+      if(ret)return ret;
 
-    if(pbi->PostProcessingLevel)
-      PostProcess(pbi);
+      if(pbi->PostProcessingLevel)
+        PostProcess(pbi);
 
-    if(op->granulepos>-1)
-      th->granulepos=op->granulepos;
-    else{
-      if(th->granulepos==-1){
-        th->granulepos=0;
-      }else{
-        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;
-          th->granulepos<<=pbi->keyframe_granule_shift;
-        }else
-          th->granulepos++;
+      if(op->granulepos>-1)
+        th->granulepos=op->granulepos;
+      else{
+        if(th->granulepos==-1){
+          th->granulepos=0;
+        }else{
+          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;
+            th->granulepos<<=pbi->keyframe_granule_shift;
+          }else
+            th->granulepos++;
+        }
       }
+
+      return(0);
     }
-
-    return(0);
+  }else{
+    th->granulepos++;
+    return(OC_DUPFRAME);
   }
 
   return OC_BADPACKET;



More information about the commits mailing list