Lines Matching refs:hAdts
129 int adtsWrite_GetHeaderBits(HANDLE_ADTS hAdts) { in adtsWrite_GetHeaderBits() argument
132 if (hAdts->currentBlock == 0) { in adtsWrite_GetHeaderBits()
135 if (!hAdts->protection_absent) { in adtsWrite_GetHeaderBits()
138 if (hAdts->num_raw_blocks > 0) { in adtsWrite_GetHeaderBits()
140 bits += (hAdts->num_raw_blocks) * 16; in adtsWrite_GetHeaderBits()
144 if (!hAdts->protection_absent && hAdts->num_raw_blocks > 0) { in adtsWrite_GetHeaderBits()
150 hAdts->headerBits = bits; in adtsWrite_GetHeaderBits()
155 INT adtsWrite_Init(HANDLE_ADTS hAdts, CODER_CONFIG *config) { in adtsWrite_Init() argument
164 hAdts->mpeg_id = 0; /* MPEG 4 */ in adtsWrite_Init()
166 hAdts->mpeg_id = 1; /* MPEG 2 */ in adtsWrite_Init()
168 hAdts->layer = 0; in adtsWrite_Init()
169 hAdts->protection_absent = !(config->flags & CC_PROTECTION); in adtsWrite_Init()
170 hAdts->profile = ((int)config->aot) - 1; in adtsWrite_Init()
171 hAdts->sample_freq_index = getSamplingRateIndex(config->samplingRate, 4); in adtsWrite_Init()
172 hAdts->sample_freq = config->samplingRate; in adtsWrite_Init()
173 hAdts->private_bit = 0; in adtsWrite_Init()
174 hAdts->channel_mode = config->channelMode; in adtsWrite_Init()
175 hAdts->original = 0; in adtsWrite_Init()
176 hAdts->home = 0; in adtsWrite_Init()
178 hAdts->copyright_id = 0; in adtsWrite_Init()
179 hAdts->copyright_start = 0; in adtsWrite_Init()
181 hAdts->num_raw_blocks = config->nSubFrames - 1; /* 0 means 1 raw data block */ in adtsWrite_Init()
183 hAdts->channel_config_zero = config->channelConfigZero; in adtsWrite_Init()
185 FDKcrcInit(&hAdts->crcInfo, 0x8005, 0xFFFF, 16); in adtsWrite_Init()
187 hAdts->currentBlock = 0; in adtsWrite_Init()
192 int adtsWrite_EncodeHeader(HANDLE_ADTS hAdts, HANDLE_FDK_BITSTREAM hBitStream, in adtsWrite_EncodeHeader() argument
196 hAdts->headerBits = adtsWrite_GetHeaderBits(hAdts); in adtsWrite_EncodeHeader()
198 FDK_ASSERT(((frame_length + hAdts->headerBits) / 8) < 0x2000); /*13 bit*/ in adtsWrite_EncodeHeader()
201 if (!hAdts->protection_absent) { in adtsWrite_EncodeHeader()
202 FDKcrcReset(&hAdts->crcInfo); in adtsWrite_EncodeHeader()
205 if (hAdts->currentBlock == 0) { in adtsWrite_EncodeHeader()
209 hAdts->subFrameStartBit = FDKgetValidBits(hBitStream); in adtsWrite_EncodeHeader()
212 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()
229 getChannelConfig(hAdts->channel_mode, hAdts->channel_config_zero), 3); in adtsWrite_EncodeHeader()
230 FDKwriteBits(hBitStream, hAdts->original, 1); in adtsWrite_EncodeHeader()
231 FDKwriteBits(hBitStream, hAdts->home, 1); in adtsWrite_EncodeHeader()
233 FDKwriteBits(hBitStream, hAdts->copyright_id, 1); in adtsWrite_EncodeHeader()
234 FDKwriteBits(hBitStream, hAdts->copyright_start, 1); in adtsWrite_EncodeHeader()
235 FDKwriteBits(hBitStream, (frame_length + hAdts->headerBits) >> 3, 13); in adtsWrite_EncodeHeader()
237 FDKwriteBits(hBitStream, hAdts->num_raw_blocks, 2); in adtsWrite_EncodeHeader()
239 if (!hAdts->protection_absent) { in adtsWrite_EncodeHeader()
244 if (hAdts->num_raw_blocks == 0) { in adtsWrite_EncodeHeader()
245 adtsWrite_CrcEndReg(hAdts, hBitStream, crcIndex); in adtsWrite_EncodeHeader()
247 for (i = 0; i < hAdts->num_raw_blocks; i++) { in adtsWrite_EncodeHeader()
258 void adtsWrite_EndRawDataBlock(HANDLE_ADTS hAdts, HANDLE_FDK_BITSTREAM hBs, in adtsWrite_EndRawDataBlock() argument
260 if (!hAdts->protection_absent) { in adtsWrite_EndRawDataBlock()
267 if (hAdts->num_raw_blocks == 0) { in adtsWrite_EndRawDataBlock()
268 FDKwriteBits(&bsWriter, FDKcrcGetCRC(&hAdts->crcInfo), 16); in adtsWrite_EndRawDataBlock()
273 FDKwriteBits(hBs, FDKcrcGetCRC(&hAdts->crcInfo), 16); in adtsWrite_EndRawDataBlock()
276 if (hAdts->currentBlock < hAdts->num_raw_blocks) { in adtsWrite_EndRawDataBlock()
277 FDKpushFor(&bsWriter, hAdts->currentBlock * 16); in adtsWrite_EndRawDataBlock()
279 FDKgetValidBits(hBs) - (56 + (hAdts->num_raw_blocks) * 16 + 16); in adtsWrite_EndRawDataBlock()
287 if (hAdts->num_raw_blocks > 0 && in adtsWrite_EndRawDataBlock()
288 hAdts->currentBlock == hAdts->num_raw_blocks) { in adtsWrite_EndRawDataBlock()
295 if (!hAdts->protection_absent) { in adtsWrite_EndRawDataBlock()
296 FDKcrcReset(&hAdts->crcInfo); in adtsWrite_EndRawDataBlock()
297 crcIndex = FDKcrcStartReg(&hAdts->crcInfo, &bsWriter, 0); in adtsWrite_EndRawDataBlock()
304 if (!hAdts->protection_absent) { in adtsWrite_EndRawDataBlock()
305 FDKpushFor(&bsWriter, 11 + 2 + (hAdts->num_raw_blocks) * 16); in adtsWrite_EndRawDataBlock()
306 FDKcrcEndReg(&hAdts->crcInfo, &bsWriter, crcIndex); in adtsWrite_EndRawDataBlock()
307 FDKwriteBits(&bsWriter, FDKcrcGetCRC(&hAdts->crcInfo), 16); in adtsWrite_EndRawDataBlock()
313 *pBits -= hAdts->subFrameStartBit; in adtsWrite_EndRawDataBlock()
314 if (!hAdts->protection_absent && hAdts->num_raw_blocks > 0) { in adtsWrite_EndRawDataBlock()
318 hAdts->currentBlock++; in adtsWrite_EndRawDataBlock()