Overview

Request 4594 (accepted)

Add patch to fix

Submit package home:manfred.h / handbrake to package Multimedia / handbrake

handbrake.changes Changed
x
 
1
@@ -1,4 +1,10 @@
2
 -------------------------------------------------------------------
3
+Mon Oct 14 12:43:29 UTC 2019 - manfred.h@gmx.net
4
+
5
+- Add patch audio_resample-issue#2126.patch to fix
6
+  <https://github.com/HandBrake/HandBrake/issues/2124>
7
+
8
+-------------------------------------------------------------------
9
 Tue Feb 26 12:24:08 UTC 2019 - enzokiel@kabelmail.de
10
 
11
 - update to version 1.2.2
12
handbrake.spec Changed
17
 
1
@@ -26,6 +26,7 @@
2
 Source1:        https://github.com/HandBrake/HandBrake/releases/download/%{version}/HandBrake-%{version}-source.tar.bz2.sig
3
 Patch0:         HandBrake-no-builddate.patch
4
 Patch1:         HandBrake-build-shared.patch
5
+Patch2:         audio_resample-issue#2126.patch
6
 License:        GPL-2.0+
7
 Group:          Productivity/Multimedia/Video/Editors and Convertors
8
 BuildRequires:  autoconf
9
@@ -111,6 +112,7 @@
10
 %setup -q -n HandBrake-%{version}
11
 %patch0 -p0
12
 %patch1 -p0
13
+%patch2 -p1
14
 
15
 %build
16
 export CFLAGS="%{optflags} -fno-strict-aliasing -Wno-unused -I%{_includedir}/ffmpeg"
17
audio_resample-issue#2126.patch Added
228
 
1
@@ -0,0 +1,226 @@
2
+commit 4ba75f97f31b0e6f64ebd4684d5f2aeeba494629
3
+Author: John Stebbins <jstebbins.hb@gmail.com>
4
+Date:   Thu May 30 08:45:13 2019 -0700
5
+
6
+    audio_resample: set input and output samplerate
7
+    
8
+    Fixes https://github.com/HandBrake/HandBrake/issues/2124
9
+
10
+diff -rup HandBrake-1.2.2.orig/libhb/audio_resample.c HandBrake-1.2.2/libhb/audio_resample.c
11
+--- HandBrake-1.2.2.orig/libhb/audio_resample.c    2019-02-22 17:23:51.000000000 +0100
12
++++ HandBrake-1.2.2/libhb/audio_resample.c 2019-10-14 14:32:45.006416242 +0200
13
+@@ -12,6 +12,7 @@
14
+ #include "audio_resample.h"
15
+ 
16
+ hb_audio_resample_t* hb_audio_resample_init(enum AVSampleFormat sample_fmt,
17
++                                            int sample_rate,
18
+                                             int hb_amixdown, int normalize_mix)
19
+ {
20
+     hb_audio_resample_t *resample = calloc(1, sizeof(hb_audio_resample_t));
21
+@@ -56,6 +57,7 @@ hb_audio_resample_t* hb_audio_resample_i
22
+     resample->out.channel_layout      = channel_layout;
23
+     resample->out.matrix_encoding     = matrix_encoding;
24
+     resample->out.sample_fmt          = sample_fmt;
25
++    resample->out.sample_rate         = sample_rate;
26
+     if (normalize_mix)
27
+     {
28
+         resample->out.maxval = 1.0;
29
+@@ -68,6 +70,7 @@ hb_audio_resample_t* hb_audio_resample_i
30
+ 
31
+     // set default input characteristics
32
+     resample->in.sample_fmt         = resample->out.sample_fmt;
33
++    resample->in.sample_rate        = resample->out.sample_rate;
34
+     resample->in.channel_layout     = resample->out.channel_layout;
35
+     resample->in.lfe_mix_level      = HB_MIXLEV_ZERO;
36
+     resample->in.center_mix_level   = HB_MIXLEV_DEFAULT;
37
+@@ -145,6 +148,15 @@ void hb_audio_resample_set_sample_fmt(hb
38
+     }
39
+ }
40
+ 
41
++void hb_audio_resample_set_sample_rate(hb_audio_resample_t *resample,
42
++                                       int sample_rate)
43
++{
44
++    if (resample != NULL)
45
++    {
46
++        resample->in.sample_rate = sample_rate;
47
++    }
48
++}
49
++
50
+ int hb_audio_resample_update(hb_audio_resample_t *resample)
51
+ {
52
+     if (resample == NULL)
53
+@@ -157,11 +169,13 @@ int hb_audio_resample_update(hb_audio_re
54
+ 
55
+     resample->resample_needed =
56
+         (resample->out.sample_fmt != resample->in.sample_fmt ||
57
++         resample->out.sample_rate != resample->in.sample_rate ||
58
+          resample->out.channel_layout != resample->in.channel_layout);
59
+ 
60
+     resample_changed =
61
+         (resample->resample_needed &&
62
+          (resample->resample.sample_fmt != resample->in.sample_fmt ||
63
++          resample->resample.sample_rate != resample->in.sample_rate ||
64
+           resample->resample.channel_layout != resample->in.channel_layout ||
65
+           resample->resample.lfe_mix_level != resample->in.lfe_mix_level ||
66
+           resample->resample.center_mix_level != resample->in.center_mix_level ||
67
+@@ -181,6 +195,8 @@ int hb_audio_resample_update(hb_audio_re
68
+ 
69
+             av_opt_set_int(resample->swresample, "out_sample_fmt",
70
+                            resample->out.sample_fmt, 0);
71
++            av_opt_set_int(resample->swresample, "out_sample_rate",
72
++                           resample->out.sample_rate, 0);
73
+             av_opt_set_int(resample->swresample, "out_channel_layout",
74
+                            resample->out.channel_layout, 0);
75
+             av_opt_set_int(resample->swresample, "matrix_encoding",
76
+@@ -191,6 +207,8 @@ int hb_audio_resample_update(hb_audio_re
77
+ 
78
+         av_opt_set_int(resample->swresample, "in_sample_fmt",
79
+                        resample->in.sample_fmt, 0);
80
++        av_opt_set_int(resample->swresample, "in_sample_rate",
81
++                       resample->in.sample_rate, 0);
82
+         av_opt_set_int(resample->swresample, "in_channel_layout",
83
+                        resample->in.channel_layout, 0);
84
+         av_opt_set_double(resample->swresample, "lfe_mix_level",
85
+@@ -212,6 +230,7 @@ int hb_audio_resample_update(hb_audio_re
86
+         }
87
+ 
88
+         resample->resample.sample_fmt         = resample->in.sample_fmt;
89
++        resample->resample.sample_rate        = resample->in.sample_rate;
90
+         resample->resample.channel_layout     = resample->in.channel_layout;
91
+         resample->resample.channels           =
92
+             av_get_channel_layout_nb_channels(resample->in.channel_layout);
93
+@@ -255,11 +274,13 @@ hb_buffer_t* hb_audio_resample(hb_audio_
94
+ 
95
+     if (resample->resample_needed)
96
+     {
97
+-        out_size = av_samples_get_buffer_size(NULL,
98
+-                                              resample->out.channels, nsamples,
99
++        out_samples = (nsamples + 1) * resample->out.sample_rate /
100
++                                       resample->in.sample_rate;
101
++        out_size = av_samples_get_buffer_size(NULL, resample->out.channels,
102
++                                              out_samples,
103
+                                               resample->out.sample_fmt, 0);
104
+         out = hb_buffer_init(out_size);
105
+-        out_samples = swr_convert(resample->swresample, &out->data, nsamples,
106
++        out_samples = swr_convert(resample->swresample, &out->data, out_samples,
107
+                                                         samples,    nsamples);
108
+ 
109
+         if (out_samples <= 0)
110
+diff -rup HandBrake-1.2.2.orig/libhb/audio_resample.h HandBrake-1.2.2/libhb/audio_resample.h
111
+--- HandBrake-1.2.2.orig/libhb/audio_resample.h    2019-02-22 17:23:51.000000000 +0100
112
++++ HandBrake-1.2.2/libhb/audio_resample.h 2019-10-14 14:32:45.006416242 +0200
113
+@@ -37,6 +37,7 @@ typedef struct
114
+ 
115
+     struct
116
+     {
117
++        int sample_rate;
118
+         uint64_t channel_layout;
119
+         double lfe_mix_level;
120
+         double center_mix_level;
121
+@@ -46,6 +47,7 @@ typedef struct
122
+ 
123
+     struct
124
+     {
125
++        int sample_rate;
126
+         int channels;
127
+         uint64_t channel_layout;
128
+         double lfe_mix_level;
129
+@@ -56,6 +58,7 @@ typedef struct
130
+ 
131
+     struct
132
+     {
133
++        int sample_rate;
134
+         int channels;
135
+         int sample_size;
136
+         uint64_t channel_layout;
137
+@@ -72,6 +75,7 @@ typedef struct
138
+  * as the output characteristics (no conversion needed).
139
+  */
140
+ hb_audio_resample_t* hb_audio_resample_init(enum AVSampleFormat sample_fmt,
141
++                                            int sample_rate,
142
+                                             int hb_amixdown, int normalize_mix);
143
+ 
144
+ /* The following functions set the audio input characteristics.
145
+@@ -91,6 +95,9 @@ void                 hb_audio_resample_s
146
+ void                 hb_audio_resample_set_sample_fmt(hb_audio_resample_t *resample,
147
+                                                       enum AVSampleFormat sample_fmt);
148
+ 
149
++void                 hb_audio_resample_set_sample_rate(hb_audio_resample_t *resample,
150
++                                                       int sample_rate);
151
++
152
+ /* Update an hb_audio_resample_t.
153
+  *
154
+  * Must be called after using any of the above functions.
155
+diff -rup HandBrake-1.2.2.orig/libhb/decavcodec.c HandBrake-1.2.2/libhb/decavcodec.c
156
+--- HandBrake-1.2.2.orig/libhb/decavcodec.c    2019-02-22 17:23:51.000000000 +0100
157
++++ HandBrake-1.2.2/libhb/decavcodec.c 2019-10-14 14:32:45.006416242 +0200
158
+@@ -204,8 +204,13 @@ static int decavcodecaInit( hb_work_obje
159
+     /* Downmixing & sample_fmt conversion */
160
+     if (!(w->audio->config.out.codec & HB_ACODEC_PASS_FLAG))
161
+     {
162
++        // Currently, samplerate conversion is performed in sync.c
163
++        // So set output samplerate to input samplerate
164
++        // This should someday get reworked to be part of an audio
165
++        // filter pipleine.
166
+         pv->resample =
167
+             hb_audio_resample_init(AV_SAMPLE_FMT_FLT,
168
++                                   w->audio->config.in.samplerate,
169
+                                    w->audio->config.out.mixdown,
170
+                                    w->audio->config.out.normalize_mix_level);
171
+         if (pv->resample == NULL)
172
+@@ -2308,6 +2313,8 @@ static void decodeAudio(hb_work_private_
173
+             hb_audio_resample_set_channel_layout(pv->resample, channel_layout);
174
+             hb_audio_resample_set_sample_fmt(pv->resample,
175
+                                              pv->frame->format);
176
++            hb_audio_resample_set_sample_rate(pv->resample,
177
++                                             pv->frame->sample_rate);
178
+             if (hb_audio_resample_update(pv->resample))
179
+             {
180
+                 hb_log("decavcodec: hb_audio_resample_update() failed");
181
+Only in HandBrake-1.2.2/libhb: decavcodec.c.orig
182
+diff -rup HandBrake-1.2.2.orig/libhb/declpcm.c HandBrake-1.2.2/libhb/declpcm.c
183
+--- HandBrake-1.2.2.orig/libhb/declpcm.c   2019-02-22 17:23:51.000000000 +0100
184
++++ HandBrake-1.2.2/libhb/declpcm.c    2019-10-14 14:32:45.006416242 +0200
185
+@@ -166,8 +166,12 @@ static int declpcmInit( hb_work_object_t
186
+     pv->job = job;
187
+ 
188
+     pv->next_pts = (int64_t)AV_NOPTS_VALUE;
189
++    // Currently, samplerate conversion is performed in sync.c
190
++    // So set output samplerate to input samplerate
191
++    // This should someday get reworked to be part of an audio filter pipleine.
192
+     pv->resample =
193
+         hb_audio_resample_init(AV_SAMPLE_FMT_FLT,
194
++                               w->audio->config.in.samplerate,
195
+                                w->audio->config.out.mixdown,
196
+                                w->audio->config.out.normalize_mix_level);
197
+     if (pv->resample == NULL)
198
+@@ -333,6 +337,8 @@ static hb_buffer_t *Decode( hb_work_obje
199
+ 
200
+     hb_audio_resample_set_channel_layout(pv->resample,
201
+                                          hdr2layout[pv->nchannels - 1]);
202
++    hb_audio_resample_set_sample_rate(pv->resample,
203
++                                      pv->samplerate);
204
+     if (hb_audio_resample_update(pv->resample))
205
+     {
206
+         hb_log("declpcm: hb_audio_resample_update() failed");
207
+diff -rup HandBrake-1.2.2.orig/libhb/encavcodecaudio.c HandBrake-1.2.2/libhb/encavcodecaudio.c
208
+--- HandBrake-1.2.2.orig/libhb/encavcodecaudio.c   2019-02-22 17:23:51.000000000 +0100
209
++++ HandBrake-1.2.2/libhb/encavcodecaudio.c    2019-10-14 14:32:45.006416242 +0200
210
+@@ -249,13 +249,13 @@ static int encavcodecaInit(hb_work_objec
211
+                        context->channel_layout, 0);
212
+         av_opt_set_int(pv->swresample, "out_channel_layout",
213
+                        context->channel_layout, 0);
214
++        av_opt_set_int(pv->swresample, "in_sample_rate",
215
++                       context->sample_rate, 0);
216
++        av_opt_set_int(pv->swresample, "out_sample_rate",
217
++                       context->sample_rate, 0);
218
+         if (hb_audio_dither_is_supported(audio->config.out.codec))
219
+         {
220
+             // dithering needs the sample rate
221
+-            av_opt_set_int(pv->swresample, "in_sample_rate",
222
+-                           context->sample_rate, 0);
223
+-            av_opt_set_int(pv->swresample, "out_sample_rate",
224
+-                           context->sample_rate, 0);
225
+             av_opt_set_int(pv->swresample, "dither_method",
226
+                            audio->config.out.dither_method, 0);
227
+         }
228
Refresh
Refresh
Request History
manfred.h's avatar

manfred.h created request over 5 years ago

Add patch to fix


enzokiel's avatar

enzokiel accepted request over 5 years ago