Skip to content
This repository
Browse code

DVDAudioCodecPcm: Do not use AVCODEC_MAX_AUDIO_FRAME_SIZE since it is…

… gone in FFmpeg 2.0 and dynamically allocate buffers as needed.
  • Loading branch information...
commit 95f0fa3779b6d89c30e8a56ae07d50e6de5f5425 1 parent d603014
Alexis Ballier authored July 25, 2013
14  xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPcm.cpp
@@ -116,13 +116,15 @@ CDVDAudioCodecPcm::CDVDAudioCodecPcm() : CDVDAudioCodec()
116 116
   m_codecID = AV_CODEC_ID_NONE;
117 117
   m_iOutputChannels = 0;
118 118
 
119  
-  memset(m_decodedData, 0, sizeof(m_decodedData));
  119
+  m_decodedData = NULL;
  120
+  m_decodedDataBufSize = 0;
120 121
   memset(table, 0, sizeof(table));
121 122
 }
122 123
 
123 124
 CDVDAudioCodecPcm::~CDVDAudioCodecPcm()
124 125
 {
125 126
   Dispose();
  127
+  delete m_decodedData;
126 128
 }
127 129
 
128 130
 bool CDVDAudioCodecPcm::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
@@ -172,8 +174,14 @@ int CDVDAudioCodecPcm::Decode(uint8_t* pData, int iSize)
172 174
     src = pData;
173 175
     int buf_size = iSize;
174 176
 
175  
-    if (iSize > AVCODEC_MAX_AUDIO_FRAME_SIZE / 2)
176  
-        iSize = AVCODEC_MAX_AUDIO_FRAME_SIZE / 2;
  177
+    if (iSize > m_decodedDataBufSize)
  178
+    {
  179
+        delete m_decodedData;
  180
+        samples = m_decodedData = new short[iSize];
  181
+        if(!m_decodedData)
  182
+            return -1;
  183
+        m_decodedDataBufSize = iSize;
  184
+    }
177 185
 
178 186
     switch (m_codecID)
179 187
     {
3  xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPcm.h
@@ -41,7 +41,8 @@ class CDVDAudioCodecPcm : public CDVDAudioCodec
41 41
 protected:
42 42
   virtual void SetDefault();
43 43
 
44  
-  short m_decodedData[131072]; // could be a bit to big
  44
+  short* m_decodedData;
  45
+  int m_decodedDataBufSize;
45 46
   int m_decodedDataSize;
46 47
 
47 48
   AVCodecID m_codecID;

0 notes on commit 95f0fa3

Please sign in to comment.
Something went wrong with that request. Please try again.