~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to .pc/0007-fix_FTBFS_with_ffmpeg_from_debian.patch/intern/ffmpeg/ffmpeg_compat.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * compatibility macros to make every ffmpeg installation appear
3
 
 * like the most current installation (wrapping some functionality sometimes)
4
 
 * it also includes all ffmpeg header files at once, no need to do it 
5
 
 * seperately.
6
 
 *
7
 
 * Copyright (c) 2011 Peter Schlaile
8
 
 *
9
 
 * This program is free software; you can redistribute it and/or modify
10
 
 * it under the terms of the GNU General Public License as published by
11
 
 * the Free Software Foundation; either version 2 of the License, or
12
 
 * (at your option) any later version.
13
 
 *
14
 
 * This program is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU General Public License for more details.
18
 
 *
19
 
 */
20
 
 
21
 
#ifndef __FFMPEG_COMPAT_H__
22
 
#define __FFMPEG_COMPAT_H__
23
 
 
24
 
#include <libavformat/avformat.h>
25
 
 
26
 
/* check our ffmpeg is new enough, avoids user complaints */
27
 
#if (LIBAVFORMAT_VERSION_MAJOR < 52) || ((LIBAVFORMAT_VERSION_MAJOR == 52) && (LIBAVFORMAT_VERSION_MINOR <= 64))
28
 
#  error "FFmpeg 0.7 or newer is needed, Upgrade your FFmpeg or disable it"
29
 
#endif
30
 
/* end sanity check */
31
 
 
32
 
 
33
 
#include <libavcodec/avcodec.h>
34
 
#include <libavutil/rational.h>
35
 
#include <libavutil/opt.h>
36
 
 
37
 
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101))
38
 
#define FFMPEG_HAVE_PARSE_UTILS 1
39
 
#include <libavutil/parseutils.h>
40
 
#endif
41
 
 
42
 
#include <libswscale/swscale.h>
43
 
#include <libavcodec/opt.h>
44
 
 
45
 
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105))
46
 
#define FFMPEG_HAVE_AVIO 1
47
 
#endif
48
 
 
49
 
#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)) || ((LIBAVCODEC_VERSION_MAJOR == 52) && (LIBAVCODEC_VERSION_MINOR >= 121))
50
 
#define FFMPEG_HAVE_DEFAULT_VAL_UNION 1
51
 
#endif
52
 
 
53
 
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101))
54
 
#define FFMPEG_HAVE_AV_DUMP_FORMAT 1
55
 
#endif
56
 
 
57
 
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 45))
58
 
#define FFMPEG_HAVE_AV_GUESS_FORMAT 1
59
 
#endif
60
 
 
61
 
#if (LIBAVCODEC_VERSION_MAJOR > 52) || ((LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 23))
62
 
#define FFMPEG_HAVE_DECODE_AUDIO3 1
63
 
#define FFMPEG_HAVE_DECODE_VIDEO2 1
64
 
#endif
65
 
 
66
 
#if (LIBAVCODEC_VERSION_MAJOR > 52) || ((LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 64))
67
 
#define FFMPEG_HAVE_AVMEDIA_TYPES 1
68
 
#endif
69
 
 
70
 
#if ((LIBAVCODEC_VERSION_MAJOR > 52) || (LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 29)) && \
71
 
        ((LIBSWSCALE_VERSION_MAJOR > 0) || (LIBSWSCALE_VERSION_MAJOR >= 0) && (LIBSWSCALE_VERSION_MINOR >= 10))
72
 
#define FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT
73
 
#endif
74
 
 
75
 
#if ((LIBAVUTIL_VERSION_MAJOR > 51) || (LIBAVUTIL_VERSION_MAJOR == 51) && (LIBAVUTIL_VERSION_MINOR >= 32))
76
 
#define FFMPEG_FFV1_ALPHA_SUPPORTED
77
 
#endif
78
 
 
79
 
#ifndef FFMPEG_HAVE_AVIO
80
 
#define AVIO_FLAG_WRITE URL_WRONLY
81
 
#define avio_open url_fopen
82
 
#define avio_tell url_ftell
83
 
#define avio_close url_fclose
84
 
#define avio_size url_fsize
85
 
#endif
86
 
 
87
 
/* there are some version inbetween, which have avio_... functions but no
88
 
   AVIO_FLAG_... */
89
 
#ifndef AVIO_FLAG_WRITE
90
 
#define AVIO_FLAG_WRITE URL_WRONLY
91
 
#endif
92
 
 
93
 
#ifndef AV_PKT_FLAG_KEY
94
 
#define AV_PKT_FLAG_KEY PKT_FLAG_KEY
95
 
#endif
96
 
 
97
 
#ifndef FFMPEG_HAVE_AV_DUMP_FORMAT
98
 
#define av_dump_format dump_format
99
 
#endif
100
 
 
101
 
#ifndef FFMPEG_HAVE_AV_GUESS_FORMAT
102
 
#define av_guess_format guess_format
103
 
#endif
104
 
 
105
 
#ifndef FFMPEG_HAVE_PARSE_UTILS
106
 
#define av_parse_video_rate av_parse_video_frame_rate
107
 
#endif
108
 
 
109
 
#ifdef FFMPEG_HAVE_DEFAULT_VAL_UNION
110
 
#define FFMPEG_DEF_OPT_VAL_INT(OPT) OPT->default_val.i64
111
 
#define FFMPEG_DEF_OPT_VAL_DOUBLE(OPT) OPT->default_val.dbl
112
 
#else
113
 
#define FFMPEG_DEF_OPT_VAL_INT(OPT) OPT->default_val
114
 
#define FFMPEG_DEF_OPT_VAL_DOUBLE(OPT) OPT->default_val
115
 
#endif
116
 
 
117
 
#ifndef FFMPEG_HAVE_AVMEDIA_TYPES
118
 
#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
119
 
#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
120
 
#endif
121
 
 
122
 
#ifndef FFMPEG_HAVE_DECODE_AUDIO3
123
 
static inline 
124
 
int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
125
 
                          int *frame_size_ptr, AVPacket *avpkt)
126
 
{
127
 
        return avcodec_decode_audio2(avctx, samples,
128
 
                                     frame_size_ptr, avpkt->data,
129
 
                                     avpkt->size);
130
 
}
131
 
#endif
132
 
 
133
 
#ifndef FFMPEG_HAVE_DECODE_VIDEO2
134
 
static inline
135
 
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
136
 
                         int *got_picture_ptr,
137
 
                         AVPacket *avpkt)
138
 
{
139
 
        return avcodec_decode_video(avctx, picture, got_picture_ptr,
140
 
                                    avpkt->data, avpkt->size);
141
 
}
142
 
#endif
143
 
 
144
 
static inline
145
 
int64_t av_get_pts_from_frame(AVFormatContext *avctx, AVFrame * picture)
146
 
{
147
 
        int64_t pts = picture->pkt_pts;
148
 
 
149
 
        if (pts == AV_NOPTS_VALUE) {
150
 
                pts = picture->pkt_dts;
151
 
        }
152
 
        if (pts == AV_NOPTS_VALUE) {
153
 
                pts = 0;
154
 
        }
155
 
 
156
 
        (void)avctx;
157
 
        return pts;
158
 
}
159
 
 
160
 
#endif