Lines Matching refs:pC
53 M4VSS3GPP_intAudioMixingOpen( M4VSS3GPP_InternalAudioMixingContext *pC,
56 M4VSS3GPP_InternalAudioMixingContext *pC );
58 M4VSS3GPP_InternalAudioMixingContext *pC );
60 M4VSS3GPP_InternalAudioMixingContext *pC );
62 M4VSS3GPP_InternalAudioMixingContext *pC );
64 M4VSS3GPP_InternalAudioMixingContext *pC );
66 M4VSS3GPP_InternalAudioMixingContext *pC );
68 M4VSS3GPP_InternalAudioMixingContext *pC );
70 M4VSS3GPP_InternalAudioMixingContext *pC );
72 M4VSS3GPP_InternalAudioMixingContext *pC );
74 M4VSS3GPP_InternalAudioMixingContext *pC );
76 M4VSS3GPP_InternalAudioMixingContext *pC );
109 M4VSS3GPP_InternalAudioMixingContext *pC;
136 pC = (M4VSS3GPP_InternalAudioMixingContext
139 *pContext = pC;
141 if( M4OSA_NULL == pC )
150 memset((void *)pC ,0,
154 pC->iAddCts = pSettings->uiAddCts;
155 pC->bRemoveOriginal = pSettings->bRemoveOriginal;
156 pC->b_DuckingNeedeed = pSettings->b_DuckingNeedeed;
157 pC->InDucking_threshold = pSettings->InDucking_threshold;
158 pC->fBTVolLevel = pSettings->fBTVolLevel;
159 pC->fPTVolLevel = pSettings->fPTVolLevel;
160 pC->InDucking_lowVolume = pSettings->InDucking_lowVolume;
161 pC->bDoDucking = M4OSA_FALSE;
162 pC->bLoop = pSettings->bLoop;
163 pC->bNoLooping = M4OSA_FALSE;
164 pC->bjumpflag = M4OSA_TRUE;
168 pC->pInputClipCtxt = M4OSA_NULL;
169 pC->pAddedClipCtxt = M4OSA_NULL;
170 pC->fOrigFactor = 1.0F;
171 pC->fAddedFactor = 0.0F;
172 pC->bSupportSilence = M4OSA_FALSE;
173 pC->bHasAudio = M4OSA_FALSE;
174 pC->bAudioMixingIsNeeded = M4OSA_FALSE;
176 /* Init PC->ewc members */
178 pC->ewc.VideoStreamType = M4SYS_kVideoUnknown;
179 pC->ewc.bVideoDataPartitioning = M4OSA_FALSE;
180 pC->ewc.pVideoOutputDsi = M4OSA_NULL;
181 pC->ewc.AudioStreamType = M4SYS_kAudioUnknown;
182 pC->ewc.uiNbChannels = 1;
183 pC->ewc.pAudioOutputDsi = M4OSA_NULL;
184 pC->ewc.pAudioEncCtxt = M4OSA_NULL;
185 pC->ewc.pAudioEncDSI.pInfo = M4OSA_NULL;
186 pC->ewc.pSilenceFrameData = M4OSA_NULL;
187 pC->ewc.pEncContext = M4OSA_NULL;
188 pC->ewc.pDummyAuBuffer = M4OSA_NULL;
189 pC->ewc.p3gpWriterContext = M4OSA_NULL;
190 pC->pLVAudioResampler = M4OSA_NULL;
193 pC->pOsaFileReadPtr = pFileReadPtrFct;
194 pC->pOsaFileWritPtr = pFileWritePtrFct;
198 pC->b_SSRCneeded = M4OSA_FALSE;
199 pC->pSsrcBufferIn = M4OSA_NULL;
200 pC->pSsrcBufferOut = M4OSA_NULL;
201 pC->pTempBuffer = M4OSA_NULL;
202 pC->pPosInTempBuffer = M4OSA_NULL;
203 pC->pPosInSsrcBufferIn = M4OSA_NULL;
204 pC->pPosInSsrcBufferOut = M4OSA_NULL;
205 pC->SsrcScratch = M4OSA_NULL;
206 pC->uiBeginLoop = pSettings->uiBeginLoop;
207 pC->uiEndLoop = pSettings->uiEndLoop;
211 err = M4VSS3GPP_clearInterfaceTables(&pC->ShellAPI);
215 err = M4VSS3GPP_subscribeMediaAndCodec(&pC->ShellAPI);
220 err = M4VSS3GPP_intAudioMixingOpen(pC, pSettings);
225 if( M4OSA_NULL != pC->pInputClipCtxt->pVideoStream )
226 pC->State = M4VSS3GPP_kAudioMixingState_VIDEO;
228 pC->State = M4VSS3GPP_kAudioMixingState_AUDIO_FIRST_SEGMENT;
230 pC->ewc.iOutputDuration = (M4OSA_Int32)pC->pInputClipCtxt->pSettings->
233 pC->pLVAudioResampler = LVAudioResamplerCreate(16,
234 pC->pAddedClipCtxt->pSettings->ClipProperties.uiNbChannels,
236 if( M4OSA_NULL == pC->pLVAudioResampler )
240 LVAudiosetSampleRate(pC->pLVAudioResampler,
242 pC->pAddedClipCtxt->pSettings->ClipProperties.uiSamplingFrequency);
244 LVAudiosetVolume(pC->pLVAudioResampler,
272 M4VSS3GPP_InternalAudioMixingContext *pC =
285 switch( pC->State )
288 err = M4VSS3GPP_intAudioMixingStepVideo(pC);
297 *pProgress = (M4OSA_UInt8)(50 * (pC->ewc.WriterVideoAU.CTS)
298 / pC->pInputClipCtxt->pVideoStream->
304 if( M4SYS_kAudioUnknown == pC->ewc.WriterAudioStream.streamType )
316 if( pC->bHasAudio )
320 if( pC->iAddCts > 0 )
321 pC->State =
324 pC->State =
331 pC->State = M4VSS3GPP_kAudioMixingState_FINISHED;
352 if( pC->pAddedClipCtxt->iAudioFrameCts
353 != -pC->pAddedClipCtxt->iSilenceFrameDuration
354 && (pC->pAddedClipCtxt->iAudioFrameCts - 0.5)
355 / pC->pAddedClipCtxt->scale_audio > pC->uiEndLoop
356 && pC->uiEndLoop > 0 )
358 if(pC->bLoop == M4OSA_FALSE)
360 pC->bNoLooping = M4OSA_TRUE;
364 M4OSA_Int32 jumpCTS = (M4OSA_Int32)(pC->uiBeginLoop);
366 err = pC->pAddedClipCtxt->ShellAPI.m_pReader->m_pFctJump(
367 pC->pAddedClipCtxt->pReaderContext,
368 (M4_StreamHandler *)pC->pAddedClipCtxt->
380 pC->pAddedClipCtxt->iAoffset =
381 (M4OSA_Int32)(pC->ewc.dATo * pC->ewc.scale_audio + 0.5);
386 if( M4OSA_FALSE == pC->bRemoveOriginal )
388 err = M4VSS3GPP_intAudioMixingStepAudioMix(pC);
392 err = M4VSS3GPP_intAudioMixingStepAudioReplace(pC);
399 if( 0 != pC->ewc.iOutputDuration )
406 + (50 * pC->ewc.dATo - pC->pInputClipCtxt->iVoffset)
407 / (pC->ewc.iOutputDuration)); /**< 50 for 100/2 **/
424 pC->State = M4VSS3GPP_kAudioMixingState_FINISHED;
453 pC->State);
470 M4VSS3GPP_InternalAudioMixingContext *pC =
495 if( M4OSA_NULL != pC->pInputClipCtxt )
497 M4VSS3GPP_intClipCleanUp(pC->pInputClipCtxt);
498 pC->pInputClipCtxt = M4OSA_NULL;
503 if( M4OSA_NULL != pC->pAddedClipCtxt )
505 M4VSS3GPP_intClipCleanUp(pC->pAddedClipCtxt);
506 pC->pAddedClipCtxt = M4OSA_NULL;
512 if( M4OSA_NULL != pC->ewc.p3gpWriterContext )
515 lastCTS = pC->ewc.iOutputDuration;
517 err = pC->ShellAPI.pWriterGlobalFcts->pFctSetOption(
518 pC->ewc.p3gpWriterContext,
528 err = pC->ShellAPI.pWriterGlobalFcts->pFctCloseWrite(
529 pC->ewc.p3gpWriterContext);
538 pC->ewc.p3gpWriterContext = M4OSA_NULL;
543 if( M4OSA_NULL != pC->ewc.pAudioEncCtxt )
545 err = pC->ShellAPI.pAudioEncoderGlobalFcts->pFctClose(
546 pC->ewc.pAudioEncCtxt);
556 err = pC->ShellAPI.pAudioEncoderGlobalFcts->pFctCleanUp(
557 pC->ewc.pAudioEncCtxt);
567 pC->ewc.pAudioEncCtxt = M4OSA_NULL;
573 if( M4OSA_NULL != pC->SsrcScratch )
575 free(pC->SsrcScratch);
576 pC->SsrcScratch = M4OSA_NULL;
579 if( M4OSA_NULL != pC->pSsrcBufferIn )
581 free(pC->pSsrcBufferIn);
582 pC->pSsrcBufferIn = M4OSA_NULL;
585 if( M4OSA_NULL != pC->pSsrcBufferOut
586 && (M4OSA_TRUE == pC->b_SSRCneeded || pC->ChannelConversion > 0) )
588 free(pC->pSsrcBufferOut);
589 pC->pSsrcBufferOut = M4OSA_NULL;
592 if( M4OSA_NULL != pC->pTempBuffer )
594 free(pC->pTempBuffer);
595 pC->pTempBuffer = M4OSA_NULL;
598 if (pC->pLVAudioResampler != M4OSA_NULL)
600 LVDestroy(pC->pLVAudioResampler);
601 pC->pLVAudioResampler = M4OSA_NULL;
606 M4VSS3GPP_unRegisterAllWriters(&pC->ShellAPI);
607 M4VSS3GPP_unRegisterAllEncoders(&pC->ShellAPI);
608 M4VSS3GPP_unRegisterAllReaders(&pC->ShellAPI);
609 M4VSS3GPP_unRegisterAllDecoders(&pC->ShellAPI);
641 M4VSS3GPP_intAudioMixingOpen( M4VSS3GPP_InternalAudioMixingContext *pC,
650 pC, pSettings);
664 pC->bRemoveOriginal = M4OSA_TRUE;
669 pC->InputClipSettings.pFile =
671 pC->InputClipSettings.FileType = M4VIDEOEDITING_kFileType_3GPP;
672 pC->InputClipSettings.uiBeginCutTime =
674 pC->InputClipSettings.uiEndCutTime =
679 err = M4VSS3GPP_intClipInit(&pC->pInputClipCtxt, pC->pOsaFileReadPtr);
689 err = M4VSS3GPP_intClipOpen(pC->pInputClipCtxt, &pC->InputClipSettings,
700 if( M4OSA_NULL == pC->pInputClipCtxt->pAudioStream )
702 pC->bRemoveOriginal = M4OSA_TRUE;
706 if( M4OSA_NULL == pC->pInputClipCtxt->pVideoStream )
716 err = M4VSS3GPP_intBuildAnalysis(pC->pInputClipCtxt,
717 &pC->pInputClipCtxt->pSettings->ClipProperties);
729 pC->AddedClipSettings.pFile =
731 pC->AddedClipSettings.FileType = pSettings->AddedAudioFileType;
732 pC->AddedClipSettings.uiBeginCutTime =
734 pC->AddedClipSettings.uiEndCutTime = 0;/**< No notion of cut for the audio mixing feature */
735 pC->AddedClipSettings.ClipProperties.uiNbChannels=
737 pC->AddedClipSettings.ClipProperties.uiSamplingFrequency= pSettings->uiSamplingFrequency;
739 if( M4OSA_NULL != pC->AddedClipSettings.pFile )
743 err = M4VSS3GPP_intClipInit(&pC->pAddedClipCtxt, pC->pOsaFileReadPtr);
753 err = M4VSS3GPP_intClipOpen(pC->pAddedClipCtxt, &pC->AddedClipSettings,
766 if( M4OSA_NULL == pC->pAddedClipCtxt->pAudioStream )
776 err = M4VSS3GPP_intBuildAnalysis(pC->pAddedClipCtxt,
777 &pC->pAddedClipCtxt->pSettings->ClipProperties);
823 if( pC->bRemoveOriginal == M4OSA_TRUE
824 && (pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType
825 == M4VIDEOEDITING_kMP3 || pC->pAddedClipCtxt->pSettings->
827 || pC->pAddedClipCtxt->pSettings->
830 || pC->pAddedClipCtxt->pSettings->
832 || pC->pAddedClipCtxt->pSettings->
841 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize = 320;
845 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize =
849 pC->pInputClipCtxt->pSettings->ClipProperties.uiSamplingFrequency =
852 if( outputASF != pC->pAddedClipCtxt->pSettings->
857 pC->b_SSRCneeded = M4OSA_TRUE;
861 < pC->pAddedClipCtxt->pSettings->ClipProperties.uiNbChannels )
864 pC->ChannelConversion = 1;
867 > pC->pAddedClipCtxt->pSettings->ClipProperties.uiNbChannels )
870 pC->ChannelConversion = 2;
873 pC->pInputClipCtxt->pSettings->ClipProperties.uiNbChannels =
879 err = M4VSS3GPP_intAudioMixingCompatibility(pC,
880 &pC->pInputClipCtxt->pSettings->ClipProperties,
881 &pC->pAddedClipCtxt->pSettings->ClipProperties);
894 if( pC->uiBeginLoop > pC->pAddedClipCtxt->pSettings->
905 pC->bHasAudio = M4OSA_TRUE;
910 pC->AddedClipSettings.FileType = M4VIDEOEDITING_kFileType_Unsupported;
911 pC->bRemoveOriginal = M4OSA_TRUE;
912 pC->bHasAudio = M4OSA_FALSE;
917 pC->ewc.uiVideoBitrate =
918 pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoBitrate;
919 pC->ewc.uiVideoWidth =
920 pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoWidth;
921 pC->ewc.uiVideoHeight =
922 pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoHeight;
923 pC->ewc.uiVideoTimeScale =
924 pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoTimeScale;
925 pC->ewc.bVideoDataPartitioning =
926 pC->pInputClipCtxt->pSettings->ClipProperties.bMPEG4dataPartition;
927 pC->ewc.outputVideoProfile =
928 pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoProfile;
929 pC->ewc.outputVideoLevel =
930 pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoLevel;
931 switch( pC->pInputClipCtxt->pSettings->ClipProperties.VideoStreamType )
934 pC->ewc.VideoStreamType = M4SYS_kH263;
938 pC->ewc.VideoStreamType = M4SYS_kMPEG_4;
942 pC->ewc.VideoStreamType = M4SYS_kH264;
946 pC->ewc.VideoStreamType = M4SYS_kVideoUnknown;
951 if( M4SYS_kH264 == pC->ewc.VideoStreamType )
959 if( M4OSA_NULL == pC->ewc.pEncContext )
962 "M4VSS3GPP_intAudioMixingOpen: pC->ewc.pEncContext is NULL");
963 err = M4VSS3GPP_intAudioMixingCreateVideoEncoder(pC);
974 if( M4OSA_NULL != pC->ewc.pEncContext )
976 err = pC->ShellAPI.pVideoEncoderGlobalFcts->pFctGetOption(
977 pC->ewc.pEncContext, M4ENCODER_kOptionID_EncoderHeader,
996 pC->ewc.pVideoOutputDsi =
998 (M4OSA_Char *)"pC->ewc.pVideoOutputDsi (H264)");
1000 if( M4OSA_NULL == pC->ewc.pVideoOutputDsi )
1007 pC->ewc.uiVideoOutputDsiSize = (M4OSA_UInt16)encHeader->Size;
1008 memcpy((void *)pC->ewc.pVideoOutputDsi, (void *)encHeader->pBuf,
1012 err = M4VSS3GPP_intAudioMixingDestroyVideoEncoder(pC);
1025 "M4VSS3GPP_intAudioMixingOpen: pC->ewc.pEncContext is NULL, cannot get the DSI");
1032 pC->ewc.VideoStreamType);
1033 pC->ewc.uiVideoOutputDsiSize =
1034 (M4OSA_UInt16)pC->pInputClipCtxt->pVideoStream->
1036 pC->ewc.pVideoOutputDsi = (M4OSA_MemAddr8)pC->pInputClipCtxt->pVideoStream->
1042 if( pC->bHasAudio )
1044 if( pC->bRemoveOriginal == M4OSA_TRUE )
1046 pC->ewc.uiNbChannels =
1047 pC->pAddedClipCtxt->pSettings->ClipProperties.uiNbChannels;
1048 pC->ewc.uiAudioBitrate =
1049 pC->pAddedClipCtxt->pSettings->ClipProperties.uiAudioBitrate;
1050 pC->ewc.uiSamplingFrequency = pC->pAddedClipCtxt->pSettings->
1052 pC->ewc.uiSilencePcmSize =
1053 pC->pAddedClipCtxt->pSettings->ClipProperties.uiDecodedPcmSize;
1054 pC->ewc.scale_audio = pC->ewc.uiSamplingFrequency / 1000.0;
1058 if( pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType
1060 || pC->pAddedClipCtxt->pSettings->
1062 || pC->pAddedClipCtxt->pSettings->
1065 || pC->pAddedClipCtxt->pSettings->
1069 if( pC->pAddedClipCtxt->pAudioStream->
1074 free(pC->pAddedClipCtxt->pAudioStream->\
1077 pC->pAddedClipCtxt->pAudioStream->
1079 pC->pAddedClipCtxt->pAudioStream->
1083 pC->ewc.uiNbChannels =
1084 pC->pInputClipCtxt->pSettings->ClipProperties.uiNbChannels;
1085 pC->ewc.uiSamplingFrequency = pC->pInputClipCtxt->pSettings->
1087 pC->ewc.scale_audio = pC->ewc.uiSamplingFrequency / 1000.0;
1091 pC->ewc.AudioStreamType = M4SYS_kAMR;
1092 pC->ewc.pSilenceFrameData =
1094 pC->ewc.uiSilenceFrameSize =
1096 pC->ewc.iSilenceFrameDuration =
1098 pC->ewc.uiAudioBitrate = 12200;
1099 pC->ewc.uiSamplingFrequency = 8000;
1100 pC->ewc.uiSilencePcmSize = 320;
1101 pC->ewc.scale_audio = pC->ewc.uiSamplingFrequency / 1000.0;
1105 pC->ewc.AudioStreamType = M4SYS_kAAC;
1110 switch( pC->ewc.uiSamplingFrequency )
1113 pC->ewc.uiAudioBitrate =
1119 pC->ewc.uiAudioBitrate =
1124 pC->ewc.uiAudioBitrate =
1130 pC->ewc.uiAudioBitrate =
1135 pC->ewc.uiAudioBitrate =
1140 if( pC->ewc.uiNbChannels == 2 )
1143 pC->ewc.uiAudioBitrate += pC->ewc.uiAudioBitrate;
1148 pC->ewc.uiAudioBitrate = pSettings->outputAudioBitrate;
1151 if( pC->ewc.uiNbChannels == 1 )
1153 pC->ewc.pSilenceFrameData =
1155 pC->ewc.uiSilenceFrameSize =
1160 pC->ewc.pSilenceFrameData =
1162 pC->ewc.uiSilenceFrameSize =
1165 pC->ewc.iSilenceFrameDuration =
1171 switch( pC->pAddedClipCtxt->pSettings->
1175 pC->ewc.AudioStreamType = M4SYS_kAMR;
1176 pC->ewc.pSilenceFrameData =
1178 pC->ewc.uiSilenceFrameSize =
1180 pC->ewc.iSilenceFrameDuration =
1187 pC->ewc.AudioStreamType = M4SYS_kAAC;
1189 if( pC->ewc.uiNbChannels == 1 )
1191 pC->ewc.pSilenceFrameData =
1193 pC->ewc.uiSilenceFrameSize =
1198 pC->ewc.pSilenceFrameData =
1200 pC->ewc.uiSilenceFrameSize =
1203 pC->ewc.iSilenceFrameDuration =
1208 pC->ewc.AudioStreamType = M4SYS_kEVRC;
1209 pC->ewc.pSilenceFrameData = M4OSA_NULL;
1210 pC->ewc.uiSilenceFrameSize = 0;
1211 pC->ewc.iSilenceFrameDuration = 160; /* EVRC frames are 20 ms at 8000 Hz
1217 pC->pAddedClipCtxt->pAudioStream->
1219 pC->pAddedClipCtxt->pAudioStream->
1223 if( pC->pAddedClipCtxt->pSettings->
1226 pC->ewc.AudioStreamType = M4SYS_kAMR;
1227 pC->ewc.pSilenceFrameData = (M4OSA_UInt8
1229 pC->ewc.uiSilenceFrameSize =
1231 pC->ewc.iSilenceFrameDuration =
1233 pC->ewc.uiAudioBitrate = M4VIDEOEDITING_k12_2_KBPS;
1235 else if( pC->pAddedClipCtxt->pSettings->
1238 if( pC->ewc.uiNbChannels == 1 )
1240 pC->ewc.AudioStreamType = M4SYS_kAAC;
1241 pC->ewc.pSilenceFrameData = (M4OSA_UInt8
1243 pC->ewc.uiSilenceFrameSize =
1245 pC->ewc.iSilenceFrameDuration =
1247 pC->ewc.uiAudioBitrate =
1252 pC->ewc.AudioStreamType = M4SYS_kAAC;
1253 pC->ewc.pSilenceFrameData = (M4OSA_UInt8
1255 pC->ewc.uiSilenceFrameSize =
1257 pC->ewc.iSilenceFrameDuration =
1259 pC->ewc.uiAudioBitrate =
1265 pC->ewc.AudioStreamType = M4SYS_kAudioUnknown;
1270 pC->ewc.AudioStreamType = M4SYS_kAudioUnknown;
1276 pC->ewc.uiAudioOutputDsiSize =
1277 (M4OSA_UInt16)pC->pAddedClipCtxt->pAudioStream->
1279 pC->ewc.pAudioOutputDsi = (M4OSA_MemAddr8)pC->pAddedClipCtxt->pAudioStream->
1284 pC->ewc.uiNbChannels =
1285 pC
1286 pC->ewc.uiAudioBitrate =
1287 pC->pInputClipCtxt->pSettings->ClipProperties.uiAudioBitrate;
1288 pC->ewc.uiSamplingFrequency = pC->pInputClipCtxt->pSettings->
1290 pC->ewc.uiSilencePcmSize =
1291 pC->pInputClipCtxt->pSettings->ClipProperties.uiDecodedPcmSize;
1292 pC->ewc.scale_audio = pC->ewc.uiSamplingFrequency / 1000.0;
1294 switch( pC->pInputClipCtxt->pSettings->
1298 pC->ewc.AudioStreamType = M4SYS_kAMR;
1299 pC->ewc.pSilenceFrameData =
1301 pC->ewc.uiSilenceFrameSize =
1303 pC->ewc.iSilenceFrameDuration =
1310 pC->ewc.AudioStreamType = M4SYS_kAAC;
1312 if( pC->ewc.uiNbChannels == 1 )
1314 pC->ewc.pSilenceFrameData =
1316 pC->ewc.uiSilenceFrameSize =
1321 pC->ewc.pSilenceFrameData =
1323 pC->ewc.uiSilenceFrameSize =
1326 pC->ewc.iSilenceFrameDuration =
1331 pC->ewc.AudioStreamType = M4SYS_kAudioUnknown;
1339 pC->ewc.uiAudioOutputDsiSize =
1340 (M4OSA_UInt16)pC->pInputClipCtxt->pAudioStream->
1342 pC->ewc.pAudioOutputDsi = (M4OSA_MemAddr8)pC->pInputClipCtxt->pAudioStream->
1349 pC->pInputClipCtxt->uiSilencePcmSize = pC->ewc.uiSilencePcmSize;
1350 pC->pInputClipCtxt->pSilenceFrameData = pC->ewc.pSilenceFrameData;
1351 pC->pInputClipCtxt->uiSilenceFrameSize = pC->ewc.uiSilenceFrameSize;
1352 pC->pInputClipCtxt->iSilenceFrameDuration = pC->ewc.iSilenceFrameDuration;
1353 pC->pInputClipCtxt->scale_audio = pC->ewc.scale_audio;
1355 pC->pInputClipCtxt->iAudioFrameCts =
1356 -pC->pInputClipCtxt->iSilenceFrameDuration; /* Reset time */
1360 if( pC->bHasAudio )
1362 pC->pAddedClipCtxt->uiSilencePcmSize = pC->ewc.uiSilencePcmSize;
1363 pC->pAddedClipCtxt->pSilenceFrameData = pC->ewc.pSilenceFrameData;
1364 pC->pAddedClipCtxt->uiSilenceFrameSize = pC->ewc.uiSilenceFrameSize;
1365 pC->pAddedClipCtxt->iSilenceFrameDuration =
1366 pC->ewc.iSilenceFrameDuration;
1367 pC->pAddedClipCtxt->scale_audio = pC->ewc.scale_audio;
1369 pC->pAddedClipCtxt->iAudioFrameCts =
1370 -pC->pAddedClipCtxt->iSilenceFrameDuration; /* Reset time */
1375 if( ( M4OSA_NULL != pC->pInputClipCtxt->pVideoStream)
1376 && (pC->iAddCts > (M4OSA_Int32)pC->pInputClipCtxt->pVideoStream->
1387 if( M4OSA_FALSE == pC->pInputClipCtxt->pSettings->
1390 M4VSS3GPP_intClipDeleteAudioTrack(pC->pInputClipCtxt);
1395 if( ( ( pC->bHasAudio) && (M4OSA_FALSE
1396 == pC->pAddedClipCtxt->pSettings->ClipProperties.bAudioIsEditable))
1397 || (M4OSA_TRUE == pC->bRemoveOriginal) ) /*||
1400 pC->bAudioMixingIsNeeded = M4OSA_FALSE;
1404 pC->bAudioMixingIsNeeded = M4OSA_TRUE;
1410 if( pC->bHasAudio )
1412 pC->bSupportSilence = pC->pAddedClipCtxt->pSettings->
1415 if( M4OSA_FALSE == pC->bSupportSilence )
1417 if( pC->iAddCts > 0 )
1425 if( 0 < pC->uiEndLoop )
1434 if( pC->b_DuckingNeedeed == M4OSA_FALSE)
1438 pC->fAddedFactor = 0.50F;
1439 pC->fOrigFactor = 0.50F;
1445 if( M4OSA_TRUE == pC->b_SSRCneeded )
1464 switch( pC->pAddedClipCtxt->pSettings->
1507 pC->pAddedClipCtxt->pSettings->
1512 if( 1 == pC->pAddedClipCtxt->pSettings->ClipProperties.uiNbChannels )
1521 switch( pC->ewc.uiSamplingFrequency )
1555 pC->ewc.uiSamplingFrequency);
1645 pC->iSsrcNbSamplIn = (LVM_INT16)(
1648 pC->iSsrcNbSamplOut = (LVM_INT16)(ssrcParams.NrSamplesOut);
1651 pC->pAddedClipCtxt->pSettings->ClipProperties.uiSamplingFrequency
1652 * pC->pAddedClipCtxt->pSettings->ClipProperties.uiNbChannels;
1654 pC->pInputClipCtxt->pSettings->ClipProperties.uiSamplingFrequency
1655 * pC->pInputClipCtxt->pSettings->ClipProperties.uiNbChannels;
1667 (M4OSA_UInt32)(( pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize
1668 * ratioBuffer) / (pC->iSsrcNbSamplIn * sizeof(short)
1669 * pC->pAddedClipCtxt->pSettings->
1675 pC->minimumBufferIn = pC->iSsrcNbSamplIn * sizeof(short)
1676 * pC->pAddedClipCtxt->pSettings->
1682 pC->minimumBufferIn = ratio * (pC->iSsrcNbSamplIn * sizeof(short)
1683 * pC->pAddedClipCtxt->pSettings->
1689 pC->pSsrcBufferIn =
1690 (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->minimumBufferIn
1691 + pC->pAddedClipCtxt->
1696 if( M4OSA_NULL == pC->pSsrcBufferIn )
1703 pC->pPosInSsrcBufferIn = (M4OSA_MemAddr8)pC->pSsrcBufferIn;
1708 pC->pSsrcBufferOut =
1709 (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(3 * pC->iSsrcNbSamplOut * sizeof(short)
1710 * pC->ewc.uiNbChannels, M4VSS3GPP, (M4OSA_Char *)"pSsrcBufferOut");
1712 if( M4OSA_NULL == pC->pSsrcBufferOut )
1719 pC->pPosInSsrcBufferOut = pC->pSsrcBufferOut;
1723 if( pC->ChannelConversion > 0 )
1726 pC->pTempBuffer =
1727 (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(3 * pC->iSsrcNbSamplOut
1728 * sizeof(short) * pC->pAddedClipCtxt->pSettings->
1731 if( M4OSA_NULL == pC->pTempBuffer )
1738 pC->pPosInTempBuffer = pC->pTempBuffer;
1741 else if( pC->ChannelConversion > 0 )
1743 pC->minimumBufferIn =
1744 pC->pAddedClipCtxt->AudioDecBufferOut.m_bufferSize;
1748 pC->pSsrcBufferIn =
1749 (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->minimumBufferIn
1750 + pC->pAddedClipCtxt->
1755 if( M4OSA_NULL == pC->pSsrcBufferIn )
1762 pC->pPosInSsrcBufferIn = (M4OSA_MemAddr8)pC->pSsrcBufferIn;
1767 pC->pSsrcBufferOut = (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(
1768 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize,
1771 if( M4OSA_NULL == pC->pSsrcBufferOut )
1778 pC->pPosInSsrcBufferOut = pC->pSsrcBufferOut;
1780 else if( (pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType == M4VIDEOEDITING_kMP3)||
1781 (pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType == M4VIDEOEDITING_kPCM))
1787 pC->minimumBufferIn = 2048 * pC->ewc.uiNbChannels;
1788 minbuffer = pC->minimumBufferIn;
1792 pC->minimumBufferIn = 320;
1794 if( pC->pAddedClipCtxt->AudioDecBufferOut.m_bufferSize > 320 )
1796 minbuffer = pC->pAddedClipCtxt->AudioDecBufferOut.m_bufferSize;
1800 minbuffer = pC->minimumBufferIn; /* Not really possible ...*/
1811 pC->pSsrcBufferIn =
1815 if( M4OSA_NULL == pC->pSsrcBufferIn )
1822 pC->pPosInSsrcBufferIn = (M4OSA_MemAddr8)pC->pSsrcBufferIn;
1824 pC->pPosInSsrcBufferOut = pC->pPosInSsrcBufferIn;
1825 pC->pSsrcBufferOut = pC->pSsrcBufferIn;
1830 if( M4OSA_TRUE == pC->bAudioMixingIsNeeded || M4VIDEOEDITING_kPCM
1831 == pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType
1833 == pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType
1834 || pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType
1836 || pC->pAddedClipCtxt->pSettings->ClipProperties.uiSamplingFrequency
1838 || pC->pAddedClipCtxt->pSettings->ClipProperties.uiNbChannels
1843 err = M4VSS3GPP_intCreateAudioEncoder(&pC->ewc, &pC->ShellAPI,
1844 pC->ewc.uiAudioBitrate);
1855 if( pC->ewc.uiAudioOutputDsiSize == 0 && (M4VIDEOEDITING_kPCM
1856 == pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType
1857 || M4VIDEOEDITING_kMP3 == pC->pAddedClipCtxt->pSettings->
1859 || pC->pAddedClipCtxt->pSettings->
1862 || pC->pAddedClipCtxt->pSettings->
1864 || pC->pAddedClipCtxt->pSettings->
1868 pC->ewc.uiAudioOutputDsiSize =
1869 (M4OSA_UInt16)pC->ewc.pAudioEncDSI.infoSize;
1870 pC->ewc.pAudioOutputDsi = pC->ewc.pAudioEncDSI.pInfo;
1877 err = M4VSS3GPP_intCreate3GPPOutputFile(&pC->ewc, &pC->ShellAPI,
1878 pC->pOsaFileWritPtr, pSettings->pOutputClipFile,
1879 pC->pOsaFileReadPtr, pSettings->pTemporaryFile, 0);
1900 * @param pC (IN) VSS audio mixing internal context
1905 M4VSS3GPP_InternalAudioMixingContext *pC )
1909 err = pC->ShellAPI.pWriterDataFcts->pStartAU(pC->ewc.p3gpWriterContext,
1910 M4VSS3GPP_WRITER_AUDIO_STREAM_ID, &pC->ewc.WriterAudioAU);
1921 memcpy((void *)pC->ewc.WriterAudioAU.dataAddress,
1922 (void *)pC->ewc.pSilenceFrameData, pC->ewc.uiSilenceFrameSize);
1924 pC->ewc.WriterAudioAU.size = pC->ewc.uiSilenceFrameSize;
1925 pC->ewc.WriterAudioAU.CTS =
1926 (M4OSA_Time)(pC->ewc.dATo * pC->ewc.scale_audio + 0.5);
1929 (M4OSA_Int32)(pC->ewc.dATo), pC->ewc.WriterAudioAU.size);
1931 err = pC->ShellAPI.pWriterDataFcts->pProcessAU(pC->ewc.p3gpWriterContext,
1932 M4VSS3GPP_WRITER_AUDIO_STREAM_ID, &pC->ewc.WriterAudioAU);
1943 pC->ewc.dATo += pC->ewc.iSilenceFrameDuration / pC->ewc.scale_audio;
1950 * M4OSA_ERR M4VSS3GPP_intAudioMixingStepVideo(M4VSS3GPP_InternalAudioMixingContext *pC)
1953 * @param pC (IN) VSS audio mixing internal context
1958 M4VSS3GPP_InternalAudioMixingContext *pC )
1964 pC->ewc.dOutputVidCts, pC->State, pC->pInputClipCtxt->iVoffset);
1968 err = pC->pInputClipCtxt->ShellAPI.m_pReaderDataIt->m_pFctGetNextAu(
1969 pC->pInputClipCtxt->pReaderContext,
1970 (M4_StreamHandler *)pC->pInputClipCtxt->pVideoStream,
1971 &pC->pInputClipCtxt->VideoAU);
1982 pC->pInputClipCtxt->VideoAU.m_CTS, pC->pInputClipCtxt->iVoffset,
1983 pC->pInputClipCtxt->VideoAU.m_size);
1987 err = pC->ShellAPI.pWriterDataFcts->pStartAU(pC->ewc.p3gpWriterContext,
1988 M4VSS3GPP_WRITER_VIDEO_STREAM_ID, &pC->ewc.WriterVideoAU);
2000 if( pC->pInputClipCtxt->pVideoStream->m_basicProperties.m_streamType
2007 pC->pInputClipCtxt->VideoAU.m_size -= offset;
2010 if( pC->pInputClipCtxt->VideoAU.m_size > pC->ewc.uiVideoMaxAuSize )
2015 pC->pInputClipCtxt->VideoAU.m_size, pC->ewc.uiVideoMaxAuSize);
2021 memcpy((void *)pC->ewc.WriterVideoAU.dataAddress,
2022 (void *)(pC->pInputClipCtxt->VideoAU.m_dataAddress + offset),
2023 (pC->pInputClipCtxt->VideoAU.m_size));
2027 pC->ewc.WriterVideoAU.size = pC->pInputClipCtxt->VideoAU.m_size;
2028 pC->ewc.WriterVideoAU.CTS =
2029 (M4OSA_UInt32)(pC->pInputClipCtxt->VideoAU.m_CTS + 0.5);
2030 pC->ewc.WriterVideoAU.attribute = pC->pInputClipCtxt->VideoAU.m_attribute;
2035 pC->ewc.WriterVideoAU.CTS, pC->ewc.WriterVideoAU.size);
2037 err = pC->ShellAPI.pWriterDataFcts->pProcessAU(pC->ewc.p3gpWriterContext,
2038 M4VSS3GPP_WRITER_VIDEO_STREAM_ID, &pC->ewc.WriterVideoAU);
2056 * M4OSA_ERR M4VSS3GPP_intAudioMixingStepAudioMix(M4VSS3GPP_InternalAudioMixingContext *pC)
2059 * @param pC (IN) VSS audio mixing internal context
2064 M4VSS3GPP_InternalAudioMixingContext *pC )
2069 pC->ewc.dATo, pC->State, pC->pInputClipCtxt->iAoffset);
2071 switch( pC->State )
2076 err = M4VSS3GPP_intAudioMixingCopyOrig(pC);
2089 if( pC->ewc.dATo >= pC->iAddCts )
2093 pC->State = M4VSS3GPP_kAudioMixingState_AUDIO_SECOND_SEGMENT;
2096 err = M4VSS3GPP_intAudioMixingTransition(pC);
2108 pC->pAddedClipCtxt->iAoffset =
2109 (M4OSA_Int32)(pC->ewc.dATo * pC->ewc.scale_audio + 0.5);
2122 if( M4OSA_TRUE == pC->bAudioMixingIsNeeded ) /**< Mix */
2126 if( pC->ChannelConversion > 0 || pC->b_SSRCneeded == M4OSA_TRUE
2127 || pC->pAddedClipCtxt->pSettings->
2137 M4VSS3GPP_intClipReadNextAudioFrame(pC->pAddedClipCtxt);
2140 pC->pAddedClipCtxt->iAudioFrameCts
2141 / pC->pAddedClipCtxt->scale_audio,
2142 pC->pAddedClipCtxt->iAoffset
2143 / pC->pAddedClipCtxt->scale_audio,
2144 pC->pAddedClipCtxt->uiAudioFrameSize);
2150 if( pC->uiEndLoop > 0 )
2154 M4OSA_Int32 time = (M4OSA_Int32)(pC->uiBeginLoop);
2156 err = pC->pAddedClipCtxt->ShellAPI.m_pReader->
2158 pC->pAddedClipCtxt->pReaderContext,
2160 *)pC->pAddedClipCtxt->pAudioStream,
2175 err = M4VSS3GPP_intAudioMixingTransition(pC);
2189 pC->State =
2213 err = M4VSS3GPP_intClipReadNextAudioFrame(pC->pInputClipCtxt);
2216 pC->pInputClipCtxt->iAudioFrameCts
2217 / pC->pInputClipCtxt->scale_audio,
2218 pC->pInputClipCtxt->iAoffset
2219 / pC->pInputClipCtxt->scale_audio,
2220 pC->pInputClipCtxt->uiAudioFrameSize);
2231 if( pC->ChannelConversion == 0
2232 && pC->b_SSRCneeded == M4OSA_FALSE
2233 && pC->pAddedClipCtxt->pSettings->
2238 err = pC->ShellAPI.pWriterDataFcts->pStartAU(
2239 pC->ewc.p3gpWriterContext,
2241 &pC->ewc.WriterAudioAU);
2255 err = M4VSS3GPP_intAudioMixingDoMixing(pC);
2273 err = M4VSS3GPP_intAudioMixingCopyAdded(pC);
2279 if( pC->uiEndLoop > 0 )
2283 M4OSA_Int32 time = (M4OSA_Int32)(pC->uiBeginLoop);
2286 pC->pAddedClipCtxt->ShellAPI.m_pReader->m_pFctJump(
2287 pC->pAddedClipCtxt->pReaderContext,
2289 *)pC->pAddedClipCtxt->pAudioStream,
2304 err = M4VSS3GPP_intAudioMixingWriteSilence(pC);
2318 pC->pAddedClipCtxt->iAoffset =
2319 (M4OSA_Int32)(pC->ewc.dATo * pC->ewc.scale_audio
2330 err = M4VSS3GPP_intAudioMixingTransition(pC);
2343 pC->State =
2366 if( pC->ewc.dATo >= pC->ewc.iOutputDuration )
2379 err = M4VSS3GPP_intAudioMixingCopyOrig(pC);
2392 if( pC->ewc.dATo >= pC->ewc.iOutputDuration )
2414 * M4OSA_ERR M4VSS3GPP_intAudioMixingStepAudioReplace(M4VSS3GPP_InternalAudioMixingContext *pC)
2417 * @param pC (IN) VSS audio mixing internal context
2422 M4VSS3GPP_InternalAudioMixingContext *pC )
2427 pC->ewc.dATo, pC->State, pC->pInputClipCtxt->iAoffset);
2429 switch( pC->State )
2436 err = M4VSS3GPP_intAudioMixingWriteSilence(pC);
2449 if( pC->ewc.dATo >= pC->iAddCts )
2453 pC->State = M4VSS3GPP_kAudioMixingState_AUDIO_SECOND_SEGMENT;
2457 pC->pAddedClipCtxt->iAoffset =
2458 (M4OSA_Int32)(pC->ewc.dATo * pC->ewc.scale_audio + 0.5);
2470 err = M4VSS3GPP_intAudioMixingCopyAdded(pC);
2477 if( pC->uiEndLoop > 0 )
2481 M4OSA_Int32 time = (M4OSA_Int32)(pC->uiBeginLoop);
2483 err = pC->pAddedClipCtxt->ShellAPI.m_pReader->m_pFctJump(
2484 pC->pAddedClipCtxt->pReaderContext,
2486 *)pC->pAddedClipCtxt->pAudioStream, &time);
2500 err = M4VSS3GPP_intAudioMixingWriteSilence(pC);
2514 pC->pAddedClipCtxt->iAoffset =
2515 (M4OSA_Int32)(pC->ewc.dATo * pC->ewc.scale_audio + 0.5);
2523 else if( M4OSA_TRUE == pC->bSupportSilence )
2527 pC->State = M4VSS3GPP_kAudioMixingState_AUDIO_THIRD_SEGMENT;
2541 pC->State = M4VSS3GPP_kAudioMixingState_FINISHED;
2562 pC->ewc.dATo >= pC->ewc.iOutputDuration )
2577 err = M4VSS3GPP_intAudioMixingWriteSilence(pC);
2590 if( pC->ewc.dATo >= pC->ewc.iOutputDuration )
2612 * M4OSA_ERR M4VSS3GPP_intAudioMixingCopyOrig(M4VSS3GPP_InternalAudioMixingContext *pC)
2615 * @param pC (IN) VSS audio mixing internal context
2619 M4VSS3GPP_InternalAudioMixingContext *pC )
2625 err = M4VSS3GPP_intClipReadNextAudioFrame(pC->pInputClipCtxt);
2628 pC->pInputClipCtxt->iAudioFrameCts / pC->pInputClipCtxt->scale_audio,
2629 pC->pInputClipCtxt->iAoffset / pC->pInputClipCtxt->scale_audio,
2630 pC->pInputClipCtxt->uiAudioFrameSize);
2642 err = pC->ShellAPI.pWriterDataFcts->pStartAU(pC->ewc.p3gpWriterContext,
2643 M4VSS3GPP_WRITER_AUDIO_STREAM_ID, &pC->ewc.WriterAudioAU);
2655 pC->ewc.WriterAudioAU.size = pC->pInputClipCtxt->uiAudioFrameSize;
2656 pC->ewc.WriterAudioAU.CTS =
2657 pC->pInputClipCtxt->iAudioFrameCts + pC->pInputClipCtxt->iAoffset;
2661 memcpy((void *)pC->ewc.WriterAudioAU.dataAddress,
2662 (void *)pC->pInputClipCtxt->pAudioFramePtr, pC->ewc.WriterAudioAU.size);
2667 (M4OSA_Int32)(pC->ewc.WriterAudioAU.CTS / pC->ewc.scale_audio),
2668 pC->ewc.WriterAudioAU.size);
2670 err = pC->ShellAPI.pWriterDataFcts->pProcessAU(pC->ewc.p3gpWriterContext,
2671 M4VSS3GPP_WRITER_AUDIO_STREAM_ID, &pC->ewc.WriterAudioAU);
2683 pC->ewc.dATo += pC->ewc.iSilenceFrameDuration / pC->ewc.scale_audio;
2693 * M4OSA_ERR M4VSS3GPP_intAudioMixingCopyAdded(M4VSS3GPP_InternalAudioMixingContext *pC)
2696 * @param pC (IN) VSS audio mixing internal context
2700 M4VSS3GPP_InternalAudioMixingContext *pC )
2704 if(pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType == M4VIDEOEDITING_kMP3 ||
2705 pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType == M4VIDEOEDITING_kPCM ||
2706 pC->b_SSRCneeded == M4OSA_TRUE ||
2707 pC->ChannelConversion > 0)
2716 err = M4VSS3GPP_intAudioMixingConvert(pC);
2734 err = pC->ShellAPI.pWriterDataFcts->pStartAU(pC->ewc.p3gpWriterContext,
2735 M4VSS3GPP_WRITER_AUDIO_STREAM_ID, &pC->ewc.WriterAudioAU);
2747 pEncInBuffer.pTableBuffer[0] = pC->pSsrcBufferOut;
2749 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
2755 / pC->ewc.uiNbChannels;
2760 (M4OSA_MemAddr8)pC->ewc.WriterAudioAU.dataAddress;
2767 err = pC->ShellAPI.pAudioEncoderGlobalFcts->pFctStep(
2768 pC->ewc.pAudioEncCtxt, &pEncInBuffer, &pEncOutBuffer);
2781 pC->ewc.WriterAudioAU.size =
2784 pC->ewc.WriterAudioAU.CTS += frameTimeDelta;
2787 if( M4OSA_TRUE == pC->b_SSRCneeded || pC->ChannelConversion > 0 )
2789 tempPosBuffer = pC->pSsrcBufferOut
2790 + pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
2791 memmove((void *)pC->pSsrcBufferOut, (void *)tempPosBuffer,
2792 pC->pPosInSsrcBufferOut - tempPosBuffer);
2793 pC->pPosInSsrcBufferOut -=
2794 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
2798 tempPosBuffer = pC->pSsrcBufferIn + pC->minimumBufferIn;
2799 memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
2800 pC->pPosInSsrcBufferIn - tempPosBuffer);
2801 pC->pPosInSsrcBufferIn -= pC->minimumBufferIn;
2807 (M4OSA_Int32)(pC->ewc.WriterAudioAU.CTS / pC->ewc.scale_audio),
2808 pC->ewc.WriterAudioAU.size);
2811 pC->ShellAPI.pWriterDataFcts->pProcessAU(pC->ewc.p3gpWriterContext,
2812 M4VSS3GPP_WRITER_AUDIO_STREAM_ID, &pC->ewc.WriterAudioAU);
2825 pC->ewc.dATo += frameTimeDelta / pC->ewc.scale_audio;
2831 err = M4VSS3GPP_intClipReadNextAudioFrame(pC->pAddedClipCtxt);
2834 pC->pAddedClipCtxt->iAudioFrameCts
2835 / pC->pAddedClipCtxt->scale_audio,
2836 pC->pAddedClipCtxt->iAoffset / pC->pAddedClipCtxt->scale_audio,
2837 pC->pAddedClipCtxt->uiAudioFrameSize);
2849 err = pC->ShellAPI.pWriterDataFcts->pStartAU(pC->ewc.p3gpWriterContext,
2850 M4VSS3GPP_WRITER_AUDIO_STREAM_ID, &pC->ewc.WriterAudioAU);
2868 if( pC->pAddedClipCtxt->uiAudioFrameSize > pC->ewc.WriterAudioAU.size )
2872 pC->pAddedClipCtxt->uiAudioFrameSize,
2873 pC->ewc.WriterAudioAU.size);
2879 pC->ewc.WriterAudioAU.size = pC->pAddedClipCtxt->uiAudioFrameSize;
2880 pC->ewc.WriterAudioAU.CTS =
2881 pC->pAddedClipCtxt->iAudioFrameCts + pC->pAddedClipCtxt->iAoffset;
2885 memcpy((void *)pC->ewc.WriterAudioAU.dataAddress,
2886 (void *)pC->pAddedClipCtxt->pAudioFramePtr, pC->ewc.WriterAudioAU.size);
2891 (M4OSA_Int32)(pC->ewc.WriterAudioAU.CTS / pC->ewc.scale_audio),
2892 pC->ewc.WriterAudioAU.size);
2895 pC->ShellAPI.pWriterDataFcts->pProcessAU(pC->ewc.p3gpWriterContext,
2896 M4VSS3GPP_WRITER_AUDIO_STREAM_ID, &pC->ewc.WriterAudioAU);
2909 pC->ewc.dATo += pC->ewc.iSilenceFrameDuration / pC->ewc.scale_audio;
2920 * M4OSA_ERR M4VSS3GPP_intAudioMixingConvert(M4VSS3GPP_InternalAudioMixingContext *pC)
2923 * @param pC (IN) VSS audio mixing internal context
2928 M4VSS3GPP_InternalAudioMixingContext *pC )
2933 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize / sizeof(short)
2934 / pC->pInputClipCtxt->pSettings->ClipProperties.uiNbChannels;
2941 while( pC->pPosInSsrcBufferIn - pC->pSsrcBufferIn < (M4OSA_Int32)pC->minimumBufferIn )
2944 if (pC->bNoLooping == M4OSA_TRUE)
2950 err = M4VSS3GPP_intClipReadNextAudioFrame(pC->pAddedClipCtxt);
2952 if(pC->bjumpflag)
2956 M4OSA_Int32 time = (M4OSA_Int32)(pC->uiBeginLoop);
2959 pC->pAddedClipCtxt->ShellAPI.m_pReader->m_pFctJump\
2960 (pC->pAddedClipCtxt->pReaderContext,
2961 (M4_StreamHandler*)pC->pAddedClipCtxt->pAudioStream, &time);
2968 pC->bjumpflag = M4OSA_FALSE;
2971 pC->pAddedClipCtxt->iAudioFrameCts / pC->pAddedClipCtxt->scale_audio,
2972 pC->pAddedClipCtxt->iAoffset / pC->pAddedClipCtxt->scale_audio,
2973 pC->pAddedClipCtxt->uiAudioFrameSize);
2976 if(pC->bNoLooping == M4OSA_TRUE)
2978 pC->uiEndLoop =0; /* Value 0 means no looping is required */
2982 if( pC->uiEndLoop > 0 )
2986 M4OSA_Int32 time = (M4OSA_Int32)(pC->uiBeginLoop);
2988 err = pC->pAddedClipCtxt->ShellAPI.m_pReader->m_pFctJump(
2989 pC->pAddedClipCtxt->pReaderContext,
2990 (M4_StreamHandler *)pC->pAddedClipCtxt->
3005 err = M4VSS3GPP_intAudioMixingTransition(pC);
3017 pC->State = M4VSS3GPP_kAudioMixingState_AUDIO_THIRD_SEGMENT;
3035 err = M4VSS3GPP_intClipDecodeCurrentAudioFrame(pC->pAddedClipCtxt);
3047 memcpy((void *)pC->pPosInSsrcBufferIn,
3048 (void *)pC->pAddedClipCtxt->AudioDecBufferOut.m_dataAddress,
3049 pC->pAddedClipCtxt->AudioDecBufferOut.m_bufferSize);
3052 pC->pPosInSsrcBufferIn +=
3053 pC->pAddedClipCtxt->AudioDecBufferOut.m_bufferSize;
3057 if( pC->b_SSRCneeded == M4OSA_TRUE )
3059 pC->ChannelConversion = 0;
3060 if( pC->ChannelConversion > 0 )
3062 while( pC->pPosInTempBuffer - pC->pTempBuffer
3063 < (M4OSA_Int32)(pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize
3064 *pC->pAddedClipCtxt->pSettings->ClipProperties.uiNbChannels)
3065 / pC->ChannelConversion )
3069 memset((void *)pC->pPosInTempBuffer,0,
3070 (pC->iSsrcNbSamplOut * sizeof(short) * pC->ewc.uiNbChannels));
3072 LVAudioresample_LowQuality((short*)pC->pPosInTempBuffer,
3073 (short*)pC->pSsrcBufferIn,
3074 pC->iSsrcNbSamplOut,
3075 pC->pLVAudioResampler);
3084 pC->pPosInTempBuffer += pC->iSsrcNbSamplOut * sizeof(short)
3085 * pC->pAddedClipCtxt->pSettings->
3090 pC->pSsrcBufferIn + (pC->iSsrcNbSamplIn * sizeof(short)
3091 * pC->pAddedClipCtxt->pSettings->
3093 memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
3094 pC->pPosInSsrcBufferIn - tempPosBuffer);
3095 pC->pPosInSsrcBufferIn -= pC->iSsrcNbSamplIn * sizeof(short)
3096 * pC->pAddedClipCtxt->pSettings->
3102 while( pC->pPosInSsrcBufferOut - pC->pSsrcBufferOut
3103 < (M4OSA_Int32)pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize )
3106 memset((void *)pC->pPosInSsrcBufferOut,0,
3107 (pC->iSsrcNbSamplOut * sizeof(short) * pC->ewc.uiNbChannels));
3109 LVAudioresample_LowQuality((short*)pC->pPosInSsrcBufferOut,
3110 (short*)pC->pSsrcBufferIn,
3111 pC->iSsrcNbSamplOut,
3112 pC->pLVAudioResampler);
3120 pC->pPosInSsrcBufferOut +=
3121 pC->iSsrcNbSamplOut * sizeof(short) * pC->ewc.uiNbChannels;
3125 pC->pSsrcBufferIn + (pC->iSsrcNbSamplIn * sizeof(short)
3126 * pC->pAddedClipCtxt->pSettings->
3128 memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
3129 pC->pPosInSsrcBufferIn - tempPosBuffer);
3130 pC->pPosInSsrcBufferIn -= pC->iSsrcNbSamplIn * sizeof(short)
3131 * pC->pAddedClipCtxt->pSettings->
3137 switch( pC->ChannelConversion )
3143 if( pC->pPosInSsrcBufferOut - pC->pSsrcBufferOut
3144 < (M4OSA_Int32)pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize )
3146 From2iToMono_16((short *)pC->pTempBuffer,
3147 (short *)pC->pSsrcBufferOut,
3150 tempPosBuffer = pC->pTempBuffer
3152 * pC->pAddedClipCtxt->pSettings->
3155 memmove((void *)pC->pTempBuffer, (void *)tempPosBuffer,
3156 pC->pPosInTempBuffer - tempPosBuffer);
3157 pC->pPosInTempBuffer -=
3159 * pC->pAddedClipCtxt->pSettings->
3161 pC->pPosInSsrcBufferOut +=
3162 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
3167 if( pC->pPosInSsrcBufferOut - pC->pSsrcBufferOut
3168 < (M4OSA_Int32)pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize )
3170 MonoTo2I_16((short *)pC->pTempBuffer,
3171 (short *)pC->pSsrcBufferOut,
3173 tempPosBuffer = pC->pTempBuffer
3175 * pC->pAddedClipCtxt->pSettings->
3177 memmove((void *)pC->pTempBuffer, (void *)tempPosBuffer,
3178 pC->pPosInTempBuffer - tempPosBuffer);
3179 pC->pPosInTempBuffer -=
3181 * pC->pAddedClipCtxt->pSettings->
3183 pC->pPosInSsrcBufferOut +=
3184 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
3189 else if( pC->ChannelConversion > 0 )
3192 // pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize / sizeof(short) /
3193 // pC->pInputClipCtxt->pSettings->ClipProperties.uiNbChannels;
3195 switch( pC->ChannelConversion )
3201 if( pC->pPosInSsrcBufferOut - pC->pSsrcBufferOut
3202 < (M4OSA_Int32)pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize )
3204 From2iToMono_16((short *)pC->pSsrcBufferIn,
3205 (short *)pC->pSsrcBufferOut,
3208 tempPosBuffer = pC->pSsrcBufferIn
3210 * pC->pAddedClipCtxt->pSettings->
3213 memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
3214 pC->pPosInSsrcBufferIn - tempPosBuffer);
3215 pC->pPosInSsrcBufferIn -=
3217 * pC->pAddedClipCtxt->pSettings->
3219 pC->pPosInSsrcBufferOut +=
3220 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
3225 if( pC->pPosInSsrcBufferOut - pC->pSsrcBufferOut
3226 < (M4OSA_Int32)pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize )
3228 MonoTo2I_16((short *)pC->pSsrcBufferIn,
3229 (short *)pC->pSsrcBufferOut,
3231 tempPosBuffer = pC->pSsrcBufferIn
3233 * pC->pAddedClipCtxt->pSettings->
3235 memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
3236 pC->pPosInSsrcBufferIn - tempPosBuffer);
3237 pC->pPosInSsrcBufferIn -=
3239 * pC->pAddedClipCtxt->pSettings->
3241 pC->pPosInSsrcBufferOut +=
3242 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
3250 pC->pPosInSsrcBufferOut = pC->pPosInSsrcBufferIn;
3318 * M4OSA_ERR M4VSS3GPP_intAudioMixingDoMixing(M4VSS3GPP_InternalAudioMixingContext *pC)
3321 * @param pC (IN) VSS audio mixing internal context
3326 M4VSS3GPP_InternalAudioMixingContext *pC )
3348 err = M4VSS3GPP_intClipDecodeCurrentAudioFrame(pC->pInputClipCtxt);
3359 if( M4OSA_TRUE == pC->b_SSRCneeded || pC->ChannelConversion > 0
3360 || pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType
3363 err = M4VSS3GPP_intAudioMixingConvert(pC);
3380 err = pC->ShellAPI.pWriterDataFcts->pStartAU(pC->ewc.p3gpWriterContext,
3381 M4VSS3GPP_WRITER_AUDIO_STREAM_ID, &pC->ewc.WriterAudioAU);
3392 pPCMdata2 = (M4OSA_Int16 *)pC->pSsrcBufferOut;
3398 err = M4VSS3GPP_intClipDecodeCurrentAudioFrame(pC->pAddedClipCtxt);
3411 if( pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize
3412 != pC->pAddedClipCtxt->AudioDecBufferOut.m_bufferSize )
3419 pPCMdata2 = (M4OSA_Int16 *)pC->pAddedClipCtxt->AudioDecBufferOut.m_dataAddress;
3425 (M4OSA_Int16 *)pC->pInputClipCtxt->AudioDecBufferOut.m_dataAddress;
3426 uiPCMsize = pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize
3429 if( pC->b_DuckingNeedeed )
3435 pPCM16Sample = (M4OSA_Int16 *)pC->pInputClipCtxt->
3440 < pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize
3458 pC->audioVolumeArray[pC->audVolArrIndex] =
3462 if( pC->audVolArrIndex >= WINDOW_SIZE - 1 )
3464 pC->bDoDucking =
3465 M4VSS3GPP_isThresholdBreached((M4OSA_Int32 *)&(pC->audioVolumeArray),
3466 pC->audVolArrIndex, pC->InDucking_threshold);
3468 pC->audVolArrIndex = 0;
3472 pC->audVolArrIndex++;
3486 if( pC->bDoDucking )
3488 if( pC->duckingFactor
3489 > pC->InDucking_lowVolume ) // FADE OUT BG Track
3493 pC->duckingFactor -= (pC->InDucking_lowVolume);
3497 pC->duckingFactor = pC->InDucking_lowVolume;
3502 if( pC->duckingFactor < 1.0 ) // FADE IN BG Track
3506 pC->duckingFactor += (pC->InDucking_lowVolume);
3510 pC->duckingFactor = 1.0;
3522 *pPCMdata2 = (M4OSA_Int16)(*pPCMdata2 * pC->fBTVolLevel);
3524 *pPCMdata1 = (M4OSA_Int16)(*pPCMdata1 * pC->fPTVolLevel);
3528 *pPCMdata2 = (M4OSA_Int16)(( *pPCMdata2) * (pC->duckingFactor));
3570 *pPCMdata1 = (M4OSA_Int16)(*pPCMdata1 * pC->fOrigFactor * pC->fPTVolLevel
3571 + *pPCMdata2 * pC->fAddedFactor * pC->fBTVolLevel );
3578 /* Update pC->pSsrcBufferOut buffer */
3580 if( M4OSA_TRUE == pC->b_SSRCneeded || pC->ChannelConversion > 0 )
3582 tempPosBuffer = pC->pSsrcBufferOut
3583 + pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
3584 memmove((void *)pC->pSsrcBufferOut, (void *)tempPosBuffer,
3585 pC->pPosInSsrcBufferOut - tempPosBuffer);
3586 pC->pPosInSsrcBufferOut -=
3587 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
3589 else if( pC->pAddedClipCtxt->pSettings->ClipProperties.AudioStreamType
3592 tempPosBuffer = pC->pSsrcBufferIn
3593 + pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
3594 memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
3595 pC->pPosInSsrcBufferIn - tempPosBuffer);
3596 pC->pPosInSsrcBufferIn -=
3597 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
3602 pC->pInputClipCtxt->AudioDecBufferOut.m_dataAddress;
3604 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
3610 pEncInBuffer.pTableBufferSize[0] / sizeof(short) / pC->ewc.uiNbChannels;
3615 (M4OSA_MemAddr8)pC->ewc.WriterAudioAU.dataAddress;
3622 err = pC->ShellAPI.pAudioEncoderGlobalFcts->pFctStep(pC->ewc.pAudioEncCtxt,
3635 pC->ewc.WriterAudioAU.size =
3637 pC->ewc.WriterAudioAU.CTS += frameTimeDelta;
3642 (M4OSA_Int32)(pC->ewc.WriterAudioAU.CTS / pC->ewc.scale_audio),
3643 pC->ewc.WriterAudioAU.size);
3645 err = pC->ShellAPI.pWriterDataFcts->pProcessAU(pC->ewc.p3gpWriterContext,
3646 M4VSS3GPP_WRITER_AUDIO_STREAM_ID, &pC->ewc.WriterAudioAU);
3658 pC->ewc.dATo += frameTimeDelta / pC->ewc.scale_audio;
3668 * M4OSA_ERR M4VSS3GPP_intAudioMixingTransition(M4VSS3GPP_InternalAudioMixingContext *pC)
3671 * @param pC (IN) VSS audio mixing internal context
3676 M4VSS3GPP_InternalAudioMixingContext *pC )
3690 err = M4VSS3GPP_intAudioMixingWriteSilence(pC);
3701 iCurrentCts = (M4OSA_Int32)(pC->ewc.dATo * pC->ewc.scale_audio + 0.5);
3704 if( M4OSA_FALSE == pC->bAudioMixingIsNeeded )
3710 err = M4VSS3GPP_intClipJumpAudioAt(pC->pInputClipCtxt, &iCurrentCts);
3726 err = pC->ShellAPI.pWriterDataFcts->pStartAU(
3727 pC->ewc.p3gpWriterContext, M4VSS3GPP_WRITER_AUDIO_STREAM_ID,
3728 &pC->ewc.WriterAudioAU);
3742 * pC->ewc.iSilenceFrameDuration;
3749 err = M4VSS3GPP_intClipJumpAudioAt(pC->pInputClipCtxt, &iTargetCts);
3762 while( pC->pInputClipCtxt->iAudioFrameCts < iCurrentCts )
3764 err = M4VSS3GPP_intClipReadNextAudioFrame(pC->pInputClipCtxt);
3767 pC->pInputClipCtxt->iAudioFrameCts
3768 / pC->pInputClipCtxt->scale_audio,
3769 pC->pInputClipCtxt->iAoffset
3770 / pC->pInputClipCtxt->scale_audio,
3771 pC->pInputClipCtxt->uiAudioFrameSize);
3783 pC->pInputClipCtxt);
3796 pC->pInputClipCtxt->AudioDecBufferOut.m_dataAddress;
3798 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
3805 / pC->ewc.uiNbChannels;
3810 (M4OSA_MemAddr8)pC->ewc.WriterAudioAU.dataAddress;
3817 err = pC->ShellAPI.pAudioEncoderGlobalFcts->pFctStep(
3818 pC->ewc.pAudioEncCtxt, &pEncInBuffer, &pEncOutBuffer);
3832 pC->ewc.WriterAudioAU.size = pEncOutBuffer.pTableBufferSize[
3834 pC->ewc.WriterAudioAU.CTS += frameTimeDelta;
3839 (M4OSA_Int32)(pC->ewc.WriterAudioAU.CTS / pC->ewc.scale_audio),
3840 pC->ewc.WriterAudioAU.size);
3842 err = pC->ShellAPI.pWriterDataFcts->pProcessAU(
3843 pC->ewc.p3gpWriterContext, M4VSS3GPP_WRITER_AUDIO_STREAM_ID,
3844 &pC->ewc.WriterAudioAU);
3856 pC->ewc.dATo += pC->ewc.iSilenceFrameDuration / pC->ewc.scale_audio;
3871 M4VSS3GPP_InternalAudioMixingContext *pC )
3878 pC->ewc.OurWriterDataInterface.pProcessAU =
3881 pC->ewc.OurWriterDataInterface.pStartAU =
3884 pC->ewc.OurWriterDataInterface.pWriterContext =
3886 pC; /**< We give the internal context as writer context */
3890 if( M4OSA_NULL == pC->ShellAPI.pVideoEncoderGlobalFcts )
3892 err = M4VSS3GPP_setCurrentVideoEncoder(&pC->ShellAPI,
3893 pC->ewc.VideoStreamType);
3905 EncParams.FrameWidth = pC->ewc.uiVideoWidth;
3906 EncParams.FrameHeight = pC->ewc.uiVideoHeight;
3907 EncParams.uiTimeScale = pC->ewc.uiVideoTimeScale;
3908 EncParams.videoProfile = pC->ewc.outputVideoProfile;
3909 EncParams.videoLevel = pC->ewc.outputVideoLevel;
3929 switch( pC->ewc.VideoStreamType )
3949 if( M4OSA_FALSE == pC->ewc.bVideoDataPartitioning )
3977 pC->ewc.VideoStreamType);
3982 pC->pInputClipCtxt->pSettings->ClipProperties.uiVideoBitrate;
3988 err = pC->ShellAPI.pVideoEncoderGlobalFcts->pFctInit(&pC->ewc.pEncContext,
3989 &pC->ewc.OurWriterDataInterface, M4VSS3GPP_intVPP, pC,
3990 pC->ShellAPI.pCurrentVideoEncoderExternalAPI,
3991 pC->ShellAPI.pCurrentVideoEncoderUserData);
4002 pC->ewc.encoderState = M4VSS3GPP_kEncoderClosed;
4007 err = pC->ShellAPI.pVideoEncoderGlobalFcts->pFctOpen(pC->ewc.pEncContext,
4008 &pC->ewc.WriterVideoAU, &EncParams);
4019 pC->ewc.encoderState = M4VSS3GPP_kEncoderStopped;
4023 if( M4OSA_NULL != pC->ShellAPI.pVideoEncoderGlobalFcts->pFctStart )
4025 err = pC->ShellAPI.pVideoEncoderGlobalFcts->pFctStart(
4026 pC->ewc.pEncContext);
4038 pC->ewc.encoderState = M4VSS3GPP_kEncoderRunning;
4055 M4VSS3GPP_InternalAudioMixingContext *pC )
4059 if( M4OSA_NULL != pC->ewc.pEncContext )
4061 if( M4VSS3GPP_kEncoderRunning == pC->ewc.encoderState )
4063 if( pC->ShellAPI.pVideoEncoderGlobalFcts->pFctStop != M4OSA_NULL )
4065 err = pC->ShellAPI.pVideoEncoderGlobalFcts->pFctStop(
4066 pC->ewc.pEncContext);
4077 pC->ewc.encoderState = M4VSS3GPP_kEncoderStopped;
4081 if( M4VSS3GPP_kEncoderStopped == pC->ewc.encoderState )
4083 err = pC->ShellAPI.pVideoEncoderGlobalFcts->pFctClose(
4084 pC->ewc.pEncContext);
4094 pC->ewc.encoderState = M4VSS3GPP_kEncoderClosed;
4097 err = pC->ShellAPI.pVideoEncoderGlobalFcts->pFctCleanup(
4098 pC->ewc.pEncContext);
4109 pC->ewc.encoderState = M4VSS3GPP_kNoEncoder;
4112 pC->ewc.pEncContext = M4OSA_NULL;