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 E6C924A5AC for ; Thu, 2 May 2024 18:33:26 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A86EB68D83E; Thu, 2 May 2024 21:33:25 +0300 (EEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CF87A68C07E for ; Thu, 2 May 2024 21:33:18 +0300 (EEST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1e8bbcbc2b7so75856045ad.0 for ; Thu, 02 May 2024 11:33:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714674796; x=1715279596; darn=ffmpeg.org; 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=jF1XoYpJdm7NoxCF5+cdxqo9uw/9mtpy1lVmu05fkLY=; b=AdI8/dyGhRfaP7nVyKNlgcRIq6+WiHCrZn79g5P+tHhfobsqcIODTAob4SXwpA7AVW DwXGCCKlQIahNJew+uZPXKY//xemH4GJTfH317LC8TCMwftXrln8DKTvPy56IOm+lFlY Y76v+hBO9di9VklIbDIAP4LhmrIxYutyQ9eRCG+s8G2BMcuzUScNHE2vSLmna/wrRFr0 A5Tb9rK7qd4p0bRLHS6xe5UdyvuGj9zjM+YDt0V055iT1KVlXa7H29tsiFUgE1Ba2QBU WPyMNr8HzOgufoR7ur+Qf6AcZMiX9+8zt3ef2MoFNbVwQ6JfKZuPClzCG4jGyu8IVoT5 BvYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714674796; x=1715279596; 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=jF1XoYpJdm7NoxCF5+cdxqo9uw/9mtpy1lVmu05fkLY=; b=iJcW7iSs+hGwz5JkyssrrfjdaFQ6afgWV4hTan1yaTQW5UF7VyW3Dx73CtiB+A6F3a T1oPZm0unJwI86TbeVSZIIpnremkf76YiRCWMGrDf/Szesnld5Tv9m2HxurgJRpWJ345 VVxAYdJL7FlDFLkMiGEdLMvJYXtryxNJmCK5g8WJubVc58BhJ/i4wk1dpRtocWYCHRdT ddq1nQqS+dqOQXir3nPrazZ+kwNkHYsm9CGF1NPqpFFFcJUfll6uQABYszhJHm5poGmK NgdUAjGxtYGanahIDTV//Q6ec7RS9s/zBAbX9b7Ys2C8iDL/JpcEs6qfTY4HnjGsf5dD 2SXA== X-Gm-Message-State: AOJu0YyeODVZRRpypA1UGFlgYKcMf2lj7VPK8sCgYfyYKjRMVfR4+yNW mmZ3hSfDyIJHAwDhrwHXIugq0cd0bZ60UWc1CIMmcgEXimHYM+5d3zldkg== X-Google-Smtp-Source: AGHT+IEMSi6ss4cR3WsepB+4P5OUtsZEwRMFT0S3/+lSMoEWK6cXNN3MQdS5K1yt8nikU+afro7+8g== X-Received: by 2002:a17:902:db08:b0:1e3:c327:35c0 with SMTP id m8-20020a170902db0800b001e3c32735c0mr590354plx.2.1714674796416; Thu, 02 May 2024 11:33:16 -0700 (PDT) Received: from [192.168.0.10] ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id d14-20020a170902cece00b001eb15178370sm1635308plg.130.2024.05.02.11.33.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 May 2024 11:33:15 -0700 (PDT) Message-ID: <7103a942-4ed9-472f-97f2-db18ae194b90@gmail.com> Date: Thu, 2 May 2024 15:33:16 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20240430231926.2506728-1-michael@niedermayer.cc> <20240502150549.1733-1-jamrial@gmail.com> Content-Language: en-US From: James Almer In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] avformat/framecrcenc: support calculating checksum of IAMF side data 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 5/2/2024 12:16 PM, Andreas Rheinhardt wrote: > James Almer: >> The total allocated size for types is arch dependent, so instead calculate a >> checksum of the fields only. >> >> Signed-off-by: James Almer >> --- >> Depends on "[PATCH v3] avformat/framecrcenc: compute the checksum for side data" >> >> libavformat/framecrcenc.c | 76 ++++++++++++++++++++++++++++++++++++--- >> 1 file changed, 71 insertions(+), 5 deletions(-) >> >> diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c >> index 8cc4a93053..6d46b51489 100644 >> --- a/libavformat/framecrcenc.c >> +++ b/libavformat/framecrcenc.c >> @@ -24,6 +24,7 @@ >> #include "config.h" >> #include "libavutil/adler32.h" >> #include "libavutil/avstring.h" >> +#include "libavutil/iamf.h" >> #include "libavutil/intreadwrite.h" >> >> #include "libavcodec/codec_id.h" >> @@ -76,7 +77,8 @@ static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) >> for (int i = 0; i < pkt->side_data_elems; i++) { >> const AVPacketSideData *const sd = &pkt->side_data[i]; >> const uint8_t *data = sd->data; >> - int64_t side_data_crc = 0; >> + size_t size = sd->size; >> + uint32_t side_data_crc = 0; >> >> switch (sd->type) { >> #if HAVE_BIGENDIAN >> @@ -127,12 +129,76 @@ static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) >> case AV_PKT_DATA_IAMF_MIX_GAIN_PARAM: >> case AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM: >> case AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM: >> - side_data_crc = -1; >> + { >> + const AVIAMFParamDefinition *param = (AVIAMFParamDefinition *)sd->data; >> + uint8_t buf[8]; >> + ptrdiff_t offset = 0; >> + size = 0; >> +#define READ_UINT32(struct, parent, child) do { \ >> + if ((offset + offsetof(struct, child) + sizeof(parent->child)) > sd->size) \ >> + goto iamf_end; \ >> + AV_WL32(buf, parent->child); \ >> + side_data_crc = av_adler32_update(side_data_crc, buf, 4); \ >> + size += 4; \ >> +} while (0) >> +#define READ_RATIONAL(struct, parent, child) do { \ >> + if ((offset + offsetof(struct, child) + sizeof(parent->child)) > sd->size) \ >> + goto iamf_end; \ >> + AV_WL32(buf + 0, parent->child.num); \ >> + AV_WL32(buf + 4, parent->child.den); \ >> + side_data_crc = av_adler32_update(side_data_crc, buf, 8); \ >> + size += 8; \ >> +} while (0) >> + READ_UINT32(AVIAMFParamDefinition, param, nb_subblocks); >> + READ_UINT32(AVIAMFParamDefinition, param, type); >> + READ_UINT32(AVIAMFParamDefinition, param, parameter_id); >> + READ_UINT32(AVIAMFParamDefinition, param, parameter_rate); >> + READ_UINT32(AVIAMFParamDefinition, param, duration); >> + READ_UINT32(AVIAMFParamDefinition, param, constant_subblock_duration); >> + for (unsigned int i = 0; i < param->nb_subblocks; i++) { >> + void *subblock = av_iamf_param_definition_get_subblock(param, i); >> + >> + offset = (intptr_t)subblock - (intptr_t)sd->data; >> + switch (param->type) { >> + case AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN: { >> + const AVIAMFMixGain *mix = subblock; >> + READ_UINT32(AVIAMFMixGain, mix, subblock_duration); >> + READ_UINT32(AVIAMFMixGain, mix, animation_type); >> + READ_RATIONAL(AVIAMFMixGain, mix, start_point_value); >> + READ_RATIONAL(AVIAMFMixGain, mix, end_point_value); >> + READ_RATIONAL(AVIAMFMixGain, mix, control_point_value); >> + READ_RATIONAL(AVIAMFMixGain, mix, control_point_relative_time); >> + break; >> + } >> + case AV_IAMF_PARAMETER_DEFINITION_DEMIXING: { >> + const AVIAMFDemixingInfo *demix = subblock; >> + READ_UINT32(AVIAMFDemixingInfo, demix, subblock_duration); >> + READ_UINT32(AVIAMFDemixingInfo, demix, dmixp_mode); >> + break; >> + } >> + case AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN: { >> + const AVIAMFReconGain *recon = subblock; >> + READ_UINT32(AVIAMFReconGain, recon, subblock_duration); >> + if ((offset + offsetof(AVIAMFReconGain, recon_gain) >> + + sizeof(recon->recon_gain)) > sd->size) >> + goto iamf_end; >> + side_data_crc = av_adler32_update(side_data_crc, >> + (uint8_t *)recon->recon_gain, >> + sizeof(recon->recon_gain)); >> + size += sizeof(recon->recon_gain); >> + break; >> + } >> + default: >> + break; >> + } >> + } >> + iamf_end: >> + break; >> + } >> } >> >> - av_strlcatf(buf, sizeof(buf), ", T=%2d, %8"SIZE_SPECIFIER, pkt->side_data[i].type, pkt->side_data[i].size); >> - if (side_data_crc >= 0) >> - av_strlcatf(buf, sizeof(buf), ", 0x%08"PRIx32, (uint32_t)side_data_crc); >> + av_strlcatf(buf, sizeof(buf), ", T=%2d, %8"SIZE_SPECIFIER, pkt->side_data[i].type, size); >> + av_strlcatf(buf, sizeof(buf), ", 0x%08"PRIx32, side_data_crc); >> } >> } >> av_strlcatf(buf, sizeof(buf), "\n"); > > This is overkill; tests for IAMF side data should use ffprobe. This is adding support to these three side data types in framecrc regardless of host arch, because of the nature of the structs. The IAMF tests already use ffprobe. _______________________________________________ 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".