~alpine/aports

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH] testing/loudgain: new aport

Holy-Elie Scaide <hey@hescaide.me>
Details
Message ID
<20241128202520.20807-1-hey@hescaide.me>
DKIM signature
missing
Download raw message
Patch: +248 -0
https://github.com/Moonbase59/loudgain
A loudness normalizer according to the EBU R128 standard
---
 testing/loudgain/APKBUILD             |  33 +++++++
 testing/loudgain/av_register.patch    |  14 +++
 testing/loudgain/ffmpeg7.patch        | 122 ++++++++++++++++++++++++++
 testing/loudgain/loudgain-0.6.8.patch |  14 +++
 testing/loudgain/taglib.patch         |  65 ++++++++++++++
 5 files changed, 248 insertions(+)
 create mode 100644 testing/loudgain/APKBUILD
 create mode 100644 testing/loudgain/av_register.patch
 create mode 100644 testing/loudgain/ffmpeg7.patch
 create mode 100644 testing/loudgain/loudgain-0.6.8.patch
 create mode 100644 testing/loudgain/taglib.patch

diff --git a/testing/loudgain/APKBUILD b/testing/loudgain/APKBUILD
new file mode 100644
index 00000000000..cddcefd4312
--- /dev/null
+++ b/testing/loudgain/APKBUILD
@@ -0,0 +1,33 @@
# Maintainer: Holy-Elie Scaide <hey@hescaide.me>
pkgname=loudgain
pkgver=0.6.8
pkgrel=0
pkgdesc="A loudness normalizer according to the EBU R128 standard"
url="https://github.com/Moonbase59/loudgain"
arch="all"
license="BSD 2-Clause"
makedepends="cmake taglib-dev libebur128-dev ffmpeg-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/Moonbase59/loudgain/archive/refs/tags/v$pkgver.tar.gz
	av_register.patch
	loudgain-0.6.8.patch
	ffmpeg7.patch
	taglib.patch
	"

build() {
	cmake -B build -DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
e41bb6ee3dd85728b8b59b84a1371a88a439a30166db628fae70abe5c20cf9b6c450ee5b1aaa61c971de124cd9be9dbacac4b50f232f64c076d45aafc79ed94c  loudgain-0.6.8.tar.gz
233a0b671415fbf848e6d4e7f46ded6ef254e25fd11b36290d41f94703fc849e26e4b55ac6d02b607b2b15c4b4150519caee00ce7b3c9cf772d25c5c9edec619  av_register.patch
6666a8cb3a74294b0825170c940090138ac4616e56c330836883187edf2c6b284ff5ede557206fc8e57111a23b7fd68d84922c5604cd065e25d3d5a54d224c77  loudgain-0.6.8.patch
ecf37010f33490e6ba61a00bf2541b5ec1b87210af0c23f842148ad689605c0fcd15925d99b425329fbcbdb71498d82f149b177aa0f5ddb64bbc2924589396ee  ffmpeg7.patch
b6046112bdb96a4e16edf0bbb6c75c73f3b4965f9e4ed5dfa321b78918b4f8af1aa813ab248824637638dc469074e84db364049d6dc23ce1bbed6bfc753da80b  taglib.patch
"
diff --git a/testing/loudgain/av_register.patch b/testing/loudgain/av_register.patch
new file mode 100644
index 00000000000..7b02714de79
--- /dev/null
+++ b/testing/loudgain/av_register.patch
@@ -0,0 +1,14 @@
# Source: https://github.com/Moonbase59/loudgain/pull/50#issuecomment-1050879198
--- a/src/scan.c~	2019-09-06 16:31:19.000000000 +0100
+++ b/src/scan.c	2022-02-25 13:33:06.186080276 +0000
@@ -69,8 +69,9 @@ int scan_init(unsigned nb_files) {
 	 * It is now useless
 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
 	 */
-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58,9,100)
     av_register_all();
+#endif
 
 	av_log_set_callback(scan_av_log);
 
diff --git a/testing/loudgain/ffmpeg7.patch b/testing/loudgain/ffmpeg7.patch
new file mode 100644
index 00000000000..09f559566c6
--- /dev/null
+++ b/testing/loudgain/ffmpeg7.patch
@@ -0,0 +1,122 @@
Description: Update src/scan.c for FFmpeg 7.0
Author: Hugh McMaster <hmc@debian.org>
Bug-Debian: https://bugs.debian.org/1072433
Forwarded: https://github.com/Moonbase59/loudgain/pull/66
Last-Update: 2024-07-30

---
 src/scan.c | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

--- a/src/scan.c
+++ b/src/scan.c
@@ -120,7 +120,7 @@
 	AVCodecContext *ctx;
 
 	AVFrame *frame;
-	AVPacket packet;
+	AVPacket *packet;
 
 	SwrContext *swr;
 
@@ -178,8 +178,8 @@
 	}
 
   // try to get default channel layout (they aren’t specified in .wav files)
-  if (!ctx->channel_layout)
-    ctx->channel_layout = av_get_default_channel_layout(ctx->channels);
+  if (ctx->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
+    av_channel_layout_default(&ctx->ch_layout, ctx->ch_layout.nb_channels);
 
   // show some information about the file
   // only show bits/sample where it makes sense
@@ -188,21 +188,21 @@
     snprintf(infotext, sizeof(infotext), "%d bit, ",
       ctx->bits_per_raw_sample > 0 ? ctx->bits_per_raw_sample : ctx->bits_per_coded_sample);
   }
-  av_get_channel_layout_string(infobuf, sizeof(infobuf), -1, ctx->channel_layout);
+  av_channel_layout_describe(&ctx->ch_layout, infobuf, sizeof(infobuf));
   ok_printf("Stream #%d: %s, %s%d Hz, %d ch, %s",
-    stream_id, codec->long_name, infotext, ctx->sample_rate, ctx->channels, infobuf);
+    stream_id, codec->long_name, infotext, ctx->sample_rate, ctx->ch_layout.nb_channels, infobuf);
 
 	scan_codecs[index] = codec -> id;
 
-	av_init_packet(&packet);
+	packet = av_packet_alloc();
 
-	packet.data = buffer;
-	packet.size = buffer_size;
+	packet->data = buffer;
+	packet->size = buffer_size;
 
 	swr = swr_alloc();
 
 	*ebur128 = ebur128_init(
-		ctx -> channels, ctx -> sample_rate,
+		ctx->ch_layout.nb_channels, ctx->sample_rate,
 		EBUR128_MODE_S | EBUR128_MODE_I | EBUR128_MODE_LRA |
 		EBUR128_MODE_SAMPLE_PEAK | EBUR128_MODE_TRUE_PEAK
 	);
@@ -223,10 +223,10 @@
 
 	progress_bar(0, 0, 0, 0);
 
-	while (av_read_frame(container, &packet) >= 0) {
-		if (packet.stream_index == stream_id) {
+	while (av_read_frame(container, packet) >= 0) {
+		if (packet->stream_index == stream_id) {
 
-      rc = avcodec_send_packet(ctx, &packet);
+      rc = avcodec_send_packet(ctx, packet);
       if (rc < 0) {
         err_printf("Error while sending a packet to the decoder");
         break;
@@ -253,7 +253,7 @@
       av_frame_unref(frame);
     }
 
-		av_packet_unref(&packet);
+		av_packet_unref(packet);
 	}
 
   // complete progress bar for very short files (only cosmetic)
@@ -264,9 +264,11 @@
 
 	av_frame_free(&frame);
 
+        av_packet_free(&packet);
+
 	swr_free(&swr);
 
-	avcodec_close(ctx);
+	avcodec_free_context(&ctx);
 
 	avformat_close_input(&container);
 
@@ -414,12 +416,12 @@
 	int                 out_linesize;
 	enum AVSampleFormat out_fmt = AV_SAMPLE_FMT_S16;
 
-	av_opt_set_channel_layout(swr, "in_channel_layout", frame -> channel_layout, 0);
-	av_opt_set_channel_layout(swr, "out_channel_layout", frame -> channel_layout, 0);
+	av_opt_set_chlayout(swr, "in_chlayout", &frame->ch_layout, 0);
+	av_opt_set_chlayout(swr, "out_chlayout", &frame->ch_layout, 0);
 
   // add channel count to properly handle .wav reading
-  av_opt_set_int(swr, "in_channel_count",  frame -> channels, 0);
-  av_opt_set_int(swr, "out_channel_count", frame -> channels, 0);
+  av_opt_set_int(swr, "in_channel_count",  frame->ch_layout.nb_channels, 0);
+  av_opt_set_int(swr, "out_channel_count", frame->ch_layout.nb_channels, 0);
 
   av_opt_set_int(swr, "in_sample_rate", frame -> sample_rate, 0);
   av_opt_set_int(swr, "out_sample_rate", frame -> sample_rate, 0);
@@ -435,7 +437,7 @@
 	}
 
 	out_size = av_samples_get_buffer_size(
-		&out_linesize, frame -> channels, frame -> nb_samples, out_fmt, 0
+		&out_linesize, frame->ch_layout.nb_channels, frame->nb_samples, out_fmt, 0
 	);
 
 	out_data = av_malloc(out_size);
diff --git a/testing/loudgain/loudgain-0.6.8.patch b/testing/loudgain/loudgain-0.6.8.patch
new file mode 100644
index 00000000000..78724c221d6
--- /dev/null
+++ b/testing/loudgain/loudgain-0.6.8.patch
@@ -0,0 +1,14 @@
diff --git a/src/scan.c~ b/src/scan.c
index 671353d..b46c4d3 100644
--- a/src/scan.c~
+++ b/src/scan.c
@@ -116,7 +116,7 @@ int scan_file(const char *file, unsigned index) {
 
 	AVFormatContext *container = NULL;
 
-	AVCodec *codec;
+	const AVCodec *codec;
 	AVCodecContext *ctx;
 
 	AVFrame *frame;

diff --git a/testing/loudgain/taglib.patch b/testing/loudgain/taglib.patch
new file mode 100644
index 00000000000..f76cae54cbf
--- /dev/null
+++ b/testing/loudgain/taglib.patch
@@ -0,0 +1,65 @@
Description: Update src/tag.cc for TagLib >= 1.12.
 Adapted from an upstream commit.
Author: Hugh McMaster <hmc@debian.org>
Origin: https://github.com/Moonbase59/loudgain/commit/0e03353e6d90198204c2edd9ccf9ecaad6a8e7c8
Forwarded: not-needed
Last-Update: 2024-08-12

--- a/src/tag.cc
+++ b/src/tag.cc
@@ -204,7 +204,9 @@
   if (strip)
     f.strip(TagLib::MPEG::File::APE);
 
-  return f.save(TagLib::MPEG::File::ID3v2, strip, id3v2version);
+  return f.save(TagLib::MPEG::File::ID3v2,
+    strip ? TagLib::MPEG::File::StripOthers : TagLib::MPEG::File::StripNone,
+    id3v2version == 3 ? TagLib::ID3v2::v3 : TagLib::ID3v2::v4);
 }
 
 bool tag_clear_mp3(scan_result *scan, bool strip, int id3v2version) {
@@ -217,7 +219,9 @@
   if (strip)
     f.strip(TagLib::MPEG::File::APE);
 
-  return f.save(TagLib::MPEG::File::ID3v2, strip, id3v2version);
+  return f.save(TagLib::MPEG::File::ID3v2,
+    strip ? TagLib::MPEG::File::StripOthers : TagLib::MPEG::File::StripNone,
+    id3v2version == 3 ? TagLib::ID3v2::v3 : TagLib::ID3v2::v4);
 }
 
 
@@ -490,9 +494,9 @@
 
 void tag_remove_mp4(TagLib::MP4::Tag *tag) {
   TagLib::String desc;
-  TagLib::MP4::ItemListMap &items = tag->itemListMap();
+  TagLib::MP4::ItemMap items = tag->itemMap();
 
-  for(TagLib::MP4::ItemListMap::Iterator item = items.begin();
+  for(TagLib::MP4::ItemMap::Iterator item = items.begin();
       item != items.end(); ++item)
   {
     desc = item->first.upper();
@@ -715,7 +719,9 @@
   }
 
   // no stripping
-  return f.save(TagLib::RIFF::WAV::File::AllTags, false, id3v2version);
+  return f.save(TagLib::RIFF::WAV::File::AllTags,
+    TagLib::RIFF::WAV::File::StripNone,
+    id3v2version == 3 ? TagLib::ID3v2::v3 : TagLib::ID3v2::v4);
 }
 
 bool tag_clear_wav(scan_result *scan, bool strip, int id3v2version) {
@@ -725,7 +731,9 @@
   tag_remove_wav(tag);
 
   // no stripping
-  return f.save(TagLib::RIFF::WAV::File::AllTags, false, id3v2version);
+  return f.save(TagLib::RIFF::WAV::File::AllTags,
+    TagLib::RIFF::WAV::File::StripNone,
+    id3v2version == 3 ? TagLib::ID3v2::v3 : TagLib::ID3v2::v4);
 }
 
 
-- 
2.45.2
Reply to thread Export thread (mbox)