From patchwork Mon May 9 20:23:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Lancaster X-Patchwork-Id: 35711 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp3083897pzb; Mon, 9 May 2022 13:23:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzA+3xxq2GqkY3lc5cEjHP5DFWE0bTjbvbHHRXkjDAW8q5uxcZvVj6UeCRsXqTJtBJ1ObVP X-Received: by 2002:a05:6402:2808:b0:427:c823:8152 with SMTP id h8-20020a056402280800b00427c8238152mr19113340ede.84.1652127812346; Mon, 09 May 2022 13:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652127812; cv=none; d=google.com; s=arc-20160816; b=h8mLKdYXLWypobE2sa7mWu8jUycXZ7MTWn84SjM08+dB9jnEsixglOecqTCF9EVOMc MCehz6yWv94oPI+R92LRY1U81gHF9As64Akg6l+0cRC/YTUm2tIyiEpmiuQJr1l9sbya /XUMl0KmcuhfD5pH1JbyUrWa4mrsSlnTWzdWa+PanTf1dr2gbdFiZ1AbIZg/27+7QYjs 2Jv0w4PtnCsXn0iYH4uNuepV3OotipEUfU0YtXJeM5CQ+sRBLfdencQtoElDzQp/y2JO HzJH0gnl7RNeq7Jp7UcgSUOZGQ8V0wAxJiiOMxlyx818Wv6ABS1lwb9L81tQ38LQHIpQ 2m4Q== 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:to:message-id:date:from:mime-version :dkim-signature:delivered-to; bh=7lRMi8g/nEUDvGE2ezpzArDHBcyWq8Cr3XyF0FmmcJI=; b=BCN2eQ7ps9Qnm35hwz9/vNDmpWTk73ZQq83I7yaJ27aK6ofeGnLIkGDVX4L9BeUgal i258X39wRyYb8wJPYHnwsMcANSQu4ra2jof5pevFfMY1WIEmzd6BWTkFfrnTyRJkdWCD wa3MLfj4LQ62GgOpab3UCx244bf94cUFdH0Xc5DMELwVdph5iUucdA9j97p+WEhYeRr9 YMIs5VS1wzQxHiq8pgXklQid3HDMIgUCCxJ/x2jkezJyInwFPSMfAjofQKM094X3/XnF okxCWCjwvpsJcSkOd5DKxZGg4rdz9r6LZumDuhu0JkIDr8EZjVaU6j05uwmhpgHVNk1O lGUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="NNt/3Btu"; 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 e21-20020a170906315500b006f47e8eaf84si1805356eje.645.2022.05.09.13.23.31; Mon, 09 May 2022 13:23:32 -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=20210112 header.b="NNt/3Btu"; 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 765C968B39C; Mon, 9 May 2022 23:23:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 481886881B1 for ; Mon, 9 May 2022 23:23:22 +0300 (EEST) Received: by mail-yb1-f170.google.com with SMTP id g28so27007336ybj.10 for ; Mon, 09 May 2022 13:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=be3flzBCAbv1hEAJ3LW+HlbPAPm5sbL57DvgoIpQbVs=; b=NNt/3BtuX8cRwc/K4VGHTqGUv4e9cjJe2NCsZXpz80Ml7Ld59+WUo0dRH94WKcPyVV o+yOIxhWqZAqrCzCR/goOrAQ63v/1DAvTt+Ss9JFKskDkvzzpZ1d95vx0kL8DsmSNH3+ GRErBj0Hk4N519RjgBX1sf5sMWiZEIvJMFWVSiBPhViItSkgWW696XC8tUk6Vp3WztP2 K38iy8lPn5o3SlxZ8MwBT3XxOIKEdcqGrn5qnkh97kW1JBukrG9f1tpFMjyzQvHWuvYm VX/4Y+6uQgrkUvcDidjpNOJVipG/vx/NGXw2szFWdZKEmdSNYD1gUBuAgVzRIL2J9J/A YsBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=be3flzBCAbv1hEAJ3LW+HlbPAPm5sbL57DvgoIpQbVs=; b=4dxqc2gWfguMbvNNNDJTYBKTNZ/oAr43NihJtoHAtrAKDXMx6zEZh51eAjccC0nLXs YoUaVsDFt16DxcImZVdBx9vkTEbVHtup4XNSbzvPNO5VttVk2EweJF5dieChZhRopS+r 37UFQ44B04i/RNs4lIP79Q/Fl1sHxoVxs4ScWeF2fCRTc27dZbSAQ99GhDNBwr21LQ9w MlqIRfyUK53ajl0sRBQ40BRluBOqFaDmLJU0zgrHj9TJd8repA0p4cFtGm0OQGpHlvkT UOW5UvcWhUxCDVIp1SZA306/xdjXR6negCXF+phSODaPOa3bojoSX2wjEWeGGefGjyTa 24ig== X-Gm-Message-State: AOAM5309W972LKUtGPC/G6WYYNXqzpT2KbWRJ4SvTIM4OeO3qWPm75Ug NTEzFpf3PS2JMpAThXp1t0fQcXwIGkPbCLph9EMyVRllRXQ= X-Received: by 2002:a25:db8f:0:b0:648:a5e3:e254 with SMTP id g137-20020a25db8f000000b00648a5e3e254mr14534898ybf.465.1652127800752; Mon, 09 May 2022 13:23:20 -0700 (PDT) MIME-Version: 1.0 From: James Lancaster Date: Mon, 9 May 2022 15:23:09 -0500 Message-ID: To: ffmpeg-devel@ffmpeg.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH 1/1] Add Mono/2D option to stereo3d filter 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: W//tr7rjPis6 The following patch adds the option for mono input to the stereo3d filter, allowing a 2D video source to be duplicated to any of the output formats. This enables a few things which I find very useful: 1. Playing regular videos on VR headsets. Using this to simply use the VR headset as a HMD without affecting anything else. Example usage: ffplay -vf stereo3d=mono:sbsl 2dvideofile.avi Will simply modify it to display everywhere. 2. Screen capture and display on VR headsets as a 2D video. This is something which for me works FAR better than any of the VR 'desktop' software which enables you to use your desktop in a VR space (which always gives me a headache). In fact even watching videos of it gives me a headache. Whereas I spent about 5 hours using my system this way yesterday with no headache or problems aside from that (well and the whole not being able to see things) Note for anyone using this: I do recommend only going lower to the same resolution or higher resolution, if possible. Examples: (Main monitor set at 1280x1024 and off, and the VR headset) Basic capture: ffplay -vf stereo3d=mono:sbsl -video_size 1280x1024 -f x11grab :0.0+0,0 Also to pad it out, so you can see all of it. (Most Desktops aren't quite setup for circular view.) This adds a 300 px border around the left/right (and by default top bottom) which means that everything is in view in my headset. ffplay -vf pad=1580:1080:150:0,stereo3d=mono:sbsl -video_size 1280x1024 -f x11grab :0.0+0,0 The default is pretty much exactly what is needed (frame copied to both right and left output) this patch is pretty trivial, and I've used it on multiple versions, but forgot to submit the patch for it in the past. Since I don't see anything in particular about it, just to cover bases (And if there's anything I did wrong, let me know so I can fix it in future submissions): Permission to apply and redistribute under the GNU GPL v2 or later versions granted (As is the case for the file) 2022 James Lancaster --- libavfilter/vf_stereo3d.c | 4 ++++ 1 file changed, 4 insertions(+) STEREO_CODE_COUNT // TODO: needs autodetection }; @@ -177,6 +178,7 @@ static const AVOption stereo3d_options[] = { { "irr", "interleave rows right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_ROWS_RL}, 0, 0, FLAGS, "in" }, { "icl", "interleave columns left first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_LR}, 0, 0, FLAGS, "in" }, { "icr", "interleave columns right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_RL}, 0, 0, FLAGS, "in" }, + { "mono", "2D video", 0, AV_OPT_TYPE_CONST, {.i64=MONO}, 0, 0, FLAGS, "in" }, { "out", "set output format", OFFSET(out.format), AV_OPT_TYPE_INT, {.i64=ANAGLYPH_RC_DUBOIS}, 0, STEREO_CODE_COUNT-1, FLAGS, "out"}, { "ab2l", "above below half height left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_LR}, 0, 0, FLAGS, "out" }, { "tb2l", "above below half height left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_LR}, 0, 0, FLAGS, "out" }, @@ -452,6 +454,8 @@ static int config_output(AVFilterLink *outlink) s->out.format != CHECKERBOARD_RL) s->height = inlink->h / 2; break; + case MONO: + break; default: av_log(ctx, AV_LOG_ERROR, "input format %d is not supported\n", s->in.format); return AVERROR(EINVAL); -- 2.32.0 diff --git a/libavfilter/vf_stereo3d.c b/libavfilter/vf_stereo3d.c index 0ba18861af..09397af14a 100644 --- a/libavfilter/vf_stereo3d.c +++ b/libavfilter/vf_stereo3d.c @@ -66,6 +66,7 @@ enum StereoCode { INTERLEAVE_COLS_LR, // column-interleave (left eye first, right eye second) INTERLEAVE_COLS_RL, // column-interleave (right eye first, left eye second) HDMI, // HDMI frame pack (left eye first, right eye second) + MONO, // Mono input for 2d to 3d