From patchwork Mon Aug 28 12:34:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43368 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp113920pzf; Mon, 28 Aug 2023 05:37:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtIvfyk9m52cZ5ue0ztBHbL51FhIY+BPz/BbwCDBfE3iaMwr7hBxVXMsqupYaGNK9lAH19 X-Received: by 2002:a05:6402:14c3:b0:523:1e18:3a78 with SMTP id f3-20020a05640214c300b005231e183a78mr19547319edx.12.1693226246042; Mon, 28 Aug 2023 05:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226246; cv=none; d=google.com; s=arc-20160816; b=bdRp/TiYARQdS17gaghYB28eNOzjVf2wTpLrKGcZb9Gl7NrWp/sKX6pxqiAVfHlrtq Cf6wkKL3zw0EFed8991Gi8tqsBbOWLkZ+abjDjHmk2pV/0gQmX/ix98Qs7DMdf8JFqkR vItckLd59r6eE6Drtej+iWle1S0EF0t2U6sSFnhHDUdaPlIcTFKl8Jmzd0E6cieC/ZVo ySX6ANKj4JEf4381N/dHaqdyh/yES2RHLI9EzQzOTTq1LVFINeoAecSEMbFdb4ot9eQ0 9inH7nfT899mU5ppcq16WCEKzntUdDDQoIf4NeAnQOxlqdx2oEzNmA8QY/wfUmYA59TW QOTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=AMZEW36AZJ+7cWQJyOMbGyy1TyGmmhXPUzhuF+iDAZs=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=uwinfM7T00Qa1np+Mo/215IhfNNltgn6U1jPBo8vb20nkSgNIHMU0Z/N7HT3tgens9 WZY9D8BW76CYpt59tfrnixGlst1mwrrJoFWanm04PttkfIXGnkcrD90ujLLlmwFWLLAP hAKwk6iz39xCw6jV289zCxWGL6a4fex94sRNRWKf3AN4Ms0zfzVwNWWE7Su84RN/Vbvi VJ3Fm7BprzwUBAoy0E1OzTBESSeOnqpKdKwTgcyqODnHMyRfpmvQS58egZakj+ZKQr5y CL/TnTbYcYSrc6SnIIbFLP77KHQiyRgi4+aG1b7mdTcRtokJnkeVMi32oAovzpqYVrx8 iQsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=CryVLocO; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y23-20020aa7ccd7000000b0052a49441c0esi4677827edt.554.2023.08.28.05.37.06; Mon, 28 Aug 2023 05:37:26 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=CryVLocO; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E69BB68C602; Mon, 28 Aug 2023 15:36:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D77168A360 for ; Mon, 28 Aug 2023 15:36:44 +0300 (EEST) Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6bf0decd032so968552a34.0 for ; Mon, 28 Aug 2023 05:36:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226202; x=1693831002; 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=DOBQAv0ALr5uGXugeWGjRi1QbFdyAGVLRYQSve7Kl5o=; b=CryVLocOZju/fuZYe2Z83hpsLNRZ3ukWnmNllaAOMO8zeQzoXIZL3khfwlfePtjNCa GQPSUsWxbFdla+ampRFV/rOHv/shdHrk1zKug3vEizZI2lZbKmXerjsM3aGH0lr0cZIY j6z6i+KiiqSLa3kckUpQjL0BN4zSNp33B58UfatAjXx83yf3g2JvBitnWJ3YNnOeDUko FGgsxN7k1jfh731BJx7p7m74JiXpbGJ1ROL0kTAYVeKtRCkWaoSrJDQ4FSmoAJW0DpTX oivo4PnWJo1+jB1Da8EKwp/X0XGZRTnajtnfx+yjTJ+8/wkf4FsPIki/EJFJXCdW61xq tsEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226202; x=1693831002; 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=DOBQAv0ALr5uGXugeWGjRi1QbFdyAGVLRYQSve7Kl5o=; b=Ri/jPLPK75XP1wXva419Iv6vJK+fJf+IvNwHzA29Jq/L0WYUC5yH7BrKBymMovJavZ mTn06fB1kwQ5XJwuhnK12uOzF+x4r018wvzpViphavzRqIz49aC3w5utVQKMNMlDc6vz PUCpd1MvEsXRWnQNDIDpXTch8WR42OI9DZHElY/4d83wAqhQfkirwmHnmbqsUiM4nDDM qJa15RdwKwrn7lZE7ZPgkGClKTfjyzBJnMZqOMm6P6hgtUFVWHkiPRbKevTG60QuhYm0 3hw834wu85I8I1Q+7iPfv/4q5IX36r85RW7voDuKbVCt8ccBjHh1HQH+UFLVcPd23a4o GMfg== X-Gm-Message-State: AOJu0YyEo5M6OiZ5i39a8dCETg1j72kRbu6dzmVLWkz0bNB1tNzvqmpD r3uAsTUC/Nw/fwIrCmawnbeuKedIiOE= X-Received: by 2002:a05:6830:1e8d:b0:6b9:9129:dddf with SMTP id n13-20020a0568301e8d00b006b99129dddfmr12579676otr.16.1693226202543; Mon, 28 Aug 2023 05:36:42 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:42 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:34:53 -0300 Message-ID: <20230828123617.57535-2-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/12] avcodec/avcodec: add side data to AVCodecContext 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +lsGxCERx2up Signed-off-by: James Almer --- libavcodec/avcodec.c | 2 + libavcodec/avcodec.h | 8 ++++ libavcodec/avpacket.c | 103 ++++++++++++++++++++++++++++++++++++++++++ libavcodec/packet.h | 64 ++++++++++++++++++++++++++ 4 files changed, 177 insertions(+) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 0700a53b5c..c811d1f7c4 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -474,6 +474,8 @@ av_cold int avcodec_close(AVCodecContext *avctx) av_freep(&avctx->internal); } + av_packet_side_data_set_free(&avctx->packet_side_data); + for (i = 0; i < avctx->nb_coded_side_data; i++) av_freep(&avctx->coded_side_data[i].data); av_freep(&avctx->coded_side_data); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 649411ac79..dda8a2412b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2100,6 +2100,14 @@ typedef struct AVCodecContext { * an error. */ int64_t frame_num; + + /** + * Additional data associated with the entire stream. + * + * - decoding: set by user + * - encoding: unused + */ + AVPacketSideDataSet packet_side_data; } AVCodecContext; /** diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 5fef65e97a..7e646d82f5 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -645,3 +645,106 @@ int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp) return 0; } + +AVPacketSideData *av_packet_side_data_set_get(const AVPacketSideDataSet *set, + enum AVPacketSideDataType type) +{ + for (int i = 0; i < set->nb_sd; i++) + if (set->sd[i]->type == type) + return set->sd[i]; + + return NULL; +} + +static int add_side_data_to_set(AVPacketSideDataSet *set, + AVPacketSideData **psd, + enum AVPacketSideDataType type, + uint8_t *data, size_t size) +{ + AVPacketSideData *sd, **tmp; + + for (int i = 0; i < set->nb_sd; i++) { + sd = set->sd[i]; + + if (sd->type == type) { + av_freep(&sd->data); + sd->data = data; + sd->size = size; + *psd = sd; + return 0; + } + } + + if (set->nb_sd + 1U > FFMIN(INT_MAX, SIZE_MAX / sizeof(*tmp))) + return AVERROR(ERANGE); + + tmp = av_realloc_array(set->sd, set->nb_sd + 1, sizeof(*tmp)); + if (!tmp) + return AVERROR(ENOMEM); + + set->sd = tmp; + + sd = av_mallocz(sizeof(*sd)); + if (!sd) + return AVERROR(ENOMEM); + + sd->type = type; + sd->data = data; + sd->size = size; + + set->sd[set->nb_sd++] = sd; + *psd = sd; + + return 0; +} + +int av_packet_side_data_set_add(AVPacketSideDataSet *set, + enum AVPacketSideDataType type, + uint8_t *data, size_t size) +{ + AVPacketSideData *sd; + + return add_side_data_to_set(set, &sd, type, data, size); +} + +AVPacketSideData *av_packet_side_data_set_new(AVPacketSideDataSet *set, + enum AVPacketSideDataType type, + size_t size) +{ + AVPacketSideData *sd = NULL; + uint8_t *data = av_malloc(size); + int ret; + + if (!data) + return NULL; + + ret = add_side_data_to_set(set, &sd, type, data, size); + if (ret < 0) + av_freep(&data); + + return sd; +} + +void av_packet_side_data_set_remove(AVPacketSideDataSet *set, + enum AVPacketSideDataType type) +{ + for (int i = set->nb_sd - 1; i >= 0; i--) { + AVPacketSideData *sd = set->sd[i]; + if (sd->type != type) + continue; + av_free(set->sd[i]->data); + av_free(set->sd[i]); + set->sd[i] = set->sd[--set->nb_sd]; + } +} + +void av_packet_side_data_set_free(AVPacketSideDataSet *set) +{ + for (int i = 0; i < set->nb_sd; i++) { + av_free(set->sd[i]->data); + av_free(set->sd[i]); + } + set->nb_sd = 0; + + av_freep(&set->sd); +} diff --git a/libavcodec/packet.h b/libavcodec/packet.h index f28e7e7011..a0220c64b3 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -318,6 +318,14 @@ typedef struct AVPacketSideData { enum AVPacketSideDataType type; } AVPacketSideData; +/** + * Structure to hold a set of AVPacketSideDataSet + */ +typedef struct AVPacketSideDataSet { + AVPacketSideData **sd; + int nb_sd; +} AVPacketSideDataSet; + /** * This structure stores compressed data. It is typically exported by demuxers * and then passed as input to decoders, or received as output from encoders and @@ -724,6 +732,62 @@ int av_packet_make_writable(AVPacket *pkt); */ void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst); +/** + * Allocate a new side data entry into to a set. + * + * @param set a set to which the side data should be added + * @param type side data type + * @param size side data size + * @return pointer to freshly allocated side data entry or NULL otherwise. + */ +AVPacketSideData *av_packet_side_data_set_new(AVPacketSideDataSet *set, + enum AVPacketSideDataType type, + size_t size); + +/** + * Wrap an existing array as a packet side data into a set. + * + * @param set a set to which the side data should be added + * @param type side information type + * @param data the side data array. It must be allocated with the av_malloc() + * family of functions. The ownership of the data is transferred to + * pkt. + * @param size side information size + * @return a non-negative number on success, a negative AVERROR code on + * failure. On failure, the set is unchanged and the data remains + * owned by the caller. + */ +int av_packet_side_data_set_add(AVPacketSideDataSet *set, + enum AVPacketSideDataType type, + uint8_t *data, size_t size); + +/** + * Remove side data of the given type from a set. + * + * @param set a set from which the side data should be removed + * @param type side information type + */ +void av_packet_side_data_set_remove(AVPacketSideDataSet *set, + enum AVPacketSideDataType type); + +/** + * Get side information from set. + * + * @param set a set from which the side data should be fetched + * @param type desired side information type + * + * @return pointer to side data if present or NULL otherwise + */ +AVPacketSideData *av_packet_side_data_set_get(const AVPacketSideDataSet *set, + enum AVPacketSideDataType type); + +/** + * Convenience function to free all the side data stored in a set. + * + * @param set the set to free + */ +void av_packet_side_data_set_free(AVPacketSideDataSet *set); + /** * @} */ From patchwork Mon Aug 28 12:34:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43367 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp113866pzf; Mon, 28 Aug 2023 05:37:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGoexg9uRSr7RjEqvFEoERyetvkwT900S7R1rJRwBa80MLHy/KK2nTDlwN4UGfj+yUUsng9 X-Received: by 2002:a17:907:7714:b0:99d:fd27:b38d with SMTP id kw20-20020a170907771400b0099dfd27b38dmr19076420ejc.70.1693226241755; Mon, 28 Aug 2023 05:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226241; cv=none; d=google.com; s=arc-20160816; b=Bk94HRflWu3KGJK5BO9oxbV7vXVD55JTl8Cv5RqE8ufMrS21K1vSgSVOHldrOmZIIh azuMqb81Um0XItERP6o1HPKQwYYCBiQUpR7j2y/jUPFCCaGdQhe+tMwJNsoufEt+bgc2 rm4siD2l7Wdf02CUlu5bBg/shWvgzOz1V4kzJErXBI7usOMOugLEgnhtoGtgdC/5cJAi XWeqbAkm1hqem/DCMnJbJ5rRmSLr8WBRXXSPpBTF/DDxnMgEqcVhKuioIUDMea3PpPpP anJ/k9OS3hgWeJOu50kJ8juT9xNsKunmBF0fhKScZ5Bfvp3Vf3P6JhuQIcYQ0X2mZhiv AdrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=PaFiw0sLN90sid8m6r7HFGLt30ffNrg74XJ9dkZ5MBg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=BMn7QAkOmrcjhCl/TYDiPiiMdDZdHCoQFCY2KZFPEwY7WgoOtL1xhHbRDMLoE8K73p A1RrWMp1JAFcgi8iwFj0twxPi3OMDFsEdwcQx0NDM+zptGY43mbAv0UtdVR2wM5PD1Sd VBZN+2/Nmn45HhkJreNrbCP0wcNkTbMfRvkmNOm9pBB8+pl8bVVelo/wY6XjF4E0ULVY 85amuRn6bt0cHb4jFpG1AI/psAjGSNUGjeAAezx8/8SFak9z3XJ8QsZkcXz1vVG5uTJR e5q8EIskAdTvaMRLk7gD9VK7+ChjECewpGtQzOQCGEw0+Y8azC87b0L20xG7aaHyk9CK xuug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=pkjRloV4; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id mb9-20020a170906eb0900b0099bd73c9bcesi4091148ejb.730.2023.08.28.05.37.16; Mon, 28 Aug 2023 05:37:21 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=pkjRloV4; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EB0F368C618; Mon, 28 Aug 2023 15:36:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9409268A05D for ; Mon, 28 Aug 2023 15:36:45 +0300 (EEST) Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6bc886d1504so2497137a34.0 for ; Mon, 28 Aug 2023 05:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226204; x=1693831004; 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=fBGwHDWBas4ZxHAXuMVV1jUMBspTKvRWmn3N4xVQl/Q=; b=pkjRloV4uN3HAZ3nUvPM1KGfvGqB2mdhDC4yPaM9zATdZqxlVXH9SR/Q7JTmV752tm rt8yzreTHNuiJB1xzrwMIfZtP1jBJUJhut8tcuRVC8rqgy9MdK2b8p7sMxYNgP+IaUpL PHtQlO1FCsIlt8QwWs1d7eoj+7fUxnjNquSq4hetcFq7N1bYgNn1zOzjMIeNR1igd9UC 96IYCLAmQShE0hsAgV16EKXzyHsECMzH23sB8hVdmoFKj6u16INfVYjXLhm5kBjTWccF Cqz59+tYm8bfsZTC0ETDlqscuoItsxs2ayBXe6bJ9pxLtTFMuGXd1zrp+Nh/8ko6MgU+ cB8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226204; x=1693831004; 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=fBGwHDWBas4ZxHAXuMVV1jUMBspTKvRWmn3N4xVQl/Q=; b=dDrZExOQD6joyzFjjZhxbeHucStqRnOlbyGcceTOGCDoCMIwtYyr+tGL4lxc3RJevz 6rd1oPn6nqPY5oUhyBwiqbVgCapbesHavSf3FG4T5Pa0LjCO01KeZq56L7cWauPKJj8l 2hyV3cFFbRhDs7j2kzyG3lzjsUIzTk2RhGu3Ostj1vaugtmfs3QmVAFfsqd+zJQhzhNO Ws8JYmqbdZjA+594IoV+ctJnVPmP9aiuCUQVHGwCwU4wDL8PLAb4CIEsw1B5RX9NE05F RVCoTe02CsRbX4z0/MgH1KSCy6F+zeUbwd0+8Qg5mDdqunZBQ8ACn1kzPC2wmkq1AZiv IRIg== X-Gm-Message-State: AOJu0YywmN1fG4ypjImA68YMtKXvRWiHfGTuwMJmGUr8daSp66Y8zC7I St1fMiVqsFD5tJSKb42yhBc/ssZfnS8= X-Received: by 2002:a05:6830:22e4:b0:6be:fcc2:a3f5 with SMTP id t4-20020a05683022e400b006befcc2a3f5mr5748470otc.37.1693226203759; Mon, 28 Aug 2023 05:36:43 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:43 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:34:54 -0300 Message-ID: <20230828123617.57535-3-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/12] avcodec/codec_par: add side data to AVCodecParameters 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: JWfgt4wXFhmk Signed-off-by: James Almer --- libavcodec/codec_par.c | 43 ++++++++++++++++++++++++++++++++++++++++++ libavcodec/codec_par.h | 6 ++++++ 2 files changed, 49 insertions(+) diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c index a38a475dc7..a932323759 100644 --- a/libavcodec/codec_par.c +++ b/libavcodec/codec_par.c @@ -27,11 +27,13 @@ #include "libavutil/mem.h" #include "avcodec.h" #include "codec_par.h" +#include "packet.h" static void codec_parameters_reset(AVCodecParameters *par) { av_freep(&par->extradata); av_channel_layout_uninit(&par->ch_layout); + av_packet_side_data_set_free(&par->side_data); memset(par, 0, sizeof(*par)); @@ -72,6 +74,37 @@ void avcodec_parameters_free(AVCodecParameters **ppar) av_freep(ppar); } +static int codec_parameters_copy_side_data(AVPacketSideDataSet *dst, + const AVPacketSideDataSet *src) +{ + if (!src->nb_sd) + return 0; + + dst->nb_sd = 0; + dst->sd = av_calloc(src->nb_sd, sizeof(*dst->sd)); + if (!dst->sd) + return AVERROR(ENOMEM); + + for (int i = 0; i < src->nb_sd; i++) { + AVPacketSideData *sd = av_mallocz(sizeof(*sd)); + + if (!sd) + return AVERROR(ENOMEM); + + sd->data = av_memdup(src->sd[i]->data, src->sd[i]->size); + if (!sd->data) { + return AVERROR(ENOMEM); + av_free(sd); + } + + sd->type = src->sd[i]->type; + sd->size = src->sd[i]->size; + dst->sd[dst->nb_sd++] = sd; + } + + return 0; +} + int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src) { int ret; @@ -89,6 +122,9 @@ int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src memcpy(dst->extradata, src->extradata, src->extradata_size); dst->extradata_size = src->extradata_size; } + ret = codec_parameters_copy_side_data(&dst->side_data, &src->side_data); + if (ret < 0) + return ret; ret = av_channel_layout_copy(&dst->ch_layout, &src->ch_layout); if (ret < 0) @@ -177,6 +213,9 @@ FF_ENABLE_DEPRECATION_WARNINGS memcpy(par->extradata, codec->extradata, codec->extradata_size); par->extradata_size = codec->extradata_size; } + ret = codec_parameters_copy_side_data(&par->side_data, &codec->packet_side_data); + if (ret < 0) + return ret; return 0; } @@ -261,6 +300,10 @@ FF_ENABLE_DEPRECATION_WARNINGS memcpy(codec->extradata, par->extradata, par->extradata_size); codec->extradata_size = par->extradata_size; } + av_packet_side_data_set_free(&codec->packet_side_data); + ret = codec_parameters_copy_side_data(&codec->packet_side_data, &par->side_data); + if (ret < 0) + return ret; return 0; } diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h index add90fdb1e..169e595b7c 100644 --- a/libavcodec/codec_par.h +++ b/libavcodec/codec_par.h @@ -29,6 +29,7 @@ #include "libavutil/pixfmt.h" #include "codec_id.h" +#include "packet.h" /** * @addtogroup lavc_core @@ -223,6 +224,11 @@ typedef struct AVCodecParameters { * when no higher-level timing information is available. */ AVRational framerate; + + /** + * Additional data associated with the entire stream. + */ + AVPacketSideDataSet side_data; } AVCodecParameters; /** From patchwork Mon Aug 28 12:34:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43369 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp113932pzf; Mon, 28 Aug 2023 05:37:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZAX0fimTCtkDN5KzORvbH71D4Z+flS4ioaJ6JvnLgV93AXImx+gn1RHlQacjRTaPgqNfv X-Received: by 2002:a17:906:cc:b0:9a2:139:f469 with SMTP id 12-20020a17090600cc00b009a20139f469mr9302324eji.69.1693226247249; Mon, 28 Aug 2023 05:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226247; cv=none; d=google.com; s=arc-20160816; b=pAFimTkrA5/XPW+sV6V+nV+8HstMxeVvfBciZn8rFlrb/ssriuTeQo+Fe3PT3TdLhO aKUnxTp4lBZqcq2khuPJ5dFqVLvHwq2wSkeDJHmKKt7bHXOo8PHZfD2NMcl1i78BpPSh sM+gBtNyCIBZxjEvoSOXWSD0dZ60tCrpg7XdaZWQAUIOBmZYERJ5cyc8w/H3emfbAzZ0 qiw9R63IETTPkquo4tHD2q1OC8RXaFMj1R0VNM15ImtsVF8B+ueRbZVBt4KUbWG3VXgH jTf9CJ6BlFwx8MHkAWHRPX0YA4fi0D9+X8AUOUXfv6Z63ax945PeHvCLZ7nnFczbanRL 7G1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=LoipzpwqEK2pP0IhZHRmoXPS2o+QHdYRZ88w4ZE8uRM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=NKo738ceTTnl/P9DeITexD1VlDyKQWvD/W1Fg2exxFIJWmR+kjPki3XJLTtrDpZN95 UT6IPQJzg4Rg52kNaYaYcDCCzooEjtDSqzwd+Lb6g7zdwkNckpZLILlvJHFbsHMymIWy XqOmNky8dn+5r8JTKTeHPp175BNRawrlYBRztbY7N9022c9IXIPZhWD5ekdl/RCKVVAL 8S9qQiqEBsZ0osmviYHwd6jT6yfg1WI+AgmSwj8fbH6Gce5gZQXYhaWx0LuGmOf+DIIB sQ4EUN41aTZ/T5eRJ/G9wbnTvzTfVeuANw+FW2dv8WEsthb3iQKo14BFWf6Sdo3IsWSe 2iOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=FUIz30sI; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id lw28-20020a170906bcdc00b009a5bbaad78bsi705828ejb.985.2023.08.28.05.37.26; Mon, 28 Aug 2023 05:37:27 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=FUIz30sI; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ECED368C5F3; Mon, 28 Aug 2023 15:36:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9792268C5FB for ; Mon, 28 Aug 2023 15:36:47 +0300 (EEST) Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6bda8559fddso2423471a34.1 for ; Mon, 28 Aug 2023 05:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226206; x=1693831006; 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=erHhFtBjg9pXxpTczNgu5NKR3DcNrVRclLAvZmqQM2o=; b=FUIz30sIQt8JKeh4sL1HJk2NuBDxwWud5ue4SEEAdB5ZrzO1Tyvm51mkAv1H7R8SGu vujU/rnpaGMkE1yajSpEp5cqUw1nnPkWm1ezQwpPtYCn8PZOOeSHBpPfpejU0MKC6xmW O6VOxM3bnx1mp3Rl5xDErWIiYws3S7eKTWQBJmlj1lExAkUM7O/1JE18Pj83IMGwhVk7 7QrQ2L6JBdbGCXiEBcGBiSdMf2WjyhCxjgdiEupjYdlwOU9/3/havBUVMIBPFyMyUNuK D2iznfMTcrLHz0hdTBNZwCfToM0TkfVkD25e49RbUP27aaJ3+L13iYWRXxMR+M4rwW0E 8t5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226206; x=1693831006; 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=erHhFtBjg9pXxpTczNgu5NKR3DcNrVRclLAvZmqQM2o=; b=b37tnReh/rZM9u6CEKIrDmj0XFe6XdcpXo85uMNcpzFWsmzirzlphcrhPf/+CoFx5w SyS0lfBcK7T6nfz3IJo99mUc2nnEhMk+I1DWCtyZZ8FbN3fePor20Uz7emAoprW8sGdb gEC68bxYmluVpkY4P38XU1T+BrAnuENCTWVHjg+THJL2d9mHvPH029V1gObAvY4pVnjJ JH9nVY4NsuKWg5UJMvFV/ZjekI0aXPoJ/tDD3x7XbEcJSQI34U2MqL+R5QmQ7gkJYzx0 cpm+a9F74317ibHPwr6u/FuLEYnpscOpwahO/OcJPbOlwH2mRz05J7q1ENoaaloSaRcC OqTA== X-Gm-Message-State: AOJu0YyVSWYDDBe/e65E0+7Cxj1wwXCMhbFOU6Gbkpx5MygAZ0l5EhoI +9lpjYrOA5/cnQ9HlkADUK0afq4fw8I= X-Received: by 2002:a9d:620a:0:b0:6bd:c8c2:b70f with SMTP id g10-20020a9d620a000000b006bdc8c2b70fmr13634263otj.34.1693226205221; Mon, 28 Aug 2023 05:36:45 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:44 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:34:55 -0300 Message-ID: <20230828123617.57535-4-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/12] avformat/avformat: use the side data from AVStream.codecpar 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: x9wwGabGLJ6A Signed-off-by: James Almer --- libavdevice/android_camera.c | 6 +-- libavformat/avformat.c | 42 ++++----------------- libavformat/avformat.h | 28 ++++++++++++++ libavformat/concatdec.c | 1 - libavformat/dashdec.c | 11 ------ libavformat/demux.c | 40 +++++++++++++++++--- libavformat/demux_utils.c | 4 ++ libavformat/dovi_isom.c | 2 +- libavformat/dump.c | 6 +-- libavformat/hls.c | 11 ------ libavformat/hlsenc.c | 11 +++--- libavformat/internal.h | 4 ++ libavformat/matroska.c | 2 +- libavformat/matroskadec.c | 20 +++++----- libavformat/matroskaenc.c | 48 +++++++++++++----------- libavformat/mov.c | 41 +++++++++++--------- libavformat/movenc.c | 73 +++++++++++++++++------------------- libavformat/mp3enc.c | 8 ++-- libavformat/mpegenc.c | 15 +++++--- libavformat/mpegts.c | 2 +- libavformat/mux.c | 19 ++++++++++ libavformat/mxfdec.c | 9 +++-- libavformat/mxfenc.c | 8 ++-- libavformat/options.c | 2 + libavformat/replaygain.c | 6 ++- libavformat/seek.c | 2 + libavformat/version_major.h | 1 + 27 files changed, 239 insertions(+), 183 deletions(-) diff --git a/libavdevice/android_camera.c b/libavdevice/android_camera.c index 1934999c18..a4d6151809 100644 --- a/libavdevice/android_camera.c +++ b/libavdevice/android_camera.c @@ -638,7 +638,7 @@ static int wait_for_image_format(AVFormatContext *avctx) static int add_display_matrix(AVFormatContext *avctx, AVStream *st) { AndroidCameraCtx *ctx = avctx->priv_data; - uint8_t *side_data; + AVPacketSideData *side_data; int32_t display_matrix[9]; av_display_rotation_set(display_matrix, ctx->sensor_orientation); @@ -647,14 +647,14 @@ static int add_display_matrix(AVFormatContext *avctx, AVStream *st) av_display_matrix_flip(display_matrix, 1, 0); } - side_data = av_stream_new_side_data(st, + side_data = av_packet_new_side_data_to_set(&st->codecpar->side_data, AV_PKT_DATA_DISPLAYMATRIX, sizeof(display_matrix)); if (!side_data) { return AVERROR(ENOMEM); } - memcpy(side_data, display_matrix, sizeof(display_matrix)); + memcpy(side_data->data, display_matrix, sizeof(display_matrix)); return 0; } diff --git a/libavformat/avformat.c b/libavformat/avformat.c index 356b4de931..3afc5afd7f 100644 --- a/libavformat/avformat.c +++ b/libavformat/avformat.c @@ -46,9 +46,13 @@ void ff_free_stream(AVStream **pst) if (!st) return; +#if FF_API_AVSTREAM_SIDE_DATA +FF_DISABLE_DEPRECATION_WARNINGS for (int i = 0; i < st->nb_side_data; i++) av_freep(&st->side_data[i].data); av_freep(&st->side_data); +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (st->attached_pic.data) av_packet_unref(&st->attached_pic); @@ -138,6 +142,8 @@ void avformat_free_context(AVFormatContext *s) av_free(s); } +#if FF_API_AVSTREAM_SIDE_DATA +FF_DISABLE_DEPRECATION_WARNINGS uint8_t *av_stream_get_side_data(const AVStream *st, enum AVPacketSideDataType type, size_t *size) { @@ -205,36 +211,8 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, return data; } - -int ff_stream_side_data_copy(AVStream *dst, const AVStream *src) -{ - /* Free existing side data*/ - for (int i = 0; i < dst->nb_side_data; i++) - av_free(dst->side_data[i].data); - av_freep(&dst->side_data); - dst->nb_side_data = 0; - - /* Copy side data if present */ - if (src->nb_side_data) { - dst->side_data = av_calloc(src->nb_side_data, - sizeof(*dst->side_data)); - if (!dst->side_data) - return AVERROR(ENOMEM); - dst->nb_side_data = src->nb_side_data; - - for (int i = 0; i < src->nb_side_data; i++) { - uint8_t *data = av_memdup(src->side_data[i].data, - src->side_data[i].size); - if (!data) - return AVERROR(ENOMEM); - dst->side_data[i].type = src->side_data[i].type; - dst->side_data[i].size = src->side_data[i].size; - dst->side_data[i].data = data; - } - } - - return 0; -} +FF_ENABLE_DEPRECATION_WARNINGS +#endif /** * Copy all stream parameters from source to destination stream, with the @@ -270,10 +248,6 @@ static int stream_params_copy(AVStream *dst, const AVStream *src) if (ret < 0) return ret; - ret = ff_stream_side_data_copy(dst, src); - if (ret < 0) - return ret; - av_packet_unref(&dst->attached_pic); if (src->attached_pic.data) { ret = av_packet_ref(&dst->attached_pic, &src->attached_pic); diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 1916aa2dc5..22769c3ba0 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -164,6 +164,12 @@ * decoding functions avcodec_send_packet() or avcodec_decode_subtitle2() if the * caller wishes to decode the data. * + * There may be no overlap between AVCodecParameters.side_data and side data in + * packets. I.e. a given side data is either exported by the demuxer in + * AVCodecParameters, then it never appears in the packets, or the side data is + * exported through the packets (always in the first packet where the value + * becomes known or changes), then it does not appear in AVCodecParameters. + * * AVPacket.pts, AVPacket.dts and AVPacket.duration timing information will be * set if known. They may also be unset (i.e. AV_NOPTS_VALUE for * pts/dts, 0 for duration) if the stream does not provide them. The timing @@ -209,6 +215,11 @@ * AVCodecParameters, rather than using @ref avcodec_parameters_copy() during * remuxing: there is no guarantee that the codec context values remain valid * for both input and output format contexts. + * - There may be no overlap between AVCodecParameters.side_data and side data in + * packets. I.e. a given side data is either set by the caller in + * AVCodecParameters, then it never appears in the packets, or the side data is + * sent through the packets (always in the first packet where the value becomes + * known or changes), then it does not appear in AVCodecParameters. * - The caller may fill in additional information, such as @ref * AVFormatContext.metadata "global" or @ref AVStream.metadata "per-stream" * metadata, @ref AVFormatContext.chapters "chapters", @ref @@ -937,6 +948,7 @@ typedef struct AVStream { */ AVPacket attached_pic; +#if FF_API_AVSTREAM_SIDE_DATA /** * An array of side data that applies to the whole stream (i.e. the * container does not allow it to change between packets). @@ -953,13 +965,20 @@ typedef struct AVStream { * * Freed by libavformat in avformat_free_context(). * + * @deprecated use AVStream's codecpar.side_data + * * @see av_format_inject_global_side_data() */ + attribute_deprecated AVPacketSideData *side_data; /** * The number of elements in the AVStream.side_data array. + * + * @deprecated use AVStream's codecpar.side_data */ + attribute_deprecated int nb_side_data; +#endif /** * Flags indicating events happening on the stream, a combination of @@ -1715,11 +1734,14 @@ typedef struct AVFormatContext { int (*io_close2)(struct AVFormatContext *s, AVIOContext *pb); } AVFormatContext; +#if FF_API_AVSTREAM_SIDE_DATA /** * This function will cause global side data to be injected in the next packet * of each stream as well as after any subsequent seek. */ +attribute_deprecated void av_format_inject_global_side_data(AVFormatContext *s); +#endif /** * Returns the method used to set ctx->duration. @@ -1856,7 +1878,9 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c); * * @return zero on success, a negative AVERROR code on failure. On failure, * the stream is unchanged and the data remains owned by the caller. + * @deprecated use av_packet_side_data_set_add() and stream->codecpar->side_data */ +attribute_deprecated int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, uint8_t *data, size_t size); @@ -1868,7 +1892,9 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, * @param size side information size * * @return pointer to fresh allocated data or NULL otherwise + * @deprecated use av_packet_side_data_set_new() and stream->codecpar->side_data */ +attribute_deprecated uint8_t *av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, size_t size); /** @@ -1880,7 +1906,9 @@ uint8_t *av_stream_new_side_data(AVStream *stream, * or to zero if the desired side data is not present. * * @return pointer to data if present or NULL otherwise + * @deprecated use av_packet_side_data_set_get() and stream->codecpar->side_data */ +attribute_deprecated uint8_t *av_stream_get_side_data(const AVStream *stream, enum AVPacketSideDataType type, size_t *size); diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 5d4f67d0ac..2aeb4f1dfd 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -194,7 +194,6 @@ static int copy_stream_props(AVStream *st, AVStream *source_st) avpriv_set_pts_info(st, 64, source_st->time_base.num, source_st->time_base.den); av_dict_copy(&st->metadata, source_st->metadata, 0); - ff_stream_side_data_copy(st, source_st); return 0; } diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 29d4680c68..2441087606 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1952,17 +1952,6 @@ static int open_demux_for_component(AVFormatContext *s, struct representation *p // copy disposition st->disposition = ist->disposition; - - // copy side data - for (int i = 0; i < ist->nb_side_data; i++) { - const AVPacketSideData *sd_src = &ist->side_data[i]; - uint8_t *dst_data; - - dst_data = av_stream_new_side_data(st, sd_src->type, sd_src->size); - if (!dst_data) - return AVERROR(ENOMEM); - memcpy(dst_data, sd_src->data, sd_src->size); - } } return 0; diff --git a/libavformat/demux.c b/libavformat/demux.c index b218f64574..4f46f010bd 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -1409,9 +1409,10 @@ FF_ENABLE_DEPRECATION_WARNINGS sti->skip_samples = 0; } +#if FF_API_AVSTREAM_SIDE_DATA if (sti->inject_global_side_data) { - for (int i = 0; i < st->nb_side_data; i++) { - const AVPacketSideData *const src_sd = &st->side_data[i]; + for (int i = 0; i < st->codecpar->side_data.nb_sd; i++) { + const AVPacketSideData *const src_sd = st->codecpar->side_data.sd[i]; uint8_t *dst_data; if (av_packet_get_side_data(pkt, src_sd->type, NULL)) @@ -1427,6 +1428,7 @@ FF_ENABLE_DEPRECATION_WARNINGS } sti->inject_global_side_data = 0; } +#endif } if (!si->metafree) { @@ -2435,11 +2437,11 @@ static int add_coded_side_data(AVStream *st, AVCodecContext *avctx) { for (int i = 0; i < avctx->nb_coded_side_data; i++) { const AVPacketSideData *const sd_src = &avctx->coded_side_data[i]; - uint8_t *dst_data; - dst_data = av_stream_new_side_data(st, sd_src->type, sd_src->size); - if (!dst_data) + AVPacketSideData *sd_dst = av_packet_side_data_set_new(&st->codecpar->side_data, + sd_src->type, sd_src->size); + if (!sd_dst) return AVERROR(ENOMEM); - memcpy(dst_data, sd_src->data, sd_src->size); + memcpy(sd_dst->data, sd_src->data, sd_src->size); } return 0; } @@ -2976,6 +2978,32 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) goto find_stream_info_err; } +#if FF_API_AVSTREAM_SIDE_DATA +FF_DISABLE_DEPRECATION_WARNINGS + if (st->codecpar->side_data.nb_sd > 0) { + av_assert0(!st->side_data && !st->nb_side_data); + st->side_data = av_calloc(st->codecpar->side_data.nb_sd, + sizeof(*st->side_data)); + if (!st->side_data) { + ret = AVERROR(ENOMEM); + goto find_stream_info_err; + } + + for (int i = 0; i < st->codecpar->side_data.nb_sd; i++) { + uint8_t *data = av_memdup(st->codecpar->side_data.sd[i]->data, + st->codecpar->side_data.sd[i]->size); + if (!data) { + ret = AVERROR(ENOMEM); + goto find_stream_info_err; + } + st->side_data[i].type = st->codecpar->side_data.sd[i]->type; + st->side_data[i].size = st->codecpar->side_data.sd[i]->size; + st->side_data[i].data = data; + st->nb_side_data++; + } + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif sti->avctx_inited = 0; } diff --git a/libavformat/demux_utils.c b/libavformat/demux_utils.c index 56cc6e15d8..2946e82295 100644 --- a/libavformat/demux_utils.c +++ b/libavformat/demux_utils.c @@ -80,6 +80,8 @@ AVChapter *avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_ba return chapter; } +#if FF_API_AVSTREAM_SIDE_DATA +FF_DISABLE_DEPRECATION_WARNINGS void av_format_inject_global_side_data(AVFormatContext *s) { FFFormatContext *const si = ffformatcontext(s); @@ -89,6 +91,8 @@ void av_format_inject_global_side_data(AVFormatContext *s) ffstream(st)->inject_global_side_data = 1; } } +FF_ENABLE_DEPRECATION_WARNINGS +#endif int avformat_queue_attached_pictures(AVFormatContext *s) { diff --git a/libavformat/dovi_isom.c b/libavformat/dovi_isom.c index c8fdf566e4..c1675bbf83 100644 --- a/libavformat/dovi_isom.c +++ b/libavformat/dovi_isom.c @@ -64,7 +64,7 @@ int ff_isom_parse_dvcc_dvvc(void *logctx, AVStream *st, dovi->dv_bl_signal_compatibility_id = 0; } - ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, + ret = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_DOVI_CONF, (uint8_t *)dovi, dovi_size); if (ret < 0) { av_free(dovi); diff --git a/libavformat/dump.c b/libavformat/dump.c index d31e4c2ec6..d6f32f0c68 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -431,11 +431,11 @@ static void dump_sidedata(void *ctx, const AVStream *st, const char *indent) { int i; - if (st->nb_side_data) + if (st->codecpar->side_data.nb_sd) av_log(ctx, AV_LOG_INFO, "%sSide data:\n", indent); - for (i = 0; i < st->nb_side_data; i++) { - const AVPacketSideData *sd = &st->side_data[i]; + for (i = 0; i < st->codecpar->side_data.nb_sd; i++) { + const AVPacketSideData *sd = st->codecpar->side_data.sd[i]; av_log(ctx, AV_LOG_INFO, "%s ", indent); switch (sd->type) { diff --git a/libavformat/hls.c b/libavformat/hls.c index c625e30291..8f80cf64f4 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1851,17 +1851,6 @@ static int set_stream_info_from_input_stream(AVStream *st, struct playlist *pls, av_dict_copy(&st->metadata, ist->metadata, 0); - // copy side data - for (int i = 0; i < ist->nb_side_data; i++) { - const AVPacketSideData *sd_src = &ist->side_data[i]; - uint8_t *dst_data; - - dst_data = av_stream_new_side_data(st, sd_src->type, sd_src->size); - if (!dst_data) - return AVERROR(ENOMEM); - memcpy(dst_data, sd_src->data, sd_src->size); - } - ffstream(st)->need_context_update = 1; return 0; diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 27d97f5f72..fcc875e236 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1351,16 +1351,17 @@ static const char* get_relative_url(const char *master_url, const char *media_ur static int64_t get_stream_bit_rate(AVStream *stream) { - AVCPBProperties *props = (AVCPBProperties*)av_stream_get_side_data( - stream, - AV_PKT_DATA_CPB_PROPERTIES, - NULL + AVPacketSideData *sd = av_packet_side_data_set_get( + &stream->codecpar->side_data, + AV_PKT_DATA_CPB_PROPERTIES ); if (stream->codecpar->bit_rate) return stream->codecpar->bit_rate; - else if (props) + else if (sd) { + AVCPBProperties *props = (AVCPBProperties*)sd->data; return props->max_bitrate; + } return 0; } diff --git a/libavformat/internal.h b/libavformat/internal.h index 594afd731d..430ebb7536 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -148,7 +148,9 @@ typedef struct FFFormatContext { int missing_ts_warning; #endif +#if FF_API_AVSTREAM_SIDE_DATA int inject_global_side_data; +#endif int avoid_negative_ts_use_pts; @@ -355,10 +357,12 @@ typedef struct FFStream { uint8_t dts_ordered; uint8_t dts_misordered; +#if FF_API_AVSTREAM_SIDE_DATA /** * Internal data to inject global side data */ int inject_global_side_data; +#endif /** * display aspect ratio (0 if unknown) diff --git a/libavformat/matroska.c b/libavformat/matroska.c index 79b2d09984..9b5a4459aa 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -198,7 +198,7 @@ int ff_mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode) break; } - ret = av_stream_add_side_data(st, AV_PKT_DATA_STEREO3D, (uint8_t *)stereo, + ret = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_STEREO3D, (uint8_t *)stereo, sizeof(*stereo)); if (ret < 0) { av_freep(&stereo); diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 49950956b6..a635cfe5e3 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2202,7 +2202,7 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) { AVContentLightMetadata *metadata = av_content_light_metadata_alloc(&size); if (!metadata) return AVERROR(ENOMEM); - ret = av_stream_add_side_data(st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, + ret = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, (uint8_t *)metadata, size); if (ret < 0) { av_freep(&metadata); @@ -2213,13 +2213,13 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) { } if (has_mastering_primaries || has_mastering_luminance) { - AVMasteringDisplayMetadata *metadata = - (AVMasteringDisplayMetadata*) av_stream_new_side_data( - st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, + AVMasteringDisplayMetadata *metadata; + AVPacketSideData *sd = av_packet_side_data_set_new( + &st->codecpar->side_data, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, sizeof(AVMasteringDisplayMetadata)); - if (!metadata) { + if (!sd) return AVERROR(ENOMEM); - } + metadata = (AVMasteringDisplayMetadata*)sd->data; memset(metadata, 0, sizeof(AVMasteringDisplayMetadata)); if (has_mastering_primaries) { metadata->display_primaries[0][0] = av_d2q(mastering_meta->r_x, INT_MAX); @@ -2245,6 +2245,7 @@ static int mkv_create_display_matrix(AVStream *st, const MatroskaTrackVideoProjection *proj, void *logctx) { + AVPacketSideData *sd; double pitch = proj->pitch, yaw = proj->yaw, roll = proj->roll; int32_t *matrix; int hflip; @@ -2261,10 +2262,11 @@ static int mkv_create_display_matrix(AVStream *st, st->index, yaw, pitch, roll); return 0; } - matrix = (int32_t*)av_stream_new_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, + sd = av_packet_side_data_set_new(&st->codecpar->side_data, AV_PKT_DATA_DISPLAYMATRIX, 9 * sizeof(*matrix)); - if (!matrix) + if (!sd) return AVERROR(ENOMEM); + matrix = (int32_t*)sd->data; hflip = yaw != 0.0; /* ProjectionPoseRoll is in the counter-clockwise direction @@ -2365,7 +2367,7 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track, spherical->bound_right = r; spherical->bound_bottom = b; - ret = av_stream_add_side_data(st, AV_PKT_DATA_SPHERICAL, (uint8_t *)spherical, + ret = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_SPHERICAL, (uint8_t *)spherical, spherical_size); if (ret < 0) { av_freep(&spherical); diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index e813ef86cf..cc197763b3 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1327,7 +1327,7 @@ fail: static void mkv_write_video_color(EbmlWriter *writer, const AVStream *st, const AVCodecParameters *par) { - const void *side_data; + const AVPacketSideData *side_data; ebml_writer_open_master(writer, MATROSKA_ID_VIDEOCOLOR); @@ -1361,20 +1361,18 @@ static void mkv_write_video_color(EbmlWriter *writer, const AVStream *st, (ypos >> 7) + 1); } - side_data = av_stream_get_side_data(st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, - NULL); + side_data = av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_CONTENT_LIGHT_LEVEL); if (side_data) { - const AVContentLightMetadata *metadata = side_data; + const AVContentLightMetadata *metadata = (AVContentLightMetadata *)side_data->data; ebml_writer_add_uint(writer, MATROSKA_ID_VIDEOCOLORMAXCLL, metadata->MaxCLL); ebml_writer_add_uint(writer, MATROSKA_ID_VIDEOCOLORMAXFALL, metadata->MaxFALL); } - side_data = av_stream_get_side_data(st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, - NULL); + side_data = av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_MASTERING_DISPLAY_METADATA); if (side_data) { - const AVMasteringDisplayMetadata *metadata = side_data; + const AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)side_data->data; ebml_writer_open_master(writer, MATROSKA_ID_VIDEOCOLORMASTERINGMETA); if (metadata->has_primaries) { ebml_writer_add_float(writer, MATROSKA_ID_VIDEOCOLOR_RX, @@ -1410,12 +1408,15 @@ static void mkv_write_video_color(EbmlWriter *writer, const AVStream *st, static void mkv_handle_rotation(void *logctx, const AVStream *st, double *yaw, double *roll) { - const int32_t *matrix = - (const int32_t*)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, NULL); + const int32_t *matrix; + const AVPacketSideData *side_data = + av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_DISPLAYMATRIX); - if (!matrix) + if (!side_data) return; + matrix = (int32_t *)side_data->data; + /* Check whether this is an affine transformation */ if (matrix[2] || matrix[5]) goto ignore; @@ -1462,13 +1463,13 @@ static int mkv_handle_spherical(void *logctx, EbmlWriter *writer, const AVStream *st, uint8_t private[], double *yaw, double *pitch, double *roll) { - const AVSphericalMapping *spherical = - (const AVSphericalMapping *)av_stream_get_side_data(st, AV_PKT_DATA_SPHERICAL, - NULL); + AVPacketSideData *sd = av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_SPHERICAL); + const AVSphericalMapping *spherical; - if (!spherical) + if (!sd) return 0; + spherical = (const AVSphericalMapping *)sd->data; if (spherical->projection != AV_SPHERICAL_EQUIRECTANGULAR && spherical->projection != AV_SPHERICAL_EQUIRECTANGULAR_TILE && spherical->projection != AV_SPHERICAL_CUBEMAP) { @@ -1583,9 +1584,9 @@ static int mkv_write_stereo_mode(AVFormatContext *s, EbmlWriter *writer, AVStream *st, int is_webm, int *h_width, int *h_height) { + AVPacketSideData *sd; const AVDictionaryEntry *tag; MatroskaVideoStereoModeType format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB; - const AVStereo3D *stereo; *h_width = 1; *h_height = 1; @@ -1608,9 +1609,9 @@ static int mkv_write_stereo_mode(AVFormatContext *s, EbmlWriter *writer, } } - stereo = (const AVStereo3D*)av_stream_get_side_data(st, AV_PKT_DATA_STEREO3D, - NULL); - if (stereo) { + sd = av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_STEREO3D); + if (sd) { + const AVStereo3D *stereo = (const AVStereo3D*)sd->data; switch (stereo->type) { case AV_STEREO3D_2D: format = MATROSKA_VIDEO_STEREOMODE_TYPE_MONO; @@ -1677,6 +1678,7 @@ static void mkv_write_blockadditionmapping(AVFormatContext *s, const MatroskaMux { #if CONFIG_MATROSKA_MUXER const AVDOVIDecoderConfigurationRecord *dovi; + const AVPacketSideData *sd; if (IS_SEEKABLE(s->pb, mkv)) { track->blockadditionmapping_offset = avio_tell(pb); @@ -1693,9 +1695,13 @@ static void mkv_write_blockadditionmapping(AVFormatContext *s, const MatroskaMux } } - dovi = (const AVDOVIDecoderConfigurationRecord *) - av_stream_get_side_data(st, AV_PKT_DATA_DOVI_CONF, NULL); - if (dovi && dovi->dv_profile <= 10) { + sd = av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_DOVI_CONF); + + if (!sd) + return; + + dovi = (const AVDOVIDecoderConfigurationRecord *)sd->data; + if (dovi->dv_profile <= 10) { ebml_master mapping; uint8_t buf[ISOM_DVCC_DVVC_SIZE]; uint32_t type; diff --git a/libavformat/mov.c b/libavformat/mov.c index be9975f297..59431860ca 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -799,6 +799,7 @@ static int mov_read_esds(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; + AVPacketSideData *sd; enum AVAudioServiceType *ast; int ac3info, acmod, lfeon, bsmod; uint64_t mask; @@ -807,11 +808,12 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; st = c->fc->streams[c->fc->nb_streams-1]; - ast = (enum AVAudioServiceType*)av_stream_new_side_data(st, AV_PKT_DATA_AUDIO_SERVICE_TYPE, + sd = av_packet_side_data_set_new(&st->codecpar->side_data, AV_PKT_DATA_AUDIO_SERVICE_TYPE, sizeof(*ast)); - if (!ast) + if (!sd) return AVERROR(ENOMEM); + ast = (enum AVAudioServiceType*)sd->data; ac3info = avio_rb24(pb); bsmod = (ac3info >> 14) & 0x7; acmod = (ac3info >> 11) & 0x7; @@ -833,6 +835,7 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; + AVPacketSideData *sd; enum AVAudioServiceType *ast; int eac3info, acmod, lfeon, bsmod; uint64_t mask; @@ -841,11 +844,13 @@ static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; st = c->fc->streams[c->fc->nb_streams-1]; - ast = (enum AVAudioServiceType*)av_stream_new_side_data(st, AV_PKT_DATA_AUDIO_SERVICE_TYPE, + sd = av_packet_side_data_set_new(&st->codecpar->side_data, AV_PKT_DATA_AUDIO_SERVICE_TYPE, sizeof(*ast)); - if (!ast) + if (!sd) return AVERROR(ENOMEM); + ast = (enum AVAudioServiceType*)sd->data; + /* No need to parse fields for additional independent substreams and its * associated dependent substreams since libavcodec's E-AC-3 decoder * does not support them yet. */ @@ -1747,7 +1752,6 @@ static int mov_read_pcmc(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; - uint8_t *icc_profile; char color_parameter_type[5] = { 0 }; uint16_t color_primaries, color_trc, color_matrix; int ret; @@ -1768,10 +1772,10 @@ static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom) } if (!strncmp(color_parameter_type, "prof", 4)) { - icc_profile = av_stream_new_side_data(st, AV_PKT_DATA_ICC_PROFILE, atom.size - 4); - if (!icc_profile) + AVPacketSideData *sd = av_packet_side_data_set_new(&st->codecpar->side_data, AV_PKT_DATA_ICC_PROFILE, atom.size - 4); + if (!sd) return AVERROR(ENOMEM); - ret = ffio_read_size(pb, icc_profile, atom.size - 4); + ret = ffio_read_size(pb, sd->data, atom.size - 4); if (ret < 0) return ret; } else { @@ -6838,8 +6842,9 @@ static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom) AVEncryptionInitInfo *info, *old_init_info; uint8_t **key_ids; AVStream *st; - uint8_t *side_data, *extra_data, *old_side_data; - size_t side_data_size, old_side_data_size; + AVPacketSideData *old_side_data; + uint8_t *side_data, *extra_data; + size_t side_data_size; int ret = 0; unsigned int version, kid_count, extra_data_size, alloc_size = 0; @@ -6917,9 +6922,9 @@ static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom) info->data_size = extra_data_size; // If there is existing initialization data, append to the list. - old_side_data = av_stream_get_side_data(st, AV_PKT_DATA_ENCRYPTION_INIT_INFO, &old_side_data_size); + old_side_data = av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_ENCRYPTION_INIT_INFO); if (old_side_data) { - old_init_info = av_encryption_init_info_get_side_data(old_side_data, old_side_data_size); + old_init_info = av_encryption_init_info_get_side_data(old_side_data->data, old_side_data->size); if (old_init_info) { // Append to the end of the list. for (AVEncryptionInitInfo *cur = old_init_info;; cur = cur->next) { @@ -6941,7 +6946,7 @@ static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom) ret = AVERROR(ENOMEM); goto finish; } - ret = av_stream_add_side_data(st, AV_PKT_DATA_ENCRYPTION_INIT_INFO, + ret = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_ENCRYPTION_INIT_INFO, side_data, side_data_size); if (ret < 0) av_free(side_data); @@ -8720,7 +8725,7 @@ static int mov_read_header(AVFormatContext *s) break; case AVMEDIA_TYPE_VIDEO: if (sc->display_matrix) { - err = av_stream_add_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, (uint8_t*)sc->display_matrix, + err = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_DISPLAYMATRIX, (uint8_t*)sc->display_matrix, sizeof(int32_t) * 9); if (err < 0) return err; @@ -8728,7 +8733,7 @@ static int mov_read_header(AVFormatContext *s) sc->display_matrix = NULL; } if (sc->stereo3d) { - err = av_stream_add_side_data(st, AV_PKT_DATA_STEREO3D, + err = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_STEREO3D, (uint8_t *)sc->stereo3d, sizeof(*sc->stereo3d)); if (err < 0) @@ -8737,7 +8742,7 @@ static int mov_read_header(AVFormatContext *s) sc->stereo3d = NULL; } if (sc->spherical) { - err = av_stream_add_side_data(st, AV_PKT_DATA_SPHERICAL, + err = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_SPHERICAL, (uint8_t *)sc->spherical, sc->spherical_size); if (err < 0) @@ -8746,7 +8751,7 @@ static int mov_read_header(AVFormatContext *s) sc->spherical = NULL; } if (sc->mastering) { - err = av_stream_add_side_data(st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, + err = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, (uint8_t *)sc->mastering, sizeof(*sc->mastering)); if (err < 0) @@ -8755,7 +8760,7 @@ static int mov_read_header(AVFormatContext *s) sc->mastering = NULL; } if (sc->coll) { - err = av_stream_add_side_data(st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, + err = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, (uint8_t *)sc->coll, sc->coll_size); if (err < 0) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7ef6cef46a..193e00067d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -672,11 +672,11 @@ struct mpeg4_bit_rate_values { static struct mpeg4_bit_rate_values calculate_mpeg4_bit_rates(MOVTrack *track) { - AVCPBProperties *props = track->st ? - (AVCPBProperties*)av_stream_get_side_data(track->st, - AV_PKT_DATA_CPB_PROPERTIES, - NULL) : + AVPacketSideData *sd = track->st ? + av_packet_side_data_set_get(&track->st->codecpar->side_data, + AV_PKT_DATA_CPB_PROPERTIES) : NULL; + AVCPBProperties *props = sd ? (AVCPBProperties *)sd->data : NULL; struct mpeg4_bit_rate_values bit_rates = { 0 }; bit_rates.avg_bit_rate = compute_avg_bitrate(track); @@ -2132,18 +2132,16 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track, int prefer_icc) // Ref (MOV): https://developer.apple.com/library/mac/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG9 // Ref (MP4): ISO/IEC 14496-12:2012 - const uint8_t *icc_profile; - size_t icc_profile_size; - if (prefer_icc) { - icc_profile = av_stream_get_side_data(track->st, AV_PKT_DATA_ICC_PROFILE, &icc_profile_size); + AVPacketSideData *sd = av_packet_side_data_set_get(&track->st->codecpar->side_data, + AV_PKT_DATA_ICC_PROFILE); - if (icc_profile) { - avio_wb32(pb, 12 + icc_profile_size); + if (sd) { + avio_wb32(pb, 12 + sd->size); ffio_wfourcc(pb, "colr"); ffio_wfourcc(pb, "prof"); - avio_write(pb, icc_profile, icc_profile_size); - return 12 + icc_profile_size; + avio_write(pb, sd->data, sd->size); + return 12 + sd->size; } else { av_log(NULL, AV_LOG_INFO, "no ICC profile found, will write nclx/nclc colour info instead\n"); @@ -2176,14 +2174,14 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track, int prefer_icc) static int mov_write_clli_tag(AVIOContext *pb, MOVTrack *track) { - const uint8_t *side_data; + const AVPacketSideData *side_data; const AVContentLightMetadata *content_light_metadata; - side_data = av_stream_get_side_data(track->st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, NULL); + side_data = av_packet_side_data_set_get(&track->st->codecpar->side_data, AV_PKT_DATA_CONTENT_LIGHT_LEVEL); if (!side_data) { return 0; } - content_light_metadata = (const AVContentLightMetadata*)side_data; + content_light_metadata = (const AVContentLightMetadata*)side_data->data; avio_wb32(pb, 12); // size ffio_wfourcc(pb, "clli"); @@ -2201,11 +2199,12 @@ static int mov_write_mdcv_tag(AVIOContext *pb, MOVTrack *track) { const int chroma_den = 50000; const int luma_den = 10000; - const uint8_t *side_data; - const AVMasteringDisplayMetadata *metadata; + const AVPacketSideData *side_data; + const AVMasteringDisplayMetadata *metadata = NULL; - side_data = av_stream_get_side_data(track->st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL); - metadata = (const AVMasteringDisplayMetadata*)side_data; + side_data = av_packet_side_data_set_get(&track->st->codecpar->side_data, AV_PKT_DATA_MASTERING_DISPLAY_METADATA); + if (side_data) + metadata = (const AVMasteringDisplayMetadata*)side_data->data; if (!metadata || !metadata->has_primaries || !metadata->has_luminance) { return 0; } @@ -2424,7 +2423,7 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex track->par->color_trc != AVCOL_TRC_UNSPECIFIED && track->par->color_space != AVCOL_SPC_UNSPECIFIED; if (has_color_info || mov->flags & FF_MOV_FLAG_WRITE_COLR || - av_stream_get_side_data(track->st, AV_PKT_DATA_ICC_PROFILE, NULL)) { + av_packet_side_data_set_get(&track->st->codecpar->side_data, AV_PKT_DATA_ICC_PROFILE)) { int prefer_icc = mov->flags & FF_MOV_FLAG_PREFER_ICC || !has_color_info; mov_write_colr_tag(pb, track, prefer_icc); } @@ -2438,17 +2437,16 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex } if (track->mode == MODE_MP4 && mov->fc->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) { - AVStereo3D* stereo_3d = (AVStereo3D*) av_stream_get_side_data(track->st, AV_PKT_DATA_STEREO3D, NULL); - AVSphericalMapping* spherical_mapping = (AVSphericalMapping*)av_stream_get_side_data(track->st, AV_PKT_DATA_SPHERICAL, NULL); - AVDOVIDecoderConfigurationRecord *dovi = (AVDOVIDecoderConfigurationRecord *) - av_stream_get_side_data(track->st, AV_PKT_DATA_DOVI_CONF, NULL); + AVPacketSideData *stereo_3d = av_packet_side_data_set_get(&track->st->codecpar->side_data, AV_PKT_DATA_STEREO3D); + AVPacketSideData *spherical_mapping = av_packet_side_data_set_get(&track->st->codecpar->side_data, AV_PKT_DATA_SPHERICAL); + AVPacketSideData *dovi = av_packet_side_data_set_get(&track->st->codecpar->side_data, AV_PKT_DATA_DOVI_CONF); if (stereo_3d) - mov_write_st3d_tag(s, pb, stereo_3d); + mov_write_st3d_tag(s, pb, (AVStereo3D*)stereo_3d->data); if (spherical_mapping) - mov_write_sv3d_tag(mov->fc, pb, spherical_mapping); + mov_write_sv3d_tag(mov->fc, pb, (AVSphericalMapping*)spherical_mapping->data); if (dovi) - mov_write_dvcc_dvvc_tag(s, pb, dovi); + mov_write_dvcc_dvvc_tag(s, pb, (AVDOVIDecoderConfigurationRecord *)dovi->data); } if (track->par->sample_aspect_ratio.den && track->par->sample_aspect_ratio.num) { @@ -3395,7 +3393,6 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov, int group = 0; uint32_t *display_matrix = NULL; - size_t display_matrix_size; int i; if (mov->mode == MODE_AVIF) @@ -3405,15 +3402,15 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov, duration *= mov->avif_loop_count; if (st) { + AVPacketSideData *sd; if (mov->per_stream_grouping) group = st->index; else group = st->codecpar->codec_type; - display_matrix = (uint32_t*)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, - &display_matrix_size); - if (display_matrix && display_matrix_size < 9 * sizeof(*display_matrix)) - display_matrix = NULL; + sd = av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_DISPLAYMATRIX); + if (sd && sd->size == 9 * sizeof(*display_matrix)) + display_matrix = (uint32_t *)sd->data; } if (track->flags & MOV_TRACK_ENABLED) @@ -4611,12 +4608,10 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, track->tref_tag = MKTAG('h','i','n','t'); track->tref_id = mov->tracks[track->src_track].track_id; } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) { - size_t size; - int *fallback; - fallback = (int*)av_stream_get_side_data(track->st, - AV_PKT_DATA_FALLBACK_TRACK, - &size); - if (fallback != NULL && size == sizeof(int)) { + AVPacketSideData *sd = av_packet_side_data_set_get(&track->st->codecpar->side_data, + AV_PKT_DATA_FALLBACK_TRACK ); + if (sd && sd->size == sizeof(int)) { + int *fallback = (int *)sd->data; if (*fallback >= 0 && *fallback < mov->nb_streams) { track->tref_tag = MKTAG('f','a','l','l'); track->tref_id = mov->tracks[*fallback].track_id; @@ -5449,7 +5444,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) if (st->codecpar->codec_id == AV_CODEC_ID_AC3 || st->codecpar->codec_id == AV_CODEC_ID_EAC3 || st->codecpar->codec_id == AV_CODEC_ID_TRUEHD || - av_stream_get_side_data(st, AV_PKT_DATA_DOVI_CONF, NULL)) + av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_DOVI_CONF)) has_dolby = 1; } diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 5e81f72a59..9fc1c4fea4 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -400,10 +400,10 @@ static int mp3_queue_flush(AVFormatContext *s) static void mp3_update_xing(AVFormatContext *s) { MP3Context *mp3 = s->priv_data; + AVPacketSideData *sd; AVReplayGain *rg; uint16_t tag_crc; uint8_t *toc; - size_t rg_size; int i; int64_t old_pos = avio_tell(s->pb); @@ -423,11 +423,11 @@ static void mp3_update_xing(AVFormatContext *s) } /* write replaygain */ - rg = (AVReplayGain*)av_stream_get_side_data(s->streams[0], AV_PKT_DATA_REPLAYGAIN, - &rg_size); - if (rg && rg_size >= sizeof(*rg)) { + sd = av_packet_side_data_set_get(&s->streams[0]->codecpar->side_data, AV_PKT_DATA_REPLAYGAIN); + if (sd && sd->size >= sizeof(*rg)) { uint16_t val; + rg = (AVReplayGain *)sd->data; AV_WB32(mp3->xing_frame + mp3->xing_offset + 131, av_rescale(rg->track_peak, 1 << 23, 100000)); diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index c06e308296..c3465e819a 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -342,8 +342,6 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) lpcm_id = LPCM_ID; for (i = 0; i < ctx->nb_streams; i++) { - AVCPBProperties *props; - st = ctx->streams[i]; stream = av_mallocz(sizeof(StreamInfo)); if (!stream) @@ -431,12 +429,16 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) s->audio_bound++; break; case AVMEDIA_TYPE_VIDEO: + AVPacketSideData *sd; + AVCPBProperties *props = NULL; if (st->codecpar->codec_id == AV_CODEC_ID_H264) stream->id = h264_id++; else stream->id = mpv_id++; - props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL); + sd = av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_CPB_PROPERTIES); + if (sd) + props = (AVCPBProperties*)sd->data; if (props && props->buffer_size) stream->max_buffer_size = 6 * 1024 + props->buffer_size / 8; else { @@ -470,12 +472,15 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) audio_bitrate = 0; video_bitrate = 0; for (i = 0; i < ctx->nb_streams; i++) { - AVCPBProperties *props; + AVPacketSideData *sd; + AVCPBProperties *props = NULL; int codec_rate; st = ctx->streams[i]; stream = (StreamInfo *)st->priv_data; - props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL); + sd = av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_CPB_PROPERTIES); + if (sd) + props = (AVCPBProperties*)sd->data; if (props) codec_rate = props->max_bitrate; else diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 0b3edda817..134b17f894 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2221,7 +2221,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type dovi->dv_bl_signal_compatibility_id = 0; } - ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, + ret = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_DOVI_CONF, (uint8_t *)dovi, dovi_size); if (ret < 0) { av_free(dovi); diff --git a/libavformat/mux.c b/libavformat/mux.c index 415bd3948f..718bdd9390 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -277,6 +277,25 @@ FF_ENABLE_DEPRECATION_WARNINGS break; } +#if FF_API_AVSTREAM_SIDE_DATA +FF_DISABLE_DEPRECATION_WARNINGS + /* if the caller is using the deprecated AVStream side_data API, + * copy its contents to AVStream.codecpar, giving it priority + over existing side data in the latter */ + for (int i = 0; i < st->nb_side_data; i++) { + const AVPacketSideData *sd_src = &st->side_data[i]; + AVPacketSideData *sd_dst; + + sd_dst = av_packet_side_data_set_new(&st->codecpar->side_data, sd_src->type, sd_src->size); + if (!sd_dst) { + ret = AVERROR(EINVAL); + goto fail; + } + memcpy(sd_dst->data, sd_src->data, sd_src->size); + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + desc = avcodec_descriptor_get(par->codec_id); if (desc && desc->props & AV_CODEC_PROP_REORDER) sti->reorder = 1; diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 34230ece98..e02bbc22c0 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -2577,10 +2577,11 @@ static int parse_mca_labels(MXFContext *mxf, MXFTrack *source_track, MXFDescript if (service_type != AV_AUDIO_SERVICE_TYPE_NB && service_type != AV_AUDIO_SERVICE_TYPE_MAIN && !ambigous_service_type) { enum AVAudioServiceType *ast; - uint8_t* side_data = av_stream_new_side_data(st, AV_PKT_DATA_AUDIO_SERVICE_TYPE, sizeof(*ast)); + AVPacketSideData *side_data = av_packet_side_data_set_new(&st->codecpar->side_data, + AV_PKT_DATA_AUDIO_SERVICE_TYPE, sizeof(*ast)); if (!side_data) return AVERROR(ENOMEM); - ast = (enum AVAudioServiceType*)side_data; + ast = (enum AVAudioServiceType*)side_data->data; *ast = service_type; } @@ -2980,7 +2981,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) st->codecpar->color_trc = mxf_get_codec_ul(ff_mxf_color_trc_uls, &descriptor->color_trc_ul)->id; st->codecpar->color_space = mxf_get_codec_ul(ff_mxf_color_space_uls, &descriptor->color_space_ul)->id; if (descriptor->mastering) { - ret = av_stream_add_side_data(st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, + ret = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, (uint8_t *)descriptor->mastering, sizeof(*descriptor->mastering)); if (ret < 0) @@ -2988,7 +2989,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) descriptor->mastering = NULL; } if (descriptor->coll) { - ret = av_stream_add_side_data(st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, + ret = av_packet_side_data_set_add(&st->codecpar->side_data, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, (uint8_t *)descriptor->coll, descriptor->coll_size); if (ret < 0) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index d8252ed68f..33922400e6 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -556,7 +556,7 @@ static void mxf_write_primer_pack(AVFormatContext *s) if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_H264 && !sc->avc_intra) { will_have_avc_tags = 1; } - if (av_stream_get_side_data(s->streams[i], AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL)) { + if (av_packet_side_data_set_get(&s->streams[i]->codecpar->side_data, AV_PKT_DATA_MASTERING_DISPLAY_METADATA)) { will_have_mastering_tags = 1; } if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_FFV1) { @@ -1158,7 +1158,7 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID const MXFCodecUL *color_trc_ul; const MXFCodecUL *color_space_ul; int64_t pos = mxf_write_generic_desc(s, st, key); - uint8_t *side_data; + AVPacketSideData *side_data; color_primaries_ul = mxf_get_codec_ul_by_id(ff_mxf_color_primaries_uls, st->codecpar->color_primaries); color_trc_ul = mxf_get_codec_ul_by_id(ff_mxf_color_trc_uls, st->codecpar->color_trc); @@ -1344,9 +1344,9 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID avio_write(pb, *sc->codec_ul, 16); // Mastering Display metadata - side_data = av_stream_get_side_data(st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL); + side_data = av_packet_side_data_set_get(&st->codecpar->side_data, AV_PKT_DATA_MASTERING_DISPLAY_METADATA); if (side_data) { - const AVMasteringDisplayMetadata *metadata = (const AVMasteringDisplayMetadata*)side_data; + const AVMasteringDisplayMetadata *metadata = (const AVMasteringDisplayMetadata*)side_data->data; if (metadata->has_primaries) { mxf_write_local_tag(s, 12, 0x8301); avio_wb16(pb, rescale_mastering_chroma(metadata->display_primaries[0][0])); diff --git a/libavformat/options.c b/libavformat/options.c index e4a3aceed0..ef0b593d36 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -309,7 +309,9 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c) st->sample_aspect_ratio = (AVRational) { 0, 1 }; +#if FF_API_AVSTREAM_SIDE_DATA sti->inject_global_side_data = si->inject_global_side_data; +#endif sti->need_context_update = 1; diff --git a/libavformat/replaygain.c b/libavformat/replaygain.c index 915bcb2382..bd95b4e266 100644 --- a/libavformat/replaygain.c +++ b/libavformat/replaygain.c @@ -69,16 +69,18 @@ static int32_t parse_value(const char *value, int32_t min) int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp, int32_t ag, uint32_t ap) { + AVPacketSideData *sd; AVReplayGain *replaygain; if (tg == INT32_MIN && ag == INT32_MIN) return 0; - replaygain = (AVReplayGain*)av_stream_new_side_data(st, AV_PKT_DATA_REPLAYGAIN, + sd = av_packet_side_data_set_new(&st->codecpar->side_data, AV_PKT_DATA_REPLAYGAIN, sizeof(*replaygain)); - if (!replaygain) + if (!sd) return AVERROR(ENOMEM); + replaygain = (AVReplayGain*)sd->data; replaygain->track_gain = tg; replaygain->track_peak = tp; replaygain->album_gain = ag; diff --git a/libavformat/seek.c b/libavformat/seek.c index 386312cd3a..0180188595 100644 --- a/libavformat/seek.c +++ b/libavformat/seek.c @@ -745,8 +745,10 @@ void ff_read_frame_flush(AVFormatContext *s) for (int j = 0; j < MAX_REORDER_DELAY + 1; j++) sti->pts_buffer[j] = AV_NOPTS_VALUE; +#if FF_API_AVSTREAM_SIDE_DATA if (si->inject_global_side_data) sti->inject_global_side_data = 1; +#endif sti->skip_samples = 0; } diff --git a/libavformat/version_major.h b/libavformat/version_major.h index 293fbd3397..c348e3eb37 100644 --- a/libavformat/version_major.h +++ b/libavformat/version_major.h @@ -45,6 +45,7 @@ #define FF_API_GET_END_PTS (LIBAVFORMAT_VERSION_MAJOR < 61) #define FF_API_AVIODIRCONTEXT (LIBAVFORMAT_VERSION_MAJOR < 61) #define FF_API_AVFORMAT_IO_CLOSE (LIBAVFORMAT_VERSION_MAJOR < 61) +#define FF_API_AVSTREAM_SIDE_DATA (LIBAVFORMAT_VERSION_MAJOR < 61) #define FF_API_R_FRAME_RATE 1 From patchwork Mon Aug 28 12:34:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43370 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp114022pzf; Mon, 28 Aug 2023 05:37:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERuN7iz83GuMFJt5uB6WGkNSEccHkxSVvTC/qKVfij/EJWc3dqKNm1EJ+MTOcQVcMxQR73 X-Received: by 2002:a05:6512:318f:b0:500:b74b:e53 with SMTP id i15-20020a056512318f00b00500b74b0e53mr3105574lfe.46.1693226256668; Mon, 28 Aug 2023 05:37:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226256; cv=none; d=google.com; s=arc-20160816; b=E+tvVIwtxJsefiWXKujqQ1AY2beV/XVvKNdNO/yRvM5UANvqoP7iER8DGvv1L+V4Da XzBnhlcZYGxlS5eXIlzA6qoM4WnStGLaAcEfrD/XQyoWzsu4YkArW5UwL6ieDuH636gi UCUm80LRztVl0JTAEAQHbKywmkP8ui+GWg1ubm4b8cS3NST1IZG5tmESNY1O7fu0sJn3 G2hL+rGaYAszlOTJAxpv38bLGeWlJTXSSnjDrICxqLQhjwTj9zaUfRAGkmbkfmh4oDuG yUudx1Z6lwEE+8e2QT9bGWU+XPCR5XzjFMgBwSn3pKr862FJSSr94kzTlY0vOHfZ34V6 TfmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=YqRwwGW/MOwm3jvnofNCPZ70mvIz48/w4GN93BNZUxY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Ypmdluz58cKcEVBhGu1QhUk7lCFMj9b6Y2CwRqOnvqoJWLIkU2f5vOjHLKZbloUXrN 9rvxMLSriafIcJMCFHBrBd+68GdNCCpzanLDvatELNnUqtYsz/27MJB4578n1dX/wlpg LnbRvjwclxVY92Q7b8G4xmwPHuCcs/0uQvvs5qvrI8Mucn/LKiVI0zof/HmfVB1Vx1wx bDH3TUjY/xR/9fZnkR3FMVsp6tfjkdiMfSXRnrm4aSGRk0fP6kruM8JTv5s4YhitIJPq xOiC9tehc0d1RaEkRdc1CYO7RgCG6VoB6f7eE+MuIfOOGEEPvHTQhRNHpUiWDTHHacx6 o8ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=i+vm2GwV; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r6-20020aa7d586000000b00523215dd857si4338304edq.52.2023.08.28.05.37.36; Mon, 28 Aug 2023 05:37:36 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=i+vm2GwV; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EC4EA68C62F; Mon, 28 Aug 2023 15:36:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DD9D968C642 for ; Mon, 28 Aug 2023 15:36:48 +0300 (EEST) Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-570e63f5224so2142042eaf.0 for ; Mon, 28 Aug 2023 05:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226207; x=1693831007; 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=/nrnAaxWix1J4g3gceAU4BOaFuXxsXxWFSzvAhoCjFg=; b=i+vm2GwVm0lf2LFRyHMlhIz69i4KihhllyVEEDqkoCnYnVKLYfuPFdnA6nqEup3nh4 i9oSpwwqEqii60myyIao0et8P8OEpK1enY3z6JDuE968xLEdN+EsKqCiMyy1YLi41y+P qLhzByR1pvqCMyyQLp4F9IhurmCqd2oO1mkJCUGsADHAm26NjlrcNKttSP57kpUqJqAY HplINORioaQDcaLxfP1RU4KRNgzoe5Leuvfj27TyqTmuZmCOg3E27IM+C7fWweMU455L ixl2AHyaHr+/8K5gxis+5FYhH08EmQR0TTCoXp4zhPTlnyaQTPAvN8yVIFChc4niVtU6 t/wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226207; x=1693831007; 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=/nrnAaxWix1J4g3gceAU4BOaFuXxsXxWFSzvAhoCjFg=; b=eOqPsFsXNPSG7R+2U4ar2VVJTu4cQJARHWtkCWLaKR7LwXonfWaq2mCp3QXvj+9XE1 ekq8URjjbKf5rxpbTdLy8cwRFzWeIub2EeLh01FzIfmi8BeJmB/z4tertYlsSPJz4v15 HHioQUvGRoeLAU0eBbxBeLm26SnAUAFB0ADmxATDYAae8srwrc4nwdXJB+YLQ2ZYWhcn nGVuUHjlWHNDNYUr8oNJmwc88ZAoZuDUMb2QjPpUnerdxjy7gsfoeWFpWPbL/HKrrQdY daUhf8tygL1T4TK8TKBSYHj+bW9rFSkAV3QQfE7p7zE2vsm2dN6Jh8/DwLnb7lt4DCUG 6APg== X-Gm-Message-State: AOJu0YzSH5BELnNMbpW/li4hwjuK7ecTaALvYiiOmKWwyWr6mI56bzdJ frF52blQGh7gVHoPBRH0RFXVvTEA6A4= X-Received: by 2002:a05:6871:b11:b0:1b0:3cdc:f5f0 with SMTP id fq17-20020a0568710b1100b001b03cdcf5f0mr6059404oab.19.1693226206632; Mon, 28 Aug 2023 05:36:46 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:46 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:34:56 -0300 Message-ID: <20230828123617.57535-5-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/12] fftools/ffmpeg: stop using AVStream.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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: oiUykqJAvBaB Signed-off-by: James Almer --- fftools/ffmpeg_demux.c | 11 +++++++---- fftools/ffmpeg_enc.c | 25 +++++++++++++------------ fftools/ffmpeg_filter.c | 5 ++++- fftools/ffmpeg_mux_init.c | 16 ++++++++-------- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 48edbd7f6b..7c66617126 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -482,8 +482,8 @@ static int input_packet_process(Demuxer *d, DemuxMsg *msg, AVPacket *src) /* add the stream-global side data to the first packet */ if (ds->nb_packets == 1) { - for (int i = 0; i < ist->st->nb_side_data; i++) { - AVPacketSideData *src_sd = &ist->st->side_data[i]; + for (int i = 0; i < ist->st->codecpar->side_data.nb_sd; i++) { + AVPacketSideData *src_sd = ist->st->codecpar->side_data.sd[i]; uint8_t *dst_data; if (src_sd->type == AV_PKT_DATA_DISPLAYMATRIX) @@ -979,6 +979,7 @@ static int add_display_matrix_to_stream(const OptionsContext *o, AVFormatContext *ctx, InputStream *ist) { AVStream *st = ist->st; + AVPacketSideData *sd; double rotation = DBL_MAX; int hflip = -1, vflip = -1; int hflip_set = 0, vflip_set = 0, rotation_set = 0; @@ -995,12 +996,14 @@ static int add_display_matrix_to_stream(const OptionsContext *o, if (!rotation_set && !hflip_set && !vflip_set) return 0; - buf = (int32_t *)av_stream_new_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); - if (!buf) { + sd = av_packet_side_data_set_new(&st->codecpar->side_data, AV_PKT_DATA_DISPLAYMATRIX, + sizeof(int32_t) * 9); + if (!sd) { av_log(ist, AV_LOG_FATAL, "Failed to generate a display matrix!\n"); return AVERROR(ENOMEM); } + buf = (int32_t *)sd->data; av_display_rotation_set(buf, rotation_set ? -(rotation) : -0.0f); diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 96424272bf..852d1f6282 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -428,12 +428,12 @@ int enc_open(OutputStream *ost, AVFrame *frame) for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) { const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i]; - uint8_t *dst_data; + AVPacketSideData *sd_dst; - dst_data = av_stream_new_side_data(ost->st, sd_src->type, sd_src->size); - if (!dst_data) + sd_dst = av_packet_side_data_set_new(&ost->par_in->side_data, sd_src->type, sd_src->size); + if (!sd_dst) return AVERROR(ENOMEM); - memcpy(dst_data, sd_src->data, sd_src->size); + memcpy(sd_dst->data, sd_src->data, sd_src->size); } } @@ -446,15 +446,16 @@ int enc_open(OutputStream *ost, AVFrame *frame) */ if (ist) { int i; - for (i = 0; i < ist->st->nb_side_data; i++) { - AVPacketSideData *sd = &ist->st->side_data[i]; - if (sd->type != AV_PKT_DATA_CPB_PROPERTIES) { - uint8_t *dst = av_stream_new_side_data(ost->st, sd->type, sd->size); - if (!dst) + for (i = 0; i < ist->st->codecpar->side_data.nb_sd; i++) { + AVPacketSideData *sd_src = ist->st->codecpar->side_data.sd[i]; + if (sd_src->type != AV_PKT_DATA_CPB_PROPERTIES) { + AVPacketSideData *sd_dst = av_packet_side_data_set_new(&ost->par_in->side_data, + sd_src->type, sd_src->size); + if (!sd_dst) return AVERROR(ENOMEM); - memcpy(dst, sd->data, sd->size); - if (ist->autorotate && sd->type == AV_PKT_DATA_DISPLAYMATRIX) - av_display_rotation_set((int32_t *)dst, 0); + memcpy(sd_dst->data, sd_src->data, sd_src->size); + if (ist->autorotate && sd_src->type == AV_PKT_DATA_DISPLAYMATRIX) + av_display_rotation_set((int32_t *)sd_dst->data, 0); } } } diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 925b5116cc..943e6bb713 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1383,11 +1383,14 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, // TODO: insert hwaccel enabled filters like transpose_vaapi into the graph if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { + AVPacketSideData *sd = NULL; int32_t *displaymatrix = ifp->displaymatrix; double theta; if (!ifp->displaymatrix_present) - displaymatrix = (int32_t *)av_stream_get_side_data(ist->st, AV_PKT_DATA_DISPLAYMATRIX, NULL); + sd = av_packet_side_data_set_get(&ist->st->codecpar->side_data, AV_PKT_DATA_DISPLAYMATRIX); + if (sd) + displaymatrix = (int32_t *)sd->data; theta = get_rotation(displaymatrix); if (fabs(theta - 90) < 1.0) { diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 0289cdabad..238273fc57 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1041,24 +1041,24 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost) } } - for (int i = 0; i < ist->st->nb_side_data; i++) { - const AVPacketSideData *sd_src = &ist->st->side_data[i]; - uint8_t *dst_data; + for (int i = 0; i < ist->st->codecpar->side_data.nb_sd; i++) { + const AVPacketSideData *sd_src = ist->st->codecpar->side_data.sd[i]; + AVPacketSideData *sd_dst; - dst_data = av_stream_new_side_data(ost->st, sd_src->type, sd_src->size); - if (!dst_data) { + sd_dst = av_packet_side_data_set_new(&ost->st->codecpar->side_data, sd_src->type, sd_src->size); + if (!sd_dst) { ret = AVERROR(ENOMEM); goto fail; } - memcpy(dst_data, sd_src->data, sd_src->size); + memcpy(sd_dst->data, sd_src->data, sd_src->size); } #if FFMPEG_ROTATION_METADATA if (ost->rotate_overridden) { - uint8_t *sd = av_stream_new_side_data(ost->st, AV_PKT_DATA_DISPLAYMATRIX, + AVPacketSideData *sd = av_packet_side_data_set_new(&ost->st->codecpar->side_data, AV_PKT_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); if (sd) - av_display_rotation_set((int32_t *)sd, -ost->rotate_override_value); + av_display_rotation_set((int32_t *)sd->data, -ost->rotate_override_value); } #endif From patchwork Mon Aug 28 12:34:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43371 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp114113pzf; Mon, 28 Aug 2023 05:37:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkeT3VFPTFF6jJsRm3vO9kKejdNoJ/D+aUP59hZ3ZygPCmK0iaYlGwhjf2re/tpfSCWCOU X-Received: by 2002:aa7:c38e:0:b0:523:1095:6980 with SMTP id k14-20020aa7c38e000000b0052310956980mr19655931edq.20.1693226267287; Mon, 28 Aug 2023 05:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226267; cv=none; d=google.com; s=arc-20160816; b=AKcQv59VxkYk9lB/CgoYEHYa86zt4QLLSMupoHcrfsg/+WTKKfZNttIaSnGCToFJwV UjiQb57np6+lOsuD4mbXcxYCzXMvt78DoeaHv2/VJYvQRs/LJNx5DZpZQr2MQnm3Uxwg iaaNzv/+OcSqe+yHynEnpq4aeToHspLOP7j6TI7LGeY3UdZoNOC6NuS6+AbQmI6gbHNA G9Jg3XoSNEU6d1FP0HPHBWdd740kUooQVxlRTvOsTrRzvhmRhcdHjFGQbeZT2QSnyXVb LbaAZYyHBRsKFjtPZcBCZUB/3iU/SvSRhUs4xnkGC6zpXrWs7wpr07uPcL6yfjsJroO/ +QvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=V2U2Z38caoBoP6pd4f2HUi551iExcFpNyuE4Jr2/Ku8=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Lpk9YR5mCoX2mfXefg38gNugexlPOy9v4YVl3SWGmEXf1hPG75gBRWWneXpvSFhffO vMT265fKExL5bzhSjIBZl7TpusB8fVuURx3Iwd6T781coeGwC3VL+a9BL0NaG3xyMyEA uVTC1AgB093pEHUyVicFZ8XMyz/IOoSjAiT73uqJgF4U+ofdYT+xSzJ4fhnY4f5C6oyT MKniv2dfNgjvjnH8HE1U/y9O9I4xETUf3bijcEL3f4xL7qOaNJ/fObJePXTvFaVWXOhR F6Di8y7cQc9UqULPzB/38hJz961xNThEH5hww97G5BPvlkoW2uoEF/vUEUYPl3KMwmdb EZfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=Nz83WvkW; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j10-20020aa7ca4a000000b005256721cda6si4469161edt.509.2023.08.28.05.37.45; Mon, 28 Aug 2023 05:37:47 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=Nz83WvkW; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EF9C368C67A; Mon, 28 Aug 2023 15:36:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A965168C62F for ; Mon, 28 Aug 2023 15:36:49 +0300 (EEST) Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6bca3588edbso2126630a34.0 for ; Mon, 28 Aug 2023 05:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226208; x=1693831008; 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=7GBv9A+jvHIbKq/ntXlKNCI1GJTEuxtIBZE1IQihxpo=; b=Nz83WvkWpSHVq2oFgSBrc2X+/YW9NtbqJcaF+RkMOEz6cCv+lQtJBWENhaP1VYESR4 9CoOZD9ZyOYQww7eirelOxNPazjSa5WdLUSxPk2aAzvHnROoJD6tn0hrHU+fm2kNFXe4 DNUp04qguoEeikov6RHFMHKSR8UeweZEmE24c2i8Wxp3w3KLHYdf8ZqwWpiuJIbOgtl7 B9M73jPpwmy7exnO+clVNTiNPTPq9zs9KFUTkZzk1DLZD4ns93x++x6DxaarkjwmP5CF 5kcBQnZbqqmHN8IuBwfYVTVg46L64lMYF74j5prA8/E/GP0a/SM29ZKOmc2yaNxqY3PY xcyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226208; x=1693831008; 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=7GBv9A+jvHIbKq/ntXlKNCI1GJTEuxtIBZE1IQihxpo=; b=k4T5N3IG1vkO1TebVbc80cgElRnE2QjdebxAKOUfHQeVXXWFfpG5hy1iuEop4ANwGd RTzysw5Ugf0Ji36iKf1Tgg7t7b6uSyEShApaFipUxUrvsfCRLAhiF8y6iqNemZNXM8E7 +/GQBG9xs8H3iJySHeGa0a6A1cmnoqT9049IExP90rgi+tcfNM1JG65NNWhXMM6IdBNL c8rltyoJTMhogzEHwZ1Bss+SGy00CxuugisL5xLLfj7mBRZcMGB0GDSx2lmr7KPDEzOd JnaQ3yTww8CcEhtr4tkZdDAMiSWfOxmWJwVwL9q3ueZJezSY0tyazWc8iJ0Ny/EZMwfo yWFg== X-Gm-Message-State: AOJu0Yzy5ubPc+ER4X4M/OVCzOS4Oe4dlKTM6zQQz4Zk9kRlW6dqs5tN UdwGjjlkFdXirA0tZrmAR/CJ0NOMQzo= X-Received: by 2002:a9d:69d3:0:b0:6bf:17d3:4268 with SMTP id v19-20020a9d69d3000000b006bf17d34268mr2325612oto.25.1693226207920; Mon, 28 Aug 2023 05:36:47 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:47 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:34:57 -0300 Message-ID: <20230828123617.57535-6-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/12] fftools/ffplay: stop using AVStream.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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 7KgC4lVryh9e Signed-off-by: James Almer --- fftools/ffplay.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 5212ad053e..299d7b16d9 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -1904,8 +1904,12 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX); if (sd) displaymatrix = (int32_t *)sd->data; - if (!displaymatrix) - displaymatrix = (int32_t *)av_stream_get_side_data(is->video_st, AV_PKT_DATA_DISPLAYMATRIX, NULL); + if (!displaymatrix) { + AVPacketSideData *sd = av_packet_side_data_set_get(&is->video_st->codecpar->side_data, + AV_PKT_DATA_DISPLAYMATRIX); + if (sd) + displaymatrix = (int32_t *)sd->data; + } theta = get_rotation(displaymatrix); if (fabs(theta - 90) < 1.0) { From patchwork Mon Aug 28 12:34:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43372 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp114181pzf; Mon, 28 Aug 2023 05:37:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOrhP03s7ivoD1S6b6/Ran8grFzQrcwFUvNpUcyR0LgXyYYnKIbF/ZKwXiWyvJgOU/MYaw X-Received: by 2002:a05:6402:12cb:b0:528:89d0:90b7 with SMTP id k11-20020a05640212cb00b0052889d090b7mr21416488edx.16.1693226274677; Mon, 28 Aug 2023 05:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226274; cv=none; d=google.com; s=arc-20160816; b=oXrdGpVfGPakCcKW7WwABJ/5ykWd65+6eM+f5sJxglun0YNW1oY5xoNB4E5gwxNC4y M+tsBVeLuN+icFBNBEuAfhFbaxZiBaXqZc720tWFRjOuVqHmYWh8e9ZiR/41Gwn7DqIz aWX+X0IYMKlg5ZCywVhUwevXZssQOrg4zCd4mq1ov4THgQrk91cohz4ZCqCHS+tTqOq+ tuJjYE5nMbwEW+oFcSX8XB3guz4GI0sFVNDQowaSxXSxG8FFkBXVG2lJwY8TBrBvTVNr Kb5ctzU+K03s0euJmBzwtyl/qdrVeoHQI3HZsZG1ltWmZbPqMIbrmGlVFUXnf1Us1wR/ riHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=OUhApItFynFxlvtaNOT9xaUrvg+h+BE5a1wRXcuvDIs=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=NIi1/ILqHrp00cSLiscGmbm1qLsy3CgzfOnL8U6iI02T8rC2KAYTGkZVAOOXdMkjTk 6rjDdS/yTnSvlh7ZA8bNn4zM6MqQ1Qin3ODMKQTZ84Rg2KxRQozDD5saQhso7/baOmYO u0MHSc5qWadk5a7PeSGjqO/xgN1yKpAJUisKxR53T0TCwFpR5aUNxa6K24QYi+U8UMdt 70CHoiTnsKe9PwzyGcX/8S8EMS/qh4VSRPiEU6ZSlXGILSHW6k263J1VQY4YWTTY9iKD y6wjgIA0GJQS3Ec6U4GjsNDWfJ5ezp8jgm5fh4x+9R5Kx2DwnV1DzmxZaR0ncUPUgrtQ +eXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=sI5iLNBc; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bo13-20020a0564020b2d00b0052596c88933si2380563edb.129.2023.08.28.05.37.54; Mon, 28 Aug 2023 05:37:54 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=sI5iLNBc; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 15E2068C6AE; Mon, 28 Aug 2023 15:36:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0DF5068C680 for ; Mon, 28 Aug 2023 15:36:51 +0300 (EEST) Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-6bca5d6dcedso2489840a34.1 for ; Mon, 28 Aug 2023 05:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226209; x=1693831009; 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=K2arKltEJcJXOJeGD93nLfC8jaH9HdmIjnYIfZ2doEU=; b=sI5iLNBcqeVvFt+BqKIKtMDMxsD/GFmREavtzmxKEgIvSLUUSXqNOqP/hVU+d+lF43 8O7YsmIHM3fI7h6brahrfcU578JnzT3dx1RUAzA4goiGrOVNz8T4XvoM1NyL9pNRhTHU CCDqOhGcuutdb6N1yZy0DiZN+oV7KPjKfOPcZAn1EvKnKYFXh4X/4Z6yWOyGqwF08SHZ OosFRt0Az7QgnsNSzOpvZaJFI6CMzFJi3J+2KAjSEZP6fTO7i49tAV+1t35hNEthmGQd 5FA2ihXpBCxTL7mWkpZUxlaiT001bdZySTx7yrKpolkj0GwNxs+7tniPUOKr953HLpAH rpyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226209; x=1693831009; 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=K2arKltEJcJXOJeGD93nLfC8jaH9HdmIjnYIfZ2doEU=; b=kkxggOvxMNLSH69tGAneJv0k55NxvCqZAoUp5s1+Ds0IBBKUhfhmx9GXgQ25QuQEGD y9/8zhtC6sU3e9WHTXkgVreWBWKWg/a4y4ZlNF9L6xTFlrXGCbcEeetIH7Y4jh49xWko L/zGgYVEOy67b7xj2RzwyTaLGdxoveLOmrPIzdDartvOnI+OW5OmNTsPw9d5WgiYqAr5 jj2aQCzEotLFbO+efqjxMq6suLgmaZirZ47JE88dvwExkzxBEP5iGzpTTHsvB+OcgRtR dXx1j/xyAv8D/Dj/PHyBXTwrZjPOMDAQr7tB378SARXr7UgpB8yHEOppwXCJzxT7KANF X02A== X-Gm-Message-State: AOJu0YwaR7m/CVO1NCgYTxOY9lJsO9Pj594H8x6K3eMz4KDBbO5/Ul4q pntFc+Y1F7pdIOBpeBaQCmaqMNRdGZg= X-Received: by 2002:a9d:73cc:0:b0:6b9:1917:b2f3 with SMTP id m12-20020a9d73cc000000b006b91917b2f3mr14285405otk.33.1693226209328; Mon, 28 Aug 2023 05:36:49 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:48 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:34:58 -0300 Message-ID: <20230828123617.57535-7-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/12] fftools/ffprobe: stop using AVStream.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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Z9QbokcOkBVt Signed-off-by: James Almer --- fftools/ffprobe.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 4fcfe1164b..28ccb45b26 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2279,16 +2279,9 @@ static void print_ambient_viewing_environment(WriterContext *w, static void print_pkt_side_data(WriterContext *w, AVCodecParameters *par, - const AVPacketSideData *side_data, - int nb_side_data, - SectionID id_data_list, + const AVPacketSideData *sd, SectionID id_data) { - int i; - - writer_print_section_header(w, id_data_list); - for (i = 0; i < nb_side_data; i++) { - const AVPacketSideData *sd = &side_data[i]; const char *name = av_packet_side_data_name(sd->type); writer_print_section_header(w, id_data); @@ -2382,9 +2375,6 @@ static void print_pkt_side_data(WriterContext *w, } else if (sd->type == AV_PKT_DATA_AFD && sd->size > 0) { print_int("active_format", *sd->data); } - writer_print_section_footer(w); - } - writer_print_section_footer(w); } static void print_private_data(WriterContext *w, void *priv_data) @@ -2544,9 +2534,13 @@ static void show_packet(WriterContext *w, InputFile *ifile, AVPacket *pkt, int p av_dict_free(&dict); } - print_pkt_side_data(w, st->codecpar, pkt->side_data, pkt->side_data_elems, - SECTION_ID_PACKET_SIDE_DATA_LIST, + writer_print_section_header(w, SECTION_ID_PACKET_SIDE_DATA_LIST); + for (int i = 0; i < pkt->side_data_elems; i++) { + print_pkt_side_data(w, st->codecpar, &pkt->side_data[i], SECTION_ID_PACKET_SIDE_DATA); + writer_print_section_footer(w); + } + writer_print_section_footer(w); } writer_print_section_footer(w); @@ -3188,10 +3182,14 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id if (do_show_stream_tags) ret = show_tags(w, stream->metadata, in_program ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS); - if (stream->nb_side_data) { - print_pkt_side_data(w, stream->codecpar, stream->side_data, stream->nb_side_data, - SECTION_ID_STREAM_SIDE_DATA_LIST, + if (stream->codecpar->side_data.nb_sd) { + writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA_LIST); + for (int i = 0; i < stream->codecpar->side_data.nb_sd; i++) { + print_pkt_side_data(w, stream->codecpar, stream->codecpar->side_data.sd[i], SECTION_ID_STREAM_SIDE_DATA); + writer_print_section_footer(w); + } + writer_print_section_footer(w); } writer_print_section_footer(w); From patchwork Mon Aug 28 12:34:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43375 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp114404pzf; Mon, 28 Aug 2023 05:38:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFx734/h66kYdF+yIlSVpT/+uWD9pHZSaL85bDPlLc7zErk9afzWvlY0Irv/WHZlY+x2+6G X-Received: by 2002:ac2:4c82:0:b0:4fb:7675:1ff9 with SMTP id d2-20020ac24c82000000b004fb76751ff9mr14892241lfl.9.1693226302410; Mon, 28 Aug 2023 05:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226302; cv=none; d=google.com; s=arc-20160816; b=rKaCJ2F5jjbdy6zhvYhDPWNwYfjHd9FcH2qsFdx09KUCfR5Mn/iU6GV1xn6wu11guP gkHKZU5hBmgzidTgULcHsQYz72H8LlzQxShjRfrWeJ9Oqw5y+UJQRILo/c5a5R6qvJY5 4eH/SvJiS4ubvjEqrECrH2ES+fdI1lcPEi17oudzKX/CERkK120a6i0HPpR8oaMndPCW yb28Ei/r2LiyN/MyzuulhPkDIXjNA9vtiWvNe5RDjGgOFOAOe2+ilcpWM/SJh0KGWIf4 Dp6LAK0In8hnZtO8fgOctasn/J4aysJsZNDfct5wISEENXzKvTspnuC5PF048L2TXdtY vSQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=RKMkOyQphOO7U0SLSwECEK/7QRPG0IMvzh5gE6uU7zk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=FVluDAjh+xiH7BEofVUcypvtthD77XoA+mwy1pTpVT1f5sb0wXFj1yualh6tbSDg6Z zKfVSn7U3Wqktohmw1qmt0wT4ZAuKcdITuklMLrBOTwR7s935KZ/6HwxH5PYT/SVRd3P jUyiDakePraj0cvub3ZDRaJtJVqD+ehK7XODmeVxw4Smy+QmdT2LuUJTEdvD4/bbNrFq aRmOlQeUMS9EOZnB5eYFk51xoTGvbdqhlVyifqv2ObuoS4wepC2xras7cPwpFFVxJNLy E4e4/AqKZ8uLPrTjH+VqfPzOKtI5OysCfx7SvoSh93iq194wUOpGehqTF9tPpRG/W7oC u70g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=XRo6g0YU; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d24-20020aa7d698000000b0052a4165d083si4361922edr.463.2023.08.28.05.38.20; Mon, 28 Aug 2023 05:38:22 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=XRo6g0YU; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 089EE68C6E8; Mon, 28 Aug 2023 15:37:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2A9A068C643 for ; Mon, 28 Aug 2023 15:36:52 +0300 (EEST) Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-6beff322a97so1382521a34.3 for ; Mon, 28 Aug 2023 05:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226210; x=1693831010; 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=k0LD2GDbkXxsBRvvDORBcnHK+fIrlL6wWzdtPYqlMtA=; b=XRo6g0YUZ+9kHKgdZsSNvhwdueL1ZJU5e8GXn1y9V0ZNcJijQQM706OcyPB3IzDHx7 /dQZPhUh7lUN6tARGLXz7Uvk0yERXzRu1S8SwsZerwaZZxapMztvQTuyYuphbMfPPt85 2+qZ+EdJqbOY/CCQfrPBM1ha8VSXxeZt2yfHxXZkhLi2sHNdcR9nnbiLLu99R5TvhQSL fjxh9kDtnHhpIpAVbsam1nx4XvLEXoiENXGCxIB5z6Y/kV4TdE8s4DOFL1I9NPitYBeB JxjdxHldFynbuxoOCVMxF3615KK1VwxTV8KWeEFwas0VYbQWrTD01h27sCJ48N3NPaoy mA3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226210; x=1693831010; 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=k0LD2GDbkXxsBRvvDORBcnHK+fIrlL6wWzdtPYqlMtA=; b=PjCQQZ69zZyaNMWer+i9Cmmg+eCimjOHh9umyrn1PV5GHBn9b+fV2gCOTl+EboS83B hpZcRpmh3B88eGf1AwaNI03lpHdurJiOIkLgrFHMOx1WtpqUSj8vhg9z1/cp6MYeJtD0 6rik6x8/hxU3QubkFi/f7FwrYCBeklKLZoFy8tZfalAypFh71oZqUROx3rHjrnqCBmgM ShOscOe9AQuLjs8K22ocjenSh7RTYHHbNFEyMThwc7bng78mxpEa7L8ZpXouvP4019n+ biEBcK/mprhzQclkJDhfVw/SJ+KvRgEipuc1D9tW7WS1O8XFY+ffZ4/VDkWE4LioI0oD YpqA== X-Gm-Message-State: AOJu0Yy9SCGbcpWWWtPCv0PU+RwWeiLqSL4JPiMkkkT2ifpTF+8cl60s DC4XzCCrOP5oWiF9YDNJSAacaRgcM+0= X-Received: by 2002:a9d:6f01:0:b0:6b9:1af7:48c5 with SMTP id n1-20020a9d6f01000000b006b91af748c5mr13040962otq.9.1693226210535; Mon, 28 Aug 2023 05:36:50 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:50 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:34:59 -0300 Message-ID: <20230828123617.57535-8-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/12] avcodec/hevcdec: check for DOVI configuration record in AVCodecContext 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: s/queJ1CjTfh Signed-off-by: James Almer --- libavcodec/hevcdec.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index df40c91ba6..dabfe89d4a 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -3337,8 +3337,15 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe, } sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_DOVI_CONF, &sd_size); - if (sd && sd_size > 0) + if (sd && sd_size > 0) { + int old = s->dovi_ctx.dv_profile; + ff_dovi_update_cfg(&s->dovi_ctx, (AVDOVIDecoderConfigurationRecord *) sd); + if (old) + av_log(avctx, AV_LOG_DEBUG, + "New DOVI configuration record from input packet (profile %d -> %u).\n", + old, s->dovi_ctx.dv_profile); + } s->ref = NULL; ret = decode_nal_units(s, avpkt->data, avpkt->size); @@ -3641,12 +3648,18 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx) atomic_init(&s->wpp_err, 0); if (!avctx->internal->is_copy) { + AVPacketSideData *sd; + if (avctx->extradata_size > 0 && avctx->extradata) { ret = hevc_decode_extradata(s, avctx->extradata, avctx->extradata_size, 1); if (ret < 0) { return ret; } } + + sd = av_packet_side_data_set_get(&avctx->packet_side_data, AV_PKT_DATA_DOVI_CONF); + if (sd && sd->size > 0) + ff_dovi_update_cfg(&s->dovi_ctx, (AVDOVIDecoderConfigurationRecord *) sd->data); } return 0; From patchwork Mon Aug 28 12:35:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43377 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp114530pzf; Mon, 28 Aug 2023 05:38:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDx5abHvjFAL2YT+8c7v0+Cxy3z+BMd+Y0C8sMsHjlWbDcpR4ot3aK3BjuVdsDDR2ne+Ut X-Received: by 2002:a17:906:209e:b0:99d:dd43:d427 with SMTP id 30-20020a170906209e00b0099ddd43d427mr21402970ejq.10.1693226318472; Mon, 28 Aug 2023 05:38:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226318; cv=none; d=google.com; s=arc-20160816; b=0u69aLYKIMLEcyw40OHwglBUpWWl4RvhF4qpUfQDmhZdFCuHq+lEpGIqqeGxu3wgbP OLjlMs+VUA9ROOGCMY8zvFTxbCPo38gFoyFa1L6Losc8H02YIrmLXag6k+nSkgqyvcYC K7TRu4sKsYd2SqAXP0ndlDQ/0hLusNWKA5O3ok70M7E11vx9Qay/ORj1500S3awy9DOH rYxXPBe7KzYUx0LTFmLvOAyDG6EjNlRwb1jQ1teVdLbMc7zxL5TnP3MYcpxOtV4naEKI iTPXoBMhGDTJaFPf+zHl7vU+vVQIr1Ra7VPbDtACU+Cjbh51UoUvkoaYIxHRtCRhCNTb Px1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=6x3MQpL9Guoz5ERTV61fAyCVJyOxQa4MnInYVUdTO7k=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=gDwQEpDF/OyVa73V3lTjQlFDoSMNPkZcDhnfs4iOElgxFMuky+hYbuKR4eHJacuvd6 wqMmfcUYCUcaT8iVICC8ztkBzZP1qb/nwmE65uZTfTP/LHxkw/h1d3eWBaH/uJFCghMW 8Qr/UBF5nM5AnbCstVjEWJgqcemVVHzyu8UxtUzuaIDVezT9Qu76ijOps4Y7qG4OIg1R HQap7QweIsCwJAEPozONwjpzuSDVimWOtf112rjXXQJnMzZaNmQ/R4vFOIXVpe07FUx+ hFNKyzZrwfmPXlnge1C6+VS4taXxVzQi6hRvegZOqo7wJ1nXyF4ET7poZK9Dmk0EYpDH 9aag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=AKoqpCcX; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o23-20020a17090637d700b0099cd371dd90si4182733ejc.928.2023.08.28.05.38.38; Mon, 28 Aug 2023 05:38:38 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=AKoqpCcX; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D514968C6C5; Mon, 28 Aug 2023 15:37:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C24268C6B4 for ; Mon, 28 Aug 2023 15:36:53 +0300 (EEST) Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6bca857accbso2489426a34.0 for ; Mon, 28 Aug 2023 05:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226212; x=1693831012; 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=F/7ci8ywX+qHCPghN1OkTa909lwwP1+fjlT474xwMSw=; b=AKoqpCcXVeU5x+tvnFIbGdls9puav33/JzhLq8s4JZNlCGLmeDJjeSnli8DZsIhNEq IR9BnyoR8DIDG1yRF1wU1HcaTUb5JMUYfLchiSlF4WsH35R0cJxfDPNnf9SH+ejGnWfG 1j5VZ8gu4XPNLsnmwibA42V7pwrsphYvHxvA8oC4mS91iLmI3OmAwsdq7iUUq9zMVnGN hwiVxCnpXKP9QB9CMR+ndkdojGBfCJ6+UIcWRiYMtWoqzEyKVRc3j63wUvJIOPSSWXtg W33HzxveNajZ0gvVIESUsedjpyapF65bs1CFAgHn2sKehx6ILD7BxTwepp9Mx/WOP0Y8 xjiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226212; x=1693831012; 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=F/7ci8ywX+qHCPghN1OkTa909lwwP1+fjlT474xwMSw=; b=cSMO1obUfisVOqhVfdoX3JXrPftgDggAnNUn64Va1uAcyXM4w0yT223h3P81LfUAuE 78F8lPqAB3mReXAzVjLkeG6+k+9fd74U4EN/okztxQLkds0diuO6RcscacjIgYNomIt3 KWS7IJgEkZWQozZ/ymUkzQcYT1dMscsd79SLxoTdaonP66J+B4kkratgRv48q8phsP5V lv+a72zopmOOZyPHor6dZS5aRXzx70OXM0g/3fDMF8faDQr/AzeCe893gob1SO3JfXre JjV6Fn0uDYPD6HYDLhyoO4S8JjZyowVywWaPUGOWUUgQ3W/NgivSm7ozfIelTa7JGvcm IDZg== X-Gm-Message-State: AOJu0YwnpmzDrJ1BCaH1gJxa+n36ge7IQp3hklbLtcKjxY0WG8zXjcSp LSiawjLSmKK/jqeBE3VDNnlBvKmjjYw= X-Received: by 2002:a9d:68d1:0:b0:6bf:3f4:3edc with SMTP id i17-20020a9d68d1000000b006bf03f43edcmr6454292oto.22.1693226211782; Mon, 28 Aug 2023 05:36:51 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:51 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:35:00 -0300 Message-ID: <20230828123617.57535-9-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/12] avcodec/decode: check for global side data in AVCodecContext 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YgM1baqRBWGy Signed-off-by: James Almer --- libavcodec/decode.c | 56 +++++++++++++++++++++++++++++++++++++-------- libavcodec/decode.h | 2 +- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 7eada8e9ab..4b8c1bc74d 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1408,25 +1408,30 @@ static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame) return av_packet_unpack_dictionary(side_metadata, size, frame_md); } -int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx, +static const struct { + enum AVPacketSideDataType packet; + enum AVFrameSideDataType frame; +} sd_global_map[] = { + { AV_PKT_DATA_REPLAYGAIN , AV_FRAME_DATA_REPLAYGAIN }, + { AV_PKT_DATA_SPHERICAL, AV_FRAME_DATA_SPHERICAL }, + { AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D }, + { AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE }, + { AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA }, + { AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL }, + { AV_PKT_DATA_ICC_PROFILE, AV_FRAME_DATA_ICC_PROFILE }, + { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS }, +}; + +int ff_decode_frame_props_from_pkt(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt) { static const struct { enum AVPacketSideDataType packet; enum AVFrameSideDataType frame; } sd[] = { - { AV_PKT_DATA_REPLAYGAIN , AV_FRAME_DATA_REPLAYGAIN }, - { AV_PKT_DATA_DISPLAYMATRIX, AV_FRAME_DATA_DISPLAYMATRIX }, - { AV_PKT_DATA_SPHERICAL, AV_FRAME_DATA_SPHERICAL }, - { AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D }, - { AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE }, - { AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA }, - { AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL }, { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC }, { AV_PKT_DATA_AFD, AV_FRAME_DATA_AFD }, - { AV_PKT_DATA_ICC_PROFILE, AV_FRAME_DATA_ICC_PROFILE }, { AV_PKT_DATA_S12M_TIMECODE, AV_FRAME_DATA_S12M_TIMECODE }, - { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS }, { AV_PKT_DATA_SKIP_SAMPLES, AV_FRAME_DATA_SKIP_SAMPLES }, }; @@ -1439,6 +1444,23 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif + for (int i = 0; i < FF_ARRAY_ELEMS(sd_global_map); i++) { + size_t size; + uint8_t *packet_sd = av_packet_get_side_data(pkt, sd_global_map[i].packet, &size); + if (packet_sd) { + AVFrameSideData *frame_sd; + + av_log(avctx, AV_LOG_DEBUG, + "Overwriting global side data of type \"%s\" in output frame with side data " + "from input packet.\n", av_packet_side_data_name(sd_global_map[i].packet)); + + av_frame_remove_side_data(frame, sd_global_map[i].frame); + frame_sd = av_frame_new_side_data(frame, sd_global_map[i].frame, size); + if (!frame_sd) + return AVERROR(ENOMEM); + memcpy(frame_sd->data, packet_sd, size); + } + } for (int i = 0; i < FF_ARRAY_ELEMS(sd); i++) { size_t size; uint8_t *packet_sd = av_packet_get_side_data(pkt, sd[i].packet, &size); @@ -1475,6 +1497,20 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) const AVPacket *pkt = avctx->internal->last_pkt_props; int ret; + for (int i = 0; i < FF_ARRAY_ELEMS(sd_global_map); i++) { + AVPacketSideData *packet_sd = av_packet_side_data_set_get(&avctx->packet_side_data, + sd_global_map[i].packet); + if (packet_sd) { + AVFrameSideData *frame_sd = av_frame_new_side_data(frame, + sd_global_map[i].frame, + packet_sd->size); + if (!frame_sd) + return AVERROR(ENOMEM); + + memcpy(frame_sd->data, packet_sd->data, packet_sd->size); + } + } + if (!(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { ret = ff_decode_frame_props_from_pkt(avctx, frame, pkt); if (ret < 0) diff --git a/libavcodec/decode.h b/libavcodec/decode.h index a52152e4a7..52e5aafc34 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -67,7 +67,7 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt); /** * Set various frame properties from the provided packet. */ -int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx, +int ff_decode_frame_props_from_pkt(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt); /** From patchwork Mon Aug 28 12:35:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43374 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp114383pzf; Mon, 28 Aug 2023 05:38:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8Z4QItdupCRknANLaoaqA2DXMwpiPZtCBJFvvrgYaKFlwB3AkArtFj41gJ1VIKHo+Ru5q X-Received: by 2002:a05:6402:1610:b0:525:469a:fc38 with SMTP id f16-20020a056402161000b00525469afc38mr19241873edv.31.1693226300096; Mon, 28 Aug 2023 05:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226300; cv=none; d=google.com; s=arc-20160816; b=JTLvo1BXKh1LFhIRbidHRa96cSh3taTm1pQmcDrGbwH5maBIJhm3eX2VTPn2loQAJz P20GME7XSikFZtiGgHXqMuC6wIA029E4OwHdVwULkKkhYnPSudMWOjgy51RjXzNk1WO+ fdq7zcVUadi3ShFWtjg4sZuPDmj83q4PrDye9rWMpVwHdyQPeOAF+0C3+n7hCC8VF5hr 8CddzAGZemFA1ZBRrATeNri6r2mJY7EIJI+mUC1qZzhr6l42I+JsystSLJ2j+1gkcKMw emCOlbxtAdRkGYjqo722AABSIFQSErOiaQCIiXsXOwug4UIZ/PETjgOy+RJi6pyZXmtf gJ+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=1mRfbQxmnuOBgvgfeo+Z0P6Lg8BCZrsv8uSYD8kNCjQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=gelYrMOPu1UX8z7nuUtBApbe1p/IUv5Q4SyWsBipxPgT18zyV4sksuq74JdYABgXoi de+QLpxYSuiIdy+jF7CzqIz1d+P1qv7Af7C/+iJG0zcv96I9CoipW69+x8KMCbSLUd5J eR1fBOFA5JqQD815+5P6abRARlayZLh1UavveOanjLpIoTD7ruOBMrTxhFb1+vwhY7j+ tdXDy6tjb0vsWNLzvBr6UPRz6fM7RsvyG6C4S4AntqIHGor67nulOUbe83tcMmxXQAbK OW3yj31uoLGtSb2OTtMAlceZyghmPbEwBK+smkH5yoonaFdW+3kEK1ZiiiKOzPijR33P /73A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=IFoGXBdw; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u13-20020aa7d98d000000b005234b452a4fsi4426853eds.68.2023.08.28.05.38.11; Mon, 28 Aug 2023 05:38:20 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=IFoGXBdw; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 19FD568C6D1; Mon, 28 Aug 2023 15:37:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 706F368C687 for ; Mon, 28 Aug 2023 15:36:56 +0300 (EEST) Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-1c8e9d75ce1so1766539fac.3 for ; Mon, 28 Aug 2023 05:36:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226213; x=1693831013; 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=vlgw3U3+j+NXfo8YZ6gma2AXIXPQpoyNN1jrh7wr+RQ=; b=IFoGXBdwlFvKCFuzejvItIyq3sEj+xxn0D30/PDNdNKEmjlDG+Woll3rU6AAfHp7fS 4izC0Oeu7qjta7q4LeXEdYFxEXz3AFzaQmgoCDyCgTIpEC5294NlNENgdDeEd89WKr4r 57c0UtDh1L4vItV7lZ3CEKqis0pb4qK6+GhNyQDwcYa2J6YEe3zOEiVevY1EosW7sO8f TBiU/znBrYj6LE4Nazt9S/kY4YtDv+sdsSHJP7oMx7lnaLZtsEPLB5pWFAfp9iNjEc3G agRSCm9eNNaeVBKjEemEkJJEiW0Ca97TcBICvlhGN3X5MYpDA1wDXg8wbFjxBenh9f7w 1oGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226213; x=1693831013; 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=vlgw3U3+j+NXfo8YZ6gma2AXIXPQpoyNN1jrh7wr+RQ=; b=Nr/ISinIPX39cvjaY54P1shkK4Ml42ZORbxL1eWDDCKSDg39GmvrLTWNk7hz6dGWq1 yeY1gXi3ysLzKuxe4JyOqnSFtMeXRP2RmYnqKiAhKuelcOW+Fe6qRgR3YVfk8T/9Ul4i hxZ938rUgmr2BG6NtSD5BDcsdwAL5Nh5JAU3Ec2TEWoQazdHm8YCS00q8ptoSTgc47J5 FK0tXvZokVPGJ/uS0W+FMNqf58wrMq4eQwmmupUXDg+PgYcG3CovbVSHvaRPtng/chzk kwhNK5TvkckBUPsIdCJ1PLlCgl7y5zRmY5uEFy8MdFkGieF2ZeHQ66IO0scaZ8YKwJ6j D43A== X-Gm-Message-State: AOJu0YwwP7MbWdIMpIxniG7OoO4sQ0mD8W8oWQGjNAhAA46Kx2+UTBQE uRsiH4rn4YhMqI0zEwQf5phOXY4wLIw= X-Received: by 2002:a05:6870:2185:b0:1bb:9fd0:6b7f with SMTP id l5-20020a056870218500b001bb9fd06b7fmr10940912oae.11.1693226213075; Mon, 28 Aug 2023 05:36:53 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:52 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:35:01 -0300 Message-ID: <20230828123617.57535-10-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/12] fftools/ffmpeg: stop injecting stream side data in packets 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /kIxzc9oa3cd This is no longer needed as the side data is available for decoders in the AVCodecContext. The tests affected reflect the removal of useless CPB and Stereo 3D side data in packets. Signed-off-by: James Almer --- fftools/ffmpeg_demux.c | 22 ------------------- tests/ref/fate/autorotate | 4 ++-- tests/ref/fate/copy-trac3074 | 2 +- tests/ref/fate/matroska-avoid-negative-ts | 2 +- tests/ref/fate/matroska-dovi-write-config7 | 2 +- tests/ref/fate/matroska-dovi-write-config8 | 2 +- tests/ref/fate/matroska-encoding-delay | 2 +- .../fate/matroska-mastering-display-metadata | 4 ++-- tests/ref/fate/matroska-spherical-mono-remux | 4 ++-- tests/ref/fate/matroska-stereo_mode | 8 +++---- tests/ref/fate/matroska-vp8-alpha-remux | 2 +- .../ref/fate/mov-mp4-disposition-mpegts-remux | 4 ++-- tests/ref/fate/mxf-d10-user-comments | 2 +- tests/ref/fate/mxf-remux-applehdr10 | 2 +- tests/ref/fate/vp9-superframe-bsf | 2 +- 15 files changed, 21 insertions(+), 43 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 7c66617126..f545e8b499 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -480,28 +480,6 @@ static int input_packet_process(Demuxer *d, DemuxMsg *msg, AVPacket *src) ds->data_size += pkt->size; ds->nb_packets++; - /* add the stream-global side data to the first packet */ - if (ds->nb_packets == 1) { - for (int i = 0; i < ist->st->codecpar->side_data.nb_sd; i++) { - AVPacketSideData *src_sd = ist->st->codecpar->side_data.sd[i]; - uint8_t *dst_data; - - if (src_sd->type == AV_PKT_DATA_DISPLAYMATRIX) - continue; - - if (av_packet_get_side_data(pkt, src_sd->type, NULL)) - continue; - - dst_data = av_packet_new_side_data(pkt, src_sd->type, src_sd->size); - if (!dst_data) { - ret = AVERROR(ENOMEM); - goto fail; - } - - memcpy(dst_data, src_sd->data, src_sd->size); - } - } - if (debug_ts) { av_log(NULL, AV_LOG_INFO, "demuxer+ffmpeg -> ist_index:%d:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s off:%s off_time:%s\n", f->index, pkt->stream_index, diff --git a/tests/ref/fate/autorotate b/tests/ref/fate/autorotate index dff628bbff..2aa29fafa7 100644 --- a/tests/ref/fate/autorotate +++ b/tests/ref/fate/autorotate @@ -11,8 +11,8 @@ #codec_id 1: ac3 #sample_rate 1: 44100 #channel_layout_name 1: mono -0, -512, 0, 512, 6997, 0x55c700f6, S=1, 40 -1, -256, -256, 1536, 416, 0x92ddc529, S=2, 10, 4 +0, -512, 0, 512, 6997, 0x55c700f6 +1, -256, -256, 1536, 416, 0x92ddc529, S=1, 10 0, 0, 512, 512, 4847, 0xe74f522e, F=0x0 1, 1280, 1280, 1536, 418, 0x0a7fcd2d 0, 512, 1024, 512, 5281, 0xbd4a5dac, F=0x0 diff --git a/tests/ref/fate/copy-trac3074 b/tests/ref/fate/copy-trac3074 index b6d23f8c1c..53ba27e920 100644 --- a/tests/ref/fate/copy-trac3074 +++ b/tests/ref/fate/copy-trac3074 @@ -5,7 +5,7 @@ #codec_id 0: eac3 #sample_rate 0: 48000 #channel_layout_name 0: stereo -0, 0, 0, 1536, 512, 0x2beaf79f, S=1, 4 +0, 0, 0, 1536, 512, 0x2beaf79f 0, 1536, 1536, 1536, 512, 0x29ddf9d6 0, 3072, 3072, 1536, 512, 0xba0afa79 0, 4608, 4608, 1536, 512, 0xe019f394 diff --git a/tests/ref/fate/matroska-avoid-negative-ts b/tests/ref/fate/matroska-avoid-negative-ts index 05821cbf09..3ba289c6e6 100644 --- a/tests/ref/fate/matroska-avoid-negative-ts +++ b/tests/ref/fate/matroska-avoid-negative-ts @@ -11,7 +11,7 @@ dede1d72a28c7eb0a849acf230b08247 *tests/data/fate/matroska-avoid-negative-ts.mat #codec_id 1: mp3 #sample_rate 1: 44100 #channel_layout_name 1: mono -0, -37, 43, 40, 9156, 0xe5bd034a, S=1, 40 +0, -37, 43, 40, 9156, 0xe5bd034a 1, 0, 0, 26, 417, 0x7198c15e 0, 3, 3, 40, 1740, 0x29ac4480, F=0x0 1, 26, 26, 26, 417, 0x3c67c32d diff --git a/tests/ref/fate/matroska-dovi-write-config7 b/tests/ref/fate/matroska-dovi-write-config7 index aaeeb34751..dc5b73a44e 100644 --- a/tests/ref/fate/matroska-dovi-write-config7 +++ b/tests/ref/fate/matroska-dovi-write-config7 @@ -13,7 +13,7 @@ #dimensions 1: 1920x1080 #sar 1: 0/1 0, -83, 0, 41, 699, 0x728548f1 -1, -83, 0, 41, 1085, 0xfb2dba82, S=1, 8 +1, -83, 0, 41, 1085, 0xfb2dba82 0, -42, 167, 41, 95, 0xc0312044, F=0x0 1, -42, 167, 41, 481, 0xf23f91d5, F=0x0 0, 0, 83, 41, 99, 0x5e0a2221, F=0x0 diff --git a/tests/ref/fate/matroska-dovi-write-config8 b/tests/ref/fate/matroska-dovi-write-config8 index 55fe191047..472cbed708 100644 --- a/tests/ref/fate/matroska-dovi-write-config8 +++ b/tests/ref/fate/matroska-dovi-write-config8 @@ -12,7 +12,7 @@ #codec_id 1: aac #sample_rate 1: 44100 #channel_layout_name 1: stereo -0, -67, 0, 33, 63375, 0xc76606ab, S=1, 8 +0, -67, 0, 33, 63375, 0xc76606ab 0, -34, 133, 33, 46706, 0x0e08a7e5, F=0x0 0, 0, 67, 33, 29766, 0x753c031a, F=0x0 1, 0, 0, 23, 6, 0x031e0108 diff --git a/tests/ref/fate/matroska-encoding-delay b/tests/ref/fate/matroska-encoding-delay index d2ff2d07be..ee1989cbcb 100644 --- a/tests/ref/fate/matroska-encoding-delay +++ b/tests/ref/fate/matroska-encoding-delay @@ -12,7 +12,7 @@ #sample_rate 1: 48000 #channel_layout_name 1: stereo 1, -10, -10, 24, 1152, 0x724077b8 -0, 0, 0, 40, 237628, 0xeff25579, S=1, 40 +0, 0, 0, 40, 237628, 0xeff25579 1, 14, 14, 24, 1152, 0x80625572 1, 38, 38, 24, 1152, 0x7d7f4dce 0, 40, 40, 40, 238066, 0xb2265f41 diff --git a/tests/ref/fate/matroska-mastering-display-metadata b/tests/ref/fate/matroska-mastering-display-metadata index 3726469213..53f84c1793 100644 --- a/tests/ref/fate/matroska-mastering-display-metadata +++ b/tests/ref/fate/matroska-mastering-display-metadata @@ -22,9 +22,9 @@ #codec_id 3: ffv1 #dimensions 3: 1280x720 #sar 3: 1/1 -0, 0, 0, 16, 57008, 0x43416399, S=2, 8, 88 +0, 0, 0, 16, 57008, 0x43416399 1, 0, 0, 16, 2403, 0xaa818522 -3, 0, 0, 16, 274117, 0xc439610f, S=2, 8, 88 +3, 0, 0, 16, 274117, 0xc439610f 0, 17, 17, 16, 57248, 0xa06cd7b5 1, 17, 17, 16, 2403, 0xe1a991e5 2, 17, 17, 16, 1602, 0x5d868171 diff --git a/tests/ref/fate/matroska-spherical-mono-remux b/tests/ref/fate/matroska-spherical-mono-remux index e9904b2c92..6fcda14822 100644 --- a/tests/ref/fate/matroska-spherical-mono-remux +++ b/tests/ref/fate/matroska-spherical-mono-remux @@ -12,8 +12,8 @@ fddfea5f05a7a9a0d187df9a72900055 *tests/data/fate/matroska-spherical-mono-remux. #codec_id 1: h264 #dimensions 1: 1920x1080 #sar 1: 0/1 -0, -80, 0, 40, 69118, 0x73cb52f0, S=2, 12, 36 -1, -80, 0, 40, 69118, 0x73cb52f0, S=2, 12, 36 +0, -80, 0, 40, 69118, 0x73cb52f0 +1, -80, 0, 40, 69118, 0x73cb52f0 0, -40, 160, 40, 1103, 0x082a059f, F=0x0 1, -40, 160, 40, 1103, 0x082a059f, F=0x0 [STREAM] diff --git a/tests/ref/fate/matroska-stereo_mode b/tests/ref/fate/matroska-stereo_mode index d406bb9b52..45296e7746 100644 --- a/tests/ref/fate/matroska-stereo_mode +++ b/tests/ref/fate/matroska-stereo_mode @@ -43,10 +43,10 @@ #dimensions 6: 512x512 #sar 6: 2/1 0, 0, 0, 1000, 206173, 0x95af7455 -1, 0, 0, 1000, 206173, 0x95af7455, S=1, 12 -2, 0, 0, 1000, 206173, 0x95af7455, S=1, 12 -3, 0, 0, 1000, 206173, 0x95af7455, S=1, 12 -4, 0, 0, 1000, 206173, 0x95af7455, S=1, 12 +1, 0, 0, 1000, 206173, 0x95af7455 +2, 0, 0, 1000, 206173, 0x95af7455 +3, 0, 0, 1000, 206173, 0x95af7455 +4, 0, 0, 1000, 206173, 0x95af7455 5, 0, 0, 1000, 206173, 0x95af7455 6, 0, 0, 1000, 206173, 0x95af7455 0, 1000, 1000, 1000, 36, 0x34891010, F=0x0 diff --git a/tests/ref/fate/matroska-vp8-alpha-remux b/tests/ref/fate/matroska-vp8-alpha-remux index eba3ffb77a..8117325433 100644 --- a/tests/ref/fate/matroska-vp8-alpha-remux +++ b/tests/ref/fate/matroska-vp8-alpha-remux @@ -5,7 +5,7 @@ #codec_id 0: vp8 #dimensions 0: 320x213 #sar 0: 1/1 -0, 0, 0, 33, 2108, 0x59b92a34, S=2, 1900, 12 +0, 0, 0, 33, 2108, 0x59b92a34, S=1, 1900 0, 32, 32, 33, 142, 0x2f2a3fed, F=0x0, S=1, 160 0, 65, 65, 33, 157, 0x17804767, F=0x0, S=1, 209 0, 99, 99, 33, 206, 0x537262ca, F=0x0, S=1, 317 diff --git a/tests/ref/fate/mov-mp4-disposition-mpegts-remux b/tests/ref/fate/mov-mp4-disposition-mpegts-remux index efef043074..ba419843dc 100644 --- a/tests/ref/fate/mov-mp4-disposition-mpegts-remux +++ b/tests/ref/fate/mov-mp4-disposition-mpegts-remux @@ -10,9 +10,9 @@ adb3b95c07a5f3e0c86641dd62f01dae *tests/data/fate/mov-mp4-disposition-mpegts-rem #codec_id 1: ac3 #sample_rate 1: 48000 #channel_layout_name 1: stereo -1, 0, 0, 1536, 768, 0xa63778d4, S=1, 4 +1, 0, 0, 1536, 768, 0xa63778d4 1, 1536, 1536, 1536, 768, 0x7d577f3f -0, 3072, 3072, 1536, 768, 0xc2867884, S=1, 4 +0, 3072, 3072, 1536, 768, 0xc2867884 1, 3072, 3072, 1536, 768, 0xd86b7c8f 0, 4608, 4608, 1536, 690, 0xa2714bf3 1, 4608, 4608, 1536, 626, 0x09f4382f diff --git a/tests/ref/fate/mxf-d10-user-comments b/tests/ref/fate/mxf-d10-user-comments index 1b59beec7c..ccfdc83f11 100644 --- a/tests/ref/fate/mxf-d10-user-comments +++ b/tests/ref/fate/mxf-d10-user-comments @@ -6,7 +6,7 @@ #codec_id 0: mpeg2video #dimensions 0: 1280x720 #sar 0: 3/4 -0, -1, 0, 1, 150000, 0x0547870d, S=1, 40 +0, -1, 0, 1, 150000, 0x0547870d 0, 0, 1, 1, 150000, 0xe80a1612, F=0x0 0, 1, 2, 1, 150000, 0xc5c50e2f, F=0x0 0, 2, 3, 1, 150000, 0x51e28a04, F=0x0 diff --git a/tests/ref/fate/mxf-remux-applehdr10 b/tests/ref/fate/mxf-remux-applehdr10 index 29e0e03a72..9fbf8b60c7 100644 --- a/tests/ref/fate/mxf-remux-applehdr10 +++ b/tests/ref/fate/mxf-remux-applehdr10 @@ -10,7 +10,7 @@ #codec_id 1: pcm_s24le #sample_rate 1: 48000 #channel_layout_name 1: mono -0, 0, 0, 1, 57008, 0x43416399, S=1, 88 +0, 0, 0, 1, 57008, 0x43416399 1, 0, 0, 801, 2403, 0x00000000 0, 1, 1, 1, 57248, 0xa06cd7b5 1, 801, 801, 801, 2403, 0x00000000 diff --git a/tests/ref/fate/vp9-superframe-bsf b/tests/ref/fate/vp9-superframe-bsf index d7985c6973..485644dfb2 100644 --- a/tests/ref/fate/vp9-superframe-bsf +++ b/tests/ref/fate/vp9-superframe-bsf @@ -3,7 +3,7 @@ #codec_id 0: vp9 #dimensions 0: 352x288 #sar 0: 1/1 -0, 0, 0, 33, 6958, 0x38e58ee6, S=1, 12 +0, 0, 0, 33, 6958, 0x38e58ee6 0, 33, 33, 33, 852, 0x3edf9ed0, F=0x0 0, 66, 66, 33, 27, 0x62d007e5, F=0x0 0, 100, 100, 33, 25, 0x51980749, F=0x0 From patchwork Mon Aug 28 12:35:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43373 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp114253pzf; Mon, 28 Aug 2023 05:38:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHa5O69UQOdha47RyKxcSVg3uoyq6mVC5WRVk6p+8mKHmxD/XZnz6np+r+OSugKxNjeUuM/ X-Received: by 2002:a17:906:3287:b0:991:fef4:bb9 with SMTP id 7-20020a170906328700b00991fef40bb9mr19526259ejw.58.1693226282912; Mon, 28 Aug 2023 05:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226282; cv=none; d=google.com; s=arc-20160816; b=Rke3SZDUwCRqwFbq2xX8B3YxIZcB+2aNIdHuAfr9SpBcsaF9fyLIYrVXYMhiZe+8y/ daJ7w1W3kueRNaM/yJKKMqt9mRl7I1juVFsP6SQA8vJdvrIgtme/u11AbYra3+wSp83z W2AS0YQBtGN6jJVcb3kQyUePuEMp8347nTzf9kXLFiOFSUhl5O9axfI95B8aN4b4HTMe i7+9pIo3EvIfop8GoqtC6P6F/VhJREuocvgvxSxauPnJ/vcUvex9+lSGycmd3TNhxEDT O7zDLndYmBkSih1VfNZ6wW/KbuxiupRUrLy6RipA/wAJ7Ezb2bU2YmIWgtDDyvuVe0yB pGlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=xQ+sbhzTtXNVl4n9DfLDhH6Q6wM0pgL/FjJ7hQQ8B3w=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=0PU7YNFfeOE9/PMag4PkTCg6DMXTA8akPv/BBIXsT7EE8e4YzjQyY8rj2CZyS8Bb63 A62vrS0S+6MXVkxGcinqXm2RVsu4iFMEsRL6TuCs5WrsieA8EptYvnVizvSlOerj1ts5 iDVGt+xkzkR2jiek7DcOf1EV9LwTqoUYKicWu8DUyMPofJDYqKqywfmEZaG7EOLWVWJo RHmJdAHXyCXXXYFVg5JceKtKoMGqywqu7XqQXCTuv5UJ2OsDzA/i+vumTw0RXeOw7e2M kC8aFm8OkDpyKM++tcmfOyW228OKg55d508rTMFa8LHHgwMT10dC8NqzrhDYMAk+KZQG axKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=sCq89+Ti; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r23-20020a170906a21700b0099bd6900520si4157555ejy.1000.2023.08.28.05.38.02; Mon, 28 Aug 2023 05:38:02 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=sCq89+Ti; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 234A168C654; Mon, 28 Aug 2023 15:36:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 199B568C683 for ; Mon, 28 Aug 2023 15:36:56 +0300 (EEST) Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6bdc2f95f10so2491513a34.1 for ; Mon, 28 Aug 2023 05:36:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226214; x=1693831014; 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=46uW5mFi4rdFz/+ZDbKoTTFHlAJkYo39TWns1ZdzaaE=; b=sCq89+Til4Rn3+LsNyqRdJiQo9wNxBti6KVr33gxN6yOUfYiJoMPkXnqMFdAOHuloK GGm2HRDhFb6r/vgSw1FER3/lp/7b/L35B82q7YXfpHmzgi4JrxOmMuId+N6g2Od8YYzJ zs+iFZBHDI1oNItelItMtzNiwUCRgOzTgSup2LJtyOS5qkqenpa2bMmV9lPyiDcldyCW qYGiGsUGmpSZ7/zieW6uW68brgxDy6yj783UHqjhtYvT9Ms/tZoxiKFL0sXlycASx5/Q jf8POAqMIg/Y2jWVoYKD2c/tIxp8WFp90oufHfneEIg1PmFnrlpzqzAog+9B2ELZTIYK tV/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226214; x=1693831014; 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=46uW5mFi4rdFz/+ZDbKoTTFHlAJkYo39TWns1ZdzaaE=; b=SJ83UIhRfBi2k8BmN8Xf+CVGIGKcTQmLFFAgh+w3nmrh+GJbofinwvrXNXdH3+YRYg yHDdNzOkLn1RVnxjIyN5PYJfPpHOd7m9sCnaKcRSDurTcvfNPMyZxvE+AGbThA0Mr5/P FtT1Jbp45Oj1nFK0G/FjDR65u8m64+dWOkZ+UYxN0RbEiyr2GnLEHIMGZ3AYBK599GRx 95fuGxw+4U1C/HN0Y8kzX9LC6mUIVMYeHfQyJB24TrV62U4h/393GeyBajs15DGbX0bS nGDCHgzcfLis2e3yAZif/u8oti81HkDhnw9O9sLpAEYp4oFGDAsH8aUHsftxqHQDj2WA SZDg== X-Gm-Message-State: AOJu0Yx9g2Lld26XxEJ3cDiN1nZkF8nn5I+e4cOn7ShQMA3Dr5WfPOSk ucbSVhA7Quac+C7sLIBnTrkB+DyknrY= X-Received: by 2002:a9d:5c07:0:b0:6af:7760:f2d0 with SMTP id o7-20020a9d5c07000000b006af7760f2d0mr12831349otk.32.1693226214327; Mon, 28 Aug 2023 05:36:54 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:54 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:35:02 -0300 Message-ID: <20230828123617.57535-11-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/12] fftools/ffplay: stop injecting stream side data in packets 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ZFh6GgGCtS5e This is no longer needed as the side data is available for decoders in the AVCodecContext. Signed-off-by: James Almer --- fftools/ffplay.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 299d7b16d9..2aebab6f92 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2781,8 +2781,6 @@ static int read_thread(void *arg) if (genpts) ic->flags |= AVFMT_FLAG_GENPTS; - av_format_inject_global_side_data(ic); - if (find_stream_info) { AVDictionary **opts; int orig_nb_streams = ic->nb_streams; From patchwork Mon Aug 28 12:35:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43376 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp114471pzf; Mon, 28 Aug 2023 05:38:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmgsOxUtqVJVxklJu64fkqjjGEP8KiKCuVGv6MhlSVwtGVPyMZcoUHaR1kvY2QgnddPpjz X-Received: by 2002:a05:6402:786:b0:523:36cf:8bf1 with SMTP id d6-20020a056402078600b0052336cf8bf1mr18558447edy.34.1693226309758; Mon, 28 Aug 2023 05:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226309; cv=none; d=google.com; s=arc-20160816; b=uPFMpD4wH6gmqfBR/N/NA2X+LAa6BiJbKG7vL+JRxzb+6/wp4cVzUCdyZOV/QD/1IC kDScjUVBMa8x5f1NF/SdLcoZCCn98t6erd4mp0rhNeOaMKwaxcujFuEjpMMjKcTdqk0o L2ig4ig5u//tlEj5fyoDapTDLp21HE1FcoHsgvf3cd+5msYHYA6A/E3VYmlsVctqCzO/ Qkxiata1oqJyIVdTN5Sd+PN4+BsH/Aeg95DKItakKdEmQbtzF6nth4WEvd3AxcUBswc4 xCYzRrPmgNum32JNti+Ja9nt7OZ0pTiTlYr8nD4cVoSKeX+OmbC1mNSt64zoIiIUh2ZR PXzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=41I3ye7YmrhJ8CB/lcH7sXskVacYw8FahPv53juY4ls=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=LHizA6asiaxLyhXCzqTc+v+x9C8z5T65nPWur0TwkJo++OaFuUBMKkMFer2XPx/T6N oTlXkANZwPK84DdfXENZf8DRZ4b4AJiGLDluJzFkVA/KhaTOw929apZuN5OSGpv6pN30 UnyYypIFwO4dnloYu0wduNW6IEEV3uR7+IgB/RjOf4wQYxAP292ZE8RZlxXDMa/ewitG u5tSCEzEynfXtXeEKMHmY3+tjI8QnqdYOzpsuFReevI3fHwAY7cTL9fLsGPN7+4xB26F 9vjf3pbJ4ENq74RR+5H+BSMgjnt+iOdYONHFdX1NGJp4+db3BuyS6fZey1PgO2bJzaRy o40A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=iQhw5oB6; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a26-20020aa7d91a000000b00529f5d8ee3fsi4405126edr.574.2023.08.28.05.38.29; Mon, 28 Aug 2023 05:38:29 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=iQhw5oB6; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 00E0668C6F4; Mon, 28 Aug 2023 15:37:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 334AD68C6C1 for ; Mon, 28 Aug 2023 15:36:57 +0300 (EEST) Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-1a28de15c8aso2225468fac.2 for ; Mon, 28 Aug 2023 05:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226216; x=1693831016; 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=zvoy2kFRimyBAyYIs1FZTauKctmS+N4Tcn14MxpdBm8=; b=iQhw5oB6lWfHotQi6ma3UwuaKTHJ9su4oHo78r6DsTe/c7s/C3ueNkJbfvMZzWZVUS 8f5qB/xZtxGdezk3FQyFL2O4XTRhiwo9gTAR9su2gZyV/oVzG+zbIsGNdxBy/RWECkS7 gI+vLAO8YGZRxf2RqwBLBRRoaWh/Vupo582ne3QhmvS5W2jvuDEwQyficgs+QEU3L940 UNP3EcQeHtfcGkYMWd2k1UrF3AJUQ//5f/3HzWUd4a2mi5Q/r+xYtn0dfmFYYigpOo4F 75blyJjWBwOQO8II01QDe4c18XcjCgoi+zuUqyjiYdrrNgMui6TnzQzqdKWo71XqS/hu ajyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226216; x=1693831016; 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=zvoy2kFRimyBAyYIs1FZTauKctmS+N4Tcn14MxpdBm8=; b=RP7ZLf8yJXmREIrN4xZzIeYd0muT5r79PiicliTPLF+/AnZjM2DnLLg69OWb2qT7Z5 5T0fp2eoYhGCAgDtQYrfuzDrRffIZV0vZCMW98qxSOsHck4/CZfUUYACjDricirCwGJk //T1uUZPuN5CqJpSDi44XpMpgJoGeOxFMI8pKWby+0JNbAUoyEMQd0FXBHCELkMnCUKp x20DdPfenIQ1b2/auz39IYM32RzsAhBT4EQmFVwVvd4H0b9qTrmWhxDcG+9PPovsyg+V 4VJERF5dINziZDm14NTOIisM6VTglDlEHdlPYc7pyx+yBLuSBr3jN1WMD5NZ9Mk73x78 VJDg== X-Gm-Message-State: AOJu0YwU06amc4UIitUsse0c6MMn5aKXtPf5nduXiKKyVVoO3RzuQBBT btFSayPaAa8m4Iihk2XJ4dS4hwHBQTU= X-Received: by 2002:a05:6870:fba9:b0:1be:cc86:8a40 with SMTP id kv41-20020a056870fba900b001becc868a40mr12529203oab.18.1693226215683; Mon, 28 Aug 2023 05:36:55 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:55 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:35:03 -0300 Message-ID: <20230828123617.57535-12-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/12] avcodec/avcodec: deprecate coded_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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: BY7MA3eruRZO In favor of AVCodecContext.packet_sd Also reflect the fact the field has been used during decoding for some time now. Signed-off-by: James Almer --- libavcodec/avcodec.c | 28 ++++++++++++++++++++++++++++ libavcodec/avcodec.h | 7 ++++--- libavcodec/decode.c | 31 +++++++++++++++++++++++++++++++ libavcodec/decode.h | 5 +++++ libavcodec/encode.c | 25 +++++++++++++++++++++++++ libavcodec/encode.h | 5 +++++ libavcodec/internal.h | 5 ----- libavcodec/libaomenc.c | 2 +- libavcodec/libopenh264enc.c | 2 +- libavcodec/libsvtav1.c | 2 +- libavcodec/libvpxenc.c | 2 +- libavcodec/libx264.c | 2 +- libavcodec/libx265.c | 2 +- libavcodec/mpeg12dec.c | 2 +- libavcodec/mpegvideo_enc.c | 2 +- libavcodec/nvenc.c | 2 +- libavcodec/qsvenc.c | 2 +- libavcodec/utils.c | 31 ------------------------------- libavcodec/version_major.h | 1 + 19 files changed, 109 insertions(+), 49 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index c811d1f7c4..374831fa07 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -341,6 +341,34 @@ FF_ENABLE_DEPRECATION_WARNINGS avci->needs_close = 1; } +#if FF_API_CODED_SIDE_DATA + if (av_codec_is_encoder(avctx->codec)) { + const AVPacketSideData *sd = + av_packet_side_data_set_get(&avctx->packet_side_data, AV_PKT_DATA_CPB_PROPERTIES); + if (sd) { + uint8_t *data; + AVPacketSideData *tmp = av_realloc_array(avctx->coded_side_data, + avctx->nb_coded_side_data + 1U, + sizeof(*tmp)); + if (!tmp) { + ret = AVERROR(ENOMEM); + goto free_and_end; + } + avctx->coded_side_data = tmp; + + data = av_memdup(sd->data, sd->size); + if (!data) { + ret = AVERROR(ENOMEM); + goto free_and_end; + } + + avctx->coded_side_data[avctx->nb_coded_side_data].data = data; + avctx->coded_side_data[avctx->nb_coded_side_data].size = sd->size; + avctx->coded_side_data[avctx->nb_coded_side_data++].type = AV_PKT_DATA_CPB_PROPERTIES; + } + } +#endif + ret=0; if (av_codec_is_decoder(avctx->codec)) { diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index dda8a2412b..6ffb6b78d8 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1893,8 +1893,9 @@ typedef struct AVCodecContext { /** * Additional data associated with the entire coded stream. * - * - decoding: unused - * - encoding: may be set by libavcodec after avcodec_open2(). + * - decoding: set by libavcodec + * - encoding: the use of this field for encoding is deprecated. + * Use packet_side_data instead. */ AVPacketSideData *coded_side_data; int nb_coded_side_data; @@ -2105,7 +2106,7 @@ typedef struct AVCodecContext { * Additional data associated with the entire stream. * * - decoding: set by user - * - encoding: unused + * - encoding: may be set by libavcodec after avcodec_open2(). */ AVPacketSideDataSet packet_side_data; } AVCodecContext; diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 4b8c1bc74d..7afec14c4d 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1878,3 +1878,34 @@ AVCodecInternal *ff_decode_internal_alloc(void) { return av_mallocz(sizeof(DecodeContext)); } + +AVCPBProperties *ff_decode_add_cpb_side_data(AVCodecContext *avctx) +{ + AVPacketSideData *tmp; + AVCPBProperties *props; + size_t size; + int i; + + for (i = 0; i < avctx->nb_coded_side_data; i++) + if (avctx->coded_side_data[i].type == AV_PKT_DATA_CPB_PROPERTIES) + return (AVCPBProperties *)avctx->coded_side_data[i].data; + + props = av_cpb_properties_alloc(&size); + if (!props) + return NULL; + + tmp = av_realloc_array(avctx->coded_side_data, avctx->nb_coded_side_data + 1, sizeof(*tmp)); + if (!tmp) { + av_freep(&props); + return NULL; + } + + avctx->coded_side_data = tmp; + avctx->nb_coded_side_data++; + + avctx->coded_side_data[avctx->nb_coded_side_data - 1].type = AV_PKT_DATA_CPB_PROPERTIES; + avctx->coded_side_data[avctx->nb_coded_side_data - 1].data = (uint8_t*)props; + avctx->coded_side_data[avctx->nb_coded_side_data - 1].size = size; + + return props; +} diff --git a/libavcodec/decode.h b/libavcodec/decode.h index 52e5aafc34..cb07ab318b 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -153,4 +153,9 @@ int ff_side_data_update_matrix_encoding(AVFrame *frame, int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private, AVBufferRef **hwaccel_priv_buf); +/** + * Add a CPB properties side data to an decoding context. + */ +AVCPBProperties *ff_decode_add_cpb_side_data(AVCodecContext *avctx); + #endif /* AVCODEC_DECODE_H */ diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 32cc903b1f..854cfd59d2 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -864,3 +864,28 @@ AVCodecInternal *ff_encode_internal_alloc(void) { return av_mallocz(sizeof(EncodeContext)); } + +AVCPBProperties *ff_encode_add_cpb_side_data(AVCodecContext *avctx) +{ + AVPacketSideData *sd; + AVCPBProperties *props; + size_t size; + int ret; + + sd = av_packet_side_data_set_get(&avctx->packet_side_data, AV_PKT_DATA_CPB_PROPERTIES); + if (sd) + return (AVCPBProperties *)sd->data; + + props = av_cpb_properties_alloc(&size); + if (!props) + return NULL; + + ret = av_packet_side_data_set_add(&avctx->packet_side_data, AV_PKT_DATA_CPB_PROPERTIES, + (uint8_t *)props, size); + if (ret < 0) { + av_free(props); + return NULL; + } + + return props; +} diff --git a/libavcodec/encode.h b/libavcodec/encode.h index dfaab7c976..e019cd7702 100644 --- a/libavcodec/encode.h +++ b/libavcodec/encode.h @@ -73,6 +73,11 @@ int ff_encode_reordered_opaque(AVCodecContext *avctx, int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, AVFrame *frame, int *got_packet); +/** + * Add a CPB properties side data to an encoding context. + */ +AVCPBProperties *ff_encode_add_cpb_side_data(AVCodecContext *avctx); + /** * Rescale from sample rate to AVCodecContext.time_base. */ diff --git a/libavcodec/internal.h b/libavcodec/internal.h index a67cf713ca..83e0bc3fb2 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -180,11 +180,6 @@ int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx); int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec); -/** - * Add a CPB properties side data to an encoding context. - */ -AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx); - /** * Check AVFrame for S12M timecode side data and allocate and fill TC SEI message with timecode info * diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index f29cb0784a..53a1159b75 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -1018,7 +1018,7 @@ static av_cold int aom_init(AVCodecContext *avctx, if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) ctx->rawimg.bit_depth = enccfg.g_bit_depth; - cpb_props = ff_add_cpb_side_data(avctx); + cpb_props = ff_encode_add_cpb_side_data(avctx); if (!cpb_props) return AVERROR(ENOMEM); diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index 5b59af6f94..433accba22 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -353,7 +353,7 @@ FF_ENABLE_DEPRECATION_WARNINGS memcpy(avctx->extradata, fbi.sLayerInfo[0].pBsBuf, size); } - props = ff_add_cpb_side_data(avctx); + props = ff_encode_add_cpb_side_data(avctx); if (!props) return AVERROR(ENOMEM); props->max_bitrate = param.iMaxBitrate; diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index f2b73361d8..a8b3b62b96 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -325,7 +325,7 @@ FF_ENABLE_DEPRECATION_WARNINGS FFMAX(avctx->bit_rate, avctx->rc_max_rate) / 1000LL; if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) { - AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx); + AVCPBProperties *cpb_props = ff_encode_add_cpb_side_data(avctx); if (!cpb_props) return AVERROR(ENOMEM); diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 7a545527a9..0f6f4e785c 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -1273,7 +1273,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, ctx->rawimg.bit_depth = enccfg.g_bit_depth; #endif - cpb_props = ff_add_cpb_side_data(avctx); + cpb_props = ff_encode_add_cpb_side_data(avctx); if (!cpb_props) return AVERROR(ENOMEM); diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 1a7dc7bdd5..5c1dc5f8b8 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -1231,7 +1231,7 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->extradata_size = p - avctx->extradata; } - cpb_props = ff_add_cpb_side_data(avctx); + cpb_props = ff_encode_add_cpb_side_data(avctx); if (!cpb_props) return AVERROR(ENOMEM); cpb_props->buffer_size = x4->params.rc.i_vbv_buffer_size * 1000; diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 873b3021ee..447e6da25f 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -395,7 +395,7 @@ FF_ENABLE_DEPRECATION_WARNINGS ctx->params->rc.vbvBufferSize = avctx->rc_buffer_size / 1000; ctx->params->rc.vbvMaxBitrate = avctx->rc_max_rate / 1000; - cpb_props = ff_add_cpb_side_data(avctx); + cpb_props = ff_encode_add_cpb_side_data(avctx); if (!cpb_props) return AVERROR(ENOMEM); cpb_props->buffer_size = ctx->params->rc.vbvBufferSize * 1000; diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index e645b8e24a..4c9ed76964 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1403,7 +1403,7 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1) ff_dlog(s->avctx, "sequence extension\n"); s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO; - if (cpb_props = ff_add_cpb_side_data(s->avctx)) { + if (cpb_props = ff_decode_add_cpb_side_data(s->avctx)) { cpb_props->buffer_size = s1->rc_buffer_size; if (s->bit_rate != 0x3FFFF*400) cpb_props->max_bitrate = s->bit_rate; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 64e66ae958..9b3bf0bda0 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -972,7 +972,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) } } - cpb_props = ff_add_cpb_side_data(avctx); + cpb_props = ff_encode_add_cpb_side_data(avctx); if (!cpb_props) return AVERROR(ENOMEM); cpb_props->max_bitrate = avctx->rc_max_rate; diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 1e83ea9734..4249ff7188 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -1666,7 +1666,7 @@ FF_ENABLE_DEPRECATION_WARNINGS if (ctx->encode_config.rcParams.averageBitRate > 0) avctx->bit_rate = ctx->encode_config.rcParams.averageBitRate; - cpb_props = ff_add_cpb_side_data(avctx); + cpb_props = ff_encode_add_cpb_side_data(avctx); if (!cpb_props) return AVERROR(ENOMEM); cpb_props->max_bitrate = ctx->encode_config.rcParams.maxBitRate; diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index b3b7475b0f..ac7364f61f 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1504,7 +1504,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) } memset(avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); - cpb_props = ff_add_cpb_side_data(avctx); + cpb_props = ff_encode_add_cpb_side_data(avctx); if (!cpb_props) return AVERROR(ENOMEM); cpb_props->max_bitrate = avctx->rc_max_rate; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index bd4131db62..d54e050848 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1018,37 +1018,6 @@ AVCPBProperties *av_cpb_properties_alloc(size_t *size) return props; } -AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx) -{ - AVPacketSideData *tmp; - AVCPBProperties *props; - size_t size; - int i; - - for (i = 0; i < avctx->nb_coded_side_data; i++) - if (avctx->coded_side_data[i].type == AV_PKT_DATA_CPB_PROPERTIES) - return (AVCPBProperties *)avctx->coded_side_data[i].data; - - props = av_cpb_properties_alloc(&size); - if (!props) - return NULL; - - tmp = av_realloc_array(avctx->coded_side_data, avctx->nb_coded_side_data + 1, sizeof(*tmp)); - if (!tmp) { - av_freep(&props); - return NULL; - } - - avctx->coded_side_data = tmp; - avctx->nb_coded_side_data++; - - avctx->coded_side_data[avctx->nb_coded_side_data - 1].type = AV_PKT_DATA_CPB_PROPERTIES; - avctx->coded_side_data[avctx->nb_coded_side_data - 1].data = (uint8_t*)props; - avctx->coded_side_data[avctx->nb_coded_side_data - 1].size = size; - - return props; -} - static unsigned bcd2uint(uint8_t bcd) { unsigned low = bcd & 0xf; diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h index 95c5aec0c5..7b01300c4a 100644 --- a/libavcodec/version_major.h +++ b/libavcodec/version_major.h @@ -49,6 +49,7 @@ #define FF_API_SUBFRAMES (LIBAVCODEC_VERSION_MAJOR < 61) #define FF_API_TICKS_PER_FRAME (LIBAVCODEC_VERSION_MAJOR < 61) #define FF_API_DROPCHANGED (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_CODED_SIDE_DATA (LIBAVCODEC_VERSION_MAJOR < 61) // reminder to remove CrystalHD decoders on next major bump #define FF_CODEC_CRYSTAL_HD (LIBAVCODEC_VERSION_MAJOR < 61) From patchwork Mon Aug 28 12:35:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 43378 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3822:b0:149:dfde:5c0a with SMTP id p34csp114604pzf; Mon, 28 Aug 2023 05:38:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4koj/iN319r8XrPHZSckPkY+Eukh/PT/cfvQeQnul+0dSFhgWXyk6RZoTUFXAVnHEU5Ht X-Received: by 2002:a17:906:5daa:b0:99d:9ca9:8c19 with SMTP id n10-20020a1709065daa00b0099d9ca98c19mr18276908ejv.74.1693226326519; Mon, 28 Aug 2023 05:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693226326; cv=none; d=google.com; s=arc-20160816; b=iFN49DbHz0bEhQP5Czm/ZlAo4u6ES/cg71ntNjODS13jLkWo+p24QtCM2xVmjlX1H8 WMCttXX+lkp0USTde77ZrbBQa4dRTu3m1cXodBToLqf7zLiZ51aR5OiSlRAt2Ry4QlT3 Tt9ofEnTKv8dYNvwC5VS9lI4tzsx/f8loFI98Sdpo3yesu19LkmcuJzTAJL8u+JWCHmy v9H68POHfjbKX89U250v1KRy6F3XT3Rq/+2tIN08tHLFVDud14BV2HlPoUfCaBdSqW7I SCPNa2r4FJCxz4KxSu2NuovYTkyrSAnUCjiiCD6Kugk8wgpV5o2h3EhG/34NMXIRZILH NxFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=cTgjmDHe5g3E8Jmi56tTJuM8MBYIGJYYuvT3OYc71RU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=F+WdyfLSnMciOpzfhLRdsmmaJu93EoNpmIYMczngE6xwu2kcC3UtumSXRrs6mC1I6i vfdEPYBcat+sjN7x7fnRv8B3+tmP0z4v7N9bGhRdUd5a1GZsuxepJqMk1pblv4if3v95 NB2SuPw5X95nWwMOzY0riS3TqYzpJLi1k0+OiFq/pvxtBl/RMIDr0Y5tKZJCH/uF4Pgb CTMFHe3vSF2cY/QBobaBEZltkJFTo6iFS5HUPJYQ1S0Xj3HklgJi7ai11QFPebKNtT27 nj80obxYg0rwHzEZunSu3SmzFHJYqi8cuvqk6wgwJEWLnzKcAz4OJ6v8bTzoawbHeyvs zvOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=DRLAMyJm; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id rl28-20020a170907217c00b00991fe707692si2335089ejb.63.2023.08.28.05.38.46; Mon, 28 Aug 2023 05:38:46 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=DRLAMyJm; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D628D68C704; Mon, 28 Aug 2023 15:37:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D0C9D68C654 for ; Mon, 28 Aug 2023 15:36:58 +0300 (EEST) Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-1c504386374so2336207fac.3 for ; Mon, 28 Aug 2023 05:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693226217; x=1693831017; 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=c0lLc2rWo0yATXfqUkcLOAa1REUfYUkeZJ9MRzJGEK4=; b=DRLAMyJmv9DhkPddvm4+9KEdqiVNbt5Xxp7zD9uG1sg6fyDeWv3YFxBq1i+eJCy2TS tCnFf1N8lgBQoMZNHGJGY8HxC8E5kfQeW2+dOFVPZxm566BYEJlyOyKahRjXgWBO7dML zyDJEoEDR7pxax8W7X8ToJsW1rWisV9IPaJ985x9uxo41Nd2d774BIjkasnJhISdSN5I WYFSkPcnNhG1tZ7/Uopen9ud8L9F1OHRq577XeS60+TGXDuyecyVNPIQSde4BbePTMuj A/7bN5H8/ThI/4Xdq8e7MEwmitxu6C3nj5YAjcHf5keABouy2F4PFUCkmiyMgaILojgP X/XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693226217; x=1693831017; 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=c0lLc2rWo0yATXfqUkcLOAa1REUfYUkeZJ9MRzJGEK4=; b=YyNcKYlqkTr0lLh6Qqon9u/3Bgbe4sWWgDAX4vYM1t5+ZV6SvjKcUT/9O7cWHCQDrP FKqYS1khOevDyYLQ9AqtCxQtZtuCBYFQqd4LoUVEsMEMQL952/O5CS/qMXhMEdfzvyPQ GK+ZF8IySsZCR5QwL0NcT3RvnkKYcuaNHhh1UZFJYyC8ytwhsauZLoIzjDXcZYTwN3jo akRwFxG+urGBkUTphniOhV8pehMox+iCLiEW+Hp/AbhziDsZcV1O2Nmra9gI+/QVmU9S BBtDaLLRCMqIglEF44u+PG9gRMyqKYP4G7NM0tPrniJLRc7RnQ7i/08HRxFHCC3PEqxx NmfA== X-Gm-Message-State: AOJu0Yxzw+FnRgIw/eMmmk+tdOziVZr3nFHf4pFJNYbUMSid5FH97AiU pKaW54F+qVGdj1APNQE+IjUsIblh7FU= X-Received: by 2002:a05:6870:82a2:b0:1b8:5d9e:638b with SMTP id q34-20020a05687082a200b001b85d9e638bmr11346758oae.43.1693226216835; Mon, 28 Aug 2023 05:36:56 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id b15-20020a056830104f00b006b9a98b9659sm3404615otp.19.2023.08.28.05.36.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 05:36:56 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Aug 2023 09:35:04 -0300 Message-ID: <20230828123617.57535-13-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230828123617.57535-1-jamrial@gmail.com> References: <20230828123617.57535-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/12] fftools: stop propagating the encoder's coded_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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Zjwmw65jp+6c It's no longer needed Signed-off-by: James Almer --- fftools/ffmpeg_enc.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 852d1f6282..6ed35f737f 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -423,20 +423,6 @@ int enc_open(OutputStream *ost, AVFrame *frame) return ret; } - if (ost->enc_ctx->nb_coded_side_data) { - int i; - - for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) { - const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i]; - AVPacketSideData *sd_dst; - - sd_dst = av_packet_side_data_set_new(&ost->par_in->side_data, sd_src->type, sd_src->size); - if (!sd_dst) - return AVERROR(ENOMEM); - memcpy(sd_dst->data, sd_src->data, sd_src->size); - } - } - /* * Add global input side data. For now this is naive, and copies it * from the input stream's global side data. All side data should