Merge ~liushuyu-011/ubuntu/+source/libopenshot:ubuntu/devel into ubuntu/+source/libopenshot:ubuntu/devel
- Git
- lp:~liushuyu-011/ubuntu/+source/libopenshot
- ubuntu/devel
- Merge into ubuntu/devel
Proposed by
Zixing Liu
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 68a19b1eafbc3df18c504f5fc378a771b058f2f4 | ||||
Proposed branch: | ~liushuyu-011/ubuntu/+source/libopenshot:ubuntu/devel | ||||
Merge into: | ubuntu/+source/libopenshot:ubuntu/devel | ||||
Diff against target: |
309 lines (+289/-0) 3 files modified
debian/changelog (+7/-0) debian/patches/0002-fix-ffmpeg-7.patch (+281/-0) debian/patches/series (+1/-0) |
||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vladimir Petko (community) | Approve | ||
Review via email: mp+473479@code.launchpad.net |
Commit message
Description of the change
This merge proposal fixes the FTBFS issue with libopenshot when built using FFmpeg 7
To post a comment you must log in.
Revision history for this message
Zixing Liu (liushuyu-011) wrote : | # |
PPA build: https:/
> - Please run quilt refresh.
Again, I can't find the issue:
```
zixing@
Patch debian/
```
Revision history for this message
Vladimir Petko (vpa1977) wrote : | # |
Uploaded, thank you!!!
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/debian/changelog b/debian/changelog |
2 | index 09d7dd7..b015b2c 100644 |
3 | --- a/debian/changelog |
4 | +++ b/debian/changelog |
5 | @@ -1,3 +1,10 @@ |
6 | +libopenshot (0.3.2+dfsg1-2.1ubuntu1) oracular; urgency=medium |
7 | + |
8 | + * d/p/0002-fix-ffmpeg-7.patch: add an upstream patch to fix FTBFS |
9 | + with FFmpeg 7 (LP: #2079274). |
10 | + |
11 | + -- Zixing Liu <zixing.liu@canonical.com> Wed, 18 Sep 2024 16:41:42 -0600 |
12 | + |
13 | libopenshot (0.3.2+dfsg1-2.1build3) noble; urgency=medium |
14 | |
15 | * No-change rebuild for CVE-2024-3094 |
16 | diff --git a/debian/patches/0002-fix-ffmpeg-7.patch b/debian/patches/0002-fix-ffmpeg-7.patch |
17 | new file mode 100644 |
18 | index 0000000..865aa8a |
19 | --- /dev/null |
20 | +++ b/debian/patches/0002-fix-ffmpeg-7.patch |
21 | @@ -0,0 +1,281 @@ |
22 | +Description: Add compatibility with FFMPEG 7.0 |
23 | + channel_layout has been replaced with ch_layout |
24 | +Author: Robert-André Mauchin <zebob.m@gmail.com> |
25 | +Origin: upstream, https://github.com/OpenShot/libopenshot/commit/08d7f3354bd8e8ef5c8799b5ab59a0f8c7b05094 |
26 | +Last-Update: 2024-09-18 |
27 | +--- |
28 | +Index: libopenshot/src/FFmpegReader.cpp |
29 | +=================================================================== |
30 | +--- libopenshot.orig/src/FFmpegReader.cpp |
31 | ++++ libopenshot/src/FFmpegReader.cpp |
32 | +@@ -9,7 +9,7 @@ |
33 | + * @ref License |
34 | + */ |
35 | + |
36 | +-// Copyright (c) 2008-2019 OpenShot Studios, LLC, Fabrice Bellard |
37 | ++// Copyright (c) 2008-2024 OpenShot Studios, LLC, Fabrice Bellard |
38 | + // |
39 | + // SPDX-License-Identifier: LGPL-3.0-or-later |
40 | + |
41 | +@@ -671,8 +671,13 @@ bool FFmpegReader::HasAlbumArt() { |
42 | + |
43 | + void FFmpegReader::UpdateAudioInfo() { |
44 | + // Set default audio channel layout (if needed) |
45 | ++#if HAVE_CH_LAYOUT |
46 | ++ if (!av_channel_layout_check(&(AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->ch_layout))) |
47 | ++ AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->ch_layout = (AVChannelLayout) AV_CHANNEL_LAYOUT_STEREO; |
48 | ++#else |
49 | + if (AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channel_layout == 0) |
50 | + AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channel_layout = av_get_default_channel_layout(AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channels); |
51 | ++#endif |
52 | + |
53 | + if (info.sample_rate > 0) { |
54 | + // Skip init - if info struct already populated |
55 | +@@ -683,8 +688,13 @@ void FFmpegReader::UpdateAudioInfo() { |
56 | + info.has_audio = true; |
57 | + info.file_size = pFormatCtx->pb ? avio_size(pFormatCtx->pb) : -1; |
58 | + info.acodec = aCodecCtx->codec->name; |
59 | ++#if HAVE_CH_LAYOUT |
60 | ++ info.channels = AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->ch_layout.nb_channels; |
61 | ++ info.channel_layout = (ChannelLayout) AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->ch_layout.u.mask; |
62 | ++#else |
63 | + info.channels = AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channels; |
64 | + info.channel_layout = (ChannelLayout) AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channel_layout; |
65 | ++#endif |
66 | + info.sample_rate = AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->sample_rate; |
67 | + info.audio_bit_rate = AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->bit_rate; |
68 | + if (info.audio_bit_rate <= 0) { |
69 | +@@ -1593,13 +1603,17 @@ void FFmpegReader::ProcessAudioPacket(in |
70 | + |
71 | + // determine how many samples were decoded |
72 | + int plane_size = -1; |
73 | +- data_size = av_samples_get_buffer_size(&plane_size, |
74 | +- AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channels, |
75 | ++#if HAVE_CH_LAYOUT |
76 | ++ int nb_channels = AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->ch_layout.nb_channels; |
77 | ++#else |
78 | ++ int nb_channels = AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channels; |
79 | ++#endif |
80 | ++ data_size = av_samples_get_buffer_size(&plane_size, nb_channels, |
81 | + audio_frame->nb_samples, |
82 | + (AVSampleFormat) (AV_GET_SAMPLE_FORMAT(aStream, aCodecCtx)), 1); |
83 | + |
84 | + // Calculate total number of samples |
85 | +- packet_samples = audio_frame->nb_samples * AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channels; |
86 | ++ packet_samples = audio_frame->nb_samples * nb_channels; |
87 | + } else { |
88 | + if (audio_frame) { |
89 | + // Free audio frame |
90 | +@@ -1662,14 +1676,20 @@ void FFmpegReader::ProcessAudioPacket(in |
91 | + |
92 | + // setup resample context |
93 | + avr = SWR_ALLOC(); |
94 | ++ |
95 | ++#if HAVE_CH_LAYOUT |
96 | ++ av_opt_set_chlayout(avr, "in_chlayout", &AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->ch_layout, 0); |
97 | ++ av_opt_set_chlayout(avr, "out_chlayout", &AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->ch_layout, 0); |
98 | ++#else |
99 | + av_opt_set_int(avr, "in_channel_layout", AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channel_layout, 0); |
100 | + av_opt_set_int(avr, "out_channel_layout", AV_GET_CODEC_ATTRIBUTES(aStream, aCodecCtx)->channel_layout, 0); |
101 | ++ av_opt_set_int(avr, "in_channels", info.channels, 0); |
102 | ++ av_opt_set_int(avr, "out_channels", info.channels, 0); |
103 | ++#endif |
104 | + av_opt_set_int(avr, "in_sample_fmt", AV_GET_SAMPLE_FORMAT(aStream, aCodecCtx), 0); |
105 | + av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); |
106 | + av_opt_set_int(avr, "in_sample_rate", info.sample_rate, 0); |
107 | + av_opt_set_int(avr, "out_sample_rate", info.sample_rate, 0); |
108 | +- av_opt_set_int(avr, "in_channels", info.channels, 0); |
109 | +- av_opt_set_int(avr, "out_channels", info.channels, 0); |
110 | + SWR_INIT(avr); |
111 | + |
112 | + // Convert audio samples |
113 | +Index: libopenshot/src/FFmpegUtilities.h |
114 | +=================================================================== |
115 | +--- libopenshot.orig/src/FFmpegUtilities.h |
116 | ++++ libopenshot/src/FFmpegUtilities.h |
117 | +@@ -6,7 +6,7 @@ |
118 | + * @ref License |
119 | + */ |
120 | + |
121 | +-// Copyright (c) 2008-2019 OpenShot Studios, LLC |
122 | ++// Copyright (c) 2008-2024 OpenShot Studios, LLC |
123 | + // |
124 | + // SPDX-License-Identifier: LGPL-3.0-or-later |
125 | + |
126 | +@@ -33,6 +33,8 @@ |
127 | + #define USE_SW FFMPEG_USE_SWRESAMPLE |
128 | + #endif |
129 | + |
130 | ++#define HAVE_CH_LAYOUT (LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 28, 100)) |
131 | ++ |
132 | + // Include the FFmpeg headers |
133 | + extern "C" { |
134 | + #include <libavcodec/avcodec.h> |
135 | +Index: libopenshot/src/FFmpegWriter.cpp |
136 | +=================================================================== |
137 | +--- libopenshot.orig/src/FFmpegWriter.cpp |
138 | ++++ libopenshot/src/FFmpegWriter.cpp |
139 | +@@ -9,7 +9,7 @@ |
140 | + * @ref License |
141 | + */ |
142 | + |
143 | +-// Copyright (c) 2008-2019 OpenShot Studios, LLC, Fabrice Bellard |
144 | ++// Copyright (c) 2008-2024 OpenShot Studios, LLC, Fabrice Bellard |
145 | + // |
146 | + // SPDX-License-Identifier: LGPL-3.0-or-later |
147 | + |
148 | +@@ -1113,7 +1113,9 @@ AVStream *FFmpegWriter::add_audio_stream |
149 | + |
150 | + // Set the sample parameters |
151 | + c->bit_rate = info.audio_bit_rate; |
152 | ++#if !HAVE_CH_LAYOUT |
153 | + c->channels = info.channels; |
154 | ++#endif |
155 | + |
156 | + // Set valid sample rate (or throw error) |
157 | + if (codec->supported_samplerates) { |
158 | +@@ -1131,6 +1133,24 @@ AVStream *FFmpegWriter::add_audio_stream |
159 | + c->sample_rate = info.sample_rate; |
160 | + |
161 | + |
162 | ++#if HAVE_CH_LAYOUT |
163 | ++ // Set a valid number of channels (or throw error) |
164 | ++ AVChannelLayout ch_layout; |
165 | ++ av_channel_layout_from_mask(&ch_layout, info.channel_layout); |
166 | ++ if (codec->ch_layouts) { |
167 | ++ int i; |
168 | ++ for (i = 0; av_channel_layout_check(&codec->ch_layouts[i]); i++) |
169 | ++ if (av_channel_layout_compare(&ch_layout, &codec->ch_layouts[i])) { |
170 | ++ // Set valid channel layout |
171 | ++ av_channel_layout_copy(&c->ch_layout, &ch_layout); |
172 | ++ break; |
173 | ++ } |
174 | ++ if (!av_channel_layout_check(&codec->ch_layouts[i])) |
175 | ++ throw InvalidChannels("An invalid channel layout was detected (i.e. MONO / STEREO).", path); |
176 | ++ } else |
177 | ++ // Set valid channel layout |
178 | ++ av_channel_layout_copy(&c->ch_layout, &ch_layout); |
179 | ++#else |
180 | + // Set a valid number of channels (or throw error) |
181 | + const uint64_t channel_layout = info.channel_layout; |
182 | + if (codec->channel_layouts) { |
183 | +@@ -1146,6 +1166,7 @@ AVStream *FFmpegWriter::add_audio_stream |
184 | + } else |
185 | + // Set valid channel layout |
186 | + c->channel_layout = channel_layout; |
187 | ++#endif |
188 | + |
189 | + // Choose a valid sample_fmt |
190 | + if (codec->sample_fmts) { |
191 | +@@ -1171,13 +1192,30 @@ AVStream *FFmpegWriter::add_audio_stream |
192 | + |
193 | + AV_COPY_PARAMS_FROM_CONTEXT(st, c); |
194 | + |
195 | ++int nb_channels; |
196 | ++uint64_t channel_layout; |
197 | ++const char* nb_channels_label; |
198 | ++const char* channel_layout_label; |
199 | ++ |
200 | ++#if HAVE_CH_LAYOUT |
201 | ++ nb_channels = c->ch_layout.nb_channels; |
202 | ++ channel_layout = c->ch_layout.u.mask; |
203 | ++ nb_channels_label = "c->ch_layout.nb_channels"; |
204 | ++ channel_layout_label = "c->ch_layout.u.mask"; |
205 | ++#else |
206 | ++ nb_channels = c->channels; |
207 | ++ channel_layout = c->channel_layout; |
208 | ++ nb_channels_label = "c->channels"; |
209 | ++ channel_layout_label = "c->channel_layout"; |
210 | ++#endif |
211 | ++ |
212 | + ZmqLogger::Instance()->AppendDebugMethod( |
213 | + "FFmpegWriter::add_audio_stream", |
214 | + "c->codec_id", c->codec_id, |
215 | + "c->bit_rate", c->bit_rate, |
216 | +- "c->channels", c->channels, |
217 | ++ nb_channels_label, nb_channels, |
218 | + "c->sample_fmt", c->sample_fmt, |
219 | +- "c->channel_layout", c->channel_layout, |
220 | ++ channel_layout_label, channel_layout, |
221 | + "c->sample_rate", c->sample_rate); |
222 | + |
223 | + return st; |
224 | +@@ -1740,14 +1778,23 @@ void FFmpegWriter::write_audio_packets(b |
225 | + // setup resample context |
226 | + if (!avr) { |
227 | + avr = SWR_ALLOC(); |
228 | ++#if HAVE_CH_LAYOUT |
229 | ++ AVChannelLayout in_chlayout; |
230 | ++ AVChannelLayout out_chlayout; |
231 | ++ av_channel_layout_from_mask(&in_chlayout, channel_layout_in_frame); |
232 | ++ av_channel_layout_from_mask(&out_chlayout, info.channel_layout); |
233 | ++ av_opt_set_chlayout(avr, "in_chlayout", &in_chlayout, 0); |
234 | ++ av_opt_set_chlayout(avr, "out_chlayout", &out_chlayout, 0); |
235 | ++#else |
236 | + av_opt_set_int(avr, "in_channel_layout", channel_layout_in_frame, 0); |
237 | + av_opt_set_int(avr, "out_channel_layout", info.channel_layout, 0); |
238 | ++ av_opt_set_int(avr, "in_channels", channels_in_frame, 0); |
239 | ++ av_opt_set_int(avr, "out_channels", info.channels, 0); |
240 | ++#endif |
241 | + av_opt_set_int(avr, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0); |
242 | + av_opt_set_int(avr, "out_sample_fmt", output_sample_fmt, 0); // planar not allowed here |
243 | + av_opt_set_int(avr, "in_sample_rate", sample_rate_in_frame, 0); |
244 | + av_opt_set_int(avr, "out_sample_rate", info.sample_rate, 0); |
245 | +- av_opt_set_int(avr, "in_channels", channels_in_frame, 0); |
246 | +- av_opt_set_int(avr, "out_channels", info.channels, 0); |
247 | + SWR_INIT(avr); |
248 | + } |
249 | + // Convert audio samples |
250 | +@@ -1843,14 +1890,21 @@ void FFmpegWriter::write_audio_packets(b |
251 | + // setup resample context |
252 | + if (!avr_planar) { |
253 | + avr_planar = SWR_ALLOC(); |
254 | ++#if HAVE_CH_LAYOUT |
255 | ++ AVChannelLayout layout; |
256 | ++ av_channel_layout_from_mask(&layout, info.channel_layout); |
257 | ++ av_opt_set_chlayout(avr_planar, "in_chlayout", &layout, 0); |
258 | ++ av_opt_set_chlayout(avr_planar, "out_chlayout", &layout, 0); |
259 | ++#else |
260 | + av_opt_set_int(avr_planar, "in_channel_layout", info.channel_layout, 0); |
261 | + av_opt_set_int(avr_planar, "out_channel_layout", info.channel_layout, 0); |
262 | ++ av_opt_set_int(avr_planar, "in_channels", info.channels, 0); |
263 | ++ av_opt_set_int(avr_planar, "out_channels", info.channels, 0); |
264 | ++#endif |
265 | + av_opt_set_int(avr_planar, "in_sample_fmt", output_sample_fmt, 0); |
266 | + av_opt_set_int(avr_planar, "out_sample_fmt", audio_codec_ctx->sample_fmt, 0); // planar not allowed here |
267 | + av_opt_set_int(avr_planar, "in_sample_rate", info.sample_rate, 0); |
268 | + av_opt_set_int(avr_planar, "out_sample_rate", info.sample_rate, 0); |
269 | +- av_opt_set_int(avr_planar, "in_channels", info.channels, 0); |
270 | +- av_opt_set_int(avr_planar, "out_channels", info.channels, 0); |
271 | + SWR_INIT(avr_planar); |
272 | + } |
273 | + |
274 | +@@ -1878,9 +1932,13 @@ void FFmpegWriter::write_audio_packets(b |
275 | + |
276 | + // Create output frame (and allocate arrays) |
277 | + frame_final->nb_samples = audio_input_frame_size; |
278 | ++#if HAVE_CH_LAYOUT |
279 | ++ av_channel_layout_from_mask(&frame_final->ch_layout, info.channel_layout); |
280 | ++#else |
281 | + frame_final->channels = info.channels; |
282 | +- frame_final->format = audio_codec_ctx->sample_fmt; |
283 | + frame_final->channel_layout = info.channel_layout; |
284 | ++#endif |
285 | ++ frame_final->format = audio_codec_ctx->sample_fmt; |
286 | + av_samples_alloc(frame_final->data, frame_final->linesize, info.channels, |
287 | + frame_final->nb_samples, audio_codec_ctx->sample_fmt, 0); |
288 | + |
289 | +@@ -1929,7 +1987,12 @@ void FFmpegWriter::write_audio_packets(b |
290 | + frame_final->nb_samples = audio_input_frame_size; |
291 | + |
292 | + // Fill the final_frame AVFrame with audio (non planar) |
293 | +- avcodec_fill_audio_frame(frame_final, audio_codec_ctx->channels, |
294 | ++#if HAVE_CH_LAYOUT |
295 | ++ int nb_channels = audio_codec_ctx->ch_layout.nb_channels; |
296 | ++#else |
297 | ++ int nb_channels = audio_codec_ctx->channels; |
298 | ++#endif |
299 | ++ avcodec_fill_audio_frame(frame_final, nb_channels, |
300 | + audio_codec_ctx->sample_fmt, (uint8_t *) final_samples, |
301 | + audio_encoder_buffer_size, 0); |
302 | + } |
303 | diff --git a/debian/patches/series b/debian/patches/series |
304 | index 6270f19..522857a 100644 |
305 | --- a/debian/patches/series |
306 | +++ b/debian/patches/series |
307 | @@ -1 +1,2 @@ |
308 | 0001-Include-SOVERSION-in-VERSION.patch |
309 | +0002-fix-ffmpeg-7.patch |
- Please add ftbfs bug and reference it in the changelog/patch
- Please run quilt refresh.
- Needs PPA build