]> git.pld-linux.org Git - packages/xmms2.git/blob - xmms2-ffmpeg.patch
1abb1914318d402af9e36f0535afe350c4809c32
[packages/xmms2.git] / xmms2-ffmpeg.patch
1 --- xmms2-0.2DrJekyll/src/plugins/avformat/avformat.c.orig      2007-05-20 17:55:40.000000000 +0200
2 +++ xmms2-0.2DrJekyll/src/plugins/avformat/avformat.c   2023-05-17 17:39:28.342596542 +0200
3 @@ -24,7 +24,7 @@
4  #include <glib.h>
5  
6  #undef ABS
7 -#include "avformat.h"
8 +#include <libavformat/avformat.h>
9  
10  #define AVFORMAT_BUFFER_SIZE 4096
11  
12 @@ -33,7 +33,7 @@ typedef struct {
13  
14         AVFormatContext *fmtctx;
15         AVCodecContext *codecctx;
16 -       offset_t offset;
17 +       int64_t offset;
18  
19         guchar buffer[AVFORMAT_BUFFER_SIZE];
20         guint buffer_size;
21 @@ -72,7 +72,7 @@ static void xmms_asf_metahack (xmms_xfor
22  
23  int xmms_avformat_read_callback (void *user_data, uint8_t *buffer,
24                                   int length);
25 -offset_t xmms_avformat_seek_callback (void *user_data, offset_t offset, int whence);
26 +int64_t xmms_avformat_seek_callback (void *user_data, int64_t offset, int whence);
27  
28  /*
29   * Plugin header
30 @@ -124,7 +124,7 @@ xmms_avformat_destroy (xmms_xform_t *xfo
31         data = xmms_xform_private_data_get (xform);
32         g_return_if_fail (data);
33  
34 -       av_close_input_file (data->fmtctx);
35 +       avformat_close_input (&data->fmtctx);
36  
37         g_string_free (data->outbuf, TRUE);
38         g_free (data);
39 @@ -135,7 +135,7 @@ xmms_avformat_init (xmms_xform_t *xform)
40  {
41         xmms_avformat_data_t *data;
42         AVInputFormat *format;
43 -       ByteIOContext byteio;
44 +       AVIOContext *byteio;
45         AVCodec *codec;
46         const gchar *mimetype;
47         gint temp;
48 @@ -172,13 +172,18 @@ xmms_avformat_init (xmms_xform_t *xform)
49         }
50  
51         format->flags |= AVFMT_NOFILE;
52 -       if ((temp = init_put_byte (&byteio, data->buffer, data->buffer_size, 0,
53 +       if ((byteio = avio_alloc_context (data->buffer, data->buffer_size, 0,
54                                    xform, xmms_avformat_read_callback, NULL,
55 -                                  xmms_avformat_seek_callback)) < 0) {
56 -               XMMS_DBG ("Could not initialize ByteIOContext structure: %d", temp);
57 +                                  xmms_avformat_seek_callback)) == NULL) {
58 +               XMMS_DBG ("Could not initialize AVIOContext structure");
59                 goto err;
60         }
61 -       if ((temp = av_open_input_stream (&data->fmtctx, &byteio, "", format,
62 +       if ((data->fmtctx = avformat_alloc_context()) == NULL) {
63 +               XMMS_DBG ("Could not initialize AVFormatContext structure");
64 +               goto err;
65 +       }
66 +       data->fmtctx->pb = byteio;
67 +       if ((temp = avformat_open_input (&data->fmtctx, "", format,
68                                           NULL)) < 0) {
69                 XMMS_DBG ("Could not open input stream for ASF format: %d", temp);
70                 goto err;
71 @@ -230,7 +235,7 @@ xmms_avformat_init (xmms_xform_t *xform)
72  
73  err:
74         if (data->fmtctx) {
75 -               av_close_input_file (data->fmtctx);
76 +               avformat_close_input (data->fmtctx);
77         }
78         g_string_free (data->outbuf, TRUE);
79         g_free (data);
80 @@ -501,8 +506,8 @@ xmms_avformat_read_callback (void *user_
81         return ret;
82  }
83  
84 -offset_t
85 -xmms_avformat_seek_callback (void *user_data, offset_t offset, int whence)
86 +int64_t
87 +xmms_avformat_seek_callback (void *user_data, int64_t offset, int whence)
88  {
89         xmms_xform_t *xform;
90         xmms_avformat_data_t *data;
91 @@ -552,7 +557,7 @@ xmms_avformat_get_track (AVFormatContext
92         for (wma_idx = 0; wma_idx < fmtctx->nb_streams; wma_idx++) {
93                 codec = fmtctx->streams[wma_idx]->codec;
94  
95 -               if (codec->codec_type == CODEC_TYPE_AUDIO) {
96 +               if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
97                         break;
98                 }
99         }
100 --- xmms2-0.2DrJekyll/src/plugins/avcodec/avcodec.c.orig        2007-05-20 17:55:40.000000000 +0200
101 +++ xmms2-0.2DrJekyll/src/plugins/avcodec/avcodec.c     2023-05-18 18:38:52.423864232 +0200
102 @@ -24,7 +24,7 @@
103  #include <glib.h>
104  
105  #undef ABS
106 -#include "avcodec.h"
107 +#include <libavcodec/avcodec.h>
108  
109  #define AVCODEC_BUFFER_SIZE 16384
110  
111 @@ -134,7 +134,7 @@ xmms_avcodec_init (xmms_xform_t *xform)
112                 goto err;
113         }
114  
115 -       if (codec->type != CODEC_TYPE_AUDIO) {
116 +       if (codec->type != AVMEDIA_TYPE_AUDIO) {
117                 XMMS_DBG ("Codec '%s' found but its type is not audio", data->codec_id);
118                 goto err;
119         }
120 @@ -155,9 +155,9 @@ xmms_avcodec_init (xmms_xform_t *xform)
121         data->codecctx->extradata_size = data->extradata_size;
122  
123         /* FIXME: this is for ALAC but can be a different value */
124 -       data->codecctx->bits_per_sample = 16;
125 +       data->codecctx->bits_per_raw_sample = 16;
126  
127 -       if (avcodec_open (data->codecctx, codec) < 0) {
128 +       if (avcodec_open2 (data->codecctx, codec, NULL) < 0) {
129                 XMMS_DBG ("Opening decoder '%s' failed", codec->name);
130                 goto err;
131         } else {
132 @@ -206,7 +206,6 @@ xmms_avcodec_read (xmms_xform_t *xform,
133                     xmms_error_t *error)
134  {
135         xmms_avcodec_data_t *data;
136 -       char outbuf[AVCODEC_MAX_AUDIO_FRAME_SIZE];
137         gint outbufsize, bytes_read = 0;
138         guint size;
139  
140 @@ -215,6 +214,11 @@ xmms_avcodec_read (xmms_xform_t *xform,
141  
142         size = MIN (data->outbuf->len, len);
143         while (size == 0) {
144 +               int got_frame = 0;
145 +               AVFrame *frame;
146 +               AVPacket packet;
147 +               av_init_packet (&packet);
148 +
149                 if (data->buffer_length == 0) {
150                         bytes_read = xmms_xform_read (xform,
151                                                       (gchar *) data->buffer,
152 @@ -232,11 +236,19 @@ xmms_avcodec_read (xmms_xform_t *xform,
153                         data->buffer_length += bytes_read;
154                 }
155  
156 -               bytes_read = avcodec_decode_audio (data->codecctx, (short *) outbuf,
157 -                                                  &outbufsize, data->buffer,
158 -                                                  data->buffer_length);
159 +               packet.data = data->buffer;
160 +               packet.size = data->buffer_length;
161 +
162 +               frame = av_frame_alloc();
163 +               if (frame == NULL) {
164 +                       XMMS_DBG ("AVFrame allocation failed");
165 +                       return -1;
166 +               }
167 +
168 +               bytes_read = avcodec_decode_audio4 (data->codecctx, frame, &got_frame, &packet);
169  
170                 if (bytes_read < 0) {
171 +                       av_frame_free(&frame);
172                         XMMS_DBG ("Error decoding data!");
173                         return -1;
174                 } else if (bytes_read == 0) {
175 @@ -246,9 +258,11 @@ xmms_avcodec_read (xmms_xform_t *xform,
176  
177                 data->buffer_length -= bytes_read;
178  
179 -               if (outbufsize > 0) {
180 -                       g_string_append_len (data->outbuf, outbuf, outbufsize);
181 +               if (got_frame) {
182 +                       outbufsize = av_samples_get_buffer_size(NULL, data->codecctx->channels, frame->nb_samples, data->codecctx->sample_fmt, 1);
183 +                       g_string_append_len (data->outbuf, frame->data[0], outbufsize);
184                 }
185 +               av_frame_free(&frame);
186  
187                 size = MIN (data->outbuf->len, len);
188         }
This page took 0.104251 seconds and 2 git commands to generate.