From patchwork Sun Sep 22 18:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51700 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp2070111vqb; Sun, 22 Sep 2024 11:00:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWaKS8eWlklKUY1DccLrcd/S2cj1m6JXHu78LAs4uv3iIkfhabR0ZWwY8I+XqF5igK2Ha+SZiquMFoxyj2BhGxP@gmail.com X-Google-Smtp-Source: AGHT+IGVoIeMYKf4iIr8DD182g+YDpF3eO52owzE9i2zNqR610xgpoHXkab6S2vyPm7yJufZF/0k X-Received: by 2002:a05:6512:2313:b0:536:55cc:963e with SMTP id 2adb3069b0e04-536ac32f0b3mr5422682e87.44.1727028037082; Sun, 22 Sep 2024 11:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727028037; cv=none; d=google.com; s=arc-20240605; b=czxbPvpZAfCfOLWdOTNov2FHKk42+OeQBqcE97qBypYiFr/lLMhTEeCdeM6ZUx7LOy Onel9iNzRIq0WDepop9iKGHQcBx/nDEdG1ofm76nTjda2mbrrCIAMLCkRTs4pRH9GLJ9 Yz5ULP7m3HpUqHfPlf33Y5Fl7FngMvLDfzUI/8oUf0sp2b9njCfMvqQZXXv4Ba/DYrCk eOja9qN/FvSRhzpoGDZUMiglj28jS1KFi+eHm5vWdkpnoVinJXEDrWGIb7cFPgp9sN0P DDSOvqthkdwzy50/ucMh5JEKhLUXLFNiAG6WC43ssyIkaDVZ3Z6/NWiYRuXOtkqC+Kf7 kV9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=vM2kFDVbG6UVh+Dlq+KHdUvrxmVI8gdHIYSUmEt81SE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=bl8waUxAQMkzKLdOEMUplkx9NxRgfmTG8Oe3iMx+kJe+sEHbwY/mHdwaNg79eBsTws 0d+UxRrA+Tdo10TvNRCU2x8AexmWGboOvOI4v5bFcvJzvFHkIpKlxeq2zn4404k/rpjr Tgz7hurOvxguBYiJzuPCzhz1BwdUo9A4bKIXEOCFGlOQirpgwskq2Dmk3hDjGfNSmLKY QNjeGVbktfJ4IOJqf2EFaG0eDqLNRvXzG20Qf2PVipng1nNURWnJ7v+P2vogy6jGYZ/c ccz4Aas4V/5cCNSEbNV6HlJfz8zqn4m81loUuG0Q3bAu7126O4FySsfuiXCSOgjG1LEz jj1g==; 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=Ptqlohha; 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 2adb3069b0e04-5368709ddc2si6620198e87.345.2024.09.22.11.00.35; Sun, 22 Sep 2024 11:00:37 -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=Ptqlohha; 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 B308668DA7D; Sun, 22 Sep 2024 21:00:30 +0300 (EEST) 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 4BA7368D9FD for ; Sun, 22 Sep 2024 21:00:24 +0300 (EEST) 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=Ptqlohha; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 3CF204E07 for ; Sun, 22 Sep 2024 20:00:23 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id h10kvYRUGppQ for ; Sun, 22 Sep 2024 20:00:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727028021; bh=JyZIiJxJdVsqXIV0kGuE1VYPGa10dX1znv0hDDDhtkk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PtqlohhairpVWXQR9LPWTWctyveE1W8FQ4r13Y/gZ7VMtE4sTfBCgnrC/9oHxYF4f mxBAe63E0cqKHRF/gQdvDgsoYYM30Qjy7+yBsbm39JHDyuiCRqL3RgmkQVwTlmjU0U wV98GswrPHz87AyE10fwHaQSQNqCZaXEwxK7bjt/fwhT5m+ttaTcxsSd2GWtEv7h56 AqrmsdlLTt9OTHz6BNofVLzKpR/0T5wzCBjlwdHvrobos5bAPQ3SdiOWgN6OVXyISs Sx68Kum3adCS1XjorG35D+JsNgkPljf8OCeRhMuklNkJiWKn+iIQCeVt//jnTFCw2m q7NyvMWBTX1Kg== 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 968E54DE2 for ; Sun, 22 Sep 2024 20:00:21 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id AE0B03A0998 for ; Sun, 22 Sep 2024 20:00:14 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Sep 2024 20:00:05 +0200 Message-ID: <20240922180005.6549-3-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240922180005.6549-1-anton@khirnov.net> References: <20240922180005.6549-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] lavc/decode: merge stereo3d information from decoder with packet 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: K4Ry7NBQpUOy The HEVC decoder will start setting stereoscopic view position (left or right) based on 3D Reference Displays Info SEI message in future commits. This information should be merged with container-derived stereo3D side data. --- libavcodec/decode.c | 46 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 9303254ef3..ffae322612 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -37,6 +37,7 @@ #include "libavutil/internal.h" #include "libavutil/mastering_display_metadata.h" #include "libavutil/mem.h" +#include "libavutil/stereo3d.h" #include "avcodec.h" #include "avcodec_internal.h" @@ -1417,6 +1418,42 @@ const AVPacketSideData *ff_get_coded_side_data(const AVCodecContext *avctx, return packet_side_data_get(avctx->coded_side_data, avctx->nb_coded_side_data, type); } +static int side_data_stereo3d_merge(AVFrameSideData *sd_frame, + const AVPacketSideData *sd_pkt) +{ + const AVStereo3D *src; + AVStereo3D *dst; + int ret; + + ret = av_buffer_make_writable(&sd_frame->buf); + if (ret < 0) + return ret; + sd_frame->data = sd_frame->buf->data; + + dst = ( AVStereo3D*)sd_frame->data; + src = (const AVStereo3D*)sd_pkt->data; + + if (dst->type == AV_STEREO3D_UNSPEC) + dst->type = src->type; + + if (dst->view == AV_STEREO3D_VIEW_UNSPEC) + dst->view = src->view; + + if (dst->primary_eye == AV_PRIMARY_EYE_NONE) + dst->primary_eye = src->primary_eye; + + if (!dst->baseline) + dst->baseline = src->baseline; + + if (!dst->horizontal_disparity_adjustment.num) + dst->horizontal_disparity_adjustment = src->horizontal_disparity_adjustment; + + if (!dst->horizontal_field_of_view.num) + dst->horizontal_field_of_view = src->horizontal_field_of_view; + + return 0; +} + static int side_data_map(AVFrame *dst, const AVPacketSideData *sd_src, int nb_sd_src, const SideDataMap *map) @@ -1433,8 +1470,15 @@ static int side_data_map(AVFrame *dst, continue; sd_frame = av_frame_get_side_data(dst, type_frame); - if (sd_frame) + if (sd_frame) { + if (type_frame == AV_FRAME_DATA_STEREO3D) { + int ret = side_data_stereo3d_merge(sd_frame, sd_pkt); + if (ret < 0) + return ret; + } + continue; + } sd_frame = av_frame_new_side_data(dst, type_frame, sd_pkt->size); if (!sd_frame)