Backport fixes for Arch compile issues to 1.9

This commit is contained in:
rdb 2016-03-24 23:57:00 +01:00
parent ce947adf8f
commit 2b034506fa
3 changed files with 35 additions and 4 deletions

View File

@ -20,7 +20,6 @@
#ifdef HAVE_PYTHON #ifdef HAVE_PYTHON
#undef HAVE_LONG_LONG // NSPR and Python both define this.
#undef _POSIX_C_SOURCE #undef _POSIX_C_SOURCE
#include <Python.h> #include <Python.h>

View File

@ -210,7 +210,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;
@ -251,7 +255,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) {
@ -259,7 +267,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;
@ -312,7 +324,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

@ -89,9 +89,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 LIBAVUTIL_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)
@ -622,7 +626,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;
@ -812,14 +820,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;