3 #include <winpr/wtypes.h>
5 #include <winpr/string.h>
6 #include <winpr/path.h>
7 #include <winpr/image.h>
8 #include <winpr/print.h>
9 #include <winpr/wlog.h>
10 #include <winpr/sysinfo.h>
11 #include <winpr/file.h>
13 #include <freerdp/codec/region.h>
15 #include <freerdp/codecs.h>
16 #include <freerdp/utils/gfx.h>
18 #include <freerdp/codec/progressive.h>
19 #include <freerdp/channels/rdpgfx.h>
20 #include <freerdp/crypto/crypto.h>
22 #include "../progressive.h"
144 static int g_Width = 0;
145 static int g_Height = 0;
146 static int g_DstStep = 0;
147 static BYTE* g_DstData = NULL;
149 static void sample_file_free(EGFX_SAMPLE_FILE* file)
159 static void test_fill_image_alpha_channel(BYTE* data,
int width,
int height, BYTE value)
161 UINT32* pixel = NULL;
163 for (
int i = 0; i < height; i++)
165 for (
int j = 0; j < width; j++)
167 pixel = (UINT32*)&data[((1ULL * i * width) + j) * 4ULL];
168 *pixel = ((*pixel & 0x00FFFFFF) | (value << 24));
173 static void* test_image_memset32(UINT32* ptr, UINT32 fill,
size_t length)
183 static int test_image_fill(BYTE* pDstData,
int nDstStep,
int nXDst,
int nYDst,
int nWidth,
184 int nHeight, UINT32 color)
186 UINT32* pDstPixel = NULL;
189 nDstStep = 4 * nWidth;
191 for (
int y = 0; y < nHeight; y++)
193 pDstPixel = (UINT32*)&pDstData[((nYDst + y) * nDstStep) + (nXDst * 4)];
194 test_image_memset32(pDstPixel, color, nWidth);
200 static int test_image_fill_quarter(BYTE* pDstData,
int nDstStep,
int nWidth,
int nHeight,
201 UINT32 color,
int quarter)
214 height = nHeight / 2;
221 height = nHeight / 2;
228 height = nHeight / 2;
235 height = nHeight / 2;
241 test_image_fill(pDstData, nDstStep, x, y, width, height, 0xFF000000);
245 static int test_image_fill_unused_quarters(BYTE* pDstData,
int nDstStep,
int nWidth,
int nHeight,
246 UINT32 color,
int quarter)
252 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 1);
253 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 2);
254 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 3);
256 else if (quarter == 1)
258 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 0);
259 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 2);
260 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 3);
262 else if (quarter == 2)
264 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 0);
265 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 1);
266 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 3);
268 else if (quarter == 3)
270 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 0);
271 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 1);
272 test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 2);
278 static BYTE* test_progressive_load_file(
const char* path,
const char* file,
size_t* size)
280 char* filename = GetCombinedPath(path, file);
285 FILE* fp = winpr_fopen(filename,
"r");
291 (void)_fseeki64(fp, 0, SEEK_END);
292 const INT64 pos = _ftelli64(fp);
293 WINPR_ASSERT(pos >= 0);
294 WINPR_ASSERT(pos <= SIZE_MAX);
296 (void)_fseeki64(fp, 0, SEEK_SET);
297 BYTE* buffer = (BYTE*)malloc(*size);
305 if (fread(buffer, *size, 1, fp) != 1)
316 static int test_progressive_load_files(
char* ms_sample_path, EGFX_SAMPLE_FILE files[3][4][4])
322 files[imageNo][quarterNo][passNo].buffer =
323 test_progressive_load_file(ms_sample_path,
"compress/enc_0_0_025_sampleimage1.bin",
324 &(files[imageNo][quarterNo][passNo].size));
325 passNo = (passNo + 1) % 4;
326 files[imageNo][quarterNo][passNo].buffer =
327 test_progressive_load_file(ms_sample_path,
"compress/enc_0_0_050_sampleimage1.bin",
328 &(files[imageNo][quarterNo][passNo].size));
329 passNo = (passNo + 1) % 4;
330 files[imageNo][quarterNo][passNo].buffer =
331 test_progressive_load_file(ms_sample_path,
"compress/enc_0_0_075_sampleimage1.bin",
332 &(files[imageNo][quarterNo][passNo].size));
333 passNo = (passNo + 1) % 4;
334 files[imageNo][quarterNo][passNo].buffer =
335 test_progressive_load_file(ms_sample_path,
"compress/enc_0_0_100_sampleimage1.bin",
336 &(files[imageNo][quarterNo][passNo].size));
337 passNo = (passNo + 1) % 4;
338 quarterNo = (quarterNo + 1) % 4;
339 files[imageNo][quarterNo][passNo].buffer =
340 test_progressive_load_file(ms_sample_path,
"compress/enc_0_1_025_sampleimage1.bin",
341 &(files[imageNo][quarterNo][passNo].size));
342 passNo = (passNo + 1) % 4;
343 files[imageNo][quarterNo][passNo].buffer =
344 test_progressive_load_file(ms_sample_path,
"compress/enc_0_1_050_sampleimage1.bin",
345 &(files[imageNo][quarterNo][passNo].size));
346 passNo = (passNo + 1) % 4;
347 files[imageNo][quarterNo][passNo].buffer =
348 test_progressive_load_file(ms_sample_path,
"compress/enc_0_1_075_sampleimage1.bin",
349 &(files[imageNo][quarterNo][passNo].size));
350 passNo = (passNo + 1) % 4;
351 files[imageNo][quarterNo][passNo].buffer =
352 test_progressive_load_file(ms_sample_path,
"compress/enc_0_1_100_sampleimage1.bin",
353 &(files[imageNo][quarterNo][passNo].size));
354 passNo = (passNo + 1) % 4;
355 quarterNo = (quarterNo + 1) % 4;
356 files[imageNo][quarterNo][passNo].buffer =
357 test_progressive_load_file(ms_sample_path,
"compress/enc_0_2_025_sampleimage1.bin",
358 &(files[imageNo][quarterNo][passNo].size));
359 passNo = (passNo + 1) % 4;
360 files[imageNo][quarterNo][passNo].buffer =
361 test_progressive_load_file(ms_sample_path,
"compress/enc_0_2_050_sampleimage1.bin",
362 &(files[imageNo][quarterNo][passNo].size));
363 passNo = (passNo + 1) % 4;
364 files[imageNo][quarterNo][passNo].buffer =
365 test_progressive_load_file(ms_sample_path,
"compress/enc_0_2_075_sampleimage1.bin",
366 &(files[imageNo][quarterNo][passNo].size));
367 passNo = (passNo + 1) % 4;
368 files[imageNo][quarterNo][passNo].buffer =
369 test_progressive_load_file(ms_sample_path,
"compress/enc_0_2_100_sampleimage1.bin",
370 &(files[imageNo][quarterNo][passNo].size));
371 passNo = (passNo + 1) % 4;
372 quarterNo = (quarterNo + 1) % 4;
373 files[imageNo][quarterNo][passNo].buffer =
374 test_progressive_load_file(ms_sample_path,
"compress/enc_0_3_025_sampleimage1.bin",
375 &(files[imageNo][quarterNo][passNo].size));
376 passNo = (passNo + 1) % 4;
377 files[imageNo][quarterNo][passNo].buffer =
378 test_progressive_load_file(ms_sample_path,
"compress/enc_0_3_050_sampleimage1.bin",
379 &(files[imageNo][quarterNo][passNo].size));
380 passNo = (passNo + 1) % 4;
381 files[imageNo][quarterNo][passNo].buffer =
382 test_progressive_load_file(ms_sample_path,
"compress/enc_0_3_075_sampleimage1.bin",
383 &(files[imageNo][quarterNo][passNo].size));
384 passNo = (passNo + 1) % 4;
385 files[imageNo][quarterNo][passNo].buffer =
386 test_progressive_load_file(ms_sample_path,
"compress/enc_0_3_100_sampleimage1.bin",
387 &(files[imageNo][quarterNo][passNo].size));
388 passNo = (passNo + 1) % 4;
391 files[imageNo][quarterNo][passNo].buffer =
392 test_progressive_load_file(ms_sample_path,
"compress/enc_1_0_025_sampleimage2.bin",
393 &(files[imageNo][quarterNo][passNo].size));
394 passNo = (passNo + 1) % 4;
395 files[imageNo][quarterNo][passNo].buffer =
396 test_progressive_load_file(ms_sample_path,
"compress/enc_1_0_050_sampleimage2.bin",
397 &(files[imageNo][quarterNo][passNo].size));
398 passNo = (passNo + 1) % 4;
399 files[imageNo][quarterNo][passNo].buffer =
400 test_progressive_load_file(ms_sample_path,
"compress/enc_1_0_075_sampleimage2.bin",
401 &(files[imageNo][quarterNo][passNo].size));
402 passNo = (passNo + 1) % 4;
403 files[imageNo][quarterNo][passNo].buffer =
404 test_progressive_load_file(ms_sample_path,
"compress/enc_1_0_100_sampleimage2.bin",
405 &(files[imageNo][quarterNo][passNo].size));
406 passNo = (passNo + 1) % 4;
407 quarterNo = (quarterNo + 1) % 4;
408 files[imageNo][quarterNo][passNo].buffer =
409 test_progressive_load_file(ms_sample_path,
"compress/enc_1_1_025_sampleimage2.bin",
410 &(files[imageNo][quarterNo][passNo].size));
411 passNo = (passNo + 1) % 4;
412 files[imageNo][quarterNo][passNo].buffer =
413 test_progressive_load_file(ms_sample_path,
"compress/enc_1_1_050_sampleimage2.bin",
414 &(files[imageNo][quarterNo][passNo].size));
415 passNo = (passNo + 1) % 4;
416 files[imageNo][quarterNo][passNo].buffer =
417 test_progressive_load_file(ms_sample_path,
"compress/enc_1_1_075_sampleimage2.bin",
418 &(files[imageNo][quarterNo][passNo].size));
419 passNo = (passNo + 1) % 4;
420 files[imageNo][quarterNo][passNo].buffer =
421 test_progressive_load_file(ms_sample_path,
"compress/enc_1_1_100_sampleimage2.bin",
422 &(files[imageNo][quarterNo][passNo].size));
423 passNo = (passNo + 1) % 4;
424 quarterNo = (quarterNo + 1) % 4;
425 files[imageNo][quarterNo][passNo].buffer =
426 test_progressive_load_file(ms_sample_path,
"compress/enc_1_2_025_sampleimage2.bin",
427 &(files[imageNo][quarterNo][passNo].size));
428 passNo = (passNo + 1) % 4;
429 files[imageNo][quarterNo][passNo].buffer =
430 test_progressive_load_file(ms_sample_path,
"compress/enc_1_2_050_sampleimage2.bin",
431 &(files[imageNo][quarterNo][passNo].size));
432 passNo = (passNo + 1) % 4;
433 files[imageNo][quarterNo][passNo].buffer =
434 test_progressive_load_file(ms_sample_path,
"compress/enc_1_2_075_sampleimage2.bin",
435 &(files[imageNo][quarterNo][passNo].size));
436 passNo = (passNo + 1) % 4;
437 files[imageNo][quarterNo][passNo].buffer =
438 test_progressive_load_file(ms_sample_path,
"compress/enc_1_2_100_sampleimage2.bin",
439 &(files[imageNo][quarterNo][passNo].size));
440 passNo = (passNo + 1) % 4;
441 quarterNo = (quarterNo + 1) % 4;
442 files[imageNo][quarterNo][passNo].buffer =
443 test_progressive_load_file(ms_sample_path,
"compress/enc_1_3_025_sampleimage2.bin",
444 &(files[imageNo][quarterNo][passNo].size));
445 passNo = (passNo + 1) % 4;
446 files[imageNo][quarterNo][passNo].buffer =
447 test_progressive_load_file(ms_sample_path,
"compress/enc_1_3_050_sampleimage2.bin",
448 &(files[imageNo][quarterNo][passNo].size));
449 passNo = (passNo + 1) % 4;
450 files[imageNo][quarterNo][passNo].buffer =
451 test_progressive_load_file(ms_sample_path,
"compress/enc_1_3_075_sampleimage2.bin",
452 &(files[imageNo][quarterNo][passNo].size));
453 passNo = (passNo + 1) % 4;
454 files[imageNo][quarterNo][passNo].buffer =
455 test_progressive_load_file(ms_sample_path,
"compress/enc_1_3_100_sampleimage2.bin",
456 &(files[imageNo][quarterNo][passNo].size));
457 passNo = (passNo + 1) % 4;
460 files[imageNo][quarterNo][passNo].buffer =
461 test_progressive_load_file(ms_sample_path,
"compress/enc_2_0_025_sampleimage3.bin",
462 &(files[imageNo][quarterNo][passNo].size));
463 passNo = (passNo + 1) % 4;
464 files[imageNo][quarterNo][passNo].buffer =
465 test_progressive_load_file(ms_sample_path,
"compress/enc_2_0_050_sampleimage3.bin",
466 &(files[imageNo][quarterNo][passNo].size));
467 passNo = (passNo + 1) % 4;
468 files[imageNo][quarterNo][passNo].buffer =
469 test_progressive_load_file(ms_sample_path,
"compress/enc_2_0_075_sampleimage3.bin",
470 &(files[imageNo][quarterNo][passNo].size));
471 passNo = (passNo + 1) % 4;
472 files[imageNo][quarterNo][passNo].buffer =
473 test_progressive_load_file(ms_sample_path,
"compress/enc_2_0_100_sampleimage3.bin",
474 &(files[imageNo][quarterNo][passNo].size));
475 passNo = (passNo + 1) % 4;
476 quarterNo = (quarterNo + 1) % 4;
477 files[imageNo][quarterNo][passNo].buffer =
478 test_progressive_load_file(ms_sample_path,
"compress/enc_2_1_025_sampleimage3.bin",
479 &(files[imageNo][quarterNo][passNo].size));
480 passNo = (passNo + 1) % 4;
481 files[imageNo][quarterNo][passNo].buffer =
482 test_progressive_load_file(ms_sample_path,
"compress/enc_2_1_050_sampleimage3.bin",
483 &(files[imageNo][quarterNo][passNo].size));
484 passNo = (passNo + 1) % 4;
485 files[imageNo][quarterNo][passNo].buffer =
486 test_progressive_load_file(ms_sample_path,
"compress/enc_2_1_075_sampleimage3.bin",
487 &(files[imageNo][quarterNo][passNo].size));
488 passNo = (passNo + 1) % 4;
489 files[imageNo][quarterNo][passNo].buffer =
490 test_progressive_load_file(ms_sample_path,
"compress/enc_2_1_100_sampleimage3.bin",
491 &(files[imageNo][quarterNo][passNo].size));
492 passNo = (passNo + 1) % 4;
493 quarterNo = (quarterNo + 1) % 4;
494 files[imageNo][quarterNo][passNo].buffer =
495 test_progressive_load_file(ms_sample_path,
"compress/enc_2_2_025_sampleimage3.bin",
496 &(files[imageNo][quarterNo][passNo].size));
497 passNo = (passNo + 1) % 4;
498 files[imageNo][quarterNo][passNo].buffer =
499 test_progressive_load_file(ms_sample_path,
"compress/enc_2_2_050_sampleimage3.bin",
500 &(files[imageNo][quarterNo][passNo].size));
501 passNo = (passNo + 1) % 4;
502 files[imageNo][quarterNo][passNo].buffer =
503 test_progressive_load_file(ms_sample_path,
"compress/enc_2_2_075_sampleimage3.bin",
504 &(files[imageNo][quarterNo][passNo].size));
505 passNo = (passNo + 1) % 4;
506 files[imageNo][quarterNo][passNo].buffer =
507 test_progressive_load_file(ms_sample_path,
"compress/enc_2_2_100_sampleimage3.bin",
508 &(files[imageNo][quarterNo][passNo].size));
509 passNo = (passNo + 1) % 4;
510 quarterNo = (quarterNo + 1) % 4;
511 files[imageNo][quarterNo][passNo].buffer =
512 test_progressive_load_file(ms_sample_path,
"compress/enc_2_3_025_sampleimage3.bin",
513 &(files[imageNo][quarterNo][passNo].size));
514 passNo = (passNo + 1) % 4;
515 files[imageNo][quarterNo][passNo].buffer =
516 test_progressive_load_file(ms_sample_path,
"compress/enc_2_3_050_sampleimage3.bin",
517 &(files[imageNo][quarterNo][passNo].size));
518 passNo = (passNo + 1) % 4;
519 files[imageNo][quarterNo][passNo].buffer =
520 test_progressive_load_file(ms_sample_path,
"compress/enc_2_3_075_sampleimage3.bin",
521 &(files[imageNo][quarterNo][passNo].size));
522 passNo = (passNo + 1) % 4;
523 files[imageNo][quarterNo][passNo].buffer =
524 test_progressive_load_file(ms_sample_path,
"compress/enc_2_3_100_sampleimage3.bin",
525 &(files[imageNo][quarterNo][passNo].size));
529 for (imageNo = 0; imageNo < 3; imageNo++)
531 for (quarterNo = 0; quarterNo < 4; quarterNo++)
533 for (passNo = 0; passNo < 4; passNo++)
535 if (!files[imageNo][quarterNo][passNo].buffer)
544 static BYTE* test_progressive_load_bitmap(
char* path,
char* file,
size_t* size,
int quarter)
549 char* filename = NULL;
550 filename = GetCombinedPath(path, file);
555 image = winpr_image_new();
560 status = winpr_image_read(image, filename);
565 buffer = image->data;
566 *size = 1ULL * image->height * image->scanline;
567 test_fill_image_alpha_channel(image->data, image->width, image->height, 0xFF);
568 test_image_fill_unused_quarters(image->data, image->scanline, image->width, image->height,
569 quarter, 0xFF000000);
570 winpr_image_free(image, FALSE);
575 static int test_progressive_load_bitmaps(
char* ms_sample_path, EGFX_SAMPLE_FILE bitmaps[3][4][4])
581 bitmaps[imageNo][quarterNo][passNo].buffer =
582 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_0_025_sampleimage1.bmp",
583 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
584 passNo = (passNo + 1) % 4;
585 bitmaps[imageNo][quarterNo][passNo].buffer =
586 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_0_050_sampleimage1.bmp",
587 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
588 passNo = (passNo + 1) % 4;
589 bitmaps[imageNo][quarterNo][passNo].buffer =
590 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_0_075_sampleimage1.bmp",
591 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
592 passNo = (passNo + 1) % 4;
593 bitmaps[imageNo][quarterNo][passNo].buffer =
594 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_0_100_sampleimage1.bmp",
595 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
596 passNo = (passNo + 1) % 4;
597 quarterNo = (quarterNo + 1) % 4;
598 bitmaps[imageNo][quarterNo][passNo].buffer =
599 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_1_025_sampleimage1.bmp",
600 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
601 passNo = (passNo + 1) % 4;
602 bitmaps[imageNo][quarterNo][passNo].buffer =
603 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_1_050_sampleimage1.bmp",
604 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
605 passNo = (passNo + 1) % 4;
606 bitmaps[imageNo][quarterNo][passNo].buffer =
607 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_1_075_sampleimage1.bmp",
608 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
609 passNo = (passNo + 1) % 4;
610 bitmaps[imageNo][quarterNo][passNo].buffer =
611 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_1_100_sampleimage1.bmp",
612 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
613 passNo = (passNo + 1) % 4;
614 quarterNo = (quarterNo + 1) % 4;
615 bitmaps[imageNo][quarterNo][passNo].buffer =
616 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_2_025_sampleimage1.bmp",
617 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
618 passNo = (passNo + 1) % 4;
619 bitmaps[imageNo][quarterNo][passNo].buffer =
620 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_2_050_sampleimage1.bmp",
621 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
622 passNo = (passNo + 1) % 4;
623 bitmaps[imageNo][quarterNo][passNo].buffer =
624 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_2_075_sampleimage1.bmp",
625 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
626 passNo = (passNo + 1) % 4;
627 bitmaps[imageNo][quarterNo][passNo].buffer =
628 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_2_100_sampleimage1.bmp",
629 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
630 passNo = (passNo + 1) % 4;
631 quarterNo = (quarterNo + 1) % 4;
632 bitmaps[imageNo][quarterNo][passNo].buffer =
633 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_3_025_sampleimage1.bmp",
634 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
635 passNo = (passNo + 1) % 4;
636 bitmaps[imageNo][quarterNo][passNo].buffer =
637 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_3_050_sampleimage1.bmp",
638 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
639 passNo = (passNo + 1) % 4;
640 bitmaps[imageNo][quarterNo][passNo].buffer =
641 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_3_075_sampleimage1.bmp",
642 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
643 passNo = (passNo + 1) % 4;
644 bitmaps[imageNo][quarterNo][passNo].buffer =
645 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_0_3_100_sampleimage1.bmp",
646 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
647 passNo = (passNo + 1) % 4;
650 bitmaps[imageNo][quarterNo][passNo].buffer =
651 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_0_025_sampleimage2.bmp",
652 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
653 passNo = (passNo + 1) % 4;
654 bitmaps[imageNo][quarterNo][passNo].buffer =
655 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_0_050_sampleimage2.bmp",
656 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
657 passNo = (passNo + 1) % 4;
658 bitmaps[imageNo][quarterNo][passNo].buffer =
659 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_0_075_sampleimage2.bmp",
660 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
661 passNo = (passNo + 1) % 4;
662 bitmaps[imageNo][quarterNo][passNo].buffer =
663 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_0_100_sampleimage2.bmp",
664 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
665 passNo = (passNo + 1) % 4;
666 quarterNo = (quarterNo + 1) % 4;
667 bitmaps[imageNo][quarterNo][passNo].buffer =
668 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_1_025_sampleimage2.bmp",
669 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
670 passNo = (passNo + 1) % 4;
671 bitmaps[imageNo][quarterNo][passNo].buffer =
672 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_1_050_sampleimage2.bmp",
673 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
674 passNo = (passNo + 1) % 4;
675 bitmaps[imageNo][quarterNo][passNo].buffer =
676 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_1_075_sampleimage2.bmp",
677 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
678 passNo = (passNo + 1) % 4;
679 bitmaps[imageNo][quarterNo][passNo].buffer =
680 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_1_100_sampleimage2.bmp",
681 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
682 passNo = (passNo + 1) % 4;
683 quarterNo = (quarterNo + 1) % 4;
684 bitmaps[imageNo][quarterNo][passNo].buffer =
685 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_2_025_sampleimage2.bmp",
686 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
687 passNo = (passNo + 1) % 4;
688 bitmaps[imageNo][quarterNo][passNo].buffer =
689 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_2_050_sampleimage2.bmp",
690 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
691 passNo = (passNo + 1) % 4;
692 bitmaps[imageNo][quarterNo][passNo].buffer =
693 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_2_075_sampleimage2.bmp",
694 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
695 passNo = (passNo + 1) % 4;
696 bitmaps[imageNo][quarterNo][passNo].buffer =
697 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_2_100_sampleimage2.bmp",
698 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
699 passNo = (passNo + 1) % 4;
700 quarterNo = (quarterNo + 1) % 4;
701 bitmaps[imageNo][quarterNo][passNo].buffer =
702 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_3_025_sampleimage2.bmp",
703 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
704 passNo = (passNo + 1) % 4;
705 bitmaps[imageNo][quarterNo][passNo].buffer =
706 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_3_050_sampleimage2.bmp",
707 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
708 passNo = (passNo + 1) % 4;
709 bitmaps[imageNo][quarterNo][passNo].buffer =
710 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_3_075_sampleimage2.bmp",
711 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
712 passNo = (passNo + 1) % 4;
713 bitmaps[imageNo][quarterNo][passNo].buffer =
714 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_1_3_100_sampleimage2.bmp",
715 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
716 passNo = (passNo + 1) % 4;
719 bitmaps[imageNo][quarterNo][passNo].buffer =
720 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_0_025_sampleimage3.bmp",
721 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
722 passNo = (passNo + 1) % 4;
723 bitmaps[imageNo][quarterNo][passNo].buffer =
724 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_0_050_sampleimage3.bmp",
725 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
726 passNo = (passNo + 1) % 4;
727 bitmaps[imageNo][quarterNo][passNo].buffer =
728 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_0_075_sampleimage3.bmp",
729 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
730 passNo = (passNo + 1) % 4;
731 bitmaps[imageNo][quarterNo][passNo].buffer =
732 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_0_100_sampleimage3.bmp",
733 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
734 passNo = (passNo + 1) % 4;
735 quarterNo = (quarterNo + 1) % 4;
736 bitmaps[imageNo][quarterNo][passNo].buffer =
737 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_1_025_sampleimage3.bmp",
738 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
739 passNo = (passNo + 1) % 4;
740 bitmaps[imageNo][quarterNo][passNo].buffer =
741 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_1_050_sampleimage3.bmp",
742 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
743 passNo = (passNo + 1) % 4;
744 bitmaps[imageNo][quarterNo][passNo].buffer =
745 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_1_075_sampleimage3.bmp",
746 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
747 passNo = (passNo + 1) % 4;
748 bitmaps[imageNo][quarterNo][passNo].buffer =
749 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_1_100_sampleimage3.bmp",
750 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
751 passNo = (passNo + 1) % 4;
752 quarterNo = (quarterNo + 1) % 4;
753 bitmaps[imageNo][quarterNo][passNo].buffer =
754 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_2_025_sampleimage3.bmp",
755 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
756 passNo = (passNo + 1) % 4;
757 bitmaps[imageNo][quarterNo][passNo].buffer =
758 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_2_050_sampleimage3.bmp",
759 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
760 passNo = (passNo + 1) % 4;
761 bitmaps[imageNo][quarterNo][passNo].buffer =
762 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_2_075_sampleimage3.bmp",
763 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
764 passNo = (passNo + 1) % 4;
765 bitmaps[imageNo][quarterNo][passNo].buffer =
766 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_2_100_sampleimage3.bmp",
767 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
768 passNo = (passNo + 1) % 4;
769 quarterNo = (quarterNo + 1) % 4;
770 bitmaps[imageNo][quarterNo][passNo].buffer =
771 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_3_025_sampleimage3.bmp",
772 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
773 passNo = (passNo + 1) % 4;
774 bitmaps[imageNo][quarterNo][passNo].buffer =
775 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_3_050_sampleimage3.bmp",
776 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
777 passNo = (passNo + 1) % 4;
778 bitmaps[imageNo][quarterNo][passNo].buffer =
779 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_3_075_sampleimage3.bmp",
780 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
781 passNo = (passNo + 1) % 4;
782 bitmaps[imageNo][quarterNo][passNo].buffer =
783 test_progressive_load_bitmap(ms_sample_path,
"decompress/dec_2_3_100_sampleimage3.bmp",
784 &(bitmaps[imageNo][quarterNo][passNo].size), quarterNo);
788 for (imageNo = 0; imageNo < 3; imageNo++)
790 for (quarterNo = 0; quarterNo < 4; quarterNo++)
792 for (passNo = 0; passNo < 4; passNo++)
794 if (!bitmaps[imageNo][quarterNo][passNo].buffer)
803 static size_t test_memcmp_count(
const BYTE* mem1,
const BYTE* mem2,
size_t size,
int margin)
807 for (
size_t index = 0; index < size; index++)
811 const int error = (*mem1 > *mem2) ? *mem1 - *mem2 : *mem2 - *mem1;
824 static int test_progressive_decode(PROGRESSIVE_CONTEXT* progressive, EGFX_SAMPLE_FILE files[4],
825 EGFX_SAMPLE_FILE bitmaps[4],
int quarter,
int count)
831 clippingRect.right = g_Width;
832 clippingRect.bottom = g_Height;
834 for (
int pass = 0; pass < count; pass++)
837 progressive_decompress(progressive, files[pass].buffer, files[pass].size, g_DstData,
838 PIXEL_FORMAT_XRGB32, g_DstStep, 0, 0, NULL, 0, 0);
839 printf(
"ProgressiveDecompress: status: %d pass: %d\n", status, pass + 1);
840 PROGRESSIVE_BLOCK_REGION* region = &(progressive->region);
845 clippingRect.left = 0;
846 clippingRect.top = 0;
847 clippingRect.right = g_Width / 2;
848 clippingRect.bottom = g_Height / 2;
852 clippingRect.left = g_Width / 2;
853 clippingRect.top = g_Height / 2;
854 clippingRect.right = g_Width;
855 clippingRect.bottom = g_Height;
859 clippingRect.left = 0;
860 clippingRect.top = g_Height / 2;
861 clippingRect.right = g_Width / 2;
862 clippingRect.bottom = g_Height;
866 clippingRect.left = g_Width / 2;
867 clippingRect.top = 0;
868 clippingRect.right = g_Width;
869 clippingRect.bottom = g_Height / 2;
875 for (UINT16 index = 0; index < region->numTiles; index++)
879 const RECTANGLE_16 tileRect = { tile->x, tile->y, tile->x + tile->width,
880 tile->y + tile->height };
882 rectangles_intersection(&tileRect, &clippingRect, &updateRect);
883 const UINT16 nXDst = updateRect.left;
884 const UINT16 nYDst = updateRect.top;
885 const UINT16 nWidth = updateRect.right - updateRect.left;
886 const UINT16 nHeight = updateRect.bottom - updateRect.top;
888 if ((nWidth <= 0) || (nHeight <= 0))
891 nXSrc = nXDst - tile->x;
892 nYSrc = nYDst - tile->y;
893 freerdp_image_copy(g_DstData, PIXEL_FORMAT_XRGB32, g_DstStep, nXDst, nYDst, nWidth,
894 nHeight, tile->data, PIXEL_FORMAT_XRGB32, 64 * 4, nXSrc, nYSrc, NULL,
898 const size_t size = bitmaps[pass].size;
899 const size_t cnt = test_memcmp_count(g_DstData, bitmaps[pass].buffer, size, 1);
903 const float rate = ((float)cnt) / ((float)size) * 100.0f;
904 printf(
"Progressive RemoteFX decompression failure\n");
905 printf(
"Actual, Expected (%" PRIuz
"/%" PRIuz
" = %.3f%%):\n", cnt, size, rate);
914 static int test_progressive_ms_sample(
char* ms_sample_path)
918 EGFX_SAMPLE_FILE files[3][4][4] = { 0 };
919 EGFX_SAMPLE_FILE bitmaps[3][4][4] = { 0 };
920 PROGRESSIVE_CONTEXT* progressive = NULL;
923 g_DstStep = g_Width * 4;
924 status = test_progressive_load_files(ms_sample_path, files);
928 for (
int i = 0; i < 3; i++)
930 for (
int j = 0; j < 4; j++)
932 for (
int k = 0; k < 4; k++)
933 sample_file_free(&files[i][j][k]);
940 status = test_progressive_load_bitmaps(ms_sample_path, bitmaps);
944 for (
int i = 0; i < 3; i++)
946 for (
int j = 0; j < 4; j++)
948 for (
int k = 0; k < 4; k++)
949 sample_file_free(&files[i][j][k]);
957 progressive = progressive_context_new(FALSE);
958 g_DstData = winpr_aligned_malloc(1LL * g_DstStep * g_Height, 16);
959 progressive_create_surface_context(progressive, 0, g_Width, g_Height);
965 printf(
"\nSample Image 1\n");
966 test_image_fill(g_DstData, g_DstStep, 0, 0, g_Width, g_Height, 0xFF000000);
967 test_progressive_decode(progressive, files[0][0], bitmaps[0][0], 0, count);
968 test_progressive_decode(progressive, files[0][1], bitmaps[0][1], 1, count);
969 test_progressive_decode(progressive, files[0][2], bitmaps[0][2], 2, count);
970 test_progressive_decode(progressive, files[0][3], bitmaps[0][3], 3, count);
977 printf(
"\nSample Image 2\n");
978 test_image_fill(g_DstData, g_DstStep, 0, 0, g_Width, g_Height, 0xFF000000);
979 test_progressive_decode(progressive, files[1][0], bitmaps[1][0], 0, count);
980 test_progressive_decode(progressive, files[1][1], bitmaps[1][1], 1, count);
981 test_progressive_decode(progressive, files[1][2], bitmaps[1][2], 2, count);
982 test_progressive_decode(progressive, files[1][3], bitmaps[1][3], 3, count);
989 printf(
"\nSample Image 3\n");
990 test_image_fill(g_DstData, g_DstStep, 0, 0, g_Width, g_Height, 0xFF000000);
991 test_progressive_decode(progressive, files[2][0], bitmaps[2][0], 0, count);
992 test_progressive_decode(progressive, files[2][1], bitmaps[2][1], 1, count);
993 test_progressive_decode(progressive, files[2][2], bitmaps[2][2], 2, count);
994 test_progressive_decode(progressive, files[2][3], bitmaps[2][3], 3, count);
997 progressive_context_free(progressive);
999 for (
int i = 0; i < 3; i++)
1001 for (
int j = 0; j < 4; j++)
1003 for (
int k = 0; k < 4; k++)
1005 sample_file_free(&bitmaps[i][j][k]);
1006 sample_file_free(&files[i][j][k]);
1011 winpr_aligned_free(g_DstData);
1015 static BOOL diff(BYTE a, BYTE b)
1017 BYTE big = MAX(a, b);
1018 BYTE little = MIN(a, b);
1019 if (big - little <= 0x25)
1024 static BOOL colordiff(UINT32 format, UINT32 a, UINT32 b)
1034 FreeRDPSplitColor(a, format, &ar, &ag, &ab, &aa, NULL);
1035 FreeRDPSplitColor(b, format, &br, &bg, &bb, &ba, NULL);
1036 if (!diff(aa, ba) || !diff(ar, br) || !diff(ag, bg) || !diff(ab, bb))
1041 static BOOL test_encode_decode(
const char* path)
1045 BYTE* resultData = NULL;
1046 BYTE* dstData = NULL;
1048 UINT32 ColorFormat = PIXEL_FORMAT_BGRX32;
1050 wImage* image = winpr_image_new();
1051 wImage* dstImage = winpr_image_new();
1052 char* name = GetCombinedPath(path,
"progressive.bmp");
1053 PROGRESSIVE_CONTEXT* progressiveEnc = progressive_context_new(TRUE);
1054 PROGRESSIVE_CONTEXT* progressiveDec = progressive_context_new(FALSE);
1056 region16_init(&invalidRegion);
1057 if (!image || !dstImage || !name || !progressiveEnc || !progressiveDec)
1060 rc = winpr_image_read(image, name);
1064 resultData = calloc(image->scanline, image->height);
1069 rc = progressive_compress(progressiveEnc, image->data, image->scanline * image->height,
1070 ColorFormat, image->width, image->height, image->scanline, NULL,
1071 &dstData, &dstSize);
1076 rc = progressive_create_surface_context(progressiveDec, 0, image->width, image->height);
1080 rc = progressive_decompress(progressiveDec, dstData, dstSize, resultData, ColorFormat,
1081 image->scanline, 0, 0, &invalidRegion, 0, 0);
1089 dstImage->data = resultData;
1090 winpr_image_write(dstImage,
"/tmp/test.bmp");
1092 for (
size_t y = 0; y < image->height; y++)
1094 const BYTE* orig = &image->data[y * image->scanline];
1095 const BYTE* dec = &resultData[y * image->scanline];
1096 for (
size_t x = 0; x < image->width; x++)
1098 const BYTE* po = &orig[x * 4];
1099 const BYTE* pd = &dec[x * 4];
1101 const DWORD a = FreeRDPReadColor(po, ColorFormat);
1102 const DWORD b = FreeRDPReadColor(pd, ColorFormat);
1103 if (!colordiff(ColorFormat, a, b))
1105 printf(
"xxxxxxx [%u:%u] [%s] %08X != %08X\n", x, y,
1106 FreeRDPGetColorFormatName(ColorFormat), a, b);
1113 region16_uninit(&invalidRegion);
1114 progressive_context_free(progressiveEnc);
1115 progressive_context_free(progressiveDec);
1116 winpr_image_free(image, TRUE);
1117 winpr_image_free(dstImage, FALSE);
1127 WINPR_ASSERT(frameId);
1130 if (1 != fscanf(fp,
"frameid: %" PRIu32
"\n", frameId))
1132 if (1 != fscanf(fp,
"surfaceId: %" PRIu32
"\n", &cmd->surfaceId))
1134 if (1 != fscanf(fp,
"codecId: %" PRIu32
"\n", &cmd->codecId))
1136 if (1 != fscanf(fp,
"contextId: %" PRIu32
"\n", &cmd->contextId))
1138 if (1 != fscanf(fp,
"format: %" PRIu32
"\n", &cmd->format))
1140 if (1 != fscanf(fp,
"left: %" PRIu32
"\n", &cmd->left))
1142 if (1 != fscanf(fp,
"top: %" PRIu32
"\n", &cmd->top))
1144 if (1 != fscanf(fp,
"right: %" PRIu32
"\n", &cmd->right))
1146 if (1 != fscanf(fp,
"bottom: %" PRIu32
"\n", &cmd->bottom))
1148 if (1 != fscanf(fp,
"width: %" PRIu32
"\n", &cmd->width))
1150 if (1 != fscanf(fp,
"height: %" PRIu32
"\n", &cmd->height))
1152 if (1 != fscanf(fp,
"length: %" PRIu32
"\n", &cmd->length))
1158 size_t dlen = SIZE_MAX;
1159 SSIZE_T slen = GetLine(&data, &slen, fp);
1165 const char* b64 = &data[6];
1167 crypto_base64_decode(b64, slen, &cmd->data, &dlen);
1171 return cmd->length == dlen;
1179 static WINPR_NORETURN(
void usage(
const char* name))
1182 (void)fprintf(fp,
"%s <directory> <width> <height>\n", name);
1186 static void print_codec_stats(
const char* name, UINT64 timeNS)
1188 const double dectimems = timeNS / 1000000.0;
1189 (void)fprintf(stderr,
"[%s] took %lf ms to decode\n", name, dectimems);
1192 static int test_dump(
int argc,
char* argv[])
1197 UINT64 CAPROGRESSIVE_dectime = 0;
1198 UINT64 UNCOMPRESSED_dectime = 0;
1199 UINT64 CAVIDEO_dectime = 0;
1200 UINT64 CLEARCODEC_dectime = 0;
1201 UINT64 PLANAR_dectime = 0;
1202 UINT64 AVC420_dectime = 0;
1203 UINT64 ALPHA_dectime = 0;
1204 UINT64 AVC444_dectime = 0;
1205 UINT64 AVC444v2_dectime = 0;
1206 UINT64 copytime = 0;
1211 const char* path = argv[1];
1213 const unsigned long width = strtoul(argv[2], NULL, 0);
1214 if ((errno != 0) || (width <= 0))
1216 const unsigned long height = strtoul(argv[3], NULL, 0);
1217 if ((errno != 0) || (height <= 0))
1220 rdpCodecs* codecs = freerdp_client_codecs_new(0);
1224 UINT32 DstFormat = PIXEL_FORMAT_BGRA32;
1225 const UINT32 stride = (width + 16) * FreeRDPGetBytesPerPixel(DstFormat);
1227 BYTE* dst = calloc(stride, height);
1228 BYTE* output = calloc(stride, height);
1229 if (!dst || !output)
1232 if (!freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_ALL, width, height))
1236 while (success >= 0)
1240 winpr_asprintf(&fname, &flen,
"%s/%08" PRIx32
".raw", path, count++);
1241 FILE* fp = fopen(fname,
"r");
1250 if (read_cmd(fp, &cmd, &frameId))
1253 region16_init(&invalid);
1255 const char* cname = rdpgfx_get_codec_id_string(cmd.codecId);
1256 switch (cmd.codecId)
1258 case RDPGFX_CODECID_CAPROGRESSIVE:
1260 const UINT64 start = winpr_GetTickCount64NS();
1261 success = progressive_create_surface_context(codecs->progressive, cmd.surfaceId,
1264 success = progressive_decompress(codecs->progressive, cmd.data, cmd.length,
1265 dst, DstFormat, 0, cmd.left, cmd.top,
1266 &invalid, cmd.surfaceId, frameId);
1267 const UINT64 end = winpr_GetTickCount64NS();
1268 const UINT64 diff = end - start;
1269 const double ddiff = diff / 1000000.0;
1270 (void)fprintf(stderr,
"frame [%s] %" PRIu32
" took %lf ms\n", cname, frameId,
1272 CAPROGRESSIVE_dectime += diff;
1276 case RDPGFX_CODECID_UNCOMPRESSED:
1278 const UINT64 start = winpr_GetTickCount64NS();
1279 if (!freerdp_image_copy_no_overlap(dst, DstFormat, stride, cmd.left, cmd.top,
1280 cmd.width, cmd.height, cmd.data, cmd.format,
1281 0, 0, 0, NULL, FREERDP_FLIP_NONE))
1284 RECTANGLE_16 invalidRect = { .left = (UINT16)MIN(UINT16_MAX, cmd.left),
1285 .top = (UINT16)MIN(UINT16_MAX, cmd.top),
1286 .right = (UINT16)MIN(UINT16_MAX, cmd.right),
1287 .bottom = (UINT16)MIN(UINT16_MAX, cmd.bottom) };
1288 region16_union_rect(&invalid, &invalid, &invalidRect);
1289 const UINT64 end = winpr_GetTickCount64NS();
1290 const UINT64 diff = end - start;
1291 const double ddiff = diff / 1000000.0;
1292 (void)fprintf(stderr,
"frame [%s] %" PRIu32
" took %lf ms\n", cname, frameId,
1294 UNCOMPRESSED_dectime += diff;
1297 case RDPGFX_CODECID_CAVIDEO:
1299 const UINT64 start = winpr_GetTickCount64NS();
1300 if (!rfx_process_message(codecs->rfx, cmd.data, cmd.length, cmd.left, cmd.top,
1301 dst, DstFormat, stride, height, &invalid))
1304 const UINT64 end = winpr_GetTickCount64NS();
1305 const UINT64 diff = end - start;
1306 const double ddiff = diff / 1000000.0;
1307 (void)fprintf(stderr,
"frame [%s] %" PRIu32
" took %lf ms\n", cname, frameId,
1309 CAVIDEO_dectime += diff;
1312 case RDPGFX_CODECID_CLEARCODEC:
1314 const UINT64 start = winpr_GetTickCount64NS();
1315 success = clear_decompress(codecs->clear, cmd.data, cmd.length, cmd.width,
1316 cmd.height, dst, DstFormat, stride, cmd.left,
1317 cmd.top, width, height, NULL);
1319 const RECTANGLE_16 invalidRect = { .left = (UINT16)MIN(UINT16_MAX, cmd.left),
1320 .top = (UINT16)MIN(UINT16_MAX, cmd.top),
1321 .right = (UINT16)MIN(UINT16_MAX, cmd.right),
1323 (UINT16)MIN(UINT16_MAX, cmd.bottom) };
1324 region16_union_rect(&invalid, &invalid, &invalidRect);
1325 const UINT64 end = winpr_GetTickCount64NS();
1326 const UINT64 diff = end - start;
1327 const double ddiff = diff / 1000000.0;
1328 (void)fprintf(stderr,
"frame [%s] %" PRIu32
" took %lf ms\n", cname, frameId,
1330 CLEARCODEC_dectime += diff;
1333 case RDPGFX_CODECID_PLANAR:
1335 const UINT64 start = winpr_GetTickCount64NS();
1337 if (!planar_decompress(codecs->planar, cmd.data, cmd.length, cmd.width,
1338 cmd.height, dst, DstFormat, stride, cmd.left, cmd.top,
1339 cmd.width, cmd.height, FALSE))
1342 const RECTANGLE_16 invalidRect = { .left = (UINT16)MIN(UINT16_MAX, cmd.left),
1343 .top = (UINT16)MIN(UINT16_MAX, cmd.top),
1344 .right = (UINT16)MIN(UINT16_MAX, cmd.right),
1346 (UINT16)MIN(UINT16_MAX, cmd.bottom) };
1347 region16_union_rect(&invalid, &invalid, &invalidRect);
1349 const UINT64 end = winpr_GetTickCount64NS();
1350 const UINT64 diff = end - start;
1351 const double ddiff = diff / 1000000.0;
1352 (void)fprintf(stderr,
"frame [%s] %" PRIu32
" took %lf ms\n", cname, frameId,
1354 PLANAR_dectime += diff;
1357 case RDPGFX_CODECID_AVC420:
1359 const UINT64 start = winpr_GetTickCount64NS();
1361 const UINT64 end = winpr_GetTickCount64NS();
1362 const UINT64 diff = end - start;
1363 const double ddiff = diff / 1000000.0;
1364 (void)fprintf(stderr,
"frame [%s] %" PRIu32
" took %lf ms\n", cname, frameId,
1366 AVC420_dectime += diff;
1370 case RDPGFX_CODECID_ALPHA:
1372 const UINT64 start = winpr_GetTickCount64NS();
1374 const UINT64 end = winpr_GetTickCount64NS();
1375 const UINT64 diff = end - start;
1376 const double ddiff = diff / 1000000.0;
1377 (void)fprintf(stderr,
"frame [%s] %" PRIu32
" took %lf ms\n", cname, frameId,
1379 ALPHA_dectime += diff;
1383 case RDPGFX_CODECID_AVC444:
1385 const UINT64 start = winpr_GetTickCount64NS();
1387 const UINT64 end = winpr_GetTickCount64NS();
1388 const UINT64 diff = end - start;
1389 const double ddiff = diff / 1000000.0;
1390 (void)fprintf(stderr,
"frame [%s] %" PRIu32
" took %lf ms\n", cname, frameId,
1392 AVC444_dectime += diff;
1396 case RDPGFX_CODECID_AVC444v2:
1398 const UINT64 start = winpr_GetTickCount64NS();
1400 const UINT64 end = winpr_GetTickCount64NS();
1401 const UINT64 diff = end - start;
1402 const double ddiff = diff / 1000000.0;
1403 (void)fprintf(stderr,
"frame [%s] %" PRIu32
" took %lf ms\n", cname, frameId,
1405 AVC444v2_dectime += diff;
1410 (void)fprintf(stderr,
"unexpected codec %s [0x%08" PRIx32
"]",
1411 rdpgfx_get_codec_id_string(cmd.codecId), cmd.codecId);
1419 const UINT64 start = winpr_GetTickCount64NS();
1421 const RECTANGLE_16* rects = region16_rects(&invalid, &nbRects);
1422 for (
size_t x = 0; x < nbRects; x++)
1425 const UINT32 w = rect->right - rect->left;
1426 const UINT32 h = rect->bottom - rect->top;
1427 if (!freerdp_image_copy_no_overlap(output, DstFormat, stride, rect->left,
1428 rect->top, w, h, dst, DstFormat, stride,
1429 rect->left, rect->top, NULL, 0))
1432 const UINT64 end = winpr_GetTickCount64NS();
1433 const UINT64 diff = end - start;
1434 const double ddiff = diff / 1000000.0;
1435 (void)fprintf(stderr,
"frame %" PRIu32
" copy took %lf ms\n", frameId, ddiff);
1438 region16_clear(&invalid);
1445 freerdp_client_codecs_free(codecs);
1449 print_codec_stats(rdpgfx_get_codec_id_string(RDPGFX_CODECID_UNCOMPRESSED),
1450 UNCOMPRESSED_dectime);
1451 print_codec_stats(rdpgfx_get_codec_id_string(RDPGFX_CODECID_CAPROGRESSIVE),
1452 CAPROGRESSIVE_dectime);
1453 print_codec_stats(rdpgfx_get_codec_id_string(RDPGFX_CODECID_CAVIDEO), CAVIDEO_dectime);
1454 print_codec_stats(rdpgfx_get_codec_id_string(RDPGFX_CODECID_CLEARCODEC), CLEARCODEC_dectime);
1455 print_codec_stats(rdpgfx_get_codec_id_string(RDPGFX_CODECID_PLANAR), PLANAR_dectime);
1456 print_codec_stats(rdpgfx_get_codec_id_string(RDPGFX_CODECID_AVC420), AVC420_dectime);
1457 print_codec_stats(rdpgfx_get_codec_id_string(RDPGFX_CODECID_AVC444), AVC444_dectime);
1458 print_codec_stats(rdpgfx_get_codec_id_string(RDPGFX_CODECID_AVC444v2), AVC444v2_dectime);
1459 print_codec_stats(rdpgfx_get_codec_id_string(RDPGFX_CODECID_ALPHA), ALPHA_dectime);
1461 const UINT64 decodetime = UNCOMPRESSED_dectime + CAPROGRESSIVE_dectime + CAVIDEO_dectime +
1462 CLEARCODEC_dectime + PLANAR_dectime + AVC420_dectime +
1463 AVC444_dectime + AVC444v2_dectime + ALPHA_dectime;
1464 print_codec_stats(
"surface copy", copytime);
1465 print_codec_stats(
"total decode", decodetime);
1466 print_codec_stats(
"total", decodetime + copytime);
1471 int TestFreeRDPCodecProgressive(
int argc,
char* argv[])
1474 return test_dump(argc, argv);
1477 char* ms_sample_path = NULL;
1479 SYSTEMTIME systemTime;
1483 GetSystemTime(&systemTime);
1484 (void)sprintf_s(name,
sizeof(name),
1485 "EGFX_PROGRESSIVE_MS_SAMPLE-%04" PRIu16
"%02" PRIu16
"%02" PRIu16
"%02" PRIu16
1486 "%02" PRIu16
"%02" PRIu16
"%04" PRIu16,
1487 systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour,
1488 systemTime.wMinute, systemTime.wSecond, systemTime.wMilliseconds);
1489 ms_sample_path = _strdup(CMAKE_CURRENT_SOURCE_DIR);
1491 if (!ms_sample_path)
1493 printf(
"Memory allocation failed\n");
1497 if (winpr_PathFileExists(ms_sample_path))
1503 if (!test_encode_decode(ms_sample_path))
1509 free(ms_sample_path);