summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2021-08-25 16:35:47 +0200
committerSlávek Banko <slavek.banko@axis.cz>2021-08-25 16:35:47 +0200
commitd4affcc0cbde9d77ce6bea6029715414c37618a4 (patch)
tree9b73066fa4aa36f22d0aa4740b551b543c7bfaed
parent6dacea6e811ebff1e88fc4a9f717b3e7cbf99378 (diff)
downloadakode-d4affcc0cbde9d77ce6bea6029715414c37618a4.tar.gz
akode-d4affcc0cbde9d77ce6bea6029715414c37618a4.zip
plugins/ffmpeg_decoder: Add support for older FFmpeg API.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp b/akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp
index 4d0506c..43f5a35 100644
--- a/akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp
+++ b/akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp
@@ -18,6 +18,8 @@
Boston, MA 02110-1301, USA.
*/
+#define __STDC_CONSTANT_MACROS
+
#include "akodelib.h"
// #ifdef HAVE_FFMPEG
@@ -236,7 +238,11 @@ void FFMPEGDecoder::closeFile() {
#endif
}
if( d->packetSize > 0 ) {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 7, 0)
+ av_free_packet(&d->packet);
+#else
av_packet_unref( &d->packet );
+#endif
d->packetSize = 0;
}
@@ -259,7 +265,11 @@ bool FFMPEGDecoder::readPacket() {
do {
av_init_packet(&d->packet);
if ( av_read_frame(d->ic, &d->packet) < 0 ) {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 7, 0)
+ av_free_packet(&d->packet);
+#else
av_packet_unref( &d->packet );
+#endif
d->packetSize = 0;
d->packetData = 0;
return false;
@@ -269,7 +279,11 @@ bool FFMPEGDecoder::readPacket() {
d->packetData = d->packet.data;
return true;
}
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 7, 0)
+ av_free_packet(&d->packet);
+#else
av_packet_unref(&d->packet);
+#endif
} while (true);
return false;
@@ -313,7 +327,11 @@ bool FFMPEGDecoder::readFrame(AudioFrame* frame)
assert(d->packet.stream_index == d->audioStream);
retry:
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 45, 101)
+ AVFrame *decodeFrame = avcodec_alloc_frame();
+#else
AVFrame *decodeFrame = av_frame_alloc();
+#endif
if (!decodeFrame) {
return false;
}
@@ -363,12 +381,24 @@ retry:
default:
assert(false);
}
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 28, 0)
+ av_free(decodeFrame);
+#elif LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 45, 101)
+ avcodec_free_frame(&decodeFrame);
+#else
av_frame_free(&decodeFrame);
+#endif
if (length == 0) return readFrame(frame);
// std::cout << "akode: FFMPEG: Frame length: " << length << "\n";
if( d->packetSize <= 0 )
+ {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 7, 0)
+ av_free_packet(&d->packet);
+#else
av_packet_unref( &d->packet );
+#endif
+ }
frame->pos = (d->position*1000)/d->config.sample_rate;
d->position += length;