1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
/*
* test-resize-values.c -- testsuite for tc_compute_fast_resize_values
* (tc_functions.c); everyone feel free to add
* more tests and improve existing ones.
* (C) 2006-2010 - Francesco Romani <fromani -at- gmail -dot- com>
*
* This file is part of transcode, a video stream processing tool.
*
* transcode is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* transcode is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libtc/libtc.h"
#include "src/transcode.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
typedef struct res_ {
int width;
int height;
} Resolution;
typedef struct testcase_ {
Resolution old;
Resolution new;
int retcode;
} TestCase;
static TestCase tests[] = {
{ { 720, 576 }, { 720, 576 }, 0 },
{ { 720, 480 }, { 720, 480 }, 0 },
{ { 720, 576 }, { 720, 480 }, 0 },
{ { 720, 480 }, { 720, 576 }, 0 },
{ { 720, 576 }, { 352, 288 }, 0 },
{ { 352, 288 }, { 720, 576 }, 0 },
{ { 720, 480 }, { 352, 240 }, 0 },
{ { 352, 240 }, { 720, 480 }, 0 },
{ { 720, 576 }, { 640, 480 }, 0 },
{ { 640, 480 }, { 720, 576 }, 0 },
{ { 720, 576 }, { 1024, 768 }, 0 },
{ { 1024, 768 }, { 720, 576 }, 0 },
{ { 722, 576 }, { 720, 576 }, -1 },
{ { 720, 576 }, { 722, 576 }, -1 },
{ { 718, 576 }, { 720, 576 }, -1 },
{ { 720, 576 }, { 718, 576 }, -1 },
{ { 720, 578 }, { 720, 576 }, -1 },
{ { 720, 576 }, { 720, 578 }, -1 },
{ { 720, 572 }, { 720, 576 }, -1 },
{ { 720, 576 }, { 720, 572 }, -1 },
{ { 720, 576 }, { 1024, 480 }, 0 },
{ { 1024, 480 }, { 720, 576 }, 0 },
{ { 720, 480 }, { 480, 576 }, 0 },
{ { 480, 576 }, { 720, 480 }, 0 },
};
#define TEST_COUNT (sizeof(tests)/sizeof(tests[0]))
static int do_single_test(const TestCase *test, vob_t *vob, int strict)
{
int ret;
/* cleanup */
vob->resize1_mult = 0;
vob->resize2_mult = 0;
vob->hori_resize1 = 0;
vob->hori_resize2 = 0;
vob->vert_resize1 = 0;
vob->vert_resize2 = 0;
/* setup test values */
vob->ex_v_width = test->old.width;
vob->ex_v_height = test->old.height;
vob->zoom_width = test->new.width;
vob->zoom_height = test->new.height;
ret = tc_compute_fast_resize_values(vob, strict);
if (ret == test->retcode) {
tc_log_info(__FILE__, "%ix%i -> %ix%i (-B %i,%i,%i | -X %i,%i,%i)"
" expect %s got %s -> OK!",
test->old.width, test->old.height,
test->new.width, test->new.height,
vob->vert_resize1, vob->hori_resize1, vob->resize1_mult,
vob->vert_resize2, vob->hori_resize2, vob->resize2_mult,
(ret == 0) ?"SUCCESS" :"FAILURE",
(test->retcode == 0) ?"SUCCESS" :"FAILURE");
} else {
tc_log_warn(__FILE__, "%ix%i -> %ix%i (-B %i,%i,%i | -X %i,%i,%i)"
" expect %s got %s -> BAD!!",
test->old.width, test->old.height,
test->new.width, test->new.height,
vob->vert_resize1, vob->hori_resize1, vob->resize1_mult,
vob->vert_resize2, vob->hori_resize2, vob->resize2_mult,
(ret == 0) ?"SUCCESS" :"FAILURE",
(test->retcode == 0) ?"SUCCESS" :"FAILURE");
}
return (ret == test->retcode) ?0 :1;
}
int main(int argc, char *argv[])
{
int failed = 0, i = 0, strict = TC_FALSE;
vob_t *vob = tc_zalloc(sizeof(vob_t));
if (vob == NULL) {
return EXIT_FAILURE;
}
if (argc > 1 && !strcmp(argv[1], "strict")) {
strict = TC_TRUE;
}
for (i = 0; i < TEST_COUNT; i++) {
failed += do_single_test(&tests[i], vob, strict);
}
tc_free(vob);
tc_log_info(__FILE__, "test summary: %i tests, %i failed",
(int)TEST_COUNT, failed);
return (failed == 0) ?EXIT_SUCCESS :EXIT_FAILURE;
}
/*************************************************************************/
/*
* Local variables:
* c-file-style: "hugeouhugeup"
* c-file-offsets: ((case-label . *) (statement-case-intro . *))
* indent-tabs-mode: nil
* End:
*
* vim: expandtab shiftwidth=4:
*/
|