diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index 14283fe19b..132f2ff9f9 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -203,7 +203,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; @@ -242,7 +246,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) { @@ -250,7 +258,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; @@ -300,7 +312,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 ec79cd40b2..0be8024a0a 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -82,9 +82,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 LIBAVCODEC_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) @@ -568,7 +572,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; @@ -737,14 +745,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;