From 2b034506fad5a64efdd3f8c6a390e061c11dda0b Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 Mar 2016 23:57:00 +0100 Subject: [PATCH] Backport fixes for Arch compile issues to 1.9 --- direct/src/dcparser/dcPython.h | 1 - panda/src/ffmpeg/ffmpegAudioCursor.cxx | 16 ++++++++++++++++ panda/src/ffmpeg/ffmpegVideoCursor.cxx | 22 +++++++++++++++++++--- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/direct/src/dcparser/dcPython.h b/direct/src/dcparser/dcPython.h index d5a50baa2f..6236f8f0b6 100644 --- a/direct/src/dcparser/dcPython.h +++ b/direct/src/dcparser/dcPython.h @@ -20,7 +20,6 @@ #ifdef HAVE_PYTHON -#undef HAVE_LONG_LONG // NSPR and Python both define this. #undef _POSIX_C_SOURCE #include diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index a33db26b6f..38c3057c6f 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -210,7 +210,11 @@ cleanup() { if (_packet) { if (_packet->data) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } delete _packet; _packet = NULL; @@ -251,7 +255,11 @@ cleanup() { void FfmpegAudioCursor:: fetch_packet() { if (_packet->data) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } while (av_read_frame(_format_ctx, _packet) >= 0) { if (_packet->stream_index == _audio_index) { @@ -259,7 +267,11 @@ fetch_packet() { _packet_data = _packet->data; return; } +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } _packet->data = 0; _packet_size = 0; @@ -312,7 +324,11 @@ reload_buffer() { pkt.size = _packet_size; int len = avcodec_decode_audio4(_audio_ctx, _frame, &got_frame, &pkt); 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); +#endif bufsize = 0; if (got_frame) { diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 87b3b48395..45e72026c8 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -89,9 +89,13 @@ init_from(FfmpegVideo *source) { #ifdef HAVE_SWSCALE nassertv(_convert_ctx == NULL); - _convert_ctx = sws_getContext(_size_x, _size_y, - _video_ctx->pix_fmt, _size_x, _size_y, - PIX_FMT_BGR24, SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL); + _convert_ctx = sws_getContext(_size_x, _size_y, _video_ctx->pix_fmt, +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51, 74, 100) + _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 #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 59, 100) @@ -622,7 +626,11 @@ cleanup() { if (_packet) { if (_packet->data) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } delete _packet; _packet = NULL; @@ -812,14 +820,22 @@ fetch_packet(int default_frame) { bool FfmpegVideoCursor:: do_fetch_packet(int default_frame) { if (_packet->data) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } while (av_read_frame(_format_ctx, _packet) >= 0) { if (_packet->stream_index == _video_index) { _packet_frame = _packet->dts; return false; } +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } _packet->data = 0;