Last active
January 9, 2022 00:29
-
-
Save kode54/5c5005be2365ef7c4592f9cbccb898bc to your computer and use it in GitHub Desktop.
FFmpeg AudioToolbox fixes and other minor changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 91a7dee45f53d3b7049520363e68573a27c951c6 Mon Sep 17 00:00:00 2001 | |
From: Christopher Snowhill <kode54@gmail.com> | |
Date: Tue, 21 Dec 2021 20:51:44 -0800 | |
Subject: [PATCH] avcodec/audiotoolboxdec: Properly fill out_format | |
X-Unsent: 1 | |
To: ffmpeg-devel@ffmpeg.org | |
Monterey needs mBytesPerFrame and mBytesPerPacket to be set, and I'm | |
surprised this didn't break any previous system versions. | |
Fixes bug #9564: Cannot decode xHE-AAC with audiotoolbox (aac_at) on | |
Mac OS Monterey. Fixes likely bug that none of the AudioToolbox | |
decoders work on Monterey. | |
Signed-off-by: Christopher Snowhill <kode54@gmail.com> | |
--- | |
libavcodec/audiotoolboxdec.c | 5 +++++ | |
1 file changed, 5 insertions(+) | |
diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c | |
index 9939fef218..4abcb63a03 100644 | |
--- a/libavcodec/audiotoolboxdec.c | |
+++ b/libavcodec/audiotoolboxdec.c | |
@@ -370,6 +370,11 @@ static av_cold int ffat_create_decoder(AVCodecContext *avctx, | |
avctx->sample_rate = out_format.mSampleRate = in_format.mSampleRate; | |
avctx->channels = out_format.mChannelsPerFrame = in_format.mChannelsPerFrame; | |
+ out_format.mBytesPerFrame = | |
+ out_format.mChannelsPerFrame * (out_format.mBitsPerChannel / 8); | |
+ out_format.mBytesPerPacket = | |
+ out_format.mBytesPerFrame * out_format.mFramesPerPacket; | |
+ | |
if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_QT) | |
in_format.mFramesPerPacket = 64; | |
-- | |
2.32.0 (Apple Git-132) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 251fc6bc3cfa42947a3f72b69f1e517d2716d286 Mon Sep 17 00:00:00 2001 | |
From: Christopher Snowhill <kode54@gmail.com> | |
Date: Tue, 21 Dec 2021 20:54:38 -0800 | |
Subject: [PATCH] avcodec/audiotoolboxdec: Decode appropriate formats to float | |
X-Unsent: 1 | |
To: ffmpeg-devel@ffmpeg.org | |
These candidate formats are likely already decoded in floating point | |
internally anyway, so request float output so that it's also possible | |
to clip or peak level as necessary. | |
Signed-off-by: Christopher Snowhill <kode54@gmail.com> | |
--- | |
libavcodec/audiotoolboxdec.c | 36 ++++++++++++++++++++++++++++++++---- | |
1 file changed, 32 insertions(+), 4 deletions(-) | |
diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c | |
index 4abcb63a03..427f143468 100644 | |
--- a/libavcodec/audiotoolboxdec.c | |
+++ b/libavcodec/audiotoolboxdec.c | |
@@ -297,6 +297,25 @@ static int ffat_set_extradata(AVCodecContext *avctx) | |
return 0; | |
} | |
+static bool ffat_get_format_is_float(enum AVCodecID codec) | |
+{ | |
+ switch (codec) { | |
+ case AV_CODEC_ID_AAC: | |
+ case AV_CODEC_ID_AC3: | |
+ case AV_CODEC_ID_AMR_NB: | |
+ case AV_CODEC_ID_EAC3: | |
+ case AV_CODEC_ID_ILBC: | |
+ case AV_CODEC_ID_MP1: | |
+ case AV_CODEC_ID_MP2: | |
+ case AV_CODEC_ID_MP3: | |
+ case AV_CODEC_ID_QDMC: | |
+ case AV_CODEC_ID_QDM2: | |
+ return true; | |
+ default: | |
+ return false; | |
+ } | |
+} | |
+ | |
static av_cold int ffat_create_decoder(AVCodecContext *avctx, | |
const AVPacket *pkt) | |
{ | |
@@ -304,8 +323,12 @@ static av_cold int ffat_create_decoder(AVCodecContext *avctx, | |
OSStatus status; | |
int i; | |
- enum AVSampleFormat sample_fmt = (avctx->bits_per_raw_sample == 32) ? | |
- AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S16; | |
+ bool sample_fmt_is_float = ffat_get_format_is_float(avctx->codec_id); | |
+ | |
+ enum AVSampleFormat sample_fmt = sample_fmt_is_float ? | |
+ AV_SAMPLE_FMT_FLT : | |
+ ((avctx->bits_per_raw_sample == 32) ? | |
+ AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S16); | |
AudioStreamBasicDescription in_format = { | |
.mFormatID = ffat_get_format_id(avctx->codec_id, avctx->profile), | |
@@ -313,7 +336,10 @@ static av_cold int ffat_create_decoder(AVCodecContext *avctx, | |
}; | |
AudioStreamBasicDescription out_format = { | |
.mFormatID = kAudioFormatLinearPCM, | |
- .mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked, | |
+ .mFormatFlags = (sample_fmt_is_float ? | |
+ kAudioFormatFlagIsFloat : | |
+ kAudioFormatFlagIsSignedInteger) | | |
+ kAudioFormatFlagIsPacked, | |
.mFramesPerPacket = 1, | |
.mBitsPerChannel = av_get_bytes_per_sample(sample_fmt) * 8, | |
}; | |
@@ -471,7 +497,9 @@ static OSStatus ffat_decode_callback(AudioConverterRef converter, UInt32 *nb_pac | |
static void ffat_copy_samples(AVCodecContext *avctx, AVFrame *frame) | |
{ | |
ATDecodeContext *at = avctx->priv_data; | |
- if (avctx->sample_fmt == AV_SAMPLE_FMT_S32) { | |
+ if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) { | |
+ COPY_SAMPLES(float); | |
+ } else if (avctx->sample_fmt == AV_SAMPLE_FMT_S32) { | |
COPY_SAMPLES(int32_t); | |
} else { | |
COPY_SAMPLES(int16_t); | |
-- | |
2.32.0 (Apple Git-132) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 58a0eebe4f0aa606909ffe7d7b1a2aa5f48b7ee6 Mon Sep 17 00:00:00 2001 | |
From: Christopher Snowhill <kode54@gmail.com> | |
Date: Sat, 8 Jan 2022 16:25:39 -0800 | |
Subject: [PATCH] avformat/id3v1: Update genre list | |
Signed-off-by: Christopher Snowhill <kode54@gmail.com> | |
--- | |
libavformat/id3v1.c | 10 +++++----- | |
1 file changed, 5 insertions(+), 5 deletions(-) | |
diff --git a/libavformat/id3v1.c b/libavformat/id3v1.c | |
index 3189a48b8c..19760595d5 100644 | |
--- a/libavformat/id3v1.c | |
+++ b/libavformat/id3v1.c | |
@@ -53,7 +53,7 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] = { | |
[26] = "Ambient", | |
[27] = "Trip-Hop", | |
[28] = "Vocal", | |
- [29] = "Jazz+Funk", | |
+ [29] = "Jazz-Funk", | |
[30] = "Fusion", | |
[31] = "Trance", | |
[32] = "Classical", | |
@@ -114,7 +114,7 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] = { | |
[87] = "Revival", | |
[88] = "Celtic", | |
[89] = "Bluegrass", | |
- [90] = "Avantgarde", | |
+ [90] = "Avant-garde", | |
[91] = "Gothic Rock", | |
[92] = "Progressive Rock", | |
[93] = "Psychedelic Rock", | |
@@ -149,15 +149,15 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] = { | |
[122] = "Drum Solo", | |
[123] = "A Cappella", | |
[124] = "Euro-House", | |
- [125] = "Dance Hall", | |
+ [125] = "Dancehall", | |
[126] = "Goa", | |
[127] = "Drum & Bass", | |
[128] = "Club-House", | |
[129] = "Hardcore Techno", | |
[130] = "Terror", | |
[131] = "Indie", | |
- [132] = "BritPop", | |
- [133] = "Negerpunk", | |
+ [132] = "Britpop", | |
+ [133] = "Worldbeat", | |
[134] = "Polsk Punk", | |
[135] = "Beat", | |
[136] = "Christian Gangsta Rap", | |
-- | |
2.32.0 (Apple Git-132) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment