summaryrefslogtreecommitdiff
path: root/community-testing/deadbeef/deadbeef-0.5.1-ffmpeg-AV_VERSION_INT.patch
blob: db1c796387200154dc4d4a7fbb5a75fd32223491 (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
From 2bb5828e58fa8c187377f8ba75f8eb73a53ed7ca Mon Sep 17 00:00:00 2001
From: Igor Murzov <e-mail@date.by>
Date: Mon, 4 Jul 2011 16:47:25 +0400
Subject: [PATCH 1/2] ffmpeg: define fallback macro AV_VERSION_INT()

For ffmpeg < 0.5.  Copied from libavutil 0.5.

ffmpeg: don't use deprecated CODEC_TYPE_AUDIO with new lavc

fixes build with lavc 53.

ffmpeg: fix erroneous version comparisons

Comparing versions this way: (x.y < x1.y1) is obviously equivalent to
(x < x1 || (x == x1 && y < y1)), not to (x <= x1 && y < y1).

ffmpeg: use av_register_protocol2() if available

fixes usage with ffmpeg-0.8
---
 plugins/ffmpeg/ffmpeg.c |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/plugins/ffmpeg/ffmpeg.c b/plugins/ffmpeg/ffmpeg.c
index cd7edf4..0cb9955 100644
--- a/plugins/ffmpeg/ffmpeg.c
+++ b/plugins/ffmpeg/ffmpeg.c
@@ -44,6 +44,10 @@
 #define av_register_protocol register_protocol
 #endif
 
+#ifndef AV_VERSION_INT
+#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c)
+#endif
+
 #endif
 
 //#define trace(...) { fprintf(stderr, __VA_ARGS__); }
@@ -140,7 +144,12 @@ ffmpeg_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
     for (i = 0; i < info->fctx->nb_streams; i++)
     {
         info->ctx = info->fctx->streams[i]->codec;
-        if (info->ctx->codec_type == CODEC_TYPE_AUDIO)
+        if (info->ctx->codec_type ==
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 64, 0)
+            AVMEDIA_TYPE_AUDIO)
+#else
+            CODEC_TYPE_AUDIO)
+#endif
         {
             info->codec = avcodec_find_decoder (info->ctx->codec_id);
             if (info->codec != NULL) {
@@ -279,10 +288,10 @@ ffmpeg_read (DB_fileinfo_t *_info, char *bytes, int size) {
             int out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
             int len;
             //trace ("in: out_size=%d(%d), size=%d\n", out_size, AVCODEC_MAX_AUDIO_FRAME_SIZE, size);
-#if (LIBAVCODEC_VERSION_MAJOR <= 52) && (LIBAVCODEC_VERSION_MINOR <= 25)
-            len = avcodec_decode_audio2 (info->ctx, (int16_t *)info->buffer, &out_size, info->pkt.data, info->pkt.size);
-#else
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
             len = avcodec_decode_audio3 (info->ctx, (int16_t *)info->buffer, &out_size, &info->pkt);
+#else
+            len = avcodec_decode_audio2 (info->ctx, (int16_t *)info->buffer, &out_size, info->pkt.data, info->pkt.size);
 #endif
             trace ("out: out_size=%d, len=%d\n", out_size, len);
             if (len <= 0) {
@@ -418,7 +427,7 @@ static const char *map[] = {
 
 static int
 ffmpeg_read_metadata_internal (DB_playItem_t *it, AVFormatContext *fctx) {
-#if LIBAVFORMAT_VERSION_MAJOR <= 52 && LIBAVFORMAT_VERSION_MINOR < 43
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52,43,0)
     if (!strlen (fctx->title)) {
         // title is empty, this call will set track title to filename without extension
         deadbeef->pl_add_meta (it, "title", NULL);
@@ -490,7 +499,12 @@ ffmpeg_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
     for (i = 0; i < fctx->nb_streams; i++)
     {
         ctx = fctx->streams[i]->codec;
-        if (ctx->codec_type == CODEC_TYPE_AUDIO)
+        if (ctx->codec_type ==
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 64, 0)
+            AVMEDIA_TYPE_AUDIO)
+#else
+            CODEC_TYPE_AUDIO)
+#endif
         {
             codec = avcodec_find_decoder(ctx->codec_id);
             if (codec != NULL && !strcasecmp (codec->name, "alac")) { // only open alac streams
@@ -704,7 +718,11 @@ ffmpeg_start (void) {
     ffmpeg_init_exts ();
     avcodec_init ();
     av_register_all ();
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 64, 0)
+    av_register_protocol2 (&vfswrapper, sizeof(vfswrapper));
+#else
     av_register_protocol (&vfswrapper);
+#endif
     return 0;
 }
 
@@ -745,7 +763,12 @@ ffmpeg_read_metadata (DB_playItem_t *it) {
     for (i = 0; i < fctx->nb_streams; i++)
     {
         ctx = fctx->streams[i]->codec;
-        if (ctx->codec_type == CODEC_TYPE_AUDIO)
+        if (ctx->codec_type ==
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 64, 0)
+            AVMEDIA_TYPE_AUDIO)
+#else
+            CODEC_TYPE_AUDIO)
+#endif
         {
             codec = avcodec_find_decoder(ctx->codec_id);
             if (codec != NULL)
-- 
1.7.8.4