From patchwork Sun Jan 27 19:14:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dilshod Mukhtarov X-Patchwork-Id: 11880 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B69E244C935 for ; Sun, 27 Jan 2019 21:14:18 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D1AA168AF88; Sun, 27 Jan 2019 21:14:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 39AAD68AF81 for ; Sun, 27 Jan 2019 21:14:00 +0200 (EET) Received: by mail-wm1-f45.google.com with SMTP id r24so8779143wmh.0 for ; Sun, 27 Jan 2019 11:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=tCMN45X13hJYIO1r5wq1RrEHTll9NowlaJrSRgDd5eE=; b=iIbx59Giq9oQqxaEomPplY+M+oYFrDHv1PQ0Uc7IhEioOkRmr8ciu4+D8jG1u4/saB tgHKjGad1bDo4PY1sIjNdGb0XS7LNRoA+QWtfnLJquFg2tWh1SajBX2k714+bWb3XQKR XHssyhRCWa1q2Z7EJKWrRUiduJFHpXe2neaMSmJ1kMuJ4rbMJXwOssZg479WC/gABL0W T7c+iRdqMMVYNC+ewBfGpnSmrxmoipy2ekV3eKWGR5Na2Sfv6rnvrDwTSLZ9SLT6zoud FlUGAkv8WMzcnsTjhRBaDL0vSKryrADmQNEn5D5AYSrgtJadtsxfMMeXNjS8IjDjkwFA N+9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=tCMN45X13hJYIO1r5wq1RrEHTll9NowlaJrSRgDd5eE=; b=klNJvJQZRnEhGzp0/PNSRYUXm0MPawLTSWTv8yvSX3wB7e9E8B38tGGiTu7NDPM8Et Aosesswgmg841WWPAiqnz+trR56dWgAdxgxTY+7N2qhCviBhBl2w7fHUPFNl9KpVLffv D1NjVmtXb4pYKaQoPzsaxT+dr5/0ktkJNYamhWLsQERpWTi8Jz9Wqre9A9l5R3yWioSQ be/dXyrepvnYxh4w1bz8lCRJuos/8yCb8QrMhIYKMK5RUoxHvU7QgwzcBXn39TWIxQER hUHXh5s/5zzc21i4GZS9J42uhsnEjOq1XsQBr3kZNYLFMraQlp2+NaXD/e6Ik/r3Xh6h t0Zg== X-Gm-Message-State: AJcUukfhyb6Hqv5o0xE7TT/edBqH3AvWSglmoE2sNzEpYZgD+P/IGKof cjSPqThk5aTgIypuokDan0zVjxjvXKI= X-Google-Smtp-Source: AHgI3Ib0VZiEnH4fuScbPWn7VksaoXA6Btvis94FlQlfEzqBkltsMm5E5iWbeZb58HThCK4OwJKprQ== X-Received: by 2002:a1c:5f04:: with SMTP id t4mr2201245wmb.141.1548616459021; Sun, 27 Jan 2019 11:14:19 -0800 (PST) Received: from [192.168.101.101] ([5.30.109.119]) by smtp.googlemail.com with ESMTPSA id z206sm84289851wmc.18.2019.01.27.11.14.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Jan 2019 11:14:18 -0800 (PST) To: ffmpeg-devel@ffmpeg.org References: <13d761d6-5e68-c01a-ba09-fb565719652f@gmail.com> From: Dilshod Mukhtarov Message-ID: <2d146a0e-6459-89a6-1dc9-c9b173a1aafa@gmail.com> Date: Sun, 27 Jan 2019 23:14:15 +0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Subject: Re: [FFmpeg-devel] gdigrab: fix HIDPI support X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" On 27.01.2019 22:51, Carl Eugen Hoyos wrote: > 2019-01-27 1:45 GMT+01:00, Carl Eugen Hoyos : >> 2019-01-26 18:53 GMT+01:00, Dilshod Mukhtarov : >>> HI, this is the patch that fixes HIDPI support in gdigrab >>> + double h_dpr; // Horizontal device pixel ratio >>> + double v_dpr; // Vertical device pixel ratio >> I would expect these to be AVRational, if this is not >> possible, it should be explained why. > Sorry if this was not an ideal comment, it should have been: > All aspect ratio calculations (and all calculations related to > aspect ratio) do not need double (or floats) but should be > done as integer calculations. AVRational structs are often > used, theoretically they may not be needed. I attached new version of the patch, which uses integer arithmetics From 1db3c6d3bc8320330cd2908ef50c27e55dcfdf43 Mon Sep 17 00:00:00 2001 From: Dilshod Mukhtarov Date: Sun, 27 Jan 2019 23:09:53 +0400 Subject: [PATCH 1/2] libavdevice/gdigrab: fix HIDPI support for window capture In Windows if using scaling other than 100% then the grabbed window was not captured fully (cropped) Signed-off-by: Dilshod Mukhtarov --- libavdevice/gdigrab.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c index ab08c11788..0e6ae2bd5d 100644 --- a/libavdevice/gdigrab.c +++ b/libavdevice/gdigrab.c @@ -277,14 +277,20 @@ gdigrab_read_header(AVFormatContext *s1) } bpp = GetDeviceCaps(source_hdc, BITSPIXEL); + horzres = GetDeviceCaps(source_hdc, HORZRES); + vertres = GetDeviceCaps(source_hdc, VERTRES); + desktophorzres = GetDeviceCaps(source_hdc, DESKTOPHORZRES); + desktopvertres = GetDeviceCaps(source_hdc, DESKTOPVERTRES); + if (hwnd) { GetClientRect(hwnd, &virtual_rect); + /* window -- get the right height and width for scaling DPI */ + virtual_rect.left = virtual_rect.left * desktophorzres / horzres; + virtual_rect.right = virtual_rect.right * desktophorzres / horzres; + virtual_rect.top = virtual_rect.top * desktopvertres / vertres; + virtual_rect.bottom = virtual_rect.bottom * desktopvertres / vertres; } else { /* desktop -- get the right height and width for scaling DPI */ - horzres = GetDeviceCaps(source_hdc, HORZRES); - vertres = GetDeviceCaps(source_hdc, VERTRES); - desktophorzres = GetDeviceCaps(source_hdc, DESKTOPHORZRES); - desktopvertres = GetDeviceCaps(source_hdc, DESKTOPVERTRES); virtual_rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN); virtual_rect.top = GetSystemMetrics(SM_YVIRTUALSCREEN); virtual_rect.right = (virtual_rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN)) * desktophorzres / horzres; -- 2.17.1