From patchwork Fri Mar 22 20:28:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 47332 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1014:b0:1a3:ac71:9534 with SMTP id nk20csp163615pzb; Fri, 22 Mar 2024 13:30:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWSjos4zrZHYZk9ilN7JLqnJy3gfL3YNpaLmX7mS4a3vODpoPHVHzWE+rpy8p6dul94QcTkSKV/9c4S/5+N9MXW+vrNy8XtMcAwyw== X-Google-Smtp-Source: AGHT+IGzLF7kKnPU6QdtKpZm4Lp9PqiVSeFbmQTYeRGvTil7+Ejj3lnu96FykHEIRVovi4MlG3Rq X-Received: by 2002:a50:bb62:0:b0:566:95e3:1759 with SMTP id y89-20020a50bb62000000b0056695e31759mr456081ede.26.1711139417561; Fri, 22 Mar 2024 13:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711139417; cv=none; d=google.com; s=arc-20160816; b=xCPJrfeDGMdz2YZTMOEE3vuqP1LBVoE1YehITBTyYnHUWZhEq/Iw9V11Z2yGkS+9nN odF1KWxhVEjk7YJY6qwtnJ4oAAykEAMU07AaMJWElQqm2B0/tNRQjqctfAbhZIRDHroy PBRxBV3/aJhMoPtaYgp9DTYMEuxZH9a6CHtDqZhGCbazeDyRnef9/x5fsleRY9nq5aMZ c5uPyJBgvGGJGG9g8pTaJLERzFu8rgjKJah8duwqD18EzPZhoFvZ+nodJcUZbdDVK6Ae reSteABFN25aPpK3dHymTEYPxnf35c71QKTRMplpwYpAYsBdmLWFJLUyJ0kd8kd89+y2 M85Q== 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=CsMHAxffGV7xlDLOnFFqjbTycbX0LOLC4E69tze2VGE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=IAMi90iwrjYjm0m+x1YGsAoe2nP8WDjnOH6GTlrBetuSy441PZf1VuwyaBpYHjD8aa 6Ln4Rgh24zzS7Bbn+rVX+9dRZz5nKSUQVrPZZR9hxkMw3jD7kGooc60vt9t/ROXxFVeV ZxGbdl4A8my+OJ3YE8xupsP+q4ymgXvpDE9bjtfmnrIESU/bf6v4Z8s8Azzawm7/pVyL LIrqLFe+VRP3uYV6iRnC05KbD4cj8CDCt4WVr00Th5g/ipCdkaSu/R6aeaNWUE5Q6fZ2 rpa0psARqswx5g7qW8lHpdE80z/UNreXJ504i/l3mRdLEinBjRy4yJoG77fSUSuzckBN HCAw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=cHrxmcXI; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c4-20020a0564021f8400b00568d7a08306si159641edc.384.2024.03.22.13.30.17; Fri, 22 Mar 2024 13:30:17 -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=@khirnov.net header.s=mail header.b=cHrxmcXI; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E0FDF68D4D5; Fri, 22 Mar 2024 22:29:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ADBE768D4D5 for ; Fri, 22 Mar 2024 22:29:01 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=cHrxmcXI; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 97B5D4D4D for ; Fri, 22 Mar 2024 21:28:56 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id lfAAdjI0cIcW for ; Fri, 22 Mar 2024 21:28:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1711139334; bh=wVbSnOa7hip0R4QaKAnBAEJQFgbPp4OzxeuSxS4qDQ8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cHrxmcXIFxF1ZzzkpT1vRAO1619jL1XfpIQyko/ACjzOkk4y0VP9BD2zQx9SMRX6C +Xn3Tca4aX/L0JTPIwR9mYhAnA/7T1oVf1GbYPjdqeAprw3q7X7QnGtq0YH7avYhYs CGFV1P1W9x2a4g1xKL5IGW1O2mGroQP9D7iVFcNWGCz+qqmz8P8kIjLCielQcmzGwG 2Hc1YW9cb4iVL/vUX+2OKg6XOa7nYfsUMPFUawBVWlXtQHHwuP7ABY71o2jSw5S7Lu vF+DsvcYoRbstS9veeLd2S4b/TionqZR3spXYvZVOEtDrq/4i/I55czMGOtWeJBDA3 oIakMlK3uMz9w== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 7CFBA4D62 for ; Fri, 22 Mar 2024 21:28:54 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 920F03A0F55 for ; Fri, 22 Mar 2024 21:28:45 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Mar 2024 21:28:39 +0100 Message-ID: <20240322202841.31730-10-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322202841.31730-1-anton@khirnov.net> References: <20240322202841.31730-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/12] lavc/encode: map AVCodecContext.decoded_side_data to 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: 0s9+JPwe7pcM This way it can be automagically propagated through the encoder to muxing. --- libavcodec/encode.c | 23 +++++++++++++++++++++++ tests/ref/fate/libx265-hdr10 | 24 ++++++++++++------------ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 7fc9737e93..46e46a055e 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -782,6 +782,29 @@ int ff_encode_preinit(AVCodecContext *avctx) return AVERROR(ENOMEM); } + for (int i = 0; ff_sd_global_map[i].packet < AV_PKT_DATA_NB; i++) { + const enum AVPacketSideDataType type_packet = ff_sd_global_map[i].packet; + const enum AVFrameSideDataType type_frame = ff_sd_global_map[i].frame; + const AVFrameSideData *sd_frame; + AVPacketSideData *sd_packet; + + sd_frame = av_frame_side_data_get(avctx->decoded_side_data, + avctx->nb_decoded_side_data, + type_frame); + if (!sd_frame || + av_packet_side_data_get(avctx->coded_side_data, avctx->nb_coded_side_data, + type_packet)) + + continue; + + sd_packet = av_packet_side_data_new(&avctx->coded_side_data, &avctx->nb_coded_side_data, + type_packet, sd_frame->size, 0); + if (!sd_packet) + return AVERROR(ENOMEM); + + memcpy(sd_packet->data, sd_frame->data, sd_frame->size); + } + if (CONFIG_FRAME_THREAD_ENCODER) { ret = ff_frame_thread_encoder_init(avctx); if (ret < 0) diff --git a/tests/ref/fate/libx265-hdr10 b/tests/ref/fate/libx265-hdr10 index 571c837cac..68511202a5 100644 --- a/tests/ref/fate/libx265-hdr10 +++ b/tests/ref/fate/libx265-hdr10 @@ -1,16 +1,16 @@ frames.frame.0.side_data_list.side_data.0.side_data_type="H.26[45] User Data Unregistered SEI message" -frames.frame.0.side_data_list.side_data.1.side_data_type="H.26[45] User Data Unregistered SEI message" -frames.frame.0.side_data_list.side_data.2.side_data_type="Mastering display metadata" -frames.frame.0.side_data_list.side_data.2.red_x="13250/50000" -frames.frame.0.side_data_list.side_data.2.red_y="34500/50000" -frames.frame.0.side_data_list.side_data.2.green_x="7500/50000" -frames.frame.0.side_data_list.side_data.2.green_y="3000/50000" -frames.frame.0.side_data_list.side_data.2.blue_x="34000/50000" -frames.frame.0.side_data_list.side_data.2.blue_y="16000/50000" -frames.frame.0.side_data_list.side_data.2.white_point_x="15635/50000" -frames.frame.0.side_data_list.side_data.2.white_point_y="16450/50000" -frames.frame.0.side_data_list.side_data.2.min_luminance="50/10000" -frames.frame.0.side_data_list.side_data.2.max_luminance="10000000/10000" +frames.frame.0.side_data_list.side_data.1.side_data_type="Mastering display metadata" +frames.frame.0.side_data_list.side_data.1.red_x="13250/50000" +frames.frame.0.side_data_list.side_data.1.red_y="34500/50000" +frames.frame.0.side_data_list.side_data.1.green_x="7500/50000" +frames.frame.0.side_data_list.side_data.1.green_y="3000/50000" +frames.frame.0.side_data_list.side_data.1.blue_x="34000/50000" +frames.frame.0.side_data_list.side_data.1.blue_y="16000/50000" +frames.frame.0.side_data_list.side_data.1.white_point_x="15635/50000" +frames.frame.0.side_data_list.side_data.1.white_point_y="16450/50000" +frames.frame.0.side_data_list.side_data.1.min_luminance="50/10000" +frames.frame.0.side_data_list.side_data.1.max_luminance="10000000/10000" +frames.frame.0.side_data_list.side_data.2.side_data_type="H.26[45] User Data Unregistered SEI message" frames.frame.0.side_data_list.side_data.3.side_data_type="Content light level metadata" frames.frame.0.side_data_list.side_data.3.max_content=1000 frames.frame.0.side_data_list.side_data.3.max_average=200