1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-13 01:20:34 +02:00

All "old" APIs are deprecated in ffmgeg 2.2.3 - remove them entirely

This commit is contained in:
AlexVinS
2015-11-11 13:07:56 +03:00
parent 4b94efe6b5
commit 33c933c208
2 changed files with 0 additions and 56 deletions

View File

@ -104,11 +104,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal
return false; return false;
} }
// Retrieve stream information // Retrieve stream information
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 17, 0)
if (av_find_stream_info(format) < 0)
#else
if (avformat_find_stream_info(format, nullptr) < 0) if (avformat_find_stream_info(format, nullptr) < 0)
#endif
return false; return false;
// Find the first video stream // Find the first video stream
@ -139,11 +135,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal
} }
// Open codec // Open codec
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 6, 0)
if ( avcodec_open(codecContext, codec) < 0 )
#else
if ( avcodec_open2(codecContext, codec, nullptr) < 0 ) if ( avcodec_open2(codecContext, codec, nullptr) < 0 )
#endif
{ {
// Could not open codec // Could not open codec
codec = nullptr; codec = nullptr;
@ -151,12 +143,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal
} }
// Allocate video frame // Allocate video frame
#if LIBAVUTIL_VERSION_MAJOR > 51
frame = av_frame_alloc(); frame = av_frame_alloc();
#else
frame = avcodec_alloc_frame();
#endif
//setup scaling //setup scaling
@ -191,35 +178,20 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal
{ // Convert the image into YUV format that SDL uses { // Convert the image into YUV format that SDL uses
sws = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt, sws = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt,
pos.w, pos.h, pos.w, pos.h,
#if LIBAVUTIL_VERSION_MAJOR > 51
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P,
#else
PIX_FMT_YUV420P,
#endif
SWS_BICUBIC, nullptr, nullptr, nullptr); SWS_BICUBIC, nullptr, nullptr, nullptr);
} }
else else
{ {
#if LIBAVUTIL_VERSION_MAJOR > 51
AVPixelFormat screenFormat = AV_PIX_FMT_NONE; AVPixelFormat screenFormat = AV_PIX_FMT_NONE;
#else
PixelFormat screenFormat = PIX_FMT_NONE;
#endif
if (screen->format->Bshift > screen->format->Rshift) if (screen->format->Bshift > screen->format->Rshift)
{ {
// this a BGR surface // this a BGR surface
switch (screen->format->BytesPerPixel) switch (screen->format->BytesPerPixel)
{ {
#if LIBAVUTIL_VERSION_MAJOR > 51
case 2: screenFormat = AV_PIX_FMT_BGR565; break; case 2: screenFormat = AV_PIX_FMT_BGR565; break;
case 3: screenFormat = AV_PIX_FMT_BGR24; break; case 3: screenFormat = AV_PIX_FMT_BGR24; break;
case 4: screenFormat = AV_PIX_FMT_BGR32; break; case 4: screenFormat = AV_PIX_FMT_BGR32; break;
#else
case 2: screenFormat = PIX_FMT_BGR565; break;
case 3: screenFormat = PIX_FMT_BGR24; break;
case 4: screenFormat = PIX_FMT_BGR32; break;
#endif
default: return false; default: return false;
} }
} }
@ -228,15 +200,9 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal
// this a RGB surface // this a RGB surface
switch (screen->format->BytesPerPixel) switch (screen->format->BytesPerPixel)
{ {
#if LIBAVUTIL_VERSION_MAJOR > 51
case 2: screenFormat = AV_PIX_FMT_RGB565; break; case 2: screenFormat = AV_PIX_FMT_RGB565; break;
case 3: screenFormat = AV_PIX_FMT_RGB24; break; case 3: screenFormat = AV_PIX_FMT_RGB24; break;
case 4: screenFormat = AV_PIX_FMT_RGB32; break; case 4: screenFormat = AV_PIX_FMT_RGB32; break;
#else
case 2: screenFormat = PIX_FMT_RGB565; break;
case 3: screenFormat = PIX_FMT_RGB24; break;
case 4: screenFormat = PIX_FMT_RGB32; break;
#endif
default: return false; default: return false;
} }
} }
@ -393,12 +359,7 @@ void CVideoPlayer::close()
if (frame) if (frame)
{ {
#if LIBAVUTIL_VERSION_MAJOR > 51
av_frame_free(&frame);//will be set to null av_frame_free(&frame);//will be set to null
#else
av_free(frame);
frame = nullptr;
#endif
} }
if (codec) if (codec)
@ -410,12 +371,7 @@ void CVideoPlayer::close()
if (format) if (format)
{ {
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 17, 0)
av_close_input_file(format);
format = nullptr;
#else
avformat_close_input(&format); avformat_close_input(&format);
#endif
} }
if (context) if (context)

View File

@ -51,18 +51,6 @@ public:
extern "C" { extern "C" {
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include <libswscale/swscale.h> #include <libswscale/swscale.h>
// compatibility with different versions od libavutil
#if (LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 42, 0)) || \
(LIBAVUTIL_VERSION_INT == AV_VERSION_INT(51, 73, 101))
#define AV_PIX_FMT_NONE PIX_FMT_NONE
#define AV_PIX_FMT_NV12 PIX_FMT_NV12
#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
#define AV_PIX_FMT_UYVY422 PIX_FMT_UYVY422
#define AV_PIX_FMT_YUYV422 PIX_FMT_YUYV422
#endif
} }
class CVideoPlayer : public IMainVideoPlayer class CVideoPlayer : public IMainVideoPlayer