Lines Matching refs:hAdts
122 int adtsWrite_GetHeaderBits( HANDLE_ADTS hAdts ) in adtsWrite_GetHeaderBits() argument
126 if (hAdts->currentBlock == 0) { in adtsWrite_GetHeaderBits()
129 if (!hAdts->protection_absent) { in adtsWrite_GetHeaderBits()
132 if (hAdts->num_raw_blocks>0) { in adtsWrite_GetHeaderBits()
134 bits += (hAdts->num_raw_blocks)*16; in adtsWrite_GetHeaderBits()
138 if (!hAdts->protection_absent && hAdts->num_raw_blocks>0) { in adtsWrite_GetHeaderBits()
143 hAdts->headerBits = bits; in adtsWrite_GetHeaderBits()
148 INT adtsWrite_Init(HANDLE_ADTS hAdts, CODER_CONFIG *config) in adtsWrite_Init() argument
160 hAdts->mpeg_id = 0; /* MPEG 4 */ in adtsWrite_Init()
162 hAdts->mpeg_id = 1; /* MPEG 2 */ in adtsWrite_Init()
164 hAdts->layer=0; in adtsWrite_Init()
165 hAdts->protection_absent = ! (config->flags & CC_PROTECTION); in adtsWrite_Init()
166 hAdts->profile = ((int)config->aot) - 1; in adtsWrite_Init()
167 hAdts->sample_freq_index = getSamplingRateIndex(config->samplingRate); in adtsWrite_Init()
168 hAdts->sample_freq = config->samplingRate; in adtsWrite_Init()
169 hAdts->private_bit=0; in adtsWrite_Init()
170 hAdts->channel_mode = config->channelMode; in adtsWrite_Init()
171 hAdts->original=0; in adtsWrite_Init()
172 hAdts->home=0; in adtsWrite_Init()
174 hAdts->copyright_id=0; in adtsWrite_Init()
175 hAdts->copyright_start=0; in adtsWrite_Init()
177 hAdts->num_raw_blocks=config->nSubFrames-1; /* 0 means 1 raw data block */ in adtsWrite_Init()
179 FDKcrcInit(&hAdts->crcInfo, 0x8005, 0xFFFF, 16); in adtsWrite_Init()
181 hAdts->currentBlock = 0; in adtsWrite_Init()
187 int adtsWrite_EncodeHeader(HANDLE_ADTS hAdts, in adtsWrite_EncodeHeader() argument
195 hAdts->headerBits = adtsWrite_GetHeaderBits(hAdts); in adtsWrite_EncodeHeader()
197 FDK_ASSERT(((frame_length+hAdts->headerBits)/8)<0x2000); /*13 bit*/ in adtsWrite_EncodeHeader()
200 if (!hAdts->protection_absent) { in adtsWrite_EncodeHeader()
201 FDKcrcReset(&hAdts->crcInfo); in adtsWrite_EncodeHeader()
204 if (hAdts->currentBlock == 0) { in adtsWrite_EncodeHeader()
208 hAdts->subFrameStartBit = FDKgetValidBits(hBitStream); in adtsWrite_EncodeHeader()
211 if (hAdts->currentBlock == 0) in adtsWrite_EncodeHeader()
215 if (hAdts->num_raw_blocks == 0) { in adtsWrite_EncodeHeader()
216 crcIndex = adtsWrite_CrcStartReg(hAdts, hBitStream, 0); in adtsWrite_EncodeHeader()
221 FDKwriteBits(hBitStream, hAdts->mpeg_id, 1); in adtsWrite_EncodeHeader()
222 FDKwriteBits(hBitStream, hAdts->layer, 2); in adtsWrite_EncodeHeader()
223 FDKwriteBits(hBitStream, hAdts->protection_absent, 1); in adtsWrite_EncodeHeader()
224 FDKwriteBits(hBitStream, hAdts->profile, 2); in adtsWrite_EncodeHeader()
225 FDKwriteBits(hBitStream, hAdts->sample_freq_index, 4); in adtsWrite_EncodeHeader()
226 FDKwriteBits(hBitStream, hAdts->private_bit, 1); in adtsWrite_EncodeHeader()
227 FDKwriteBits(hBitStream, getChannelConfig(hAdts->channel_mode), 3); in adtsWrite_EncodeHeader()
228 FDKwriteBits(hBitStream, hAdts->original, 1); in adtsWrite_EncodeHeader()
229 FDKwriteBits(hBitStream, hAdts->home, 1); in adtsWrite_EncodeHeader()
231 FDKwriteBits(hBitStream, hAdts->copyright_id, 1); in adtsWrite_EncodeHeader()
232 FDKwriteBits(hBitStream, hAdts->copyright_start, 1); in adtsWrite_EncodeHeader()
233 FDKwriteBits(hBitStream, (frame_length + hAdts->headerBits)>>3, 13); in adtsWrite_EncodeHeader()
235 FDKwriteBits(hBitStream, hAdts->num_raw_blocks, 2); in adtsWrite_EncodeHeader()
237 if (!hAdts->protection_absent) { in adtsWrite_EncodeHeader()
241 if (hAdts->num_raw_blocks == 0) { in adtsWrite_EncodeHeader()
242 adtsWrite_CrcEndReg(hAdts, hBitStream, crcIndex); in adtsWrite_EncodeHeader()
244 for (i=0; i<hAdts->num_raw_blocks; i++) { in adtsWrite_EncodeHeader()
255 void adtsWrite_EndRawDataBlock(HANDLE_ADTS hAdts, in adtsWrite_EndRawDataBlock() argument
259 if (!hAdts->protection_absent) { in adtsWrite_EndRawDataBlock()
265 if (hAdts->num_raw_blocks == 0) { in adtsWrite_EndRawDataBlock()
266 FDKwriteBits(&bsWriter, FDKcrcGetCRC(&hAdts->crcInfo), 16); in adtsWrite_EndRawDataBlock()
271 FDKwriteBits(hBs, FDKcrcGetCRC(&hAdts->crcInfo), 16); in adtsWrite_EndRawDataBlock()
274 if (hAdts->currentBlock < hAdts->num_raw_blocks) { in adtsWrite_EndRawDataBlock()
275 FDKpushFor(&bsWriter, hAdts->currentBlock*16); in adtsWrite_EndRawDataBlock()
276 distance = FDKgetValidBits(hBs) - (56 + (hAdts->num_raw_blocks)*16 + 16); in adtsWrite_EndRawDataBlock()
284 if (hAdts->num_raw_blocks > 0 && hAdts->currentBlock == hAdts->num_raw_blocks) { in adtsWrite_EndRawDataBlock()
290 if (!hAdts->protection_absent) { in adtsWrite_EndRawDataBlock()
291 FDKcrcReset(&hAdts->crcInfo); in adtsWrite_EndRawDataBlock()
292 crcIndex = FDKcrcStartReg(&hAdts->crcInfo, &bsWriter, 0); in adtsWrite_EndRawDataBlock()
299 if (!hAdts->protection_absent) { in adtsWrite_EndRawDataBlock()
300 FDKpushFor(&bsWriter, 11+2 + (hAdts->num_raw_blocks)*16); in adtsWrite_EndRawDataBlock()
301 FDKcrcEndReg(&hAdts->crcInfo, &bsWriter, crcIndex); in adtsWrite_EndRawDataBlock()
302 FDKwriteBits(&bsWriter, FDKcrcGetCRC(&hAdts->crcInfo), 16); in adtsWrite_EndRawDataBlock()
308 *pBits -= hAdts->subFrameStartBit; in adtsWrite_EndRawDataBlock()
309 if (!hAdts->protection_absent && hAdts->num_raw_blocks > 0) { in adtsWrite_EndRawDataBlock()
313 hAdts->currentBlock++; in adtsWrite_EndRawDataBlock()