diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-10-09 21:19:15 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-10-09 21:19:15 +0000 |
| commit | c92c2f96b6ffbbf6969e28ba64953d32ed7ef509 (patch) | |
| tree | b4a0e5a464496390fc89f55330616dec1a0f4eb1 /src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp | |
| parent | 7fa9623e77e984ec5f792bef8ce911d36f717709 (diff) | |
| download | qmmp-c92c2f96b6ffbbf6969e28ba64953d32ed7ef509.tar.gz qmmp-c92c2f96b6ffbbf6969e28ba64953d32ed7ef509.tar.bz2 qmmp-c92c2f96b6ffbbf6969e28ba64953d32ed7ef509.zip | |
impoved ffmpeg plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7537 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp')
| -rw-r--r-- | src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp index 77ff3f0af..36d7bb9ef 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp +++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp @@ -81,7 +81,7 @@ DecoderFFmpeg::DecoderFFmpeg(const QString &path, QIODevice *i) m_decoded_frame = 0; m_channels = 0; c = 0; - wma_idx = 0; + audioIndex = 0; av_init_packet(&m_pkt); av_init_packet(&m_temp_pkt); } @@ -213,16 +213,18 @@ bool DecoderFFmpeg::initialize() ic->flags |= AVFMT_FLAG_GENPTS; av_read_play(ic); - for (wma_idx = 0; wma_idx < (int)ic->nb_streams; wma_idx++) + audioIndex = av_find_best_stream(ic, AVMEDIA_TYPE_AUDIO, -1, -1, 0, 0); + if(audioIndex < 0) { + qWarning("DecoderFFmpeg: unable to find audio stream"); + return false; + } + #if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 - avcodec_parameters_to_context(c, ic->streams[wma_idx]->codecpar); + avcodec_parameters_to_context(c, ic->streams[audioIndex]->codecpar); #else - c = ic->streams[wma_idx]->codec; + c = ic->streams[audioIndex]->codec; #endif - if (c->codec_type == AVMEDIA_TYPE_AUDIO) - break; - } #if (LIBAVCODEC_VERSION_INT >= ((55<<16)+(34<<8)+0)) //libav-10: 55.34.1; ffmpeg-2.1: 55.39.100 if (c->channels == 1) @@ -367,7 +369,7 @@ qint64 DecoderFFmpeg::ffmpeg_decode() { int out_size = 0; int got_frame = 0; - if(m_pkt.stream_index == wma_idx) + if(m_pkt.stream_index == audioIndex) { #if (LIBAVCODEC_VERSION_INT >= ((55<<16)+(34<<8)+0)) //libav-10: 55.34.1; ffmpeg-2.1: 55.39.100 @@ -453,7 +455,7 @@ void DecoderFFmpeg::fillBuffer() m_temp_pkt.size = m_pkt.size; m_temp_pkt.data = m_pkt.data; - if(m_pkt.stream_index != wma_idx) + if(m_pkt.stream_index != audioIndex) { if(m_pkt.data) #if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(24<<8)+102)) //ffmpeg-3.0 |
