Skip to content

Commit

Permalink
Fix compilation with FFmpeg 0.9.2 and 1.0.7
Browse files Browse the repository at this point in the history
Originally committed to SVN as r755.
  • Loading branch information
tgoyne committed May 19, 2013
1 parent b71b50b commit 199a28a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/ffmscompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
# undef CodecID
# endif
# if VERSION_CHECK(LIBAVCODEC_VERSION_INT, <, 54, 28, 0, 54, 59, 100)
# define avcodec_free_frame av_free
static void avcodec_free_frame(AVFrame **frame) { av_freep(frame); }
# endif
#endif

Expand Down
3 changes: 3 additions & 0 deletions src/core/audiosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ extern "C" {
#include <vector>
#include <list>
#include <memory>

#include "ffmscompat.h"

#include "indexing.h"
#include "utils.h"
#include "ffms.h"
Expand Down
18 changes: 16 additions & 2 deletions src/core/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#include <errno.h>
#include <algorithm>

// avcodec.h includes audioconvert.h, but we need to include audioconvert.h
// ourselves later
#define FF_API_OLD_AUDIOCONVERT 0
#define AVUTIL_AUDIOCONVERT_H

#include "utils.h"

#include "codectype.h"
Expand Down Expand Up @@ -217,9 +222,18 @@ void InitNullPacket(AVPacket &pkt) {
extern "C" {
#if VERSION_CHECK(LIBAVUTIL_VERSION_INT, >=, 52, 2, 0, 52, 6, 100)
#include <libavutil/channel_layout.h>
#elif VERSION_CHECK(LIBAVUTIL_VERSION_INT, >=, 51, 26, 0, 51, 45, 100)
#include <libavutil/audioconvert.h>
#else
#undef AVUTIL_AUDIOCONVERT_H

// Whether or not av_get_default_channel_layout exists in a given version
// depends on which branch that version is from, since FFmpeg doesn't
// understand the concept of version numbers. Work around this by always using
// our copy, since that's less effort than detecting whether or not it's
// available.
#define av_get_default_channel_layout av_get_default_channel_layout_hurr
#include "libavutil/audioconvert.h"
#undef av_get_default_channel_layout

static int64_t av_get_default_channel_layout(int nb_channels) {
switch(nb_channels) {
case 1: return AV_CH_LAYOUT_MONO;
Expand Down

0 comments on commit 199a28a

Please sign in to comment.