1 /********************************************************************
3 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
11 ********************************************************************
16 ********************************************************************/
20 #include "codec_internal.h"
22 void ClearTmpBuffers(PB_INSTANCE
* pbi
){
24 if(pbi
->ReconDataBuffer
)
25 _ogg_free(pbi
->ReconDataBuffer
);
26 if(pbi
->DequantBuffer
)
27 _ogg_free(pbi
->DequantBuffer
);
28 if(pbi
->TmpDataBuffer
)
29 _ogg_free(pbi
->TmpDataBuffer
);
30 if(pbi
->TmpReconBuffer
)
31 _ogg_free(pbi
->TmpReconBuffer
);
32 if(pbi
->dequant_Y_coeffs
)
33 _ogg_free(pbi
->dequant_Y_coeffs
);
34 if(pbi
->dequant_U_coeffs
)
35 _ogg_free(pbi
->dequant_U_coeffs
);
36 if(pbi
->dequant_V_coeffs
)
37 _ogg_free(pbi
->dequant_V_coeffs
);
38 if(pbi
->dequant_InterY_coeffs
)
39 _ogg_free(pbi
->dequant_InterY_coeffs
);
40 if(pbi
->dequant_InterU_coeffs
)
41 _ogg_free(pbi
->dequant_InterU_coeffs
);
42 if(pbi
->dequant_InterV_coeffs
)
43 _ogg_free(pbi
->dequant_InterV_coeffs
);
46 pbi
->ReconDataBuffer
=0;
47 pbi
->DequantBuffer
= 0;
48 pbi
->TmpDataBuffer
= 0;
49 pbi
->TmpReconBuffer
= 0;
50 pbi
->dequant_Y_coeffs
= 0;
51 pbi
->dequant_U_coeffs
= 0;
52 pbi
->dequant_V_coeffs
= 0;
53 pbi
->dequant_InterY_coeffs
= 0;
54 pbi
->dequant_InterU_coeffs
= 0;
55 pbi
->dequant_InterV_coeffs
= 0;
59 void InitTmpBuffers(PB_INSTANCE
* pbi
){
61 /* clear any existing info */
64 /* Adjust the position of all of our temporary */
65 pbi
->ReconDataBuffer
=
66 _ogg_malloc(64*sizeof(*pbi
->ReconDataBuffer
));
69 _ogg_malloc(64 * sizeof(*pbi
->DequantBuffer
));
72 _ogg_malloc(64 * sizeof(*pbi
->TmpDataBuffer
));
75 _ogg_malloc(64 * sizeof(*pbi
->TmpReconBuffer
));
77 pbi
->dequant_Y_coeffs
=
78 _ogg_malloc(64 * sizeof(*pbi
->dequant_Y_coeffs
));
80 pbi
->dequant_U_coeffs
=
81 _ogg_malloc(64 * sizeof(*pbi
->dequant_U_coeffs
));
83 pbi
->dequant_V_coeffs
=
84 _ogg_malloc(64 * sizeof(*pbi
->dequant_V_coeffs
));
86 pbi
->dequant_InterY_coeffs
=
87 _ogg_malloc(64 * sizeof(*pbi
->dequant_InterY_coeffs
));
89 pbi
->dequant_InterU_coeffs
=
90 _ogg_malloc(64 * sizeof(*pbi
->dequant_InterU_coeffs
));
92 pbi
->dequant_InterV_coeffs
=
93 _ogg_malloc(64 * sizeof(*pbi
->dequant_InterV_coeffs
));
97 void ClearPBInstance(PB_INSTANCE
*pbi
){
106 void InitPBInstance(PB_INSTANCE
*pbi
){
107 /* initialize whole structure to 0 */
108 memset(pbi
, 0, sizeof(*pbi
));
112 /* allocate memory for the oggpack_buffer */
114 pbi
->opb
= _ogg_malloc(sizeof(oggpack_buffer
));
116 pbi
->opb
= _ogg_malloc(oggpack_buffersize());
119 /* variables needing initialization (not being set to 0) */
121 pbi
->ModifierPointer
[0] = &pbi
->Modifier
[0][255];
122 pbi
->ModifierPointer
[1] = &pbi
->Modifier
[1][255];
123 pbi
->ModifierPointer
[2] = &pbi
->Modifier
[2][255];
124 pbi
->ModifierPointer
[3] = &pbi
->Modifier
[3][255];
126 pbi
->DecoderErrorCode
= 0;
127 pbi
->KeyFrameType
= DCT_KEY_FRAME
;
128 pbi
->FramesHaveBeenSkipped
= 0;