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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
/*
* test-tcmoduleinfo.c -- testsuite for tcmoduleinfo* functions;
* 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 "src/transcode.h"
#include "libtc/tcmodule-info.h"
#include "libtc/tccodecs.h"
static const TCCodecID empty_codecs[] = { TC_CODEC_ERROR };
static TCModuleInfo empty = {
TC_MODULE_FEATURE_NONE,
TC_MODULE_FLAG_NONE,
"",
"",
"",
empty_codecs,
empty_codecs
};
static const TCCodecID pass_enc_codecs[] = { TC_CODEC_ANY, TC_CODEC_ERROR };
static TCModuleInfo pass_enc = {
TC_MODULE_FEATURE_ENCODE | TC_MODULE_FEATURE_VIDEO
| TC_MODULE_FEATURE_AUDIO | TC_MODULE_FEATURE_EXTRA,
TC_MODULE_FLAG_RECONFIGURABLE,
"encode_pass.so",
"0.0.1 (2005-11-14)",
"accepts everything, outputs verbatim",
pass_enc_codecs,
pass_enc_codecs
};
static const TCCodecID fake_pcm_codecs[] = { TC_CODEC_PCM, TC_CODEC_ERROR };
static TCModuleInfo fake_wav_mplex = {
TC_MODULE_FEATURE_MULTIPLEX | TC_MODULE_FEATURE_AUDIO,
TC_MODULE_FLAG_RECONFIGURABLE,
"mplex_wav.so",
"0.0.1 (2006-06-11)",
"accepts pcm, writes wav (fake!)",
fake_pcm_codecs,
empty_codecs
};
static const TCCodecID fake_yuv_codecs[] = { TC_CODEC_YUV420P, TC_CODEC_ERROR };
static TCModuleInfo fake_y4m_mplex = {
TC_MODULE_FEATURE_MULTIPLEX | TC_MODULE_FEATURE_VIDEO,
TC_MODULE_FLAG_RECONFIGURABLE,
"mplex_y4m.so",
"0.0.1 (2006-06-11)",
"accepts yuv420p, writes YUV4MPEG2 (fake!)",
fake_yuv_codecs,
empty_codecs
};
static const TCCodecID fake_mplex_codecs[] = { TC_CODEC_ANY, TC_CODEC_ERROR };
static TCModuleInfo fake_mplex = {
TC_MODULE_FEATURE_MULTIPLEX | TC_MODULE_FEATURE_VIDEO
| TC_MODULE_FEATURE_AUDIO | TC_MODULE_FEATURE_EXTRA,
TC_MODULE_FLAG_RECONFIGURABLE,
"mplex_null.so",
"0.0.1 (2005-11-14)",
"accepts and discards everything",
fake_mplex_codecs,
empty_codecs
};
static const TCCodecID pcm_pass_codecs[] = { TC_CODEC_PCM, TC_CODEC_ERROR };
static TCModuleInfo pcm_pass = {
TC_MODULE_FEATURE_ENCODE | TC_MODULE_FEATURE_AUDIO,
TC_MODULE_FLAG_RECONFIGURABLE,
"encode_pcm.so",
"0.0.1 (2006-03-11)",
"passthrough pcm",
pcm_pass_codecs,
pcm_pass_codecs
};
static const TCCodecID yuv_pass_codecs[] = { TC_CODEC_YUV420P, TC_CODEC_ERROR };
static TCModuleInfo yuv_pass = {
TC_MODULE_FEATURE_ENCODE | TC_MODULE_FEATURE_VIDEO,
TC_MODULE_FLAG_RECONFIGURABLE,
"encode_yuv.so",
"0.0.1 (2006-03-11)",
"passthrough yuv",
yuv_pass_codecs,
yuv_pass_codecs
};
static const TCCodecID fake_mpeg_codecs_in[] = { TC_CODEC_YUV420P, TC_CODEC_ERROR };
static const TCCodecID fake_mpeg_codecs_out[] = { TC_CODEC_MPEG1VIDEO, TC_CODEC_MPEG2VIDEO, TC_CODEC_XVID, TC_CODEC_ERROR };
static TCModuleInfo fake_mpeg_enc = {
TC_MODULE_FEATURE_ENCODE | TC_MODULE_FEATURE_VIDEO,
TC_MODULE_FLAG_NONE,
"encode_mpeg.so",
"0.0.1 (2005-11-14)",
"fake YUV420P -> MPEG video encoder",
fake_mpeg_codecs_in,
fake_mpeg_codecs_out
};
static const TCCodecID fake_vorbis_codecs_in[] = { TC_CODEC_PCM, TC_CODEC_ERROR };
static const TCCodecID fake_vorbis_codecs_out[] = { TC_CODEC_VORBIS, TC_CODEC_ERROR };
static TCModuleInfo fake_vorbis_enc = {
TC_MODULE_FEATURE_ENCODE | TC_MODULE_FEATURE_AUDIO,
TC_MODULE_FLAG_NONE,
"encode_vorbis.so",
"0.0.1 (2005-11-14)",
"fake PCM -> Vorbis audio encoder",
fake_vorbis_codecs_in,
fake_vorbis_codecs_out
};
static const TCCodecID fake_avi_codecs_in[] = {
TC_CODEC_MPEG1VIDEO, TC_CODEC_XVID, TC_CODEC_YUV420P,
TC_CODEC_MP3, TC_CODEC_PCM,
TC_CODEC_ERROR
};
static TCModuleInfo fake_avi_mplex = {
TC_MODULE_FEATURE_MULTIPLEX | TC_MODULE_FEATURE_VIDEO
| TC_MODULE_FEATURE_AUDIO,
TC_MODULE_FLAG_NONE,
"mplex_avi.so",
"0.0.1 (2005-11-14)",
"fakes an AVI muxer",
fake_avi_codecs_in,
empty_codecs
};
static int test_match_helper(int codec,
const TCModuleInfo *m1,
const TCModuleInfo *m2,
int expected)
{
int match = tc_module_info_match(codec, m1, m2);
int err = 0;
#ifdef VERBOSE
const char *str = tc_codec_to_string(codec);
tc_log_msg(__FILE__, "codec: %s (0x%x)", str, codec);
#endif
if (match != expected) {
tc_log_error(__FILE__, "'%s' <-%c-> '%s' FAILED",
m1->name,
(expected == 1) ?'-' :'!',
m2->name);
err = 1;
} else {
tc_log_info(__FILE__, "'%s' <-%c-> '%s' OK",
m1->name,
(expected == 1) ?'-' :'!',
m2->name);
}
return err;
}
static int test_module_match(void)
{
int errors = 0;
errors += test_match_helper(TC_CODEC_ANY, &empty, &empty, 0);
errors += test_match_helper(TC_CODEC_ANY, &empty, &fake_mpeg_enc, 0);
errors += test_match_helper(TC_CODEC_ANY, &fake_mpeg_enc, &empty, 0);
errors += test_match_helper(TC_CODEC_ANY, &pass_enc, &fake_mplex, 1);
errors += test_match_helper(TC_CODEC_ANY, &pass_enc, &fake_avi_mplex, 1);
errors += test_match_helper(TC_CODEC_ANY, &pcm_pass, &fake_avi_mplex, 1);
errors += test_match_helper(TC_CODEC_PCM, &pass_enc, &fake_avi_mplex, 1);
// this is tricky. Should fail since there are two *encoders* chained
// and this make no sense *in our current architecture*.
// but from tcmoduleinfo infrastructure POV, it make perfectly sense (yet)
// since encoders involved have compatible I/O capabilties, so it doesn't fail.
// errors += test_match_helper(TC_CODEC_ANY, &pass_enc, &fake_mpeg_enc, 0);
errors += test_match_helper(TC_CODEC_MPEG2VIDEO, &fake_mpeg_enc, &fake_vorbis_enc, 0);
errors += test_match_helper(TC_CODEC_ANY, &fake_mpeg_enc, &fake_mplex, 1);
errors += test_match_helper(TC_CODEC_MPEG1VIDEO, &fake_mpeg_enc, &fake_mplex, 1);
errors += test_match_helper(TC_CODEC_ANY, &fake_mpeg_enc, &fake_avi_mplex, 1);
errors += test_match_helper(TC_CODEC_MPEG1VIDEO, &fake_mpeg_enc, &fake_avi_mplex, 1);
errors += test_match_helper(TC_CODEC_XVID, &fake_mpeg_enc, &fake_avi_mplex, 1);
errors += test_match_helper(TC_CODEC_VORBIS, &fake_vorbis_enc, &fake_mpeg_enc, 0);
errors += test_match_helper(TC_CODEC_VORBIS, &fake_vorbis_enc, &fake_mplex, 1);
errors += test_match_helper(TC_CODEC_VORBIS, &fake_vorbis_enc, &fake_avi_mplex, 0);
errors += test_match_helper(TC_CODEC_PCM, &pcm_pass, &fake_wav_mplex, 1);
errors += test_match_helper(TC_CODEC_PCM, &pcm_pass, &fake_y4m_mplex, 0);
errors += test_match_helper(TC_CODEC_MPEG1VIDEO, &fake_mpeg_enc, &fake_wav_mplex, 0);
errors += test_match_helper(TC_CODEC_YUV420P, &yuv_pass, &fake_y4m_mplex, 1);
errors += test_match_helper(TC_CODEC_YUV420P, &yuv_pass, &fake_wav_mplex, 0);
errors += test_match_helper(TC_CODEC_YUV420P, &yuv_pass, &fake_avi_mplex, 1);
errors += test_match_helper(TC_CODEC_YUV420P, &yuv_pass, &fake_mplex, 1);
return errors;
}
int main(void)
{
int errors = test_module_match();
putchar('\n');
tc_log_info(__FILE__, "test summary: %i error%s (%s)",
errors,
(errors > 1) ?"s" :"",
(errors > 0) ?"FAILED" :"PASSED");
return (errors > 0) ?1 :0;
}
/*************************************************************************/
/*
* Local variables:
* c-file-style: "stroustrup"
* c-file-offsets: ((case-label . *) (statement-case-intro . *))
* indent-tabs-mode: nil
* End:
*
* vim: expandtab shiftwidth=4:
*/
|