[prev in list] [next in list] [prev in thread] [next in thread]
List: helix-datatype-cvs
Subject: [Datatype-cvs] mdf/audio/dsp mdfaudfmt.cpp,1.18,1.19
From: anugrahk () helixcommunity ! org
Date: 2010-04-29 11:34:53
Message-ID: 201004291135.o3TBZ5HC005555 () mailer ! progressive-comp ! com
[Download RAW message or body]
Update of /cvsroot/datatype/mdf/audio/dsp
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv11499
Modified Files:
mdfaudfmt.cpp
Log Message:
Nokia submits this code under the terms of a commercial contribution agreement with \
RealNetworks, and I am authorized to contribute this code under said agreement."
Modified by: ext-anugrah.2.kashari@nokia.com
Reviewed by: Rathinasamy Rajesh
ext Sheldon Fu [sfu@real.com]
TSW Id: EZLU-83T9YY
Date: 04/28/2010
Project: SymbianMmf_wm
Synopsis: AppCert-WIN7-Device can not play WMV video with H264 conent
Overview: WMA audio stream is decoded as a block. Number of samples produced from \
each audio block need not be constant. When using SW codec, CWMAudioDecoder::Decode() \
(called in CWMAudioFormat::DecodeAudioData() ) returns exact number of samples \
produced after decoding. This value is used to keep track of decoded output time. \
This is later used to make decision on whether buffering is required or not. In \
case of DSP codec CHXMDFAudioDecoder::Decode()returns a dummy value for number of \
samples produced which is equal to HXMDFAudioFormat::m_uSamplesPerFrame. This is \
incorrect as number of samples produced per audio block is not constant. In this \
defect this value was much lower than the actual value. Therefore, helix goes into \
buffering mode and loading happens at regular intervals. Number of samples produced \
is required by CWMAudioFormat to keep track of current decode time. This value need \
not be accurate but should be close enough to actual decode time. Number of samples \
produces cannot be known without decoding. In case of DSP codec \
CHXMDFAudioDecoder::Decode() does not actually decode audio but simply stores data \
which is later sent in CMDFDevSound::BufferToBeFilled() call. CWMAudioFormat module \
is not aware of this and it updates current decode time according to the values \
retuned. Therefore, changes are needed in CHXMDFAudioDecoder::Decode() to ensure that \
total accumulated time is close to decode time.
Fix: 1. Number of samples produced can also be calculated using difference of \
presentation times of two consecutive audio blocks. For first audio block number of \
samples produce is approximated to HXMDFAudioFormat::m_uSamplesPerFrame. From next \
block onwards samples produced is equal to presentation time difference between the \
last audio block and current audio block (which is append to the buffer to be sent to \
DSP). This gives a better approximation for total output time than fixed \
m_uSamplesPerFrame. These calculations are done GetSamplesPerFrame() (a new function \
added to HXMDFAudioFormat)
2. In WMA audio format 0x161, wSamplesPerBlock (defined in union Samples (type WORD) \
of WAVEFORMATEXTENSIBLE) is present if and only if wBitsPerSample==0. If value of \
Samples is zero it means that wSamplesPerBlock is not constant. So it is safer to \
initialized m_uSamplesPerFrame with BlockAlign*channels( also done in SW codec). This \
value is used once and rest of calculation are based on the timestamp of audio \
blocks.
Files modified & changes:
/datatype/mdf/audio/dsp/mdfaudfmt.cpp
/datatype/mdf/audio/dsp/mdfaudfmt.h
/datatype/mdf/audio/dsp/mdfauddecoder.h
/datatype/mdf/audio/dsp/mdfauddecoder.cpp
Image Size and Heap Use impact: No major impact
Module Release testing (STIF) : Passed
Test case(s) Added : Yes WMV specfic
Memory leak check performed : Passed, No additional leaks introduced.
Platforms and Profiles Build Verified: helix-client-s60-52-mmf-mdf-dsp
Platforms and Profiles Functionality verified: armv5
Branch: 210CayS, 420Bizo and HEAD
Index: mdfaudfmt.cpp
===================================================================
RCS file: /cvsroot/datatype/mdf/audio/dsp/mdfaudfmt.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mdfaudfmt.cpp 30 Mar 2010 05:52:08 -0000 1.18
+++ mdfaudfmt.cpp 29 Apr 2010 11:34:51 -0000 1.19
@@ -718,22 +718,18 @@
m_uBitsPerSample = m_AudioTSD.m_WaveFormatEx.m_usBitsPerSample;
m_ulSamplesPerSec = m_AudioTSD.m_WaveFormatEx.m_ulSamplesPerSec;
- UINT32 uSamplesPerFrame;
- result = DetermineSamplesPerBlock( m_AudioTSD.m_WaveFormatEx.m_usFormatTag,
- m_AudioTSD.m_WaveFormatEx.m_ulSamplesPerSec,
- m_AudioTSD.m_WaveFormatEx.m_ulAvgBytesPerSec,
- m_AudioTSD.m_usEncodeOptions,
- &uSamplesPerFrame);
-
- if(SUCCEEDED(result))
+ // For WMA sampler per block need not be same this is just approx value
+ // better approximation is done in CHXMDFAudioDecoder::Decode()
+ if(m_AudioTSD.m_WaveFormatEx.m_usFormatTag == 0x0162 ||
+ m_AudioTSD.m_WaveFormatEx.m_usFormatTag == 0x0163)
{
- m_uSamplesPerFrame = (UINT16)uSamplesPerFrame;
+ m_uSamplesPerFrame = (UINT16) (m_AudioTSD.m_ulSamplesPerBlock);
}
- else
+ else
{
- m_uSamplesPerFrame = (UINT16) (m_AudioTSD.m_ulSamplesPerBlock);
+ m_uSamplesPerFrame = (UINT16) (m_uChannels \
*m_AudioTSD.m_WaveFormatEx.m_usBlockAlign); }
-
+
free(buf);
UINT16 usWMAChannels = 2;
@@ -761,6 +757,22 @@
return mdfAudioData;
}
+UINT16 HXMDFAudioWMA::GetSamplesPerFrame(UINT32 ulNextFrameTime,UINT32 \
ulLastFrameTime) +{
+ // For WMA audio samples produced per block could be variable
+ // nSamplesOut is a dummy value and there is no sure way to know number of \
samples that will be produced + // so nSamplesOut is computed using difference in \
time for two audio blocks +
+ UINT16 samples = 0;
+ if(ulNextFrameTime != ulLastFrameTime)
+ {
+ // Calculate samples produced and dividing m_ulSamplesPerSec by 1000 as \
frame time are in ms. + samples = (ulNextFrameTime - \
ulLastFrameTime)*m_ulSamplesPerSec/1000; + samples *= m_uChannels;
+ }
+ return samples;
+}
+
UINT32 HXMDFAudioFormat::PrepareHeader(HXMDFAudioData *mdfAudioData,
UINT32 uDataSize,
UINT32 uMaxBytes,
_______________________________________________
Datatype-cvs mailing list
Datatype-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/datatype-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic