VirtualBox

source: vbox/trunk/src/VBox/Main/testcase/tstRecording.cpp

Last change on this file was 105006, checked in by vboxsync, 6 months ago

Video Recording: Big revamp to improve overall performance. We now don't rely on the periodic display refresh callback anymore to render the entire framebuffer but now rely on delta updates ("dirty rectangles"). Also, we now only encode new frames when an area has changed. This also needed cursor position + change change notifications, as we render the cursor on the host side if mouse integration is enabled (requires 7.1 Guest Additions as of now). Optimized the BGRA32->YUV IV420 color space conversion as well as the overall amount of pixel data shuffled forth and back. Added a new testcase for the cropping/centering code. bugref:10650

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1/* $Id: tstRecording.cpp 105006 2024-06-24 17:43:00Z vboxsync $ */
2/** @file
3 * Recording testcases.
4 */
5
6/*
7 * Copyright (C) 2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#include <iprt/test.h>
33#include <VBox/err.h>
34
35#include "RecordingUtils.h"
36
37
38/** Tests centering / cropped centering of coordinates. */
39static void testCenteredCrop(RTTEST hTest)
40{
41 RTTestSub(hTest, "testCenteredCrop");
42
43 RECORDINGCODECPARMS Parms;
44
45 #define INIT_CROP(/* Framebuffer width / height */ a_fw, a_fh, \
46 /* Video (codec) width / height */ a_vw, a_vh) \
47 Parms.u.Video.uWidth = a_vw; \
48 Parms.u.Video.uHeight = a_vh; \
49 Parms.u.Video.Scaling.u.Crop.m_iOriginX = int32_t(Parms.u.Video.uWidth - a_fw) / 2; \
50 Parms.u.Video.Scaling.u.Crop.m_iOriginY = int32_t(Parms.u.Video.uHeight - a_fh) / 2;
51
52 #define TEST_CROP(/* Source In */ a_in_sx, a_in_sy, a_in_sw, a_in_sh, \
53 /* Dest In */ a_in_dx, a_in_dy, \
54 /* Source Out */ a_out_sx, a_out_sy, a_out_sw, a_out_sh, \
55 /* Dest Out */ a_out_dx, a_out_dy, out_rc) \
56 { \
57 int32_t sx = a_in_sx; int32_t sy = a_in_sy; int32_t sw = a_in_sw; int32_t sh = a_in_sh; \
58 int32_t dx = a_in_dx; int32_t dy = a_in_dy; \
59 RTTEST_CHECK_RC (hTest, RecordingUtilsCoordsCropCenter(&Parms, &sx, &sy, &sw, &sh, &dx, &dy), out_rc); \
60 RTTEST_CHECK_MSG(hTest, sx == a_out_sx, (hTest, "Expected a_out_sx == %RI16, but got %RI16\n", a_out_sx, sx)); \
61 RTTEST_CHECK_MSG(hTest, sy == a_out_sy, (hTest, "Expected a_out_sy == %RI16, but got %RI16\n", a_out_sy, sy)); \
62 RTTEST_CHECK_MSG(hTest, sw == a_out_sw, (hTest, "Expected a_out_sw == %RI16, but got %RI16\n", a_out_sw, sw)); \
63 RTTEST_CHECK_MSG(hTest, sh == a_out_sh, (hTest, "Expected a_out_sh == %RI16, but got %RI16\n", a_out_sh, sh)); \
64 RTTEST_CHECK_MSG(hTest, dx == a_out_dx, (hTest, "Expected a_out_dx == %RI16, but got %RI16\n", a_out_dx, dx)); \
65 RTTEST_CHECK_MSG(hTest, dy == a_out_dy, (hTest, "Expected a_out_dy == %RI16, but got %RI16\n", a_out_dy, dy)); \
66 }
67
68 /*
69 * No center / cropping performed (framebuffer and video codec are of the same size).
70 */
71 INIT_CROP(1024, 768, 1024, 768);
72 TEST_CROP(0, 0, 1024, 768,
73 0, 0,
74 0, 0, 1024, 768,
75 0, 0, VINF_SUCCESS);
76 /* Source is bigger than allowed. */
77 TEST_CROP(0, 0, 2048, 1536,
78 0, 0,
79 0, 0, 1024, 768,
80 0, 0, VINF_SUCCESS);
81 /* Source is bigger than allowed. */
82 TEST_CROP(1024, 768, 2048, 1536,
83 0, 0,
84 1024, 768, 1024, 768,
85 0, 0, VINF_SUCCESS);
86 /* Check limits with custom destination. */
87 TEST_CROP(0, 0, 1024, 768,
88 512, 512,
89 0, 0, 512, 256,
90 512, 512, VINF_SUCCESS);
91 TEST_CROP(512, 512, 1024, 768,
92 512, 512,
93 512, 512, 512, 256,
94 512, 512, VINF_SUCCESS);
95 TEST_CROP(512, 512, 1024, 768,
96 1024, 768,
97 512, 512, 0, 0,
98 1024, 768, VWRN_RECORDING_ENCODING_SKIPPED);
99 TEST_CROP(1024, 768, 1024, 768,
100 1024, 768,
101 1024, 768, 0, 0,
102 1024, 768, VWRN_RECORDING_ENCODING_SKIPPED);
103
104 /*
105 * Framebuffer is twice the size of the video codec -- center crop the framebuffer.
106 */
107 INIT_CROP(2048, 1536, 1024, 768);
108 TEST_CROP(0, 0, 2048, 1536,
109 0, 0,
110 512, 384, 1024, 768,
111 0, 0, VINF_SUCCESS);
112
113 TEST_CROP(1024, 768, 1024, 768,
114 0, 0,
115 1536, 1152, 512, 384,
116 0, 0, VINF_SUCCESS);
117 /* Check limits with custom destination. */
118 TEST_CROP(1024, 768, 1024, 768,
119 512, 384,
120 1024, 768, 1024, 768,
121 0, 0, VINF_SUCCESS);
122 TEST_CROP(1024, 768, 1024, 768,
123 512 + 42, 384 + 42,
124 1024, 768, 1024 - 42, 768 - 42,
125 42, 42, VINF_SUCCESS);
126 TEST_CROP(1024, 768, 1024 * 2, 768 * 2,
127 512, 384,
128 1024, 768, 1024, 768,
129 0, 0, VINF_SUCCESS);
130
131 /*
132 * Framebuffer is half the size of the video codec -- center (but not crop) the framebuffer within the video output.
133 */
134 INIT_CROP(1024, 768, 2048, 1536);
135 TEST_CROP(0, 0, 1024, 768,
136 0, 0,
137 0, 0, 1024, 768,
138 512, 384, VINF_SUCCESS);
139
140#undef INIT_CROP
141#undef TEST_CROP
142}
143
144int main()
145{
146 RTTEST hTest;
147 RTEXITCODE rcExit = RTTestInitAndCreate("tstRecording", &hTest);
148 if (rcExit == RTEXITCODE_SUCCESS)
149 {
150 RTTestBanner(hTest);
151
152 testCenteredCrop(hTest);
153
154 rcExit = RTTestSummaryAndDestroy(hTest);
155 }
156 return rcExit;
157}
158
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette