diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2016-06-27 10:55:12 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2016-06-27 10:55:12 +0000 |
| commit | 85472238d726cd67bb8f4758440d8c953e3f8532 (patch) | |
| tree | 913ea769db94baea97ac7fec4da3b9dd6f1b66b0 /src | |
| parent | d9d9c0a27f42fb0ebe5da8d3b95b8e9ff6db0783 (diff) | |
| download | qmmp-85472238d726cd67bb8f4758440d8c953e3f8532.tar.gz qmmp-85472238d726cd67bb8f4758440d8c953e3f8532.tar.bz2 qmmp-85472238d726cd67bb8f4758440d8c953e3f8532.zip | |
added ffmpeg 3.1 support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6534 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp | 33 | ||||
| -rw-r--r-- | src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp | 18 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp index 48e43f760..3078c58d3 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp +++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp @@ -79,6 +79,7 @@ DecoderFFmpeg::DecoderFFmpeg(const QString &path, QIODevice *i) m_stream = 0; m_decoded_frame = 0; m_channels = 0; + c = 0; av_init_packet(&m_pkt); av_init_packet(&m_temp_pkt); } @@ -88,6 +89,10 @@ DecoderFFmpeg::~DecoderFFmpeg() { m_bitrate = 0; m_temp_pkt.size = 0; +#if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 + if(c) + avcodec_free_context(&c); +#endif if (ic) avformat_free_context(ic); if(m_pkt.data) @@ -200,12 +205,19 @@ bool DecoderFFmpeg::initialize() ReplayGainReader rg(ic); setReplayGainInfo(rg.replayGainInfo()); +#if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 + c = avcodec_alloc_context3(NULL); +#endif ic->flags |= AVFMT_FLAG_GENPTS; av_read_play(ic); for (wma_idx = 0; wma_idx < (int)ic->nb_streams; wma_idx++) { +#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); +#else c = ic->streams[wma_idx]->codec; +#endif if (c->codec_type == AVMEDIA_TYPE_AUDIO) break; } @@ -362,7 +374,28 @@ qint64 DecoderFFmpeg::ffmpeg_decode() avcodec_get_frame_defaults(m_decoded_frame); #endif +#if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 + int err = 0; + if((err = avcodec_send_packet(c, &m_temp_pkt)) < 0) + { + if(err == EAGAIN) //try again + return 0; + else + { + qWarning("DecoderFFmpeg: avcodec_send_packet error: %d", err); + return -1; + } + } + if((err = avcodec_receive_frame(c, m_decoded_frame)) < 0) + { + qWarning("DecoderFFmpeg: avcodec_receive_frame error: %d", err); + return -1; + } + got_frame = av_frame_get_pkt_size(m_decoded_frame); + int l = m_temp_pkt.size; +#else int l = avcodec_decode_audio4(c, m_decoded_frame, &got_frame, &m_temp_pkt); +#endif if(got_frame) out_size = av_samples_get_buffer_size(0, c->channels, m_decoded_frame->nb_samples, diff --git a/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp b/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp index 449e55052..00de8d9aa 100644 --- a/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp +++ b/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp @@ -51,11 +51,19 @@ QHash<QString, QString> FFmpegMetaDataModel::audioProperties() ap.insert(tr("File size"), QString("%1 ").arg(avio_size(m_in->pb)) + " " + tr("KB")); ap.insert(tr("Bitrate"), QString("%1 "+tr("kbps")).arg(m_in->bit_rate/1000)); +#if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 + AVCodecParameters *c = 0; +#else AVCodecContext *c = 0; +#endif uint idx; for (idx = 0; idx < m_in->nb_streams; idx++) { +#if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 + c = m_in->streams[idx]->codecpar; +#else c = m_in->streams[idx]->codec; +#endif if (c->codec_type == AVMEDIA_TYPE_AUDIO) break; } @@ -69,10 +77,20 @@ QHash<QString, QString> FFmpegMetaDataModel::audioProperties() QPixmap FFmpegMetaDataModel::cover() { +#if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 + AVCodecParameters *c = 0; +#else AVCodecContext *c = 0; +#endif + for (uint idx = 0; idx < m_in->nb_streams; idx++) { +#if (LIBAVCODEC_VERSION_INT >= ((57<<16)+(48<<8)+0)) //ffmpeg-3.1: 57.48.101 + c = m_in->streams[idx]->codecpar; +#else c = m_in->streams[idx]->codec; +#endif + #if (LIBAVCODEC_VERSION_INT >= ((55<<16)+(34<<8)+0)) //libav 10 if (c->codec_type == AVMEDIA_TYPE_VIDEO && c->codec_id == AV_CODEC_ID_MJPEG) #else |
