~ubuntu-branches/ubuntu/vivid/sox/vivid

« back to all changes in this revision

Viewing changes to debian/patches/01_fix_ffmpeg_alignment.patch

  • Committer: Bazaar Package Importer
  • Author(s): Pascal Giard
  • Date: 2011-02-11 21:13:57 UTC
  • Revision ID: james.westby@ubuntu.com-20110211211357-w6k3v73ch2v4xmea
Tags: 14.3.1-2
* [debian/patches/01_fix_ffmpeg_alignment.patch]:
  - Fixed ffmpeg segfault caused by alignment requirements, thanks to
    Reuben Thomas (closes: #537511).
* [debian/rules]:
  - Set distro based on the build distribution, thanks to Benjamin Drung
    <bdrung@debian.org> for the patch (closes: #612409).
  - Removed -D_REENTRANT from CFLAGS.
* [debian/control, debian/copyright, debian/libsox-dev.install]:
  - Executed wrap-and-sort from ubuntu-dev-tools as suggested by
    Benjamin Drung <bdrung@debian.org>, thanks! (closes: #612410).
* [debian/control]:
  - Bumped standard version to 3.9.1.
* [debian/source/format]:
  - Specified format 1.0 (TODO: move to quilt 3.0).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- src/ffmpeg.c        2009/12/02 11:06:28     1.28
 
2
+++ src/ffmpeg.c        2011/02/11 19:20:39     1.29
 
3
@@ -1,6 +1,6 @@
 
4
 /* libSoX ffmpeg formats.
 
5
  *
 
6
- * Copyright 2007 Reuben Thomas <rrt@sc3d.org>
 
7
+ * Copyright 2007, 2011 Reuben Thomas <rrt@sc3d.org>
 
8
  *
 
9
  * Based on ffplay.c and output_example.c Copyright 2003 Fabrice Bellard
 
10
  * Note: ffplay.c is distributed under the LGPL 2.1 or later;
 
11
@@ -63,8 +63,6 @@
 
12
   AVFormatContext *ctxt;
 
13
   int audio_input_frame_size;
 
14
   AVPacket audio_pkt;
 
15
-  uint8_t *audio_pkt_data;
 
16
-  int audio_pkt_size;
 
17
 } priv_t;
 
18
 
 
19
 /* open a given stream. Return 0 if OK */
 
20
@@ -127,26 +125,27 @@
 
21
 
 
22
   for (;;) {
 
23
     /* NOTE: the audio packet can contain several frames */
 
24
-    while (ffmpeg->audio_pkt_size > 0) {
 
25
+    while (ffmpeg->audio_pkt.size > 0) {
 
26
       data_size = buf_size;
 
27
-      len1 = avcodec_decode_audio2(ffmpeg->audio_st->codec,
 
28
-                                   (int16_t *)audio_buf, &data_size,
 
29
-                                   ffmpeg->audio_pkt_data, ffmpeg->audio_pkt_size);
 
30
+      len1 = avcodec_decode_audio3(ffmpeg->audio_st->codec,
 
31
+                                  (int16_t *)audio_buf, &data_size,
 
32
+                                  pkt);
 
33
       if (len1 < 0) /* if error, we skip the rest of the packet */
 
34
        return 0;
 
35
 
 
36
-      ffmpeg->audio_pkt_data += len1;
 
37
-      ffmpeg->audio_pkt_size -= len1;
 
38
+      ffmpeg->audio_pkt.data += len1;
 
39
+      ffmpeg->audio_pkt.size -= len1;
 
40
       if (data_size <= 0)
 
41
-        continue;
 
42
+       continue;
 
43
       return data_size;
 
44
     }
 
45
-
 
46
-    ffmpeg->audio_pkt_data = pkt->data;
 
47
-    ffmpeg->audio_pkt_size = pkt->size;
 
48
   }
 
49
 }
 
50
 
 
51
+/* On some platforms, libavcodec wants the output buffer aligned to 16
 
52
+ * bytes (because it uses SSE/Altivec internally). */
 
53
+#define ALIGN16(p) ((uint8_t *)(p) + (16 - (size_t)(p) % 16))
 
54
+
 
55
 static int startread(sox_format_t * ft)
 
56
 {
 
57
   priv_t * ffmpeg = (priv_t *)ft->priv;
 
58
@@ -154,7 +153,7 @@
 
59
   int ret;
 
60
   int i;
 
61
 
 
62
-  ffmpeg->audio_buf = lsx_calloc(1, (size_t)AVCODEC_MAX_AUDIO_FRAME_SIZE);
 
63
+  ffmpeg->audio_buf = ALIGN16 (lsx_calloc(1, (size_t)AVCODEC_MAX_AUDIO_FRAME_SIZE + 16));
 
64
 
 
65
   /* Signal audio stream not found */
 
66
   ffmpeg->audio_index = -1;
 
67
@@ -201,8 +200,8 @@
 
68
   ft->encoding.encoding = SOX_ENCODING_SIGN2;
 
69
   ft->signal.channels = ffmpeg->audio_st->codec->channels;
 
70
   ft->signal.length = 0; /* Currently we can't seek; no idea how to get this
 
71
-                     info from ffmpeg anyway (in time, yes, but not in
 
72
-                     samples); but ffmpeg *can* seek */
 
73
+                    info from ffmpeg anyway (in time, yes, but not in
 
74
+                    samples); but ffmpeg *can* seek */
 
75
 
 
76
   return SOX_SUCCESS;
 
77
 }
 
78
@@ -224,7 +223,7 @@
 
79
     if (ffmpeg->audio_buf_index * 2 >= ffmpeg->audio_buf_size) {
 
80
       if ((ret = av_read_frame(ffmpeg->ctxt, pkt)) < 0 &&
 
81
          (ret == AVERROR_EOF || url_ferror(ffmpeg->ctxt->pb)))
 
82
-        break;
 
83
+       break;
 
84
       ffmpeg->audio_buf_size = audio_decode_frame(ffmpeg, ffmpeg->audio_buf, AVCODEC_MAX_AUDIO_FRAME_SIZE);
 
85
       ffmpeg->audio_buf_index = 0;
 
86
     }
 
87
@@ -335,10 +334,10 @@
 
88
 
 
89
   /* auto detect the output format from the name. default is
 
90
      mpeg. */
 
91
-  ffmpeg->fmt = guess_format(NULL, ft->filename, NULL);
 
92
+  ffmpeg->fmt = av_guess_format(NULL, ft->filename, NULL);
 
93
   if (!ffmpeg->fmt) {
 
94
     lsx_warn("ffmpeg could not deduce output format from file extension; using MPEG");
 
95
-    ffmpeg->fmt = guess_format("mpeg", NULL, NULL);
 
96
+    ffmpeg->fmt = av_guess_format("mpeg", NULL, NULL);
 
97
     if (!ffmpeg->fmt) {
 
98
       lsx_fail("ffmpeg could not find suitable output format");
 
99
       return SOX_EOF;
 
100
@@ -346,7 +345,7 @@
 
101
   }
 
102
 
 
103
   /* allocate the output media context */
 
104
-  ffmpeg->ctxt = av_alloc_format_context();
 
105
+  ffmpeg->ctxt = avformat_alloc_context();
 
106
   if (!ffmpeg->ctxt) {
 
107
     fprintf(stderr, "ffmpeg out of memory error");
 
108
     return SOX_EOF;
 
109
@@ -408,12 +407,12 @@
 
110
     if (ffmpeg->samples_index < ffmpeg->audio_input_frame_size) {
 
111
       SOX_SAMPLE_LOCALS;
 
112
       for (; nread < len && ffmpeg->samples_index < ffmpeg->audio_input_frame_size; nread++)
 
113
-        ffmpeg->samples[ffmpeg->samples_index++] = SOX_SAMPLE_TO_SIGNED_16BIT(buf[nread], ft->clips);
 
114
+       ffmpeg->samples[ffmpeg->samples_index++] = SOX_SAMPLE_TO_SIGNED_16BIT(buf[nread], ft->clips);
 
115
     }
 
116
 
 
117
     /* If output frame full or no more data to read, write it out */
 
118
     if (ffmpeg->samples_index == ffmpeg->audio_input_frame_size ||
 
119
-        (len == 0 && ffmpeg->samples_index > 0)) {
 
120
+       (len == 0 && ffmpeg->samples_index > 0)) {
 
121
       AVCodecContext *c = ffmpeg->audio_st->codec;
 
122
       AVPacket pkt;
 
123
 
 
124
@@ -426,10 +425,10 @@
 
125
 
 
126
       /* write the compressed frame to the media file */
 
127
       if (av_write_frame(ffmpeg->ctxt, &pkt) != 0)
 
128
-        lsx_fail("ffmpeg had error while writing audio frame");
 
129
+       lsx_fail("ffmpeg had error while writing audio frame");
 
130
 
 
131
       /* Increment nwritten whether write succeeded or not; we have to
 
132
-         get rid of the input! */
 
133
+        get rid of the input! */
 
134
       nwritten += ffmpeg->samples_index;
 
135
       ffmpeg->samples_index = 0;
 
136
     }
 
137
@@ -485,6 +484,7 @@
 
138
     "ffmpeg", /* special type to force use of ffmpeg */
 
139
     "mp4",
 
140
     "m4a",
 
141
+    "m4b",
 
142
     "avi",
 
143
     "wmv",
 
144
     "mpg",