summaryrefslogtreecommitdiffstats
path: root/libvideoeditor/vss/src
diff options
context:
space:
mode:
authorRajneesh Chowdury <rajneeshc@google.com>2011-07-01 18:06:15 -0700
committerRajneesh Chowdury <rajneeshc@google.com>2011-07-07 15:47:58 -0700
commitbc8e52dadeb078c45e62ebda17fd95e67f689654 (patch)
tree4958ca3a550f66364a0a3987bcf76b469498b617 /libvideoeditor/vss/src
parentb13adac0f1ce1792151192966e428d1eed3ef826 (diff)
downloadframeworks_av-bc8e52dadeb078c45e62ebda17fd95e67f689654.zip
frameworks_av-bc8e52dadeb078c45e62ebda17fd95e67f689654.tar.gz
frameworks_av-bc8e52dadeb078c45e62ebda17fd95e67f689654.tar.bz2
Fix of issue 4973565 Cannot export movie.
Also fixes 4441452 Native Crash after applying transition Change-Id: Ic48c44bc2c5d07e57edb8f63393cea424d3275f4
Diffstat (limited to 'libvideoeditor/vss/src')
-rwxr-xr-xlibvideoeditor/vss/src/M4VSS3GPP_Clip.c158
-rwxr-xr-xlibvideoeditor/vss/src/M4VSS3GPP_EditAudio.c42
2 files changed, 168 insertions, 32 deletions
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_Clip.c b/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
index 5eaedf7..91ba966 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
@@ -61,6 +61,9 @@
static M4OSA_ERR M4VSS3GPP_intClipPrepareAudioDecoder(
M4VSS3GPP_ClipContext *pClipCtxt );
+static M4OSA_ERR M4VSS3GPP_intCheckAndGetCodecAacProperties(
+ M4VSS3GPP_ClipContext *pClipCtxt);
+
/**
******************************************************************************
* M4OSA_ERR M4VSS3GPP_intClipOpen()
@@ -1140,16 +1143,16 @@ static M4OSA_ERR M4VSS3GPP_intClipPrepareAudioDecoder(
if( M4OSA_TRUE == pClipCtxt->ShellAPI.bAllowFreeingOMXCodecInterface )
{
- /* NXP SW codec interface is used*/
- if( M4DA_StreamTypeAudioAac == audiotype )
- err = pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctCreateAudioDec(
- &pClipCtxt->pAudioDecCtxt, pClipCtxt->pAudioStream,
- &(pClipCtxt->AacProperties));
- else
+ if( M4DA_StreamTypeAudioAac == audiotype ) {
+ err = M4VSS3GPP_intCheckAndGetCodecAacProperties(
+ pClipCtxt);
+ } else if (M4DA_StreamTypeAudioPcm != audiotype) {
err = pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctCreateAudioDec(
&pClipCtxt->pAudioDecCtxt, pClipCtxt->pAudioStream,
- M4OSA_NULL /* to be changed with HW interfaces */);
-
+ M4OSA_NULL);
+ } else {
+ err = M4NO_ERROR;
+ }
if( M4NO_ERROR != err )
{
M4OSA_TRACE1_1(
@@ -1310,6 +1313,16 @@ static M4OSA_ERR M4VSS3GPP_intClipPrepareAudioDecoder(
M4AD_kOptionID_UserParam, (M4OSA_DataOption) &AacDecParam);
}
+ if( M4OSA_NULL != pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctSetOptionAudioDec ) {
+ pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctSetOptionAudioDec(
+ pClipCtxt->pAudioDecCtxt, M4AD_kOptionID_3gpReaderInterface,
+ (M4OSA_DataOption) pClipCtxt->ShellAPI.m_pReaderDataIt);
+
+ pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctSetOptionAudioDec(
+ pClipCtxt->pAudioDecCtxt, M4AD_kOptionID_AudioAU,
+ (M4OSA_DataOption) &pClipCtxt->AudioAU);
+ }
+
if( M4OSA_NULL != pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctStartAudioDec )
{
/* Not implemented in all decoders */
@@ -1412,16 +1425,26 @@ M4OSA_ERR M4VSS3GPP_intClipDecodeCurrentAudioFrame(
{
/**
* Decode current AMR frame */
- pClipCtxt->AudioDecBufferIn.m_dataAddress =
- (M4OSA_MemAddr8)pClipCtxt->pAudioFramePtr;
- pClipCtxt->AudioDecBufferIn.m_bufferSize = pClipCtxt->uiAudioFrameSize;
- pClipCtxt->AudioDecBufferIn.m_timeStampUs =
- (int64_t) (pClipCtxt->iAudioFrameCts * 1000LL);
-
- err = pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctStepAudioDec(
- pClipCtxt->pAudioDecCtxt,
- &pClipCtxt->AudioDecBufferIn, &pClipCtxt->AudioDecBufferOut,
- M4OSA_FALSE);
+ if ( pClipCtxt->pAudioFramePtr != M4OSA_NULL ) {
+ pClipCtxt->AudioDecBufferIn.m_dataAddress =
+ (M4OSA_MemAddr8)pClipCtxt->pAudioFramePtr;
+ pClipCtxt->AudioDecBufferIn.m_bufferSize =
+ pClipCtxt->uiAudioFrameSize;
+ pClipCtxt->AudioDecBufferIn.m_timeStampUs =
+ (int64_t) (pClipCtxt->iAudioFrameCts * 1000LL);
+
+ err = pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctStepAudioDec(
+ pClipCtxt->pAudioDecCtxt,
+ &pClipCtxt->AudioDecBufferIn, &pClipCtxt->AudioDecBufferOut,
+ M4OSA_FALSE);
+ } else {
+ // Pass Null input buffer
+ // Reader invoked from Audio decoder source
+ err = pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctStepAudioDec(
+ pClipCtxt->pAudioDecCtxt,
+ M4OSA_NULL, &pClipCtxt->AudioDecBufferOut,
+ M4OSA_FALSE);
+ }
if( M4NO_ERROR != err )
{
@@ -1953,3 +1976,102 @@ M4OSA_UInt32 M4VSS3GPP_intGetFrameSize_EVRC( M4OSA_MemAddr8 pAudioFrame )
return (1 + (( frameSize + 7) / 8));
}
+
+M4OSA_ERR M4VSS3GPP_intCheckAndGetCodecAacProperties(
+ M4VSS3GPP_ClipContext *pClipCtxt) {
+
+ M4OSA_ERR err = M4NO_ERROR;
+ M4AD_Buffer outputBuffer;
+ uint32_t optionValue =0;
+
+ // Decode first audio frame from clip to get properties from codec
+
+ err = pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctCreateAudioDec(
+ &pClipCtxt->pAudioDecCtxt,
+ pClipCtxt->pAudioStream, &(pClipCtxt->AacProperties));
+
+ pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctSetOptionAudioDec(
+ pClipCtxt->pAudioDecCtxt, M4AD_kOptionID_3gpReaderInterface,
+ (M4OSA_DataOption) pClipCtxt->ShellAPI.m_pReaderDataIt);
+
+ pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctSetOptionAudioDec(
+ pClipCtxt->pAudioDecCtxt, M4AD_kOptionID_AudioAU,
+ (M4OSA_DataOption) &pClipCtxt->AudioAU);
+
+ if( pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctStartAudioDec != M4OSA_NULL ) {
+
+ err = pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctStartAudioDec(
+ pClipCtxt->pAudioDecCtxt);
+ if( M4NO_ERROR != err ) {
+
+ M4OSA_TRACE1_1(
+ "M4VSS3GPP_intCheckAndGetCodecAacProperties: \
+ m_pFctStartAudioDec returns 0x%x", err);
+ return err;
+ }
+ }
+
+ /**
+ * Allocate output buffer for the audio decoder */
+ outputBuffer.m_bufferSize =
+ pClipCtxt->pAudioStream->m_byteFrameLength
+ * pClipCtxt->pAudioStream->m_byteSampleSize
+ * pClipCtxt->pAudioStream->m_nbChannels;
+
+ if( outputBuffer.m_bufferSize > 0 ) {
+
+ outputBuffer.m_dataAddress =
+ (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(outputBuffer.m_bufferSize \
+ *sizeof(short), M4VSS3GPP, (M4OSA_Char *)"outputBuffer.m_bufferSize");
+
+ if( M4OSA_NULL == outputBuffer.m_dataAddress ) {
+
+ M4OSA_TRACE1_0(
+ "M4VSS3GPP_intCheckAndGetCodecAacProperties():\
+ unable to allocate outputBuffer.m_dataAddress");
+ return M4ERR_ALLOC;
+ }
+ }
+
+ err = pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctStepAudioDec(
+ pClipCtxt->pAudioDecCtxt, M4OSA_NULL, &outputBuffer, M4OSA_FALSE);
+
+ if ( err == M4WAR_INFO_FORMAT_CHANGE ) {
+
+ // Get the properties from codec node
+ pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctGetOptionAudioDec(
+ pClipCtxt->pAudioDecCtxt,
+ M4AD_kOptionID_AudioNbChannels, (M4OSA_DataOption) &optionValue);
+
+ pClipCtxt->AacProperties.aNumChan = optionValue;
+ // Reset Reader structure value also
+ pClipCtxt->pAudioStream->m_nbChannels = optionValue;
+
+ pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctGetOptionAudioDec(
+ pClipCtxt->pAudioDecCtxt,
+ M4AD_kOptionID_AudioSampFrequency, (M4OSA_DataOption) &optionValue);
+
+ pClipCtxt->AacProperties.aSampFreq = optionValue;
+ // Reset Reader structure value also
+ pClipCtxt->pAudioStream->m_samplingFrequency = optionValue;
+
+ } else if( err != M4NO_ERROR) {
+ M4OSA_TRACE1_1("M4VSS3GPP_intCheckAndGetCodecAacProperties:\
+ m_pFctStepAudioDec returns err = 0x%x", err);
+ }
+
+ free(outputBuffer.m_dataAddress);
+
+ // Reset the stream reader
+ err = pClipCtxt->ShellAPI.m_pReader->m_pFctReset(
+ pClipCtxt->pReaderContext,
+ (M4_StreamHandler *)pClipCtxt->pAudioStream);
+
+ if (M4NO_ERROR != err) {
+ M4OSA_TRACE1_1("M4VSS3GPP_intCheckAndGetCodecAacProperties\
+ Error in reseting reader: 0x%x", err);
+ }
+
+ return err;
+
+}
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_EditAudio.c b/libvideoeditor/vss/src/M4VSS3GPP_EditAudio.c
index 85b939d..746883d 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_EditAudio.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_EditAudio.c
@@ -229,6 +229,7 @@ M4OSA_ERR M4VSS3GPP_intEditStepMP3( M4VSS3GPP_InternalEditContext *pC )
M4OSA_ERR M4VSS3GPP_intEditStepAudio( M4VSS3GPP_InternalEditContext *pC )
{
M4OSA_ERR err;
+ int32_t auTimeStamp = -1;
M4ENCODER_AudioBuffer pEncInBuffer; /**< Encoder input buffer for api */
M4ENCODER_AudioBuffer pEncOutBuffer; /**< Encoder output buffer for api */
@@ -563,23 +564,21 @@ M4OSA_ERR M4VSS3GPP_intEditStepAudio( M4VSS3GPP_InternalEditContext *pC )
} //if(0 != pEncInBuffer.pTableBufferSize[0])
#endif
+ pC->pC1->pAudioFramePtr = M4OSA_NULL;
- err = M4VSS3GPP_intClipReadNextAudioFrame(pC->pC1);
-
- M4OSA_TRACE2_3(
- "F .... read : cts = %.0f + %.0f [ 0x%x ]",
- pC->pC1->iAudioFrameCts / pC->pC1->scale_audio,
- pC->pC1->iAoffset / pC->pC1->scale_audio,
- pC->pC1->uiAudioFrameSize);
+ // Get timestamp of last read AU
+ pC->pC1->ShellAPI.m_pAudioDecoder->m_pFctGetOptionAudioDec(
+ pC->pC1->pAudioDecCtxt, M4AD_kOptionID_AuCTS,
+ (M4OSA_DataOption) &auTimeStamp);
- if( M4OSA_ERR_IS_ERROR(err) )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intEditStepAudio: DECODE_ENCODE-prefetch:\
- M4VSS3GPP_intClipReadNextAudioFrame(b) returns 0x%x!",
- err);
- return err;
+ if (auTimeStamp == -1) {
+ M4OSA_TRACE1_0("M4VSS3GPP_intEditStepAudio: \
+ invalid audio timestamp returned");
+ return M4WAR_INVALID_TIME;
}
+
+ pC->pC1->iAudioFrameCts = auTimeStamp;
+
}
}
@@ -601,6 +600,21 @@ M4OSA_ERR M4VSS3GPP_intEditStepAudio( M4VSS3GPP_InternalEditContext *pC )
return err;
}
+ pC->pC1->pAudioFramePtr = M4OSA_NULL;
+
+ // Get timestamp of last read AU
+ pC->pC1->ShellAPI.m_pAudioDecoder->m_pFctGetOptionAudioDec(
+ pC->pC1->pAudioDecCtxt, M4AD_kOptionID_AuCTS,
+ (M4OSA_DataOption) &auTimeStamp);
+
+ if (auTimeStamp == -1) {
+ M4OSA_TRACE1_0("M4VSS3GPP_intEditStepAudio: invalid audio \
+ timestamp returned");
+ return M4WAR_INVALID_TIME;
+ }
+
+ pC->pC1->iAudioFrameCts = auTimeStamp;
+
/**
* Apply the effect */
if( pC->iClip1ActiveEffect >= 0 )