summaryrefslogtreecommitdiff
blob: 2d4bafd95a7d82639e88592362875a011c1cf418 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
commit f460440b3f2a9db1a9deef3faf7dae6e626dd7b5
Author: Erik Massop <e.massop@hccnet.nl>
Date:   Sun Dec 22 23:34:12 2013 +0100

    OTHER: Require avcodec_decode_audio4
    
    This was introduced in versions 53.40.0 (ffmpeg) and 53.25.0 (libav) of
    avcodec. Hence we drop compatibility for earlier versions.

diff --git a/src/plugins/avcodec/avcodec.c b/src/plugins/avcodec/avcodec.c
index 023833d..6d0b667 100644
--- a/src/plugins/avcodec/avcodec.c
+++ b/src/plugins/avcodec/avcodec.c
@@ -154,7 +154,6 @@ xmms_avcodec_init (xmms_xform_t *xform)
 
 	xmms_xform_private_data_set (xform, data);
 
-	avcodec_init ();
 	avcodec_register_all ();
 
 	mimetype = xmms_xform_indata_get_str (xform,
@@ -225,7 +224,7 @@ xmms_avcodec_init (xmms_xform_t *xform)
 	data->codecctx->sample_rate = data->samplerate;
 	data->codecctx->channels = data->channels;
 	data->codecctx->bit_rate = data->bitrate;
-	CONTEXT_BPS (data->codecctx) = data->samplebits;
+	data->codecctx->bits_per_coded_sample = data->samplebits;
 	data->codecctx->block_align = data->block_align;
 	data->codecctx->extradata = data->extradata;
 	data->codecctx->extradata_size = data->extradata_size;
diff --git a/src/plugins/avcodec/avcodec_compat.h b/src/plugins/avcodec/avcodec_compat.h
index e74b3f8..b50fa4b 100644
--- a/src/plugins/avcodec/avcodec_compat.h
+++ b/src/plugins/avcodec/avcodec_compat.h
@@ -21,69 +21,6 @@
 # include "avcodec.h"
 #endif
 
-/* Map avcodec_decode_audio2 into the deprecated version
- * avcodec_decode_audio in versions earlier than 51.28 */
-#if LIBAVCODEC_VERSION_INT < 0x331c00
-# define avcodec_decode_audio2 avcodec_decode_audio
-#endif
-
-/* Handle API change that happened in libavcodec 52.00 */
-#if LIBAVCODEC_VERSION_INT < 0x340000
-# define CONTEXT_BPS(codecctx) (codecctx)->bits_per_sample
-#else
-# define CONTEXT_BPS(codecctx) (codecctx)->bits_per_coded_sample
-#endif
-
-/* Before 52.23 AVPacket was defined in avformat.h which we
- * do not want to depend on, so we define part of it manually
- * on versions smaller than 52.23 (this makes me cry) */
-#if LIBAVCODEC_VERSION_INT < 0x341700
-typedef struct AVPacket {
-        uint8_t *data;
-        int size;
-} AVPacket;
-#endif
-
-/* Same thing as above for av_init_packet and version 52.25 */
-#if LIBAVCODEC_VERSION_INT < 0x341900
-# define av_init_packet(pkt) do { \
-    (pkt)->data = NULL; \
-    (pkt)->size = 0; \
-  } while(0)
-#endif
-
-/* Map avcodec_decode_audio3 into the deprecated version
- * avcodec_decode_audio2 in versions earlier than 52.26 */
-#if LIBAVCODEC_VERSION_INT < 0x341a00
-# define avcodec_decode_audio3(avctx, samples, frame_size_ptr, avpkt) \
-    avcodec_decode_audio2(avctx, samples, frame_size_ptr, \
-                          (avpkt)->data, (avpkt)->size)
-#endif
-
-/* Handle API change that happened in libavcodec 52.64 */
-#if LIBAVCODEC_VERSION_INT < 0x344000
-# define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
-#endif
-
-/* Calling avcodec_init is not necessary after 53.04 (ffmpeg 0.9) */
-#if LIBAVCODEC_VERSION_INT >= 0x350400
-# define avcodec_init()
-#endif
-
-/* Map avcodec_alloc_context3 into the deprecated version
- * avcodec_alloc_context in versions earlier than 53.04 (ffmpeg 0.9) */
-#if LIBAVCODEC_VERSION_INT < 0x350400
-# define avcodec_alloc_context3(codec) \
-    avcodec_alloc_context()
-#endif
-
-/* Map avcodec_open2 into the deprecated version
- * avcodec_open in versions earlier than 53.04 (ffmpeg 0.9) */
-#if LIBAVCODEC_VERSION_INT < 0x350400
-# define avcodec_open2(avctx, codec, options) \
-    avcodec_open(avctx, codec)
-#endif
-
 /* Map avcodec_free_frame to av_freep if the former doesn't exist.
  * (This is in versions earlier than 54.28.0 (libav) or 54.59.100 (ffmpeg)) */
 #if ! HAVE_AVCODEC_FREE_FRAME
diff --git a/src/plugins/avcodec/wscript b/src/plugins/avcodec/wscript
index d367816..00b182b 100644
--- a/src/plugins/avcodec/wscript
+++ b/src/plugins/avcodec/wscript
@@ -1,6 +1,24 @@
 from waftools.plugin import plugin
 
 ## Code fragments for configuration
+avcodec_decode_audio4_fragment = """
+#ifdef HAVE_LIBAVCODEC_AVCODEC_H
+# include "libavcodec/avcodec.h"
+#else
+# include "avcodec.h"
+#endif
+int main(void) {
+    AVCodecContext *ctx;
+    AVFrame *frame;
+    int got_frame;
+    AVPacket *pkt;
+
+    avcodec_decode_audio4 (ctx, frame, &got_frame, pkt);
+
+    return 0;
+}
+"""
+
 avcodec_free_frame_fragment = """
 #ifdef HAVE_LIBAVCODEC_AVCODEC_H
 # include "libavcodec/avcodec.h"
@@ -22,6 +40,13 @@ def plugin_configure(conf):
     conf.check_cc(header_name="avcodec.h", uselib="avcodec", type="cshlib", mandatory=False)
     conf.check_cc(header_name="libavcodec/avcodec.h", uselib="avcodec", type="cshlib", mandatory=False)
 
+    # mandatory function avcodec_decode_audio4 available since
+    # * ffmpeg: commit e4de716, lavc 53.40.0, release 0.9
+    # * libav: commit 0eea212, lavc 53.25.0, release 0.8
+    conf.check_cc(fragment=avcodec_decode_audio4_fragment, uselib="avcodec",
+                  uselib_store="avcodec_decode_audio4",
+                  msg="Checking for function avcodec_decode_audio4", mandatory=True)
+
     # non-mandatory function avcodec_free_frame since
     # * ffmpeg: commit 46a3595, lavc 54.59.100, release 1.0
     # * libav: commit a42aada, lavc 54.28.0, release 9