From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 64CF244E1A for ; Mon, 27 Mar 2023 12:39:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8EC3F68CAA1; Mon, 27 Mar 2023 15:39:50 +0300 (EEST) Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 771DE68C9C0 for ; Mon, 27 Mar 2023 15:39:44 +0300 (EEST) Received: by mail-oi1-f174.google.com with SMTP id b19so6202168oib.7 for ; Mon, 27 Mar 2023 05:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679920782; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=zMNJEi1RiequC38YONjkdTJdlH3jEXdqYy2o+UCPwpE=; b=c8hIdGvjb2+XWaguZtGZkl+wxYFMhJQdSDpW03Uf7oJIfetHfKlGP3kNqJfI4TPPAD SW12EF3TBdKgu60T/hYZaXGy4W0YOHWOHBCKog6eUh72SkBo0Lpj1143f2LHoXinbcQJ FXyFUQHJuyQDv5UDhESSGfwYB1+5UsKKmX/XXYE0uwtohCNxG04s05hIrJ+0kFaKepAn SJkKV7CFBzwT6KLG5Ut0S5NQT6mvTK+4XTxIEY7YaWWgC/OoIRbzVqk/krMMjciTX5SJ 3BBt4qvYzXGyiYt0w0+eAgC3CEXCHR5roLTsyW4sNi5gZiPfdTH0+hkRguv0RgCFpSd6 zppA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679920782; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zMNJEi1RiequC38YONjkdTJdlH3jEXdqYy2o+UCPwpE=; b=o5BzRo7Ji/chgO52c/6osrxumzlvyeKE6qPXjQFoLbuSEs/04vvi4Cka5vrwmGzMsE KpvoW8sY4UV7YvwoX3w0Cs/peDCBcJkl4hP2QnCfns0r/WN8hdlZJUvgv//vEh5pZgzs aG3/9bSv54YBUo9FXclIZno3GQRN6DKyOuRnKvS0huLWSDeJcQqutOfOGzHXaPEy7bNw +IdzsUvwFM0GNYaM5fH/YiwxyN06xUNgnyCQ326eQLbLPbMCLsNynGmETwdyM6tq74k9 GjyqRcJ4/BdQHMvCxSTC1hXERLx6k8B63bgamMW4W3PHXRsolXOMejhxMJruK+jmZw/B 3t9Q== X-Gm-Message-State: AO0yUKU5jyfuDa+Bzgz1sVr7SKKg2K0AzMDxb+YK3L1hbVFVRlcnx05M IGc9/qJDXI+KYOw5HpixCaDqXxm1w4s= X-Google-Smtp-Source: AK7set/zws7h86XPhZBv3X2N/disy1LdZ7nKk0NeynIT4EaBF3C+lqyn4FTPDOf7ZMKaeUgalUfaRw== X-Received: by 2002:aca:be08:0:b0:386:b298:e398 with SMTP id o8-20020acabe08000000b00386b298e398mr4130347oif.22.1679920782222; Mon, 27 Mar 2023 05:39:42 -0700 (PDT) Received: from [192.168.0.14] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id r138-20020acaa890000000b00387367989d7sm5870554oie.23.2023.03.27.05.39.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Mar 2023 05:39:41 -0700 (PDT) Message-ID: Date: Mon, 27 Mar 2023 09:39:55 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 To: ffmpeg-devel@ffmpeg.org References: Content-Language: en-US From: James Almer In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] Add option to encode short aac ld/eld frames with libfdk_aac X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 3/27/2023 9:28 AM, Raphael Schlarb wrote: > Some specifications require the size of ld/eld frames to be 480 samples > instead of the default 512. libfdk_aac provides an option to set an alternative > frame size, but it's not exposed via the ffmpeg interface. > This patch adds a boolean short_frame option to encode ld/eld frames of > size 480. > > Signed-off-by: Raphael Schlarb > --- > libavcodec/libfdk-aacenc.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c > index eb97e0fb41..bd719850dd 100644 > --- a/libavcodec/libfdk-aacenc.c > +++ b/libavcodec/libfdk-aacenc.c > @@ -55,6 +55,7 @@ typedef struct AACContext { > int metadata_mode; > AACENC_MetaData metaDataSetup; > int delay_sent; > + int short_frame; > > AudioFrameQueue afq; > } AACContext; > @@ -78,6 +79,7 @@ static const AVOption aac_enc_options[] = { > { "comp_profile", "The desired compression profile for AAC DRC", offsetof(AACContext, comp_profile), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 256, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > { "comp_target_ref", "Expected target reference level at decoder side in dB (for clipping prevention/limiter)", offsetof(AACContext, comp_target_ref), AV_OPT_TYPE_INT, { .i64 = 0.0 }, -31.75, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > { "prog_ref", "The program reference level or dialog level in dB", offsetof(AACContext, prog_ref), AV_OPT_TYPE_INT, { .i64 = 0.0 }, -31.75, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > + { "short_frame", "Encode short LD/ELD frames, using 480 instead of 512 samples per frame", offsetof(AACContext, short_frame), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > FF_AAC_PROFILE_OPTS > { NULL } > }; > @@ -166,6 +168,17 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) > } > } > > + if (s->short_frame) { > + if (aot == FF_PROFILE_AAC_LD + 1 || aot == FF_PROFILE_AAC_ELD + 1) { > + if ((err = aacEncoder_SetParam(s->handle, AACENC_GRANULE_LENGTH, > + 480)) != AACENC_OK) { Why hardcode it to 480 if the parameter accepts arbitrary values? The documentation states the currently supported values are 120, 128, 240, 256, 480, 512 and 1024. Call the option frame_length, and set the range to 120-1024, with 1024 as default value. Then in here change it to 512 if it's 1024 and profile is FF_PROFILE_AAC_LD or FF_PROFILE_AAC_ELD (otherwise don't change it), always set it, and have the library reject or accept the value. > + av_log(avctx, AV_LOG_ERROR, "Unable to set granule length: %s\n", > + aac_get_error(err)); > + goto error; > + } > + } > + } > + > if ((err = aacEncoder_SetParam(s->handle, AACENC_SAMPLERATE, > avctx->sample_rate)) != AACENC_OK) { > av_log(avctx, AV_LOG_ERROR, "Unable to set the sample rate %d: %s\n", _______________________________________________ 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".