From: Anton Khirnov <anton@khirnov.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] lavc: remove the QOA decoder Date: Sat, 2 Dec 2023 16:53:52 +0100 Message-ID: <20231202155352.4680-1-anton@khirnov.net> (raw) Its author not only failed to add any tests, as is required by the development rules, but continues to actively refuse to do so. Untested decoders are worse than useless, so remove it. --- Changelog | 2 +- libavcodec/Makefile | 1 - libavcodec/allcodecs.c | 1 - libavcodec/qoadec.c | 170 ----------------------------------------- 4 files changed, 1 insertion(+), 173 deletions(-) delete mode 100644 libavcodec/qoadec.c diff --git a/Changelog b/Changelog index f00bc27ca4..3d3b079089 100644 --- a/Changelog +++ b/Changelog @@ -5,7 +5,7 @@ version <next>: - LEAD MCMP decoder - EVC decoding using external library libxevd - EVC encoding using external library libxeve -- QOA decoder and demuxer +- QOA demuxer - aap filter version 6.1: diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 748806e702..a5941d1284 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -623,7 +623,6 @@ OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o \ OBJS-$(CONFIG_QDM2_DECODER) += qdm2.o OBJS-$(CONFIG_QDMC_DECODER) += qdmc.o OBJS-$(CONFIG_QDRAW_DECODER) += qdrw.o -OBJS-$(CONFIG_QOA_DECODER) += qoadec.o OBJS-$(CONFIG_QOI_DECODER) += qoidec.o OBJS-$(CONFIG_QOI_ENCODER) += qoienc.o OBJS-$(CONFIG_QPEG_DECODER) += qpeg.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index b0f004e15c..87595683f9 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -522,7 +522,6 @@ extern const FFCodec ff_paf_audio_decoder; extern const FFCodec ff_qcelp_decoder; extern const FFCodec ff_qdm2_decoder; extern const FFCodec ff_qdmc_decoder; -extern const FFCodec ff_qoa_decoder; extern const FFCodec ff_ra_144_encoder; extern const FFCodec ff_ra_144_decoder; extern const FFCodec ff_ra_288_decoder; diff --git a/libavcodec/qoadec.c b/libavcodec/qoadec.c deleted file mode 100644 index 443f42a527..0000000000 --- a/libavcodec/qoadec.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * QOA decoder - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "avcodec.h" -#include "codec_internal.h" -#include "decode.h" -#include "get_bits.h" -#include "bytestream.h" -#include "mathops.h" - -#define QOA_SLICE_LEN 20 -#define QOA_LMS_LEN 4 - -typedef struct QOAChannel { - int history[QOA_LMS_LEN]; - int weights[QOA_LMS_LEN]; -} QOAChannel; - -typedef struct QOAContext { - QOAChannel ch[256]; -} QOAContext; - -static const int16_t qoa_dequant_tab[16][8] = { - { 1, -1, 3, -3, 5, -5, 7, -7}, - { 5, -5, 18, -18, 32, -32, 49, -49}, - { 16, -16, 53, -53, 95, -95, 147, -147}, - { 34, -34, 113, -113, 203, -203, 315, -315}, - { 63, -63, 210, -210, 378, -378, 588, -588}, - { 104, -104, 345, -345, 621, -621, 966, -966}, - { 158, -158, 528, -528, 950, -950, 1477, -1477}, - { 228, -228, 760, -760, 1368, -1368, 2128, -2128}, - { 316, -316, 1053, -1053, 1895, -1895, 2947, -2947}, - { 422, -422, 1405, -1405, 2529, -2529, 3934, -3934}, - { 548, -548, 1828, -1828, 3290, -3290, 5117, -5117}, - { 696, -696, 2320, -2320, 4176, -4176, 6496, -6496}, - { 868, -868, 2893, -2893, 5207, -5207, 8099, -8099}, - {1064, -1064, 3548, -3548, 6386, -6386, 9933, -9933}, - {1286, -1286, 4288, -4288, 7718, -7718, 12005, -12005}, - {1536, -1536, 5120, -5120, 9216, -9216, 14336, -14336}, -}; - -static av_cold int qoa_decode_init(AVCodecContext *avctx) -{ - avctx->sample_fmt = AV_SAMPLE_FMT_S16; - - return 0; -} - -static int qoa_lms_predict(QOAChannel *lms) -{ - int prediction = 0; - for (int i = 0; i < QOA_LMS_LEN; i++) - prediction += lms->weights[i] * lms->history[i]; - return prediction >> 13; -} - -static void qoa_lms_update(QOAChannel *lms, int sample, int residual) -{ - int delta = residual >> 4; - for (int i = 0; i < QOA_LMS_LEN; i++) - lms->weights[i] += lms->history[i] < 0 ? -delta : delta; - for (int i = 0; i < QOA_LMS_LEN-1; i++) - lms->history[i] = lms->history[i+1]; - lms->history[QOA_LMS_LEN-1] = sample; -} - -static int qoa_decode_frame(AVCodecContext *avctx, AVFrame *frame, - int *got_frame_ptr, AVPacket *avpkt) -{ - QOAContext *s = avctx->priv_data; - int ret, frame_size, nb_channels, sample_rate; - GetByteContext gb; - int16_t *samples; - - bytestream2_init(&gb, avpkt->data, avpkt->size); - - nb_channels = bytestream2_get_byte(&gb); - sample_rate = bytestream2_get_be24(&gb); - if (!sample_rate || !nb_channels) - return AVERROR_INVALIDDATA; - - if (nb_channels != avctx->ch_layout.nb_channels) { - av_channel_layout_uninit(&avctx->ch_layout); - av_channel_layout_default(&avctx->ch_layout, nb_channels); - if ((ret = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout)) < 0) - return ret; - } - - frame->sample_rate = avctx->sample_rate = sample_rate; - - frame->nb_samples = bytestream2_get_be16(&gb); - frame_size = bytestream2_get_be16(&gb); - if (frame_size > avpkt->size) - return AVERROR_INVALIDDATA; - - if (frame_size < 8 + QOA_LMS_LEN * 4 * nb_channels + - 8LL * frame->nb_samples * nb_channels / QOA_SLICE_LEN) - return AVERROR_INVALIDDATA; - - if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) - return ret; - samples = (int16_t *)frame->data[0]; - - for (int ch = 0; ch < nb_channels; ch++) { - QOAChannel *qch = &s->ch[ch]; - - for (int n = 0; n < QOA_LMS_LEN; n++) - qch->history[n] = sign_extend(bytestream2_get_be16u(&gb), 16); - for (int n = 0; n < QOA_LMS_LEN; n++) - qch->weights[n] = sign_extend(bytestream2_get_be16u(&gb), 16); - } - - for (int sample_index = 0; sample_index < frame->nb_samples * nb_channels; - sample_index += QOA_SLICE_LEN) { - for (int ch = 0; ch < nb_channels; ch++) { - QOAChannel *lms = &s->ch[ch]; - uint64_t slice = bytestream2_get_be64u(&gb); - int scalefactor = (slice >> 60) & 0xf; - int slice_start = sample_index * nb_channels + ch; - int slice_end = av_clip(sample_index + QOA_SLICE_LEN, 0, frame->nb_samples) * nb_channels + ch; - - for (int si = slice_start; si < slice_end; si += nb_channels) { - int predicted = qoa_lms_predict(lms); - int quantized = (slice >> 57) & 0x7; - int dequantized = qoa_dequant_tab[scalefactor][quantized]; - int reconstructed = av_clip_int16(predicted + dequantized); - - samples[si] = reconstructed; - slice <<= 3; - - qoa_lms_update(lms, reconstructed, dequantized); - } - } - } - - *got_frame_ptr = 1; - - return avpkt->size; -} - -const FFCodec ff_qoa_decoder = { - .p.name = "qoa", - CODEC_LONG_NAME("QOA (Quite OK Audio)"), - .p.type = AVMEDIA_TYPE_AUDIO, - .p.id = AV_CODEC_ID_QOA, - .priv_data_size = sizeof(QOAContext), - .init = qoa_decode_init, - FF_CODEC_DECODE_CB(qoa_decode_frame), - .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | - AV_CODEC_CAP_DR1, - .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, - AV_SAMPLE_FMT_NONE }, -}; -- 2.42.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2023-12-02 15:54 UTC|newest] Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-02 15:53 Anton Khirnov [this message] 2023-12-02 16:07 ` Paul B Mahol [not found] ` <42528A64-3630-4EBD-A2D2-A6A3E63709BB@cosmin.at> 2023-12-02 18:19 ` Cosmin Stejerean via ffmpeg-devel 2023-12-02 18:55 ` Paul B Mahol 2023-12-04 18:57 ` Jean-Baptiste Kempf 2023-12-04 18:53 ` Nicolas George 2023-12-05 4:21 ` Vittorio Giovara 2023-12-05 7:44 ` Nicolas George 2023-12-05 14:51 ` Vittorio Giovara 2023-12-05 14:59 ` Nicolas George 2023-12-05 15:42 ` Vittorio Giovara 2023-12-06 20:47 ` Nicolas George 2023-12-06 20:55 ` Vittorio Giovara 2023-12-19 13:57 ` Tomas Härdin 2023-12-19 14:02 ` Nicolas George 2023-12-20 16:57 ` Tomas Härdin 2023-12-20 18:05 ` Nicolas George 2023-12-20 19:11 ` Michael Niedermayer 2023-12-21 19:43 ` Tomas Härdin 2023-12-21 20:05 ` Paul B Mahol 2023-12-21 20:31 ` Nicolas George 2023-12-21 21:36 ` Vittorio Giovara 2023-12-21 22:21 ` Nicolas George 2023-12-21 22:37 ` Vittorio Giovara 2023-12-21 22:41 ` Nicolas George 2023-12-21 23:12 ` Vittorio Giovara 2023-12-21 23:14 ` Nicolas George 2023-12-21 23:24 ` Vittorio Giovara 2023-12-22 0:32 ` Michael Niedermayer 2023-12-24 1:17 ` Michael Niedermayer 2023-12-26 13:52 ` [FFmpeg-devel] Mailinglist conduct [was: Re: [PATCH] lavc: remove the QOA decoder] Ronald S. Bultje 2023-12-21 21:38 ` [FFmpeg-devel] [PATCH] lavc: remove the QOA decoder Vittorio Giovara 2023-12-22 6:28 ` Anton Khirnov 2023-12-22 9:28 ` Paul B Mahol 2023-12-22 13:09 ` James Almer 2023-12-24 12:10 ` Tomas Härdin 2023-12-24 12:12 ` Nicolas George 2023-12-24 13:23 ` James Almer 2023-12-24 14:33 ` Tomas Härdin 2023-12-24 14:47 ` Paul B Mahol 2023-12-24 15:11 ` Nicolas George 2023-12-24 17:21 ` Michael Niedermayer 2023-12-24 20:55 ` Tomas Härdin 2023-12-24 21:07 ` Paul B Mahol 2023-12-26 22:20 ` [FFmpeg-devel] Mailinglist conduct [was: Re: [PATCH] lavc: remove the QOA decoder] Ronald S. Bultje 2023-12-26 22:40 ` Paul B Mahol 2023-12-26 23:53 ` James Almer 2023-12-27 8:13 ` Paul B Mahol 2023-12-22 3:32 ` [FFmpeg-devel] [PATCH] lavc: remove the QOA decoder Michael Niedermayer 2023-12-25 17:22 ` Leo Izen 2023-12-26 12:58 ` Michael Niedermayer 2023-12-06 20:49 ` James Almer 2023-12-07 7:17 ` Anton Khirnov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231202155352.4680-1-anton@khirnov.net \ --to=anton@khirnov.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git