[xiph-commits] r11119 - in trunk/theora: include/theora lib
tterribe at svn.xiph.org
tterribe at svn.xiph.org
Mon Apr 10 15:46:23 PDT 2006
Author: tterribe
Date: 2006-04-10 15:46:19 -0700 (Mon, 10 Apr 2006)
New Revision: 11119
Modified:
trunk/theora/include/theora/theora.h
trunk/theora/lib/codec_internal.h
trunk/theora/lib/compglobals.c
trunk/theora/lib/dct_decode.c
trunk/theora/lib/decode.c
trunk/theora/lib/encoder_toplevel.c
trunk/theora/lib/quant.c
trunk/theora/lib/toplevel.c
Log:
Fix handling of 0-byte packets to be spec compliant in the decoder.
Also report them back to the application, so that it does not need to process
the (unchanged) decoded frame.
Also, remove all tabs from the source code.
I don't know how these managed to creep back in.
Someone should be very ashamed.
Modified: trunk/theora/include/theora/theora.h
===================================================================
--- trunk/theora/include/theora/theora.h 2006-04-10 21:27:06 UTC (rev 11118)
+++ trunk/theora/include/theora/theora.h 2006-04-10 22:46:19 UTC (rev 11119)
@@ -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: trunk/theora/lib/codec_internal.h
===================================================================
--- trunk/theora/lib/codec_internal.h 2006-04-10 21:27:06 UTC (rev 11118)
+++ trunk/theora/lib/codec_internal.h 2006-04-10 22:46:19 UTC (rev 11119)
@@ -460,7 +460,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: trunk/theora/lib/compglobals.c
===================================================================
--- trunk/theora/lib/compglobals.c 2006-04-10 21:27:06 UTC (rev 11118)
+++ trunk/theora/lib/compglobals.c 2006-04-10 22:46:19 UTC (rev 11119)
@@ -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: trunk/theora/lib/dct_decode.c
===================================================================
--- trunk/theora/lib/dct_decode.c 2006-04-10 21:27:06 UTC (rev 11118)
+++ trunk/theora/lib/dct_decode.c 2006-04-10 22:46:19 UTC (rev 11119)
@@ -212,13 +212,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: trunk/theora/lib/decode.c
===================================================================
--- trunk/theora/lib/decode.c 2006-04-10 21:27:06 UTC (rev 11118)
+++ trunk/theora/lib/decode.c 2006-04-10 22:46:19 UTC (rev 11119)
@@ -72,7 +72,7 @@
/* Quality (Q) index */
NQIndex = 0;
theora_read(pbi->opb,6,&ret);
- if (ret < 0 || ret >= 64) { /* range check */
+ if (ret < 0 || ret >= 64) { /* range check */
ret = 0;
pbi->DecoderErrorCode = 1;
}
@@ -82,7 +82,7 @@
SpareBits = (unsigned char)ret;
if (SpareBits) {
theora_read(pbi->opb,6,&ret);
- if (ret < 0 || ret >= 64) { /* range check */
+ if (ret < 0 || ret >= 64) { /* range check */
ret = 0;
pbi->DecoderErrorCode = 1;
}
@@ -91,7 +91,7 @@
SpareBits = (unsigned char)ret;
if (SpareBits) {
theora_read(pbi->opb,6,&ret);
- if (ret < 0 || ret >= 64) { /* range check */
+ if (ret < 0 || ret >= 64) { /* range check */
ret = 0;
pbi->DecoderErrorCode = 1;
}
@@ -558,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;
Modified: trunk/theora/lib/encoder_toplevel.c
===================================================================
--- trunk/theora/lib/encoder_toplevel.c 2006-04-10 21:27:06 UTC (rev 11118)
+++ trunk/theora/lib/encoder_toplevel.c 2006-04-10 22:46:19 UTC (rev 11119)
@@ -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: trunk/theora/lib/quant.c
===================================================================
--- trunk/theora/lib/quant.c 2006-04-10 21:27:06 UTC (rev 11118)
+++ trunk/theora/lib/quant.c 2006-04-10 22:46:19 UTC (rev 11119)
@@ -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: trunk/theora/lib/toplevel.c
===================================================================
--- trunk/theora/lib/toplevel.c 2006-04-10 21:27:06 UTC (rev 11118)
+++ trunk/theora/lib/toplevel.c 2006-04-10 22:46:19 UTC (rev 11119)
@@ -340,34 +340,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