From patchwork Sat May 25 02:27:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 49228 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:542:0:b0:460:55fa:d5ed with SMTP id 63csp2097919vqf; Fri, 24 May 2024 19:28:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWGt6rvJ+vc0NOg6f3GFEgU9IdPAySIV2MsdfD/KGYOACEO05k/kA41Nq1eVaPboujUABWn1aHQPJp9TmAFqZd6HnGAHT6ZYZvg8Q== X-Google-Smtp-Source: AGHT+IGABP/HFSRTGaRUHgQgO75zrwo0uboKyzqbrjglkoRvSuzIFpDsNFgWcaPRvSCFGCZedekw X-Received: by 2002:a05:6512:4cb:b0:521:54b5:86a3 with SMTP id 2adb3069b0e04-5296717fec4mr2107157e87.64.1716604128809; Fri, 24 May 2024 19:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716604128; cv=none; d=google.com; s=arc-20160816; b=WbTgfdYiEygoLOz0TkqhD6mbbq4ub56JSGG2i/mod1p44AmxAhbemUQXPXldY2ZIIy PGW2nnbxGp6JyQGgDWYNATUhvlZbLDPjA3jCA6m51SJjaid0t+FZbEFH5YNyF+6WfN45 mSHHu8wL3NBWgFguBORBYr6HJBeZJ+1TEEdgjVneeW1WZHJfvxt/gJB+GZGyNz0x7qbq Sya77W/24opE59OuqUiQ86ktP6L2Fl5LbyO5WKsl0ukFKbhV9TNk+PDlzLF3LsW5MVqk bFhP3GTpSO4rfhsKRIv4wRMwOWNT/1UsNoJk4nTiIdd2Djds2YxaDzzDHiV38qDGOCj5 WzLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:delivered-to; bh=Y6Xh7HevtYbVRCN7hkxbwwVTSGR08q0jr1TmPy0ODBc=; fh=nenT92/WZoU6unXd3J6UhGUdod4piddKfVtctNBOh6k=; b=iM2GUUcRIIk3SZprzmvrav8oTTWiugOgeqSkRxTyf8hcBX+Pc26OztBpX17HGRLQd8 xmlkNGMykDrfldCWqmpr5O3pobH7/2sfUAL2u03Y2OmbEOjXPW2KbruHUrbLS3EZVuQb ov98fToijX32g0cnIcfitmEzoODCrr5EOu4I9oYcUMg0yj3AS6mmdzv8n5hK0MO6dxSm 1PmbP+cj3OJwmgMGDq3Fo2501Vmq8Bq8XaTeA6fcCDCl1JCYGrQTO/4WEI93FsaJAjPI BdZfO3i84xWYFg+CZ5Y8hoAduL0sWrsyPQ7ZjEaBmaJTKxwB1/hL9c4RQEco+yKdES4I l5ow==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a626c918415si137027766b.228.2024.05.24.19.28.48; Fri, 24 May 2024 19:28:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E93AF68D5A1; Sat, 25 May 2024 05:28:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5F99768D589 for ; Sat, 25 May 2024 05:28:17 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Sat, 25 May 2024 04:27:56 +0200 Message-ID: <20240525022813.2292001-4-dev@lynne.ee> X-Mailer: git-send-email 2.43.0.381.gb435a96ce8 In-Reply-To: <20240525022813.2292001-1-dev@lynne.ee> References: <20240525022813.2292001-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 03/10] aacdec: expose channel layout related functions 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: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Sqy8RtjL4Z6a --- libavcodec/aac/aacdec.c | 73 ++++++++++++++++++++--------------------- libavcodec/aac/aacdec.h | 19 +++++++++-- 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 35722f9b9b..40554ff9e4 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -111,10 +111,6 @@ Parametric Stereo. */ -static int output_configure(AACDecContext *ac, - uint8_t layout_map[MAX_ELEM_ID*4][3], int tags, - enum OCStatus oc_type, int get_new_frame); - #define overread_err "Input buffer exhausted before END element found\n" static int count_channels(uint8_t (*layout)[3], int tags) @@ -447,8 +443,8 @@ static void pop_output_configuration(AACDecContext *ac) if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) { ac->oc[1] = ac->oc[0]; ac->avctx->ch_layout = ac->oc[1].ch_layout; - output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, - ac->oc[1].status, 0); + ff_aac_output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, + ac->oc[1].status, 0); } } @@ -458,7 +454,7 @@ static void pop_output_configuration(AACDecContext *ac) * * @return Returns error status. 0 - OK, !0 - error */ -static int output_configure(AACDecContext *ac, +int ff_aac_output_configure(AACDecContext *ac, uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags, enum OCStatus oc_type, int get_new_frame) { @@ -547,7 +543,7 @@ static av_cold void flush(AVCodecContext *avctx) * * @return Returns error status. 0 - OK, !0 - error */ -static int set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, +int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, uint8_t (*layout_map)[3], int *tags, int channel_config) @@ -587,7 +583,7 @@ static int set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, return 0; } -static ChannelElement *get_che(AACDecContext *ac, int type, int elem_id) +ChannelElement *ff_aac_get_che(AACDecContext *ac, int type, int elem_id) { /* For PCE based channel configurations map the channels solely based * on tags. */ @@ -603,11 +599,11 @@ static ChannelElement *get_che(AACDecContext *ac, int type, int elem_id) av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n"); - if (set_default_channel_config(ac, ac->avctx, layout_map, - &layout_map_tags, 2) < 0) + if (ff_aac_set_default_channel_config(ac, ac->avctx, layout_map, + &layout_map_tags, 2) < 0) return NULL; - if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 1) < 0) + if (ff_aac_output_configure(ac, layout_map, layout_map_tags, + OC_TRIAL_FRAME, 1) < 0) return NULL; ac->oc[1].m4ac.chan_config = 2; @@ -627,8 +623,8 @@ static ChannelElement *get_che(AACDecContext *ac, int type, int elem_id) layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT; layout_map[0][1] = 0; layout_map[1][1] = 1; - if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 1) < 0) + if (ff_aac_output_configure(ac, layout_map, layout_map_tags, + OC_TRIAL_FRAME, 1) < 0) return NULL; if (ac->oc[1].m4ac.sbr) @@ -877,8 +873,8 @@ static int decode_ga_specific_config(AACDecContext *ac, AVCodecContext *avctx, if (tags < 0) return tags; } else { - if ((ret = set_default_channel_config(ac, avctx, layout_map, - &tags, channel_config))) + if ((ret = ff_aac_set_default_channel_config(ac, avctx, layout_map, + &tags, channel_config))) return ret; } @@ -887,7 +883,7 @@ static int decode_ga_specific_config(AACDecContext *ac, AVCodecContext *avctx, } else if (m4ac->sbr == 1 && m4ac->ps == -1) m4ac->ps = 1; - if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) + if (ac && (ret = ff_aac_output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) return ret; if (extension_flag) { @@ -967,11 +963,11 @@ static int decode_eld_specific_config(AACDecContext *ac, AVCodecContext *avctx, skip_bits_long(gb, 8 * len); } - if ((ret = set_default_channel_config(ac, avctx, layout_map, - &tags, channel_config))) + if ((ret = ff_aac_set_default_channel_config(ac, avctx, layout_map, + &tags, channel_config))) return ret; - if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) + if (ac && (ret = ff_aac_output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) return ret; ep_config = get_bits(gb, 2); @@ -1206,11 +1202,12 @@ av_cold int ff_aac_decode_init(AVCodecContext *avctx) ac->oc[1].m4ac.chan_config = i; if (ac->oc[1].m4ac.chan_config) { - int ret = set_default_channel_config(ac, avctx, layout_map, - &layout_map_tags, ac->oc[1].m4ac.chan_config); + int ret = ff_aac_set_default_channel_config(ac, avctx, layout_map, + &layout_map_tags, + ac->oc[1].m4ac.chan_config); if (!ret) - output_configure(ac, layout_map, layout_map_tags, - OC_GLOBAL_HDR, 0); + ff_aac_output_configure(ac, layout_map, layout_map_tags, + OC_GLOBAL_HDR, 0); else if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } @@ -1915,8 +1912,8 @@ static int decode_extension_payload(AACDecContext *ac, GetBitContext *gb, int cn ac->oc[1].m4ac.sbr = 1; ac->oc[1].m4ac.ps = 1; ac->avctx->profile = AV_PROFILE_AAC_HE_V2; - output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, - ac->oc[1].status, 1); + ff_aac_output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, + ac->oc[1].status, 1); } else { ac->oc[1].m4ac.sbr = 1; ac->avctx->profile = AV_PROFILE_AAC_HE; @@ -2066,13 +2063,13 @@ static int parse_adts_frame_header(AACDecContext *ac, GetBitContext *gb) push_output_configuration(ac); if (hdr_info.chan_config) { ac->oc[1].m4ac.chan_config = hdr_info.chan_config; - if ((ret = set_default_channel_config(ac, ac->avctx, - layout_map, - &layout_map_tags, - hdr_info.chan_config)) < 0) + if ((ret = ff_aac_set_default_channel_config(ac, ac->avctx, + layout_map, + &layout_map_tags, + hdr_info.chan_config)) < 0) return ret; - if ((ret = output_configure(ac, layout_map, layout_map_tags, - FFMAX(ac->oc[1].status, + if ((ret = ff_aac_output_configure(ac, layout_map, layout_map_tags, + FFMAX(ac->oc[1].status, OC_TRIAL_FRAME), 0)) < 0) return ret; } else { @@ -2088,8 +2085,8 @@ static int parse_adts_frame_header(AACDecContext *ac, GetBitContext *gb) layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT; layout_map[0][1] = 0; layout_map[1][1] = 1; - if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 0)) + if (ff_aac_output_configure(ac, layout_map, layout_map_tags, + OC_TRIAL_FRAME, 0)) return -7; } } @@ -2142,7 +2139,7 @@ static int aac_decode_er_frame(AVCodecContext *avctx, AVFrame *frame, for (i = 0; i < ff_tags_per_config[chan_config]; i++) { const int elem_type = ff_aac_channel_layout_map[chan_config-1][i][0]; const int elem_id = ff_aac_channel_layout_map[chan_config-1][i][1]; - if (!(che=get_che(ac, elem_type, elem_id))) { + if (!(che=ff_aac_get_che(ac, elem_type, elem_id))) { av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", elem_type, elem_id); @@ -2241,7 +2238,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, AVFrame *frame, } che_presence[elem_type][elem_id]++; - if (!(che=get_che(ac, elem_type, elem_id))) { + if (!(che=ff_aac_get_che(ac, elem_type, elem_id))) { av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", elem_type, elem_id); err = AVERROR_INVALIDDATA; @@ -2298,7 +2295,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, AVFrame *frame, "Not evaluating a further program_config_element as this construct is dubious at best.\n"); pop_output_configuration(ac); } else { - err = output_configure(ac, layout_map, tags, OC_TRIAL_PCE, 1); + err = ff_aac_output_configure(ac, layout_map, tags, OC_TRIAL_PCE, 1); if (!err) ac->oc[1].m4ac.chan_config = 0; pce_found = 1; diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index bbb7ea358f..bea0578e92 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -39,6 +39,7 @@ #include "libavutil/tx.h" #include "libavcodec/aac.h" +#include "libavcodec/avcodec.h" #include "libavcodec/mpeg4audio.h" typedef struct AACDecContext AACDecContext; @@ -343,10 +344,22 @@ struct AACDecContext { #define fdsp RENAME_FIXED(fdsp) #endif -int ff_aac_decode_init(struct AVCodecContext *avctx); -int ff_aac_decode_init_float(struct AVCodecContext *avctx); -int ff_aac_decode_init_fixed(struct AVCodecContext *avctx); +int ff_aac_decode_init(AVCodecContext *avctx); +int ff_aac_decode_init_float(AVCodecContext *avctx); +int ff_aac_decode_init_fixed(AVCodecContext *avctx); + int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce, GetBitContext *gb, int common_window, int scale_flag); +int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, + uint8_t (*layout_map)[3], + int *tags, + int channel_config); + +int ff_aac_output_configure(AACDecContext *ac, + uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags, + enum OCStatus oc_type, int get_new_frame); + +ChannelElement *ff_aac_get_che(AACDecContext *ac, int type, int elem_id); + #endif /* AVCODEC_AAC_AACDEC_H */