From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 4038A4DF0A for ; Thu, 5 Jun 2025 21:50:28 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 29D3B68D106; Fri, 6 Jun 2025 00:50:05 +0300 (EEST) Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com [209.85.221.173]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 656CF68C92E for ; Fri, 6 Jun 2025 00:49:56 +0300 (EEST) Received: by mail-vk1-f173.google.com with SMTP id 71dfb90a1353d-530d764149eso404152e0c.1 for ; Thu, 05 Jun 2025 14:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749160194; x=1749764994; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rORvAMioBZ0WI5YW0Ou7xyiwh13DmZZKFp2T+9nXUKw=; b=hYyilB7iCfNuziIsjAsV1wq77VtzqVQuMwWv+2G35Y0bAcevhIwf9+N4Uol6T/9xh5 sH1VZ8rlsoP5+VAJHdqH6QrTHt30kdOcvXNl/c2zgFVDDm204mpdwVfsP1eHINzl28Ow dBn3mg3ohiAmTGN0i84fmqCWEDGjcVW9OFUkz103JXCl3yAp82C9YlaS+HbtyGV8tJ3h 0eFGPyUDsIYJJRED/M+JN+tuOIKSp7YlyvYCWIIF6tiJbiPrFDvJ56phByj2GtuHWdDv x6cU2Eym/oQ7b34pGUTg2hLM2p7Q/IO5MSBYFXRcSLM/bxZ7+e2vSk1ZYT0qQuNaaTAl cysA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749160194; x=1749764994; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rORvAMioBZ0WI5YW0Ou7xyiwh13DmZZKFp2T+9nXUKw=; b=b6/1FHYNAu9lhVKDV9zf8wMlJuDtVwUVeEs+/jaj8iXlg+UZSbWwYFH6qJlDo5UM6B j+hds+CStuCymrvgZQdO78HzGkQV6gGV5YPAzaDFZzSCP77JUJ0w2/Hv9oM2mPAlx3fv 6042eAesAzkV3k2/x+krH1AEexA05/Giu5TOLc2a2IBkQzxb87zG8IFKtg4OrdST0Hi2 hZekxaZwd3gXdu3ssSQvD/EIdBprL6nuOdGHT/L9VJaPdNUD00q/C1m3VAJ11T/GU5xK LDZ2XoM+j94ynkaWcr8MwE8gRYrtTEHcP7c96SVeMCamLhqGEZ9vkCPa2y0ipiRwFOzN YF9w== X-Gm-Message-State: AOJu0YxaypVPtXfzaWgENUSUyafdKMEzqIqaTsitWI0gwoHZOsMZy0qq Lwgqr9ZhEezdF3nmqhRW+pbhOGSzhVEuKiKi7Qwf6w4hXcppAAmF8xb4fqKNcQ== X-Gm-Gg: ASbGncuMHAm+OvnJ90vM+MumCXTh+tg9kLF/93PRzhWkVrXAPAp+4SpnACXRMQXtpSB Wtz1g7zeVo5Wk8Gj6z9bJE3Qe0ZK3cExJJORDyLEYdtT6Sr9LWzBuTm0puF/49UpDBEpGm+cb4u AZ8WRge9CGsksYM+/H3KX9AHJjvELrQauTjtKHFMzCvELwI5jM/1pl3o7aOYuQPYqF3SyxyLbSZ cUFYfer+W8EhzXbyIVja9VJnQ9oBUAd2eSqD3HJr7QBnY5La3V+LqgoqUPTNtbV6+1LerCNViRw j7W45WI94BQQ4CqNFh3R5nGCx4DqdCK9AL6teg2J/E6RUn3+W1qq6alammcCT0Y0d1teq8w= X-Google-Smtp-Source: AGHT+IHulqRwClr4jj9JMk8xUo4pSludqU8fqSYVEc//y1GtxahP8IYU9EgZD6vgCw/qeKnwLO80+A== X-Received: by 2002:a05:6122:658b:b0:52d:bbab:2055 with SMTP id 71dfb90a1353d-530e48d2952mr1356596e0c.10.1749160194522; Thu, 05 Jun 2025 14:49:54 -0700 (PDT) Received: from localhost.localdomain ([2800:2121:b000:82e:287b:4d06:66a8:d1a5]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-530e62e88acsm205410e0c.12.2025.06.05.14.49.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jun 2025 14:49:54 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Jun 2025 18:49:38 -0300 Message-ID: <20250605214938.142938-3-jamrial@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605214938.142938-1-jamrial@gmail.com> References: <20250605214938.142938-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avformat/movenc: handle EAC-3 extension bits for Atmos 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: nyanmisaka Fixes commit #9996. Signed-off-by: James Almer --- libavformat/movenc.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 25360b004d..b546c8b545 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -393,6 +393,10 @@ struct eac3_info { uint16_t chan_loc; /* if there is no dependent substream, then one bit reserved instead */ } substream[1]; /* TODO: support 8 independent substreams */ + /* indicates the enhanced AC-3 extension, 1 bit */ + uint8_t eac3_extension_type_a; + /* indicates the decoding complexity, 8 bits */ + uint8_t complexity_index_type_a; }; static int mov_write_ac3_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track) @@ -474,6 +478,9 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track) info->data_rate = FFMAX(info->data_rate, hdr->bit_rate / 1000); info->ac3_bit_rate_code = FFMAX(info->ac3_bit_rate_code, hdr->ac3_bit_rate_code); + info->eac3_extension_type_a = hdr->eac3_extension_type_a; + info->complexity_index_type_a = hdr->complexity_index_type_a; + num_blocks = hdr->num_blocks; if (!info->ec3_done) { @@ -532,8 +539,6 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track) int parent = hdr->substreamid; while (cumul_size != pkt->size) { - GetBitContext gbc; - int i; ret = avpriv_ac3_parse_header(&hdr, pkt->data + cumul_size, pkt->size - cumul_size); if (ret < 0) goto end; @@ -544,20 +549,9 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track) info->substream[parent].num_dep_sub++; ret /= 8; - /* header is parsed up to lfeon, but custom channel map may be needed */ - init_get_bits8(&gbc, pkt->data + cumul_size + ret, pkt->size - cumul_size - ret); - /* skip bsid */ - skip_bits(&gbc, 5); - /* skip volume control params */ - for (i = 0; i < (hdr->channel_mode ? 1 : 2); i++) { - skip_bits(&gbc, 5); // skip dialog normalization - if (get_bits1(&gbc)) { - skip_bits(&gbc, 8); // skip compression gain word - } - } /* get the dependent stream channel map, if exists */ - if (get_bits1(&gbc)) - info->substream[parent].chan_loc |= (get_bits(&gbc, 16) >> 5) & 0x1f; + if (hdr->channel_map_present) + info->substream[parent].chan_loc |= (hdr->channel_map >> 5) & 0x1f; else info->substream[parent].chan_loc |= hdr->channel_mode; cumul_size += hdr->frame_size; @@ -614,7 +608,7 @@ static int mov_write_eac3_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra } info = track->eac3_priv; - size = 2 + ((34 * (info->num_ind_sub + 1) + 7) >> 3); + size = 2 + ((32 * (info->num_ind_sub + 1) + 7 + 1 + 8) >> 3); buf = av_malloc(size); if (!buf) { return AVERROR(ENOMEM); @@ -639,6 +633,11 @@ static int mov_write_eac3_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra put_bits(&pbc, 9, info->substream[i].chan_loc); } } + if (info->eac3_extension_type_a == 1) { + put_bits(&pbc, 7, 0); /* reserved */ + put_bits(&pbc, 1, info->eac3_extension_type_a); + put_bits(&pbc, 8, info->complexity_index_type_a); + } flush_put_bits(&pbc); size = put_bytes_output(&pbc); -- 2.49.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".