From 7d414500c6578bfbb1b1f489acc2ea7075de5dbb Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 22 Dec 2016 11:32:02 +0100 Subject: [PATCH] Various compile fixes --- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 15 ++++++++------- panda/src/ffmpeg/ffmpegVideoCursor.h | 6 +----- panda/src/movies/dr_flac.h | 8 ++++++-- .../src/putil/cachedTypedWritableReferenceCount.h | 4 +++- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 77598a3644..8e2d0b0e47 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -44,10 +44,11 @@ PStatCollector FfmpegVideoCursor::_export_frame_pcollector("*:FFMPEG Convert Vid #define AV_PIX_FMT_NONE PIX_FMT_NONE #define AV_PIX_FMT_BGR24 PIX_FMT_BGR24 #define AV_PIX_FMT_BGRA PIX_FMT_BGRA +typedef PixelFormat AVPixelFormat; #endif #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 32, 100) -#define AV_PIX_FMT_FLAG_ALPHA PIX_FMT_FLAG_ALPHA +#define AV_PIX_FMT_FLAG_ALPHA PIX_FMT_ALPHA #endif /** @@ -65,7 +66,7 @@ FfmpegVideoCursor() : _format_ctx(NULL), _video_ctx(NULL), _convert_ctx(NULL), - _pixel_format(AV_PIX_FMT_NONE), + _pixel_format((int)AV_PIX_FMT_NONE), _video_index(-1), _frame(NULL), _frame_out(NULL), @@ -121,16 +122,16 @@ init_from(FfmpegVideo *source) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(_video_ctx->pix_fmt); if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA) != 0) { _num_components = 4; - _pixel_format = AV_PIX_FMT_BGRA; + _pixel_format = (int)AV_PIX_FMT_BGRA; } else { _num_components = 3; - _pixel_format = AV_PIX_FMT_BGR24; + _pixel_format = (int)AV_PIX_FMT_BGR24; } #ifdef HAVE_SWSCALE nassertv(_convert_ctx == NULL); _convert_ctx = sws_getContext(_size_x, _size_y, _video_ctx->pix_fmt, - _size_x, _size_y, _pixel_format, + _size_x, _size_y, (AVPixelFormat)_pixel_format, SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL); #endif // HAVE_SWSCALE @@ -1115,7 +1116,7 @@ export_frame(FfmpegBuffer *buffer) { nassertv(_convert_ctx != NULL && _frame != NULL && _frame_out != NULL); sws_scale(_convert_ctx, _frame->data, _frame->linesize, 0, _size_y, _frame_out->data, _frame_out->linesize); #else - img_convert((AVPicture *)_frame_out, _pixel_format, + img_convert((AVPicture *)_frame_out, (AVPixelFormat)_pixel_format, (AVPicture *)_frame, _video_ctx->pix_fmt, _size_x, _size_y); #endif } else { @@ -1123,7 +1124,7 @@ export_frame(FfmpegBuffer *buffer) { nassertv(_convert_ctx != NULL && _frame != NULL && _frame_out != NULL); sws_scale(_convert_ctx, _frame->data, _frame->linesize, 0, _size_y, _frame_out->data, _frame_out->linesize); #else - img_convert((AVPicture *)_frame_out, _pixel_format, + img_convert((AVPicture *)_frame_out, (AVPixelFormat)_pixel_format, (AVPicture *)_frame, _video_ctx->pix_fmt, _size_x, _size_y); #endif } diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.h b/panda/src/ffmpeg/ffmpegVideoCursor.h index 23cfda389b..b37637a0b0 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.h +++ b/panda/src/ffmpeg/ffmpegVideoCursor.h @@ -105,11 +105,7 @@ private: ThreadPriority _thread_priority; PT(GenericThread) _thread; -#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 74, 100) - PixelFormat _pixel_format; -#else - AVPixelFormat _pixel_format; -#endif + int _pixel_format; // This global Mutex protects calls to avcodec_opencloseetc. static ReMutex _av_lock; diff --git a/panda/src/movies/dr_flac.h b/panda/src/movies/dr_flac.h index 26d133191d..fdac6a2f79 100644 --- a/panda/src/movies/dr_flac.h +++ b/panda/src/movies/dr_flac.h @@ -534,7 +534,9 @@ static DRFLAC_INLINE uint64_t drflac__swap_endian_uint64(uint64_t n) static DRFLAC_INLINE uint32_t drflac__be2host_32(uint32_t n) { -#ifdef __linux__ +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER == __ORDER_LITTLE_ENDIAN__) + return drflac__swap_endian_uint32(n); +#elif defined(__linux__) return be32toh(n); #else if (drflac__is_little_endian()) { @@ -547,7 +549,9 @@ static DRFLAC_INLINE uint32_t drflac__be2host_32(uint32_t n) static DRFLAC_INLINE uint64_t drflac__be2host_64(uint64_t n) { -#ifdef __linux__ +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER == __ORDER_LITTLE_ENDIAN__) + return drflac__swap_endian_uint64(n); +#elif defined(__linux__) return be64toh(n); #else if (drflac__is_little_endian()) { diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.h b/panda/src/putil/cachedTypedWritableReferenceCount.h index 7420253fcb..f2e9362dca 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.h +++ b/panda/src/putil/cachedTypedWritableReferenceCount.h @@ -46,8 +46,10 @@ PUBLISHED: MAKE_PROPERTY(cache_ref_count, get_cache_ref_count); -protected: +public: INLINE void cache_ref_only() const; + +protected: INLINE void cache_unref_only() const; bool do_test_ref_count_integrity() const;