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 :-(
This commit is contained in:
Stefan Seyfried
2016-11-12 22:16:42 +01:00
committed by svenhoefer
parent 0531618643
commit 7154f36258
3 changed files with 7 additions and 7 deletions

View File

@@ -314,7 +314,7 @@ CBaseDec::RetCode CFfmpegDec::Decoder(FILE *_in, int /*OutputFd*/, State* state,
} }
if (rpacket.stream_index != best_stream) { if (rpacket.stream_index != best_stream) {
av_free_packet(&rpacket); av_packet_unref(&rpacket);
continue; continue;
} }
@@ -373,7 +373,7 @@ CBaseDec::RetCode CFfmpegDec::Decoder(FILE *_in, int /*OutputFd*/, State* state,
} }
if (time_played && avc->streams[best_stream]->time_base.den) 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; *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); } while (*state!=STOP_REQ && Status==OK);
audioDecoder->StopClip(); audioDecoder->StopClip();
@@ -381,7 +381,7 @@ CBaseDec::RetCode CFfmpegDec::Decoder(FILE *_in, int /*OutputFd*/, State* state,
swr_free(&swr); swr_free(&swr);
av_free(outbuf); av_free(outbuf);
av_free_packet(&rpacket); av_packet_unref(&rpacket);
av_frame_free(&frame); av_frame_free(&frame);
avcodec_close(c); avcodec_close(c);
//av_free(avcc); //av_free(avcc);

View File

@@ -2207,7 +2207,7 @@ void CStreamRec::run()
AVPacket newpkt = pkt; 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) { 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); newpkt.buf = av_buffer_create(newpkt.data, newpkt.size, av_buffer_default_free, NULL, 0);
pkt = newpkt; pkt = newpkt;
} }
@@ -2216,7 +2216,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); 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_write_frame(ofcx, &pkt);
av_free_packet(&pkt); av_packet_unref(&pkt);
if (pkt.stream_index == stream_index) { if (pkt.stream_index == stream_index) {
total += (double) 1000 * pkt.duration * av_q2d(ifcx->streams[stream_index]->time_base); total += (double) 1000 * pkt.duration * av_q2d(ifcx->streams[stream_index]->time_base);

View File

@@ -900,7 +900,7 @@ void CStreamStream::run()
AVPacket newpkt = pkt; 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) { 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); newpkt.buf = av_buffer_create(newpkt.data, newpkt.size, av_buffer_default_free, NULL, 0);
pkt = newpkt; pkt = newpkt;
} }
@@ -909,7 +909,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); 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_write_frame(ofcx, &pkt);
av_free_packet(&pkt); av_packet_unref(&pkt);
} }
av_read_pause(ifcx); av_read_pause(ifcx);