From patchwork Mon Jan 1 15:52:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Beauxis X-Patchwork-Id: 45446 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6623:b0:194:e134:edd4 with SMTP id n35csp6273156pzh; Mon, 1 Jan 2024 07:53:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhclQmsNu9QN6V9giCljAzhsLx4g/gyTccdFWVkZQiQqJVWTcKmJVgAYtXyX1olfbCAXBa X-Received: by 2002:a17:906:b851:b0:a27:f06e:1af0 with SMTP id ga17-20020a170906b85100b00a27f06e1af0mr830824ejb.87.1704124423909; Mon, 01 Jan 2024 07:53:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704124423; cv=none; d=google.com; s=arc-20160816; b=zUKFzmZGrAJyH9uS8nQNpV2Df38DruQn2BrTYyHY5FaReA2r0Pa6TPnS0bwcKzdrpE hdc25HcMhJzOjuT1gphpjc0sQ5xd4Q0V9jKPmjI0ZwlhqKgj1CvvNhEr6JyFuqdXp+3M uweCH+J7kORF/V86CCG85mEsCdgea7axVx9RJmDqVdxNABKDi/MA5pl4MmzyXN4CNdsH 2S9fcNjCZXye3qBuKEPHxxtqtnS3mH956F39wULYIhWWjaRFtXhZUBcA0nxwl1rr5Kix C+TSkykxDVRDtBJ5k7Y69pDzxesAnByw5zS1a0ghZSyp+CFgyb/xdIsI+dYF3PeQ/jVG WoFA== 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 :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=5f+jUhc1LARvRU/poKvbfSlsIkVYyfcL9zWeQk9uDsQ=; fh=Dy2HmWbIgzG07YKb/uJ0dh3GBmODWRQaNOnRjO8Xj4c=; b=jQaqzjlVCV+ONv/rotSnDKCUJEZRT1yQ9DZh6B/E/xiw4P85gmlapgaFJA/C5WrBi3 Rr/6HMIcO2VmxclyQ4XMNjBoFxuNBwhpFZ3qH/BHualZSbB01vTLiZZGMZ8q1K9ej2hf PTme/nWvzpKS/wJM8YMKjJFe9quPxgu/arUsV6kzrCHwZUi/tg4VHKl26ujfKqJkkUra VNzuNPDOUaMWYkk3ZGSFb/OfyfXaraa+AwBtuI4r94dEUlgpWafw7So3YjZhs2cz+83y zqEPZUTFZfSZ6UHhlZ03fEgflqAWIAYDj2jW6+ubwOc9U1Q18gtO+3blJyTNEgo2X0by dqtQ== 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 wi18-20020a170906fd5200b00a2777fddfefsi3150110ejb.772.2024.01.01.07.53.43; Mon, 01 Jan 2024 07:53:43 -0800 (PST) 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 5886968C856; Mon, 1 Jan 2024 17:53:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 01F5D68C856 for ; Mon, 1 Jan 2024 17:53:33 +0200 (EET) Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5958d3f2d8aso146052eaf.1 for ; Mon, 01 Jan 2024 07:53:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704124411; x=1704729211; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=G0YCa2Ue3SpWzIh3wfkQkc75cZsG5diIFmExkO538qw=; b=mXipPbmfgt0gp0JuhK6xAmotEcz2rCwd8rKa4QKvTRV2A9K2drO3Yu0fGfjJ4QDVVN b4jlpIo0pUobG6E96kZROYXniKpmsQTPY0JPWso88rm2RApOkLivqwG4bEXL9vd+hvQv CtG8NBQwb5CAbQ3L+FBeJRPgnp9wmM3oObL35yceW3bHrih+uh1IcaXFM77vsme83Pkq VrAOvH8+3duK09VRZAeE/Q96YKyc1bYksepuoER+5WcvagNTzrJ/22oJjvQAtvAJdGek AQ7thbqUKVUWCvR2xBhZeQ5mH5vCQr8NjEqOCAbdNFVA/ZxeJaA7+d7az2gBqm6K0uW6 Sl0g== X-Gm-Message-State: AOJu0YwH3ZaGUbOnzir0QFNtTPMRZMKjHvTd2BCvnBl13WX9THp9OgJM mDf8bjF0UdVAH/137m5Ic3z6lbiJTKNFCw== X-Received: by 2002:a05:6830:4387:b0:6d9:d582:1970 with SMTP id s7-20020a056830438700b006d9d5821970mr29344830otv.2.1704124411527; Mon, 01 Jan 2024 07:53:31 -0800 (PST) Received: from romains-mbp.lan (ip24-252-77-224.no.no.cox.net. [24.252.77.224]) by smtp.gmail.com with ESMTPSA id l40-20020a056830336800b006dbf6784271sm2139278ott.75.2024.01.01.07.53.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 01 Jan 2024 07:53:31 -0800 (PST) From: Romain Beauxis To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 Jan 2024 09:52:50 -0600 Message-Id: <20240101155249.80569-1-toots@rastageeks.org> X-Mailer: git-send-email 2.39.3 (Apple Git-145) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] libavformat/hlsenc.c: Populate OTI using AAC profile in write_codec_attr. 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 Cc: Romain Beauxis Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: jyj0TGNYAdVi This patch populates the third entry for HLS codec attribute using the AAC profile. The HLS specifications[1] require this value to be the Object Type ID as referred to in table 1.3 of ISO/IEC 14496-3:2009[2]. The numerical constants in the code refer to these OTIs minus one, as documented in commit 372597e[3], confirmed by comparing the values in the code with the values in the table mentioned above. Links: 1: https://datatracker.ietf.org/doc/html/rfc6381#section-3.3 2: https://csclub.uwaterloo.ca/~ehashman/ISO14496-3-2009.pdf 3: https://github.com/FFmpeg/FFmpeg/commit/372597e5381c097455a7b73849254d56083eb056 Changes in this version: - Default value set to "mp4a.40.2" when profile is unknown for backward compatibility. --- libavformat/hlsenc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 7049956dd7..55123d2297 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -418,8 +418,11 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) } else if (st->codecpar->codec_id == AV_CODEC_ID_MP3) { snprintf(attr, sizeof(attr), "mp4a.40.34"); } else if (st->codecpar->codec_id == AV_CODEC_ID_AAC) { - /* TODO : For HE-AAC, HE-AACv2, the last digit needs to be set to 5 and 29 respectively */ - snprintf(attr, sizeof(attr), "mp4a.40.2"); + if (st->codecpar->profile != AV_PROFILE_UNKNOWN) + snprintf(attr, sizeof(attr), "mp4a.40.%d", st->codecpar->profile+1); + else + // This is for backward compatibility with the previous implementation. + snprintf(attr, sizeof(attr), "mp4a.40.2"); } else if (st->codecpar->codec_id == AV_CODEC_ID_AC3) { snprintf(attr, sizeof(attr), "ac-3"); } else if (st->codecpar->codec_id == AV_CODEC_ID_EAC3) {