📄 flex_mux.c
字号:
/**********************************************************************MPEG-4 Audio VMBit stream moduleThis software module was originally developed byBodo Teichmann (Fraunhofer Institute of Integrated Circuits tmn@iis.fhg.de)and edited byin the course of development of the MPEG-2 NBC/MPEG-4 Audio standardISO/IEC 13818-7, 14496-1,2 and 3. This software module is animplementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio toolsas specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC givesusers of the MPEG-2 NBC/MPEG-4 Audio standards free license to thissoftware module or modifications thereof for use in hardware orsoftware products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audiostandards. Those intending to use this software module in hardware orsoftware products are advised that this use may infringe existingpatents. The original developer of this software module and his/hercompany, the subsequent editors and their companies, and ISO/IEC haveno liability for use of this software module or modifications thereofin an implementation. Copyright is not released for non MPEG-2NBC/MPEG-4 Audio conforming products. The original developer retainsfull right to use the code for his/her own purpose, assign or donatethe code to a third party and to inhibit third party from using thecode for non MPEG-2 NBC/MPEG-4 Audio conforming products. Thiscopyright notice must be included in all copies or derivative works.Copyright (c) 1998.Source file: flex_mux.c$Id: flex_mux.c,v 1.12 1999/08/09 16:18:44 purnhage Exp $Required modules:common.o common modulebitstream.o bitstream handling moduleBT Bodo Teichmann, FhG/IIS <tmn@iis.fhg.de>**********************************************************************/#include <string.h>#include <stdio.h>#include "buffersHandle.h" /* handler, defines, enums */#include "bitstreamStruct.h" /* structs */#include "obj_descr.h" /* structs */#include "lpc_common.h" /* structs */#include "bitstream.h"#include "common_m4a.h"#include "flex_mux.h"static BsBitBuffer *tmpBuf;void initObjDescr( OBJECT_DESCRIPTOR *od){ od->ODLength.length=32; od->ODescrId.length=10; od->streamCount.length=5; od->extensionFlag.length=1; tmpBuf =BsAllocBuffer(256*8); }void presetObjDescr( OBJECT_DESCRIPTOR *od, int numLayers){ od->ODLength.value=0; od->ODescrId.value=1; od->streamCount.value=numLayers; od->extensionFlag.value=0; }static void initTFspecConf ( TF_SPECIFIC_CONFIG *tfConf ){ tfConf->TFCodingType.length=2 ; tfConf->frameLength.length=1 ; tfConf->dependsOnCoreCoder.length=1 ; tfConf->dependsOnCoreCoder.value=0 ; tfConf->coreCoderDelay.length=14 ; tfConf->coreCoderDelay.value=0 ; tfConf->extension.length=1 ; tfConf->extension.value=0 ; return;}void initCelpSpecConf (CELP_SPECIFIC_CONFIG *celpConf){ celpConf->excitationMode.length = 1; celpConf->sampleRateMode.length = 1; celpConf->fineRateControl.length = 1; /* RPE mode */ celpConf->RPE_Configuration.length = 3; /* MPE mode */ celpConf->MPE_Configuration.length = 5; celpConf->numEnhLayers.length = 2; celpConf->bandwidthScalabilityMode.length = 1;/* celpConf->BWS_Configuration.length = 2; */}/* AI 990616 */static void initHvxcSpecConf (HVXC_SPECIFIC_CONFIG *hvxcConf){ hvxcConf->HVXCvarMode.length = 1; hvxcConf->HVXCrateMode.length = 2; hvxcConf->extensionFlag.length = 1; return;}void initESDescr( ES_DESCRIPTOR **es){ *es = NULL; *es = (ES_DESCRIPTOR*) malloc(sizeof(ES_DESCRIPTOR)); if (*es==NULL) CommonExit(-1,"no mem"); memset (*es, 0, sizeof (ES_DESCRIPTOR)) ; (*es)->ESNumber.length=5; (*es)->streamDependence.length=1; (*es)->URLFlag.length=1; (*es)->extensFlag.length=1; (*es)->dependsOn_Es_number.length=5; (*es)->DecConfigDescr.profileAndLevelIndication.length=8 ; (*es)->DecConfigDescr.streamType.length=6 ; (*es)->DecConfigDescr.upsteam.length=1 ; (*es)->DecConfigDescr.specificInfoFlag.length=1 ; (*es)->DecConfigDescr.bufferSizeDB.length=24 ; (*es)->DecConfigDescr.maxBitrate.length=32 ; (*es)->DecConfigDescr.avgBitrate.length=32 ; (*es)->DecConfigDescr.specificInfoLength.length=8 ; (*es)->DecConfigDescr.audioSpecificConfig.audioDecoderType.length=3 ; (*es)->DecConfigDescr.audioSpecificConfig.samplingFreqencyIndex.length= 4; (*es)->DecConfigDescr.audioSpecificConfig.channelConfiguration.length=4 ; (*es)->ALConfigDescriptor.useAccessUnitStartFlag.length = 1; (*es)->ALConfigDescriptor.useAccessUnitEndFlag.length = 1; (*es)->ALConfigDescriptor.useRandomAccessPointFlag.length = 1; (*es)->ALConfigDescriptor.usePaddingFlag.length = 1; (*es)->ALConfigDescriptor.seqNumLength.length = 4;}void presetESDescr( ES_DESCRIPTOR *es,int layer){ es->ESNumber.value=layer+1; /* if this is the first layer, there is no dependence */ es->streamDependence.value=((layer==0)?0:1); es->URLFlag.value=0; es->extensFlag.value=0; es->dependsOn_Es_number.value=(layer>0)?layer:0; es->DecConfigDescr.profileAndLevelIndication.value=0; es->DecConfigDescr.streamType.value=6 ; /* audio stream */ es->DecConfigDescr.upsteam.value=0; es->DecConfigDescr.specificInfoFlag.value=1 ; es->DecConfigDescr.bufferSizeDB.value=6144; es->DecConfigDescr.maxBitrate.value=0; es->DecConfigDescr.avgBitrate.value=0; es->DecConfigDescr.specificInfoLength.value=2; /* 16 bits if TFcoding */ /* es->DecConfigDescr.audioSpecificConfig.samplingFreqencyIndex.value= 0x6;*/ /*24 kHz */ /* cause this is patched afterward */ es->DecConfigDescr.audioSpecificConfig.channelConfiguration.value=1 ;}static void BsRWBitWrapper(BsBitStream *stream, /* in: bit stream */ unsigned long *data, /* out: bits read/write */ int numBit, /* in: num bits to read */ int WriteFlag){ if (WriteFlag){ BsPutBit(stream,*data,numBit); } else { BsGetBit(stream,data,numBit); }}static void advanceTFspecConf ( BsBitStream* bitStream,TF_SPECIFIC_CONFIG *tfConf,int WriteFlag) { BsRWBitWrapper(bitStream, &(tfConf->TFCodingType.value), tfConf->TFCodingType.length,WriteFlag); BsRWBitWrapper(bitStream, &(tfConf->frameLength.value), tfConf->frameLength.length,WriteFlag); BsRWBitWrapper(bitStream, &(tfConf->dependsOnCoreCoder.value), tfConf->dependsOnCoreCoder.length,WriteFlag); if (tfConf->dependsOnCoreCoder.value != 0) { BsRWBitWrapper(bitStream, &(tfConf->coreCoderDelay.value), tfConf->coreCoderDelay.length,WriteFlag); } BsRWBitWrapper(bitStream, &(tfConf->extension.value), tfConf->extension.length,WriteFlag); }void advanceCelpSpecConf ( BsBitStream* bitStream,CELP_SPECIFIC_CONFIG *celpConf,int WriteFlag) { BsRWBitWrapper(bitStream, &(celpConf->excitationMode.value), celpConf->excitationMode.length,WriteFlag); BsRWBitWrapper(bitStream, &(celpConf->sampleRateMode.value), celpConf->sampleRateMode.length,WriteFlag); BsRWBitWrapper(bitStream, &(celpConf->fineRateControl.value), celpConf->fineRateControl.length,WriteFlag); if (celpConf->excitationMode.value == RegularPulseExc) { BsRWBitWrapper(bitStream, &(celpConf->RPE_Configuration.value), celpConf->RPE_Configuration.length,WriteFlag); } if (celpConf->excitationMode.value == MultiPulseExc) { BsRWBitWrapper(bitStream, &(celpConf->MPE_Configuration.value), celpConf->MPE_Configuration.length,WriteFlag); BsRWBitWrapper(bitStream, &(celpConf->numEnhLayers.value), celpConf->numEnhLayers.length,WriteFlag); BsRWBitWrapper(bitStream, &(celpConf->bandwidthScalabilityMode.value), celpConf->bandwidthScalabilityMode.length,WriteFlag); }}/* AI 990616 */static void advanceHvxcSpecConf(BsBitStream* bitStream,HVXC_SPECIFIC_CONFIG *hvxcConf,int WriteFlag) { BsRWBitWrapper(bitStream, &(hvxcConf->HVXCvarMode.value), hvxcConf->HVXCvarMode.length,WriteFlag); BsRWBitWrapper(bitStream, &(hvxcConf->HVXCrateMode.value), hvxcConf->HVXCrateMode.length,WriteFlag); BsRWBitWrapper(bitStream, &(hvxcConf->extensionFlag.value), hvxcConf->extensionFlag.length,WriteFlag); return;}void advanceESDescr ( BsBitStream* bitStream, ES_DESCRIPTOR *es, int WriteFlag) { BsRWBitWrapper(bitStream,&(es->ESNumber.value),es->ESNumber.length,WriteFlag); BsRWBitWrapper(bitStream, &(es->streamDependence.value),es->streamDependence.length,WriteFlag);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -