--- a/QTfrontend/util/LibavInteraction.cpp Mon Nov 19 02:48:21 2012 +0100
+++ b/QTfrontend/util/LibavInteraction.cpp Mon Nov 19 03:29:41 2012 +0100
@@ -70,7 +70,7 @@
// get list of all codecs
AVCodec* pCodec = NULL;
- while (pCodec = av_codec_next(pCodec))
+ while ((pCodec = av_codec_next(pCodec)))
{
#if LIBAVCODEC_VERSION_MAJOR >= 54
if (!av_codec_is_encoder(pCodec))
@@ -162,7 +162,7 @@
// get list of all formats
AVOutputFormat* pFormat = NULL;
- while (pFormat = av_oformat_next(pFormat))
+ while ((pFormat = av_oformat_next(pFormat)))
{
if (!pFormat->extensions)
continue;
@@ -270,7 +270,7 @@
QByteArray utf8path = filepath.toUtf8();
if (avformat_open_input(&pContext, utf8path.data(), NULL, NULL) < 0)
return "";
-#if LIBAVFORMAT_VERSION_MAJOR < 54
+#if LIBAVFORMAT_VERSION_MAJOR < 53
if (av_find_stream_info(pContext) < 0)
#else
if (avformat_find_stream_info(pContext, NULL) < 0)
@@ -308,7 +308,7 @@
AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0);
if (pComment)
desc += QString("\n") + pComment->value;
-#if LIBAVFORMAT_VERSION_MAJOR < 54
+#if LIBAVFORMAT_VERSION_MAJOR < 53
av_close_input_file(pContext);
#else
avformat_close_input(&pContext);
--- a/hedgewars/avwrapper.c Mon Nov 19 02:48:21 2012 +0100
+++ b/hedgewars/avwrapper.c Mon Nov 19 03:29:41 2012 +0100
@@ -22,6 +22,7 @@
#include <string.h>
#include <stdarg.h>
#include "libavformat/avformat.h"
+#include "libavutil/mathematics.h"
#ifndef AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE AVIO_WRONLY
@@ -47,13 +48,6 @@
static int16_t* g_pSamples;
static int g_NumSamples;
-/*
-Initially I wrote code for latest ffmpeg, but on Linux (Ubuntu)
-only older version is available from repository. That's why you see here
-all of this #if LIBAVCODEC_VERSION_MAJOR < 54.
-Actually, it may be possible to remove code for newer version
-and use only code for older version.
-*/
#if LIBAVCODEC_VERSION_MAJOR < 54
#define OUTBUFFER_SIZE 200000
@@ -65,7 +59,7 @@
static void FatalError(const char* pFmt, ...)
{
- const char Buffer[1024];
+ char Buffer[1024];
va_list VaArgs;
va_start(VaArgs, pFmt);
@@ -83,7 +77,7 @@
// (there is mutex in AddFileLogRaw).
static void LogCallback(void* p, int Level, const char* pFmt, va_list VaArgs)
{
- const char Buffer[1024];
+ char Buffer[1024];
vsnprintf(Buffer, 1024, pFmt, VaArgs);
AddFileLogRaw(Buffer);
@@ -91,7 +85,7 @@
static void Log(const char* pFmt, ...)
{
- const char Buffer[1024];
+ char Buffer[1024];
va_list VaArgs;
va_start(VaArgs, pFmt);
@@ -103,7 +97,7 @@
static void AddAudioStream()
{
-#if LIBAVFORMAT_VERSION_MAJOR >= 54
+#if LIBAVFORMAT_VERSION_MAJOR >= 53
g_pAStream = avformat_new_stream(g_pContainer, g_pACodec);
#else
g_pAStream = av_new_stream(g_pContainer, 1);
@@ -175,7 +169,7 @@
int NumSamples = fread(g_pSamples, 2*g_Channels, g_NumSamples, g_pSoundFile);
-#if LIBAVCODEC_VERSION_MAJOR >= 54
+#if LIBAVCODEC_VERSION_MAJOR >= 53
AVFrame* pFrame = NULL;
if (NumSamples > 0)
{
@@ -215,7 +209,7 @@
// add a video output stream
static void AddVideoStream()
{
-#if LIBAVFORMAT_VERSION_MAJOR >= 54
+#if LIBAVFORMAT_VERSION_MAJOR >= 53
g_pVStream = avformat_new_stream(g_pContainer, g_pVCodec);
#else
g_pVStream = av_new_stream(g_pContainer, 0);
@@ -254,7 +248,7 @@
if (g_pFormat->flags & AVFMT_GLOBALHEADER)
g_pVideo->flags |= CODEC_FLAG_GLOBAL_HEADER;
-#if LIBAVCODEC_VERSION_MAJOR < 54
+#if LIBAVCODEC_VERSION_MAJOR < 53
// for some versions of ffmpeg x264 options must be set explicitly
if (strcmp(g_pVCodec->name, "libx264") == 0)
{