From patchwork Sun Jan 27 18:40:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dilshod Mukhtarov X-Patchwork-Id: 11876 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 D98CA44DE98 for ; Sun, 27 Jan 2019 20:40:33 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EF00068AF2C; Sun, 27 Jan 2019 20:40:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CD94B68AF15 for ; Sun, 27 Jan 2019 20:40:15 +0200 (EET) Received: by mail-wr1-f44.google.com with SMTP id p4so15569677wrt.7 for ; Sun, 27 Jan 2019 10:40:35 -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=8iKvPg002VX6padjTyRYDVyM55n5qYHtfPAACJAvns0=; b=uDJelOaqgAmFJPk9eonZ1mnjdDabSfdC0gZ2x2KJy5ZKKQAK5pT3GT6NnfMORGcGsN ABEjeyBBxomXX4NkNGAgCKq8PFNbNoFGzqkNB+I6nRvENxDR23hIiZ86iH+033JnGgH3 S//xfCg9UNM/3EFgKuvyVuvV4jsZnRHKXNj+/0mlQXGU1QjrRw8zQMWQXBJz3iLbe1ug iIWTL5n3BSpox+8rD7HFsxnEP7s+DTNcya7K52g5J1EiRepYfvC8Uut4ZQFEgJyDXPOw jSmrwXYFNB9uON8SN8YuwzQt/Xl1xN6kNvZlFK3Oai3uh8zfG7g2NbavpKvrqhW/hf5G LlQg== 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=8iKvPg002VX6padjTyRYDVyM55n5qYHtfPAACJAvns0=; b=udJ4eWilQMh+wdrzIXznypRJHNhxqzq56GlfvqbsZ5s9DLOlsasMOwoN7VG606EJuh JnVWX4f4/Xp24mgcGJ6m6pPyhk2Mlmj2T2Y5jo4J1m2+T3W0V+i7HVndJ6VMehCGCT+C 1mb9MgvKeradvDUsa9tRGjkMHGEGtiKvm/sTvZg0ZvHVnCtzhTfdK3PZ5Hg1lFKTPOEW QrF2fj9aW0KkTr1E5eaDNfhpLE3zbz4xizV7q2wtGzcwjpLRlgwCg3cY3mxTnPaHgWkk fSoKSasGdsJBq643dJB0TgWP+vhGdzSYHPYfu5RLpglFN5M+aszwaFeyKDiFaGng5wW3 O1QQ== X-Gm-Message-State: AJcUukeZzLeNiw9AaZg7nGFOmkFoNDXFaYbz89wYFguFcwvLV3BkzYuX O01zxReIW6Fag81/pG35SrbEaemFbIo= X-Google-Smtp-Source: ALg8bN5vfE++joasihUSzUhOklY+Gi5RSKLPQuBoG1L4u88DODVOtr4LJCZkrjfk9ni8lBdTQvTQXQ== X-Received: by 2002:adf:92c7:: with SMTP id 65mr17884922wrn.228.1548614434437; Sun, 27 Jan 2019 10:40:34 -0800 (PST) Received: from [192.168.101.101] ([5.30.109.119]) by smtp.googlemail.com with ESMTPSA id v6sm112851841wrd.88.2019.01.27.10.40.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Jan 2019 10:40:33 -0800 (PST) To: ffmpeg-devel@ffmpeg.org References: <13d761d6-5e68-c01a-ba09-fb565719652f@gmail.com> From: Dilshod Mukhtarov Message-ID: <1bf60608-926b-9862-6535-ad9c50835421@gmail.com> Date: Sun, 27 Jan 2019 22:40:31 +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 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 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" Hi Carl, Thanks for advices. I split the patch to two distinct parts. The first part is here and the next one in a new message. On 27.01.2019 4:45, Carl Eugen Hoyos wrote: > 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. > > Please put "else" on the same line as "}", no linebreak > between "}" and "else". > >> 1) Mouse position was not calculated properly in area or window mode >> 2) In window mode the size of window was not calculated properly (cropped) > This may not apply here, but typically, if a patch says "fixes A and B", > it should be split in two patches to ease review and future debugging. > > Carl Eugen > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From 618c77964c6d15f5482d7298c0639b3c3452203b Mon Sep 17 00:00:00 2001 From: Dilshod Mukhtarov Date: Sun, 27 Jan 2019 22:27:35 +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 | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c index ab08c11788..f2c3077523 100644 --- a/libavdevice/gdigrab.c +++ b/libavdevice/gdigrab.c @@ -235,14 +235,12 @@ gdigrab_read_header(AVFormatContext *s1) AVStream *st = NULL; int bpp; - int horzres; - int vertres; - int desktophorzres; - int desktopvertres; RECT virtual_rect; RECT clip_rect; BITMAP bmp; int ret; + AVRational h_dpr; // Horizontal device pixel ratio + AVRational v_dpr; // Vertical device pixel ratio if (!strncmp(filename, "title=", 6)) { name = filename + 6; @@ -277,18 +275,21 @@ gdigrab_read_header(AVFormatContext *s1) } bpp = GetDeviceCaps(source_hdc, BITSPIXEL); + h_dpr = av_make_q(GetDeviceCaps(source_hdc, DESKTOPHORZRES), GetDeviceCaps(source_hdc, HORZRES)); + v_dpr = av_make_q(GetDeviceCaps(source_hdc, DESKTOPVERTRES), GetDeviceCaps(source_hdc, VERTRES)); + if (hwnd) { GetClientRect(hwnd, &virtual_rect); + virtual_rect.left *= av_q2d(h_dpr); + virtual_rect.right *= av_q2d(h_dpr); + virtual_rect.top *= av_q2d(v_dpr); + virtual_rect.bottom *= av_q2d(v_dpr); } 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; - virtual_rect.bottom = (virtual_rect.top + GetSystemMetrics(SM_CYVIRTUALSCREEN)) * desktopvertres / vertres; + virtual_rect.right = (virtual_rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN)) * av_q2d(h_dpr); + virtual_rect.bottom = (virtual_rect.top + GetSystemMetrics(SM_CYVIRTUALSCREEN)) * av_q2d(v_dpr); } /* If no width or height set, use full screen/window area */ -- 2.17.1