tags 638552 patch
thanks

On Sat, Aug 20, 2011 at 11:22:07AM +0200, Daniel Svensson wrote:
> On Fri, Aug 19, 2011 at 7:48 PM, Moritz Muehlenhoff <j...@debian.org> wrote:
> > Your package currently fails to build from source when built against
> > libav/0.7.1 and needs to be adapted. You can test this yourself by
> > building against the packages from experimental:
> 
> The commits here:
> 
> http://git.xmms.se/xmms2/xmms2-devel/log/src/plugins/avcodec
> 
> ...between 2011-05-23 and 2011-06-01 could be included in the debian
> patches which ought to fix the problem.

Thanks!  Here's that as a consolidated Debian patch, test-built on
Ubuntu Oneiric:

  * Backport from upstream:
    - Fix avcodec plugin to work with latest libavcodec (closes: #638552).

diff -Nru xmms2-0.7DrNo+dfsg/debian/patches/libav-0.7.patch 
xmms2-0.7DrNo+dfsg/debian/patches/libav-0.7.patch
--- xmms2-0.7DrNo+dfsg/debian/patches/libav-0.7.patch   1970-01-01 
01:00:00.000000000 +0100
+++ xmms2-0.7DrNo+dfsg/debian/patches/libav-0.7.patch   2011-09-01 
11:35:43.000000000 +0100
@@ -0,0 +1,239 @@
+Description: Fix avcodec plugin to work with latest libavcodec
+Author: Juho Vähä-Herttua <juh...@iki.fi>
+Origin: upstream, http://git.xmms.se/xmms2/xmms2-devel/log/src/plugins/avcodec
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=638552
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/832769
+Forwarded: not-needed
+Last-Update: 2011-09-01
+
+Index: b/src/plugins/avcodec/avcodec.c
+===================================================================
+--- a/src/plugins/avcodec/avcodec.c
++++ b/src/plugins/avcodec/avcodec.c
+@@ -24,25 +24,7 @@
+ #include <string.h>
+ #include <glib.h>
+ 
+-#undef ABS
+-#ifdef HAVE_LIBAVCODEC_AVCODEC_H
+-# include "libavcodec/avcodec.h"
+-#else
+-# include "avcodec.h"
+-#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
+-
+-/* 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
++#include "avcodec_compat.h"
+ 
+ #define AVCODEC_BUFFER_SIZE 16384
+ 
+@@ -50,7 +32,6 @@
+       AVCodecContext *codecctx;
+ 
+       guchar *buffer;
+-      guchar *buffer_pos;
+       guint buffer_length;
+       guint buffer_size;
+       gboolean no_demuxer;
+@@ -101,6 +82,10 @@
+ 
+       xmms_magic_add ("Shorten header", "audio/x-ffmpeg-shorten",
+                       "0 string ajkg", NULL);
++      xmms_magic_add ("A/52 (AC-3) header", "audio/x-ffmpeg-ac3",
++                      "0 beshort 0x0b77", NULL);
++      xmms_magic_add ("DTS header", "audio/x-ffmpeg-dca",
++                      "0 belong 0x7ffe8001", NULL); 
+ 
+       xmms_xform_plugin_indata_add (xform_plugin,
+                                     XMMS_STREAM_TYPE_MIMETYPE,
+@@ -135,7 +120,7 @@
+       AVCodec *codec;
+       const gchar *mimetype;
+       const guchar *tmpbuf;
+-      gssize tmpbuflen;
++      gsize tmpbuflen;
+       gint ret;
+ 
+       g_return_val_if_fail (xform, FALSE);
+@@ -160,7 +145,7 @@
+               goto err;
+       }
+ 
+-      if (codec->type != CODEC_TYPE_AUDIO) {
++      if (codec->type != AVMEDIA_TYPE_AUDIO) {
+               XMMS_DBG ("Codec '%s' found but its type is not audio", 
data->codec_id);
+               goto err;
+       }
+@@ -199,7 +184,9 @@
+                * demuxer so they will be handled slightly differently... */
+               if (!strcmp (data->codec_id, "shorten") ||
+                   !strcmp (data->codec_id, "adpcm_swf") ||
+-                  !strcmp (data->codec_id, "pcm_s16le")) {
++                  !strcmp (data->codec_id, "pcm_s16le") ||
++                  !strcmp (data->codec_id, "ac3") ||
++                  !strcmp (data->codec_id, "dca")) {
+                       /* number 1024 taken from libavformat raw.c 
RAW_PACKET_SIZE */
+                       data->extradata = g_malloc0 (1024);
+                       data->extradata_size = 1024;
+@@ -280,12 +267,15 @@
+ 
+       size = MIN (data->outbuf->len, len);
+       while (size == 0) {
+-              if (data->buffer_length == 0) {
++              AVPacket packet;
++              av_init_packet (&packet);
++
++              if (data->no_demuxer || data->buffer_length == 0) {
+                       gint read_total;
+ 
+                       bytes_read = xmms_xform_read (xform,
+-                                                    (gchar *) data->buffer,
+-                                                    data->buffer_size,
++                                                    (gchar *) (data->buffer + 
data->buffer_length),
++                                                    data->buffer_size - 
data->buffer_length,
+                                                     error);
+ 
+                       if (bytes_read < 0) {
+@@ -328,22 +318,35 @@
+                               }
+                       }
+ 
+-                      /* Reset the buffer position to beginning and update 
length */
+-                      data->buffer_pos = data->buffer;
+-                      data->buffer_length = read_total;
++                      /* Update the buffer length */
++                      data->buffer_length += read_total;
+               }
+ 
++              packet.data = data->buffer;
++              packet.size = data->buffer_length;
++
+               outbufsize = sizeof (outbuf);
+-              bytes_read = avcodec_decode_audio2 (data->codecctx, (short *) 
outbuf,
+-                                                  &outbufsize, 
data->buffer_pos,
+-                                                  data->buffer_length);
++              bytes_read = avcodec_decode_audio3 (data->codecctx, (short *) 
outbuf,
++                                                  &outbufsize, &packet);
++
++              /* The DTS decoder of ffmpeg is buggy and always returns
++               * the input buffer length, get frame length from header */
++              if (!strcmp (data->codec_id, "dca") && bytes_read > 0) {
++                      bytes_read = ((int)data->buffer[5] << 12) |
++                                   ((int)data->buffer[6] << 4) |
++                                   ((int)data->buffer[7] >> 4);
++                      bytes_read = (bytes_read & 0x3fff) + 1;
++              }
+ 
+               if (bytes_read < 0 || bytes_read > data->buffer_length) {
+                       XMMS_DBG ("Error decoding data!");
+                       return -1;
++              } else if (bytes_read != data->buffer_length) {
++                      g_memmove (data->buffer,
++                                 data->buffer + bytes_read,
++                                 data->buffer_length - bytes_read);
+               }
+ 
+-              data->buffer_pos += bytes_read;
+               data->buffer_length -= bytes_read;
+ 
+               if (outbufsize > 0) {
+@@ -383,10 +386,14 @@
+       /* The buggy ape decoder doesn't flush buffers, so we need to finish 
decoding
+        * the frame before seeking to avoid segfaults... this hack sucks */
+       while (data->buffer_length > 0) {
++              AVPacket packet;
++              av_init_packet (&packet);
++              packet.data = data->buffer;
++              packet.size = data->buffer_length;
++
+               outbufsize = sizeof (outbuf);
+-              bytes_read = avcodec_decode_audio2 (data->codecctx, (short *) 
outbuf,
+-                                                  &outbufsize, data->buffer,
+-                                                  data->buffer_length);
++              bytes_read = avcodec_decode_audio3 (data->codecctx, (short *) 
outbuf,
++                                                  &outbufsize, &packet);
+ 
+               if (bytes_read < 0 || bytes_read > data->buffer_length) {
+                       XMMS_DBG ("Error decoding data!");
+Index: b/src/plugins/avcodec/avcodec_compat.h
+===================================================================
+--- /dev/null
++++ b/src/plugins/avcodec/avcodec_compat.h
+@@ -0,0 +1,67 @@
++/** @file avcodec_compat.h
++ *  Compatibility header for libavcodec backwards compatibility
++ *
++ *  Copyright (C) 2011 XMMS2 Team
++ *
++ *  This library is free software; you can redistribute it and/or
++ *  modify it under the terms of the GNU Lesser General Public
++ *  License as published by the Free Software Foundation; either
++ *  version 2.1 of the License, or (at your option) any later version.
++ *
++ *  This library is distributed in the hope that it will be useful,
++ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *  Lesser General Public License for more details.
++ */
++
++#undef ABS
++#ifdef HAVE_LIBAVCODEC_AVCODEC_H
++# include "libavcodec/avcodec.h"
++#else
++# 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
++
diff -Nru xmms2-0.7DrNo+dfsg/debian/patches/series 
xmms2-0.7DrNo+dfsg/debian/patches/series
--- xmms2-0.7DrNo+dfsg/debian/patches/series    2010-08-02 22:32:27.000000000 
+0100
+++ xmms2-0.7DrNo+dfsg/debian/patches/series    2011-09-01 11:25:49.000000000 
+0100
@@ -13,3 +13,4 @@
 bp-nycli-command-line-length.patch
 plugin-tta-segment-with-startms.patch
 bp-glib-version-check.patch
+libav-0.7.patch

Regards,

-- 
Colin Watson                                       [cjwat...@ubuntu.com]




--
_______________________________________________
Xmms2-devel mailing list
Xmms2-devel@lists.xmms.se
http://lists.xmms.se/cgi-bin/mailman/listinfo/xmms2-devel

Reply via email to