From a40212a5ebe6d9c9b0a1e56f624d9b911c621f6b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 12 Nov 2016 22:16:42 +0100 Subject: [PATCH] driver: use newer ffmpeg API Reduce the "deprecated function" warnings a bit when compiling against recent ffmpeg releases. Just the drop-in-replacement "av_packet_unref" which works with both old and new ffmpeg versions. The other stuff needs rewrites which are not compatible with all ffmpeg releases :-( Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/4a400c909a9ecb276a0b529ea7e9190a7b8ac94b Author: Stefan Seyfried Date: 2016-11-12 (Sat, 12 Nov 2016) --- src/driver/audiodec/ffmpegdec.cpp | 6 +++--- src/driver/record.cpp | 4 ++-- src/driver/streamts.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/driver/audiodec/ffmpegdec.cpp b/src/driver/audiodec/ffmpegdec.cpp index 625aef79f..3262a0a95 100644 --- a/src/driver/audiodec/ffmpegdec.cpp +++ b/src/driver/audiodec/ffmpegdec.cpp @@ -310,7 +310,7 @@ CBaseDec::RetCode CFfmpegDec::Decoder(FILE *_in, int /*OutputFd*/, State* state, } if (rpacket.stream_index != best_stream) { - av_free_packet(&rpacket); + av_packet_unref(&rpacket); continue; } @@ -369,7 +369,7 @@ CBaseDec::RetCode CFfmpegDec::Decoder(FILE *_in, int /*OutputFd*/, State* state, } if (time_played && avc->streams[best_stream]->time_base.den) *time_played = (pts - start_pts) * avc->streams[best_stream]->time_base.num / avc->streams[best_stream]->time_base.den; - av_free_packet(&rpacket); + av_packet_unref(&rpacket); } while (*state!=STOP_REQ && Status==OK); audioDecoder->StopClip(); @@ -377,7 +377,7 @@ CBaseDec::RetCode CFfmpegDec::Decoder(FILE *_in, int /*OutputFd*/, State* state, swr_free(&swr); av_free(outbuf); - av_free_packet(&rpacket); + av_packet_unref(&rpacket); av_frame_free(&frame); avcodec_close(c); //av_free(avcc); diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 1f9b33172..146ba5d2a 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -2206,7 +2206,7 @@ void CStreamRec::run() AVPacket newpkt = pkt; if (av_bitstream_filter_filter(bsfc, codec, NULL, &newpkt.data, &newpkt.size, pkt.data, pkt.size, pkt.flags & AV_PKT_FLAG_KEY) >= 0) { - av_free_packet(&pkt); + av_packet_unref(&pkt); newpkt.buf = av_buffer_create(newpkt.data, newpkt.size, av_buffer_default_free, NULL, 0); pkt = newpkt; } @@ -2215,7 +2215,7 @@ void CStreamRec::run() pkt.dts = av_rescale_q(pkt.dts, ifcx->streams[pkt.stream_index]->time_base, ofcx->streams[pkt.stream_index]->time_base); av_write_frame(ofcx, &pkt); - av_free_packet(&pkt); + av_packet_unref(&pkt); if (pkt.stream_index == stream_index) { total += (double) 1000 * pkt.duration * av_q2d(ifcx->streams[stream_index]->time_base); diff --git a/src/driver/streamts.cpp b/src/driver/streamts.cpp index aebb0e168..f04cd70bc 100644 --- a/src/driver/streamts.cpp +++ b/src/driver/streamts.cpp @@ -903,7 +903,7 @@ void CStreamStream::run() AVPacket newpkt = pkt; if (av_bitstream_filter_filter(bsfc, codec, NULL, &newpkt.data, &newpkt.size, pkt.data, pkt.size, pkt.flags & AV_PKT_FLAG_KEY) >= 0) { - av_free_packet(&pkt); + av_packet_unref(&pkt); newpkt.buf = av_buffer_create(newpkt.data, newpkt.size, av_buffer_default_free, NULL, 0); pkt = newpkt; } @@ -912,7 +912,7 @@ void CStreamStream::run() pkt.dts = av_rescale_q(pkt.dts, ifcx->streams[pkt.stream_index]->time_base, ofcx->streams[pkt.stream_index]->time_base); av_write_frame(ofcx, &pkt); - av_free_packet(&pkt); + av_packet_unref(&pkt); } av_read_pause(ifcx);