aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2019-05-03 16:34:49 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2019-05-03 16:34:49 +0000
commit6ec8f326a2b50adb4168304e8427969c8ef0e0b0 (patch)
tree0f36fa8c24205e90d7c32519e77c9eaa4a7377ce /src
parentf8c396e46103a84e71406df25493c06bf0e1f2da (diff)
downloadqmmp-6ec8f326a2b50adb4168304e8427969c8ef0e0b0.tar.gz
qmmp-6ec8f326a2b50adb4168304e8427969c8ef0e0b0.tar.bz2
qmmp-6ec8f326a2b50adb4168304e8427969c8ef0e0b0.zip
ffmpeg: fixed crash on streams
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8843 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp15
-rw-r--r--src/plugins/Input/ffmpeg/decoder_ffmpeg.h8
2 files changed, 14 insertions, 9 deletions
diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp
index 662c403db..21830daf5 100644
--- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp
+++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp
@@ -86,9 +86,9 @@ DecoderFFmpeg::DecoderFFmpeg(const QString &path, QIODevice *i)
m_seekTime = -1;
av_init_packet(&m_pkt);
av_init_packet(&m_temp_pkt);
+ m_input_buf = nullptr;
}
-
DecoderFFmpeg::~DecoderFFmpeg()
{
m_bitrate = 0;
@@ -106,7 +106,11 @@ DecoderFFmpeg::~DecoderFFmpeg()
av_free_packet(&m_pkt);
#endif
if(m_stream)
+#if (LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 80, 100)) //ffmpeg-3.4
+ avio_context_free(&m_stream);
+#else
av_free(m_stream);
+#endif
if(m_decoded_frame)
#if (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,34,0)) //libav-10: 55.34.1; ffmpeg-2.1: 55.39.100
@@ -114,7 +118,6 @@ DecoderFFmpeg::~DecoderFFmpeg()
#else
av_free(m_decoded_frame);
#endif
-
}
bool DecoderFFmpeg::initialize()
@@ -145,9 +148,17 @@ bool DecoderFFmpeg::initialize()
qDebug("DecoderFFmpeg: detected format: %s", fmt->long_name);
qDebug("=%s=", fmt->name);
+#if (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,10,100)) //ffmpeg-3.5
+ m_input_buf = (uchar*)av_malloc(INPUT_BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
+#else
+ m_input_buf = (uchar*)av_malloc(INPUT_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
+#endif
+
m_stream = avio_alloc_context(m_input_buf, INPUT_BUFFER_SIZE, 0, this, ffmpeg_read, nullptr, ffmpeg_seek);
if(!m_stream)
{
+ av_free(m_input_buf);
+ m_input_buf = nullptr;
qWarning("DecoderFFmpeg: unable to initialize I/O callbacks");
return false;
}
diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.h b/src/plugins/Input/ffmpeg/decoder_ffmpeg.h
index 36a95d59f..a5748e394 100644
--- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.h
+++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.h
@@ -28,7 +28,6 @@ extern "C"{
#include <libavutil/dict.h>
}
-
#include <qmmp/decoder.h>
#define PROBE_BUFFER_SIZE 8192
@@ -61,12 +60,7 @@ private:
AVPacket m_pkt;
AVPacket m_temp_pkt;
qint64 m_output_at;
-
-#if (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,10,100)) //ffmpeg-3.5
- uchar m_input_buf[INPUT_BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
-#else
- uchar m_input_buf[INPUT_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
-#endif
+ uchar *m_input_buf;
int64_t m_seekTime;
qint64 m_skipBytes;
int m_channels;