From patchwork Tue Aug 20 17:25:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 14630 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 49969449364 for ; Tue, 20 Aug 2019 20:25:42 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 226C56800AD; Tue, 20 Aug 2019 20:25:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6F37A68A0B6 for ; Tue, 20 Aug 2019 20:25:35 +0300 (EEST) Received: by mail-io1-f47.google.com with SMTP id 18so13783352ioe.10 for ; Tue, 20 Aug 2019 10:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=icj0jNfzyIvYWk0wVVH+5/OT7keZRG3WSUAK+X0XaQQ=; b=J0xe88hno7jlVv0jHSUd7nDLJAZMeCMcY1M0H2fNBKAVHqMp1tQlLdizODS4gZXPjN pO34nkdbi0XpEtOt6sz9ZkKMdfFhO6kujSDDMoW19ghpGEW3aPwVDKv3+fEUq6Wu422u 5fD4d0veK94tj2ClgCJCIt6HoR8gHRHRkh9uPVQE7j2V0Y/sGhtD19ldscX5gAcp7rGH c/lEjtgo+Z1Wsv2KEiWQL++Ezxen8CbiBNO0oWc8zoTYrJaZvqQ9ZwJ2IXVUI4sHPkbd I+OvrdgS3BlOJBRgHikiuBSNtdZgDbHg3e8eEus22mCA1VtcI4+q29PekESijpgoqqoO 81fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=icj0jNfzyIvYWk0wVVH+5/OT7keZRG3WSUAK+X0XaQQ=; b=iTytlNFC3u8pWqf54CYtGNYctAJi+hVrm0BwXsdE1l9qVpbkbPWK1vrlcvQ6FVgQfD QzpcTjkh92IAJhcQ8UiCuGy/WhK6vV5+6LRwAGkVf+1Tnak9zdVL04sQAwv4gKd1UzZw yeVI2KfVbWogZaOODPhwIAVC2S+I3KqOT9x/ZaABiR60Bx5VURsiQq9O+OxAeY8Ds+pm tdFXinOlFWfh5d/38yT4mDp6CX4KqV+aNVZ8y8Uet3nMcnlVdYUDfv/vqDmZ0cMImhgB 0fhOdXAWotuv3M3MH9leyROcYsT53QkhQdPeED9eyzaSKTZBaeUJN9RLgeMy1XFXEJj/ eqkg== X-Gm-Message-State: APjAAAW6asSHs73o4AQa2/dTaMzeirzd4V+Xi5F/RB+5XrP5rdx+WBWH o48XKtcScuFPWvVE7Zp3FmpdCVaL5RJtqPqPo6lMvQ== X-Google-Smtp-Source: APXvYqyrpBIh0K+OPEokN8rv1sSIu68nrE89qOZjCdc73xI2FUhcSmVBVawU/bg1mhDK3175ksF4pOW2Q1M83p8AQy4= X-Received: by 2002:a5d:9d58:: with SMTP id k24mr21151659iok.289.1566321933928; Tue, 20 Aug 2019 10:25:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Carl Eugen Hoyos Date: Tue, 20 Aug 2019 19:25:22 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH]lavc/g729dec: Support decoding ACELP.KELVIN X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Am Di., 20. Aug. 2019 um 10:30 Uhr schrieb Paul B Mahol : > > Do not use full caps name for short name. New patch attached. Thank you, Carl Eugen From 8af0b279ad0c25425d075498f60b0770528687a2 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 19 Aug 2019 23:34:37 +0200 Subject: [PATCH] lavc/g729dec: Support decoding Sipro ACELP.KELVIN. Fixes ticket #4799. Analyzed-by: Aleksandr Ustinov --- Changelog | 3 +++ configure | 1 + doc/general.texi | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h | 1 + libavcodec/codec_desc.c | 6 ++++++ libavcodec/g729_parser.c | 5 +++-- libavcodec/g729dec.c | 21 +++++++++++++++++++-- libavcodec/version.h | 2 +- libavformat/riff.c | 1 + 10 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index 389ca6c4db..42c1d16207 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,9 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version : +- support Sipro ACELP.KELVIN decoding + version 4.2: - tpad filter - AV1 decoding support through libdav1d diff --git a/configure b/configure index c09c842809..fc073967b3 100755 --- a/configure +++ b/configure @@ -2635,6 +2635,7 @@ ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct" ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp mdct" ac3_encoder_select="ac3dsp audiodsp mdct me_cmp" ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp" +acelp_kelvin_decoder_select="g729_decoder" adpcm_g722_decoder_select="g722dsp" adpcm_g722_encoder_select="g722dsp" aic_decoder_select="golomb idctdsp" diff --git a/doc/general.texi b/doc/general.texi index 3c0c803449..d90588c63a 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1057,6 +1057,7 @@ following image formats are supported: @item AAC+ @tab E @tab IX @tab encoding supported through external library libfdk-aac @item AC-3 @tab IX @tab IX +@item ACELP.KELVIN @tab @tab X @item ADPCM 4X Movie @tab @tab X @item APDCM Yamaha AICA @tab @tab X @item ADPCM CDROM XA @tab @tab X diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index d2f9a39ce5..5936cdc467 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -32,6 +32,7 @@ extern AVCodec ff_a64multi_encoder; extern AVCodec ff_a64multi5_encoder; extern AVCodec ff_aasc_decoder; +extern AVCodec ff_acelp_kelvin_decoder; extern AVCodec ff_aic_decoder; extern AVCodec ff_alias_pix_encoder; extern AVCodec ff_alias_pix_decoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index d234271c5b..7ec4014d8b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -629,6 +629,7 @@ enum AVCodecID { AV_CODEC_ID_ON2AVC, AV_CODEC_ID_DSS_SP, AV_CODEC_ID_CODEC2, + AV_CODEC_ID_ACELP_KELVIN, AV_CODEC_ID_FFWAVESYNTH = 0x15800, AV_CODEC_ID_SONIC, diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 4d033c20ff..716e278b93 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2834,6 +2834,12 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("codec2 (very low bitrate speech codec)"), .props = AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_ACELP_KELVIN, + .name = "acelp.kelvin", + .long_name = NULL_IF_CONFIG_SMALL("Sipro ACELP.KELVIN"), + .props = AV_CODEC_PROP_LOSSY, + }, { .id = AV_CODEC_ID_FFWAVESYNTH, .type = AVMEDIA_TYPE_AUDIO, diff --git a/libavcodec/g729_parser.c b/libavcodec/g729_parser.c index 9982dbfffc..5a57025d62 100644 --- a/libavcodec/g729_parser.c +++ b/libavcodec/g729_parser.c @@ -45,9 +45,10 @@ static int g729_parse(AVCodecParserContext *s1, AVCodecContext *avctx, int next; if (!s->block_size) { - av_assert1(avctx->codec_id == AV_CODEC_ID_G729); /* FIXME: replace this heuristic block_size with more precise estimate */ s->block_size = (avctx->bit_rate < 8000) ? G729D_6K4_BLOCK_SIZE : G729_8K_BLOCK_SIZE; + if (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN) + s->block_size++; s->block_size *= avctx->channels; s->duration = avctx->frame_size; } @@ -76,7 +77,7 @@ static int g729_parse(AVCodecParserContext *s1, AVCodecContext *avctx, } AVCodecParser ff_g729_parser = { - .codec_ids = { AV_CODEC_ID_G729 }, + .codec_ids = { AV_CODEC_ID_G729, AV_CODEC_ID_ACELP_KELVIN }, .priv_data_size = sizeof(G729ParseContext), .parser_parse = g729_parse, .parser_close = ff_parse_close, diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c index 2e4756b805..5a5da5b03c 100644 --- a/libavcodec/g729dec.c +++ b/libavcodec/g729dec.c @@ -424,7 +424,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; - if (buf_size % (G729_8K_BLOCK_SIZE * avctx->channels) == 0) { + if (buf_size % ((G729_8K_BLOCK_SIZE + (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)) * avctx->channels) == 0) { packet_type = FORMAT_G729_8K; format = &format_g729_8k; //Reset voice decision @@ -445,6 +445,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, int bad_pitch = 0; ///< parity check failed int is_periodic = 0; ///< whether one of the subframes is declared as periodic or not out_frame = (int16_t*)frame->data[c]; + if (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN) { + if (*buf != ((avctx->channels - 1 - c) * 0x80 | 2)) + avpriv_request_sample(avctx, "First byte value %x for channel %d", *buf, c); + buf++; + } for (i = 0; i < buf_size; i++) frame_erasure |= buf[i]; @@ -727,7 +732,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, } *got_frame_ptr = 1; - return packet_type == FORMAT_G729_8K ? G729_8K_BLOCK_SIZE * avctx->channels : G729D_6K4_BLOCK_SIZE * avctx->channels; + return packet_type == FORMAT_G729_8K ? (G729_8K_BLOCK_SIZE + (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)) * avctx->channels : G729D_6K4_BLOCK_SIZE * avctx->channels; } static av_cold int decode_close(AVCodecContext *avctx) @@ -749,3 +754,15 @@ AVCodec ff_g729_decoder = { .close = decode_close, .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, }; + +AVCodec ff_acelp_kelvin_decoder = { + .name = "acelp.kelvin", + .long_name = NULL_IF_CONFIG_SMALL("Sipro ACELP.KELVIN"), + .type = AVMEDIA_TYPE_AUDIO, + .id = AV_CODEC_ID_ACELP_KELVIN, + .priv_data_size = sizeof(G729Context), + .init = decoder_init, + .decode = decode_frame, + .close = decode_close, + .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, +}; diff --git a/libavcodec/version.h b/libavcodec/version.h index 43c8cdb59f..ed767c8867 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 58 -#define LIBAVCODEC_VERSION_MINOR 55 +#define LIBAVCODEC_VERSION_MINOR 56 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavformat/riff.c b/libavformat/riff.c index e755ad8d5f..27518216a6 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -534,6 +534,7 @@ const AVCodecTag ff_codec_wav_tags[] = { { AV_CODEC_ID_AAC, 0x00ff }, { AV_CODEC_ID_G723_1, 0x0111 }, { AV_CODEC_ID_SIPR, 0x0130 }, + { AV_CODEC_ID_ACELP_KELVIN, 0x0135 }, { AV_CODEC_ID_WMAV1, 0x0160 }, { AV_CODEC_ID_WMAV2, 0x0161 }, { AV_CODEC_ID_WMAPRO, 0x0162 }, -- 2.22.0