From 1e00590f1c2f8d98ed52f8e12d70723165edc9d3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 23 May 2011 15:56:26 +0000 Subject: Fix #26728: crash with load/save on Mac, on files that close & open a window when loading them. Custom cursor shown during load was not freed correctly when closing the old window, which resulted in unpredictable crashes later on. --- intern/ghost/intern/GHOST_WindowCocoa.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 8d28c9d5b17..fb7d4a459c7 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -461,9 +461,13 @@ GHOST_WindowCocoa::GHOST_WindowCocoa( GHOST_WindowCocoa::~GHOST_WindowCocoa() { - if (m_customCursor) delete m_customCursor; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + if (m_customCursor) { + [m_customCursor release]; + m_customCursor = nil; + } + [m_openGLView release]; if (m_window) { -- cgit v1.2.3 From 3e62e518ec2d7e41658451d8c37692e31c20523c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 24 May 2011 11:01:39 +0000 Subject: Attempt to fix mingw 64 bit compile error. --- intern/bsp/CMakeLists.txt | 1 + intern/bsp/SConscript | 2 +- intern/container/CTR_TaggedIndex.h | 10 ++++++---- intern/decimation/CMakeLists.txt | 1 + intern/decimation/SConscript | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) (limited to 'intern') diff --git a/intern/bsp/CMakeLists.txt b/intern/bsp/CMakeLists.txt index 2e615314543..9f281586867 100644 --- a/intern/bsp/CMakeLists.txt +++ b/intern/bsp/CMakeLists.txt @@ -27,6 +27,7 @@ set(INC ./intern ../container + ../guardedalloc ../moto/include ../memutil ) diff --git a/intern/bsp/SConscript b/intern/bsp/SConscript index 43952f4ff18..4927c33dc8a 100644 --- a/intern/bsp/SConscript +++ b/intern/bsp/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('intern/*.cpp') -incs = 'intern ../container ../moto/include ../memutil' +incs = 'intern ../container ../moto/include ../memutil ../guardedalloc' env.BlenderLib ('bf_intern_bsp', sources, Split(incs), [], libtype=['core','player'], priority=[200,100] ) diff --git a/intern/container/CTR_TaggedIndex.h b/intern/container/CTR_TaggedIndex.h index 0a57ce11d19..f48d492c28a 100644 --- a/intern/container/CTR_TaggedIndex.h +++ b/intern/container/CTR_TaggedIndex.h @@ -52,6 +52,8 @@ #include +#include "MEM_sys_types.h" + enum { empty_tag = 0x0, @@ -100,9 +102,9 @@ public: #if defined(_WIN64) CTR_TaggedIndex( - const unsigned __int64 val + const unsigned int64_t val ) : - m_val ( ((unsigned __int64)val & index_mask) + m_val ( ((unsigned int64_t)val & index_mask) | ( (empty_tag << tag_shift) & (~index_mask) ) ) { } @@ -140,8 +142,8 @@ public: } #if defined(_WIN64) - operator unsigned __int64 () const { - return (unsigned __int64)(m_val & index_mask); + operator unsigned int64_t () const { + return (unsigned int64_t)(m_val & index_mask); } #endif diff --git a/intern/decimation/CMakeLists.txt b/intern/decimation/CMakeLists.txt index b726a8cd6a1..6f9137b7189 100644 --- a/intern/decimation/CMakeLists.txt +++ b/intern/decimation/CMakeLists.txt @@ -27,6 +27,7 @@ set(INC . ../container + ../guardedalloc ../memutil ../moto/include ) diff --git a/intern/decimation/SConscript b/intern/decimation/SConscript index 6e2929cb650..6f4befb3ffa 100644 --- a/intern/decimation/SConscript +++ b/intern/decimation/SConscript @@ -3,6 +3,6 @@ Import ('env') sources = env.Glob('intern/*.cpp') -incs = '. ../moto/include ../container ../memutil' +incs = '. ../moto/include ../container ../memutil ../guardedalloc' env.BlenderLib ('bf_intern_decimate', sources, Split(incs) , [], libtype=['core', 'player'], priority = [200, 100] ) -- cgit v1.2.3 From 4ac88bd16f3dfd9b3e338775a9eeb512b526b60a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 24 May 2011 11:19:11 +0000 Subject: Fix for mingw 64bit fix. --- intern/container/CTR_TaggedIndex.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'intern') diff --git a/intern/container/CTR_TaggedIndex.h b/intern/container/CTR_TaggedIndex.h index f48d492c28a..b5284a5da30 100644 --- a/intern/container/CTR_TaggedIndex.h +++ b/intern/container/CTR_TaggedIndex.h @@ -102,9 +102,9 @@ public: #if defined(_WIN64) CTR_TaggedIndex( - const unsigned int64_t val + const uint64_t val ) : - m_val ( ((unsigned int64_t)val & index_mask) + m_val ( ((uint64_t)val & index_mask) | ( (empty_tag << tag_shift) & (~index_mask) ) ) { } @@ -142,8 +142,8 @@ public: } #if defined(_WIN64) - operator unsigned int64_t () const { - return (unsigned int64_t)(m_val & index_mask); + operator uint64_t () const { + return (uint64_t)(m_val & index_mask); } #endif -- cgit v1.2.3 From 4b9a63c6d3b6fc90259bea708355d678d3681bc3 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Thu, 26 May 2011 21:57:02 +0000 Subject: == FFMPEG == * removed a lot of old cruft code for ancient ffmpeg versions * made it compile again against latest ffmpeg / libav GIT (also shouldn't break distro ffmpegs, since those API changes have been introduced over a year ago. If it nevertheless breaks, please send me an email) --- intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'intern') diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp index ea6e0c549fa..e748235e40e 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp @@ -52,6 +52,10 @@ int AUD_FFMPEGReader::decode(AVPacket* packet, AUD_Buffer& buffer) int read_length, data_size; + AVPacket tmp_pkt; + + av_init_packet(&tmp_pkt); + // as long as there is still data in the package while(audio_pkg_size > 0) { @@ -64,15 +68,14 @@ int AUD_FFMPEGReader::decode(AVPacket* packet, AUD_Buffer& buffer) // read samples from the packet data_size = buf_size - buf_pos; - /*read_length = avcodec_decode_audio3(m_codecCtx, - (int16_t*)(((data_t*)buffer.getBuffer())+buf_pos), - &data_size, - packet);*/ - read_length = avcodec_decode_audio2(m_codecCtx, - (int16_t*)(((data_t*)buffer.getBuffer()) + buf_pos), - &data_size, - audio_pkg_data, - audio_pkg_size); + + tmp_pkt.data = audio_pkg_data; + tmp_pkt.size = audio_pkg_size; + + read_length = avcodec_decode_audio3( + m_codecCtx, + (int16_t*)(((data_t*)buffer.getBuffer()) + buf_pos), + &data_size, &tmp_pkt); // read error, next packet! if(read_length < 0) @@ -112,7 +115,7 @@ void AUD_FFMPEGReader::init() for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++) { - if((m_formatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) + if((m_formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) && (m_stream < 0)) { m_stream=i; -- cgit v1.2.3 From 42121590f4bfd65f26e8ec705a660f4cc1bd826e Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Fri, 27 May 2011 23:33:40 +0000 Subject: == FFMPEG == Added central compatibility header file, which enables blender to compile against very old ffmpeg versions as well as very new versions using the *NEW* API. (Old API functions are simulated using macros and inline functions) Added a whole lot of additional checks, tested against 6 different versions down the timeline, hopefully, now finally all is well. --- intern/audaspace/CMakeLists.txt | 1 + intern/audaspace/SConscript | 2 +- intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp | 1 + intern/ffmpeg/ffmpeg_compat.h | 133 +++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 intern/ffmpeg/ffmpeg_compat.h (limited to 'intern') diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt index 74f483eab05..a2468d0071e 100644 --- a/intern/audaspace/CMakeLists.txt +++ b/intern/audaspace/CMakeLists.txt @@ -26,6 +26,7 @@ set(INC FX SRC ${PTHREADS_INC} ${LIBSAMPLERATE_INC} + ../ffmpeg ) set(SRC diff --git a/intern/audaspace/SConscript b/intern/audaspace/SConscript index ecc94987185..67f859b0e5f 100644 --- a/intern/audaspace/SConscript +++ b/intern/audaspace/SConscript @@ -8,7 +8,7 @@ defs = [] if env['WITH_BF_FFMPEG']: sources += env.Glob('ffmpeg/*.cpp') - incs += ' ffmpeg ' + env['BF_FFMPEG_INC'] + incs += ' ffmpeg #/intern/ffmpeg ' + env['BF_FFMPEG_INC'] defs.append('WITH_FFMPEG') if env['WITH_BF_SDL']: diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp index e748235e40e..4597432e7d1 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp @@ -39,6 +39,7 @@ extern "C" { #include #include +#include "ffmpeg_compat.h" } int AUD_FFMPEGReader::decode(AVPacket* packet, AUD_Buffer& buffer) diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h new file mode 100644 index 00000000000..834df3d7055 --- /dev/null +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -0,0 +1,133 @@ +#ifndef __ffmpeg_compat_h_included__ +#define __ffmpeg_compat_h_included__ 1 + +/* + * $Id$ + * + * compatibility macros to make every ffmpeg installation appear + * like the most current installation (wrapping some functionality sometimes) + * it also includes all ffmpeg header files at once, no need to do it + * seperately. + * + * Copyright (c) 2011 Peter Schlaile + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + + +#include +#include +#include + +#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) +#define FFMPEG_HAVE_PARSE_UTILS 1 +#include +#endif + +#include +#include + +#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105)) +#define FFMPEG_HAVE_AVIO 1 +#endif + +#if (LIBAVFORMAT_VERSION_MAJOR > 53) || ((LIBAVFORMAT_VERSION_MAJOR >= 53) && (LIBAVFORMAT_VERSION_MINOR >= 1)) +#define FFMPEG_HAVE_DEFAULT_VAL_UNION 1 +#endif + +#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) +#define FFMPEG_HAVE_AV_DUMP_FORMAT 1 +#endif + +#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 45)) +#define FFMPEG_HAVE_AV_GUESS_FORMAT 1 +#endif + +#if (LIBAVCODEC_VERSION_MAJOR > 52) || ((LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 23)) +#define FFMPEG_HAVE_DECODE_AUDIO3 1 +#define FFMPEG_HAVE_DECODE_VIDEO2 1 +#endif + +#if (LIBAVCODEC_VERSION_MAJOR > 52) || ((LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 64)) +#define FFMPEG_HAVE_AVMEDIA_TYPES 1 +#endif + +#if (LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 29) && \ + (LIBSWSCALE_VERSION_MAJOR >= 0) && (LIBSWSCALE_VERSION_MINOR >= 10) +#define FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT +#endif + +#ifndef FFMPEG_HAVE_AVIO +#define AVIO_FLAG_WRITE URL_WRONLY +#define avio_open url_fopen +#define avio_tell url_ftell +#define avio_close url_fclose +#endif + +/* there are some version inbetween, which have avio_... functions but no + AVIO_FLAG_... */ +#ifndef AVIO_FLAG_WRITE +#define AVIO_FLAG_WRITE URL_WRONLY +#endif + +#ifndef AV_PKT_FLAG_KEY +#define AV_PKT_FLAG_KEY PKT_FLAG_KEY +#endif + +#ifndef FFMPEG_HAVE_AV_DUMP_FORMAT +#define av_dump_format dump_format +#endif + +#ifndef FFMPEG_HAVE_AV_GUESS_FORMAT +#define av_guess_format guess_format +#endif + +#ifndef FFMPEG_HAVE_PARSE_UTILS +#define av_parse_video_rate av_parse_video_frame_rate +#endif + +#ifdef FFMPEG_HAVE_DEFAULT_VAL_UNION +#define FFMPEG_DEF_OPT_VAL_INT(OPT) OPT->default_val.i64 +#define FFMPEG_DEF_OPT_VAL_DOUBLE(OPT) OPT->default_val.dbl +#else +#define FFMPEG_DEF_OPT_VAL_INT(OPT) OPT->default_val +#define FFMPEG_DEF_OPT_VAL_DOUBLE(OPT) OPT->default_val +#endif + +#ifndef FFMPEG_HAVE_AVMEDIA_TYPES +#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO +#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO +#endif + +#ifndef FFMPEG_HAVE_DECODE_AUDIO3 +static inline +int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, AVPacket *avpkt) +{ + return avcodec_decode_audio2(avctx, samples, + frame_size_ptr, avpkt->data, + avpkt->size); +} +#endif + +#ifndef FFMPEG_HAVE_DECODE_VIDEO2 +static inline +int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + AVPacket *avpkt) +{ + return avcodec_decode_video(avctx, picture, got_picture_ptr, + avpkt->data, avpkt->size); +} +#endif + +#endif -- cgit v1.2.3 From 3ca0bfdd6677f870acca9fa87cf5232e8f3afb13 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sat, 28 May 2011 00:07:33 +0000 Subject: == FFMPEG == Small fix for a very old bug in swscaler color space support detection. --- intern/ffmpeg/ffmpeg_compat.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'intern') diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index 834df3d7055..06e170837d1 100644 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -61,8 +61,8 @@ #define FFMPEG_HAVE_AVMEDIA_TYPES 1 #endif -#if (LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 29) && \ - (LIBSWSCALE_VERSION_MAJOR >= 0) && (LIBSWSCALE_VERSION_MINOR >= 10) +#if ((LIBAVCODEC_VERSION_MAJOR > 52) || (LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 29)) && \ + ((LIBSWSCALE_VERSION_MAJOR > 0) || (LIBSWSCALE_VERSION_MAJOR >= 0) && (LIBSWSCALE_VERSION_MINOR >= 10)) #define FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT #endif -- cgit v1.2.3 From ce8467ffd3407197b16c267ecee9030079e13a37 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sat, 28 May 2011 14:16:56 +0000 Subject: == FFMPEG == Did some fine-tuning for AVOption -> AVOption2 crazyness --- intern/ffmpeg/ffmpeg_compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'intern') diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index 06e170837d1..ab819f41ac3 100644 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -40,7 +40,7 @@ #define FFMPEG_HAVE_AVIO 1 #endif -#if (LIBAVFORMAT_VERSION_MAJOR > 53) || ((LIBAVFORMAT_VERSION_MAJOR >= 53) && (LIBAVFORMAT_VERSION_MINOR >= 1)) +#if (LIBAVCODEC_VERSION_MAJOR > 53) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR > 1)) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR == 1) && (LIBAVCODEC_VERSION_MICRO >= 1)) #define FFMPEG_HAVE_DEFAULT_VAL_UNION 1 #endif -- cgit v1.2.3 From d635a2b1438aaff8b2aed47e9005107c0ccc09cd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 28 May 2011 15:34:02 +0000 Subject: Disabling xinput wasn't done completely. --- intern/ghost/intern/GHOST_SystemX11.cpp | 3 ++- intern/ghost/intern/GHOST_WindowX11.cpp | 5 ++++- intern/ghost/intern/GHOST_WindowX11.h | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index b44f2b18225..c53bf7de36c 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -795,6 +795,7 @@ GHOST_SystemX11::processEvent(XEvent *xe) } default: { +#ifdef WITH_X11_XINPUT if(xe->type == window->GetXTablet().MotionEvent) { XDeviceMotionEvent* data = (XDeviceMotionEvent*)xe; @@ -818,7 +819,7 @@ GHOST_SystemX11::processEvent(XEvent *xe) } else if(xe->type == window->GetXTablet().ProxOutEvent) window->GetXTablet().CommonData.Active= GHOST_kTabletModeNone; - +#endif // WITH_X11_XINPUT break; } } diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index aea5b5156d9..fc72ea09f40 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -182,9 +182,12 @@ GHOST_WindowX11( Atom atoms[2]; int natom; int glxVersionMajor, glxVersionMinor; // As in GLX major.minor - + +#ifdef WITH_X11_XINPUT /* initialize incase X11 fails to load */ memset(&m_xtablet, 0, sizeof(m_xtablet)); +#endif + m_visual= NULL; if (!glXQueryVersion(m_display, &glxVersionMajor, &glxVersionMinor)) { diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h index 96d8ad77d10..2cb269ea919 100644 --- a/intern/ghost/intern/GHOST_WindowX11.h +++ b/intern/ghost/intern/GHOST_WindowX11.h @@ -38,7 +38,9 @@ #include #include // For tablets -#include +#ifdef WITH_X11_XINPUT +# include +#endif #include @@ -190,7 +192,7 @@ public: Window getXWindow( ); - +#ifdef WITH_X11_XINPUT class XTablet { public: @@ -214,6 +216,10 @@ public: const GHOST_TabletData* GetTabletData() { return &m_xtablet.CommonData; } +#else // WITH_X11_XINPUT + const GHOST_TabletData* GetTabletData() + { return NULL; } +#endif // WITH_X11_XINPUT /* * Need this in case that we want start the window @@ -321,7 +327,9 @@ private : getEmptyCursor( ); +#ifdef WITH_X11_XINPUT void initXInputDevices(); +#endif GLXContext m_context; Window m_window; @@ -350,8 +358,10 @@ private : /** Cache of XC_* ID's to XCursor structures */ std::map m_standard_cursors; +#ifdef WITH_X11_XINPUT /* Tablet devices */ XTablet m_xtablet; +#endif void icccmSetState(int state); int icccmGetState() const; -- cgit v1.2.3