From patchwork Sat May 1 02:23:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Hards X-Patchwork-Id: 27547 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:cc:0:0:0:0 with SMTP id m12csp64158pxt; Fri, 30 Apr 2021 19:23:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPJXvb/kJcvzp7gSs8hIr6CIXLh6GcSVewH0Zk7fESqIOE7NgdTrqbhHBbzTtaSE5NBfo5 X-Received: by 2002:a17:906:7e51:: with SMTP id z17mr7453720ejr.92.1619835811323; Fri, 30 Apr 2021 19:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619835811; cv=none; d=google.com; s=arc-20160816; b=N7koWxLA8M4XgvBDeMN3WJl88DDAwkEvmUeqI6cw+nRQbD+K2wXbzKJjQiOsLl+V5E BBzlZWw8wKjyskd3TcdykH3aHtsnE4AhJZMQkkAWuLUP8lZf1xnQ5qnFM2sx4h6WTdCE rPGQS5un1EaebLrAUFUoIXHIWPQ70HDyfYbzEnyKKy7KawPKZSlMXJQoY+5ee0FZinXo GYgq/WKldRfeNMUaPdMuHPoPGJC+GdObzEiLmP3p4Xx1DhSLgBI40f4dBZtDzIg5GvUU TxMmjtFpkwWrIag4ZYvkFPSlH/IvQ8aBILVTaqH2/ZPuPZGJGket2nQpGUO6ja8LVYjw IsJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=L6oat8AJl3xcq5tn67KhhMp1YUPjEyrNBNFU58oPUZY=; b=XJCQp8eGvxGFkR5cuhMflm1iK5NtWGSo9ljZDXZFufvKriWtSYbD2WdMLutwJWeKq8 f4eSJSKZeAUPVdFk1VSq6FzczmCTFVSUxaLg/zcUU0P9WBIgJ8do4d7xYVbI9bSJ6iY8 bf3FKkD4qEyvBrmyymlHIqJyQzoNwo1sgiF3rbmcPjRaYMwWUt83HsWsuADXeqeOcfU0 YO33lrHPEJ0kJMPd60bOUoAp2oWvaC+9V7EURPt/ZrL0xLjVPXuyyUNSdbLerZEl03ec asDxgWRvgKtR4FNqSLPLE1oIW2kQAHXvL2+HWcpkqTtarSHxsoIdbrfPswKZ98D5E5A3 azWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m16si3282731eds.603.2021.04.30.19.23.30; Fri, 30 Apr 2021 19:23:31 -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; 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 F2CBF6806A2; Sat, 1 May 2021 05:23:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from cp1.nerdvana.net.au (cp1-new.nerdvana.net.au [113.212.99.70]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6265B680581 for ; Sat, 1 May 2021 05:23:17 +0300 (EEST) Received: from ppp115-205.static.internode.on.net ([150.101.115.205]:41406 helo=audax.fritz.box) by cp1.nerdvana.net.au with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lcfHm-0008W8-Cb; Sat, 01 May 2021 12:23:14 +1000 From: Brad Hards To: ffmpeg-devel@ffmpeg.org Date: Sat, 1 May 2021 12:23:01 +1000 Message-Id: <20210501022304.301425-2-bradh@frogmouth.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210501022304.301425-1-bradh@frogmouth.net> References: <20210501022304.301425-1-bradh@frogmouth.net> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cp1.nerdvana.net.au X-AntiAbuse: Original Domain - ffmpeg.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - frogmouth.net X-Get-Message-Sender-Via: cp1.nerdvana.net.au: authenticated_id: bradh@frogmouth.net X-Authenticated-Sender: cp1.nerdvana.net.au: bradh@frogmouth.net X-Source: X-Source-Args: X-Source-Dir: Subject: [FFmpeg-devel] [PATCH v2 1/4] libavcodec: write out user data unregistered SEI for x264 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Brad Hards Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: H3bHHJ3NLjgl Signed-off-by: Brad Hards --- libavcodec/libx264.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 22c91d8df7..c19a9b2804 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -31,6 +31,7 @@ #include "internal.h" #include "packet_internal.h" #include "atsc_a53.h" +#include "sei.h" #if defined(_MSC_VER) #define X264_API_IMPORTS 1 @@ -303,6 +304,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int64_t wallclock = 0; X264Opaque *out_opaque; AVFrameSideData *sd; + int total_unreg_sei = 0; x264_picture_init( &x4->pic ); x4->pic.img.i_csp = x4->params.i_csp; @@ -438,6 +440,25 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, } } } + for (int j = 0; j < frame->nb_side_data; j++) { + if (frame->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) + total_unreg_sei++; + } + if (total_unreg_sei > 0) { + x264_sei_t *sei = &(x4->pic.extra_sei); + sei->payloads = av_realloc_array(sei->payloads, + sei->num_payloads + total_unreg_sei, + sizeof(x264_sei_payload_t)); + for (int j = 0; j < frame->nb_side_data; j++) { + if (frame->side_data[j]->type == AV_FRAME_DATA_SEI_UNREGISTERED) { + x264_sei_payload_t *payload = &(sei->payloads[sei->num_payloads]); + payload->payload = frame->side_data[j]->data; + payload->payload_size = frame->side_data[j]->size; + payload->payload_type = SEI_TYPE_USER_DATA_UNREGISTERED; + sei->num_payloads++; + } + } + } } do {