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
8 +#include <libavformat/avformat.h>
10 #define AVFORMAT_BUFFER_SIZE 4096
12 @@ -33,7 +33,7 @@ typedef struct {
14 AVFormatContext *fmtctx;
15 AVCodecContext *codecctx;
19 guchar buffer[AVFORMAT_BUFFER_SIZE];
21 @@ -72,7 +72,7 @@ static void xmms_asf_metahack (xmms_xfor
23 int xmms_avformat_read_callback (void *user_data, uint8_t *buffer,
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);
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);
34 - av_close_input_file (data->fmtctx);
35 + avformat_close_input (&data->fmtctx);
37 g_string_free (data->outbuf, TRUE);
39 @@ -135,7 +135,7 @@ xmms_avformat_init (xmms_xform_t *xform)
41 xmms_avformat_data_t *data;
42 AVInputFormat *format;
43 - ByteIOContext byteio;
44 + AVIOContext *byteio;
46 const gchar *mimetype;
48 @@ -172,13 +172,18 @@ xmms_avformat_init (xmms_xform_t *xform)
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");
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");
66 + data->fmtctx->pb = byteio;
67 + if ((temp = avformat_open_input (&data->fmtctx, "", format,
69 XMMS_DBG ("Could not open input stream for ASF format: %d", temp);
71 @@ -230,7 +235,7 @@ xmms_avformat_init (xmms_xform_t *xform)
75 - av_close_input_file (data->fmtctx);
76 + avformat_close_input (data->fmtctx);
78 g_string_free (data->outbuf, TRUE);
80 @@ -501,8 +506,8 @@ xmms_avformat_read_callback (void *user_
85 -xmms_avformat_seek_callback (void *user_data, offset_t offset, int whence)
87 +xmms_avformat_seek_callback (void *user_data, int64_t offset, int whence)
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;
95 - if (codec->codec_type == CODEC_TYPE_AUDIO) {
96 + if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
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
106 -#include "avcodec.h"
107 +#include <libavcodec/avcodec.h>
109 #define AVCODEC_BUFFER_SIZE 16384
111 @@ -134,7 +134,7 @@ xmms_avcodec_init (xmms_xform_t *xform)
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);
120 @@ -155,9 +155,9 @@ xmms_avcodec_init (xmms_xform_t *xform)
121 data->codecctx->extradata_size = data->extradata_size;
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;
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);
132 @@ -206,7 +206,6 @@ xmms_avcodec_read (xmms_xform_t *xform,
135 xmms_avcodec_data_t *data;
136 - char outbuf[AVCODEC_MAX_AUDIO_FRAME_SIZE];
137 gint outbufsize, bytes_read = 0;
140 @@ -215,6 +214,11 @@ xmms_avcodec_read (xmms_xform_t *xform,
142 size = MIN (data->outbuf->len, len);
147 + av_init_packet (&packet);
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;
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;
162 + frame = av_frame_alloc();
163 + if (frame == NULL) {
164 + XMMS_DBG ("AVFrame allocation failed");
168 + bytes_read = avcodec_decode_audio4 (data->codecctx, frame, &got_frame, &packet);
170 if (bytes_read < 0) {
171 + av_frame_free(&frame);
172 XMMS_DBG ("Error decoding data!");
174 } else if (bytes_read == 0) {
175 @@ -246,9 +258,11 @@ xmms_avcodec_read (xmms_xform_t *xform,
177 data->buffer_length -= bytes_read;
179 - if (outbufsize > 0) {
180 - g_string_append_len (data->outbuf, outbuf, outbufsize);
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);
185 + av_frame_free(&frame);
187 size = MIN (data->outbuf->len, len);