Fixes for ffmpeg 3.0

This commit is contained in:
rdb 2016-03-24 22:24:16 +01:00
parent 58837c0f4a
commit 63dd1e0d2b
2 changed files with 35 additions and 3 deletions

View File

@ -203,7 +203,11 @@ cleanup() {
if (_packet) { if (_packet) {
if (_packet->data) { if (_packet->data) {
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(_packet);
#else
av_free_packet(_packet); av_free_packet(_packet);
#endif
} }
delete _packet; delete _packet;
_packet = NULL; _packet = NULL;
@ -242,7 +246,11 @@ cleanup() {
void FfmpegAudioCursor:: void FfmpegAudioCursor::
fetch_packet() { fetch_packet() {
if (_packet->data) { if (_packet->data) {
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(_packet);
#else
av_free_packet(_packet); av_free_packet(_packet);
#endif
} }
while (av_read_frame(_format_ctx, _packet) >= 0) { while (av_read_frame(_format_ctx, _packet) >= 0) {
if (_packet->stream_index == _audio_index) { if (_packet->stream_index == _audio_index) {
@ -250,7 +258,11 @@ fetch_packet() {
_packet_data = _packet->data; _packet_data = _packet->data;
return; return;
} }
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(_packet);
#else
av_free_packet(_packet); av_free_packet(_packet);
#endif
} }
_packet->data = 0; _packet->data = 0;
_packet_size = 0; _packet_size = 0;
@ -300,7 +312,11 @@ reload_buffer() {
pkt.size = _packet_size; pkt.size = _packet_size;
int len = avcodec_decode_audio4(_audio_ctx, _frame, &got_frame, &pkt); int len = avcodec_decode_audio4(_audio_ctx, _frame, &got_frame, &pkt);
movies_debug("avcodec_decode_audio4 returned " << len); movies_debug("avcodec_decode_audio4 returned " << len);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(&pkt);
#else
av_free_packet(&pkt); av_free_packet(&pkt);
#endif
bufsize = 0; bufsize = 0;
if (got_frame) { if (got_frame) {

View File

@ -82,9 +82,13 @@ init_from(FfmpegVideo *source) {
#ifdef HAVE_SWSCALE #ifdef HAVE_SWSCALE
nassertv(_convert_ctx == NULL); nassertv(_convert_ctx == NULL);
_convert_ctx = sws_getContext(_size_x, _size_y, _convert_ctx = sws_getContext(_size_x, _size_y, _video_ctx->pix_fmt,
_video_ctx->pix_fmt, _size_x, _size_y, #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(51, 74, 100)
PIX_FMT_BGR24, SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL); _size_x, _size_y, AV_PIX_FMT_BGR24,
#else
_size_x, _size_y, PIX_FMT_BGR24,
#endif
SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL);
#endif // HAVE_SWSCALE #endif // HAVE_SWSCALE
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 59, 100) #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 59, 100)
@ -568,7 +572,11 @@ cleanup() {
if (_packet) { if (_packet) {
if (_packet->data) { if (_packet->data) {
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(_packet);
#else
av_free_packet(_packet); av_free_packet(_packet);
#endif
} }
delete _packet; delete _packet;
_packet = NULL; _packet = NULL;
@ -737,14 +745,22 @@ fetch_packet(int default_frame) {
bool FfmpegVideoCursor:: bool FfmpegVideoCursor::
do_fetch_packet(int default_frame) { do_fetch_packet(int default_frame) {
if (_packet->data) { if (_packet->data) {
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(_packet);
#else
av_free_packet(_packet); av_free_packet(_packet);
#endif
} }
while (av_read_frame(_format_ctx, _packet) >= 0) { while (av_read_frame(_format_ctx, _packet) >= 0) {
if (_packet->stream_index == _video_index) { if (_packet->stream_index == _video_index) {
_packet_frame = _packet->dts; _packet_frame = _packet->dts;
return false; return false;
} }
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(_packet);
#else
av_free_packet(_packet); av_free_packet(_packet);
#endif
} }
_packet->data = 0; _packet->data = 0;