60
60
#include "config_win32.h"
61
61
62
62
#include <stdint.h>
63
+ #include <stdio.h>
64
+ #include <stdlib.h>
63
65
66
+ #include "audio/types.h"
64
67
#include "debug.h"
65
68
#include "host.h"
66
69
#include "lib_common.h"
67
70
#include "tv.h"
68
71
#include "types.h"
69
- #include "video.h"
70
- #include "video_capture.h"
71
72
#include "utils/color_out.h"
72
73
#include "utils/macros.h"
73
74
#include "utils/misc.h"
75
+ #include "utils/pam.h"
74
76
#include "utils/string.h"
75
77
#include "utils/vf_split.h"
76
- #include "utils/pam.h"
77
- #include "utils/y4m.h"
78
- #include <stdio.h>
79
- #include <stdlib.h>
80
- #include "audio/types.h"
81
78
#include "utils/video_pattern_generator.h"
79
+ #include "utils/y4m.h"
80
+ #include "video.h"
81
+ #include "video_capture.h"
82
82
#include "video_capture/testcard_common.h"
83
83
84
84
enum {
@@ -133,6 +133,7 @@ static void configure_fallback_audio(struct testcard_state *s) {
133
133
134
134
for (int i = 0 ; i < AUDIO_BUFFER_SIZE (s -> audio .ch_count ) / AUDIO_BPS ; i += 1 ) {
135
135
* ((int16_t * )(void * )(& s -> audio_data [i * AUDIO_BPS ])) = round (sin (((double ) i / ((double ) AUDIO_SAMPLE_RATE / s -> audio_frequency )) * M_PI * 2. ) * ((1U << (AUDIO_BPS * 8U - 1 )) - 1 ) * scale );
136
+
136
137
}
137
138
}
138
139
@@ -426,7 +427,7 @@ static void show_help(bool full) {
426
427
color_printf ("Examples:\n" );
427
428
color_printf (TBOLD ("\t%s -t testcard:file=picture.pam\n" ), uv_argv [0 ]);
428
429
color_printf (TBOLD ("\t%s -t testcard:mode=VGA\n" ), uv_argv [0 ]);
429
- color_printf (TBOLD ("\t%s -t testcard:size =1920x1080:fps =59.94i\n" ), uv_argv [0 ]);
430
+ color_printf (TBOLD ("\t%s -t testcard:s =1920x1080:f =59.94i\n" ), uv_argv [0 ]);
430
431
color_printf ("\n" );
431
432
color_printf ("Default mode: %s\n" , video_desc_to_string (DEFAULT_FORMAT ));
432
433
color_printf (TBOLD ("Note:" ) " only certain codec and generator combinations produce full-depth samples (not up-sampled 8-bit), use " TBOLD ("pattern=help" ) " for details.\n" );
@@ -471,8 +472,6 @@ static int vidcap_testcard_init(struct vidcap_params *params, void **state)
471
472
while (tmp ) {
472
473
if (strcmp (tmp , "p" ) == 0 ) {
473
474
s -> pan = 48 ;
474
- } else if (strstr (tmp , "file=" ) == tmp || strstr (tmp , "filename=" ) == tmp ) {
475
- filename = strchr (tmp , '=' ) + 1 ;
476
475
} else if (strncmp (tmp , "s=" , 2 ) == 0 ) {
477
476
strip_fmt = tmp ;
478
477
} else if (strcmp (tmp , "i" ) == 0 ) {
@@ -483,20 +482,20 @@ static int vidcap_testcard_init(struct vidcap_params *params, void **state)
483
482
log_msg (LOG_LEVEL_WARNING , "[testcard] Deprecated 'sf' option. Use format testcard:1920:1080:25sf:UYVY instead!\n" );
484
483
} else if (strcmp (tmp , "still" ) == 0 ) {
485
484
s -> still_image = true;
486
- } else if (strncmp (tmp , "pattern=" , strlen ( "pattern=" )) == 0 ) {
485
+ } else if (IS_KEY_PREFIX (tmp , "pattern" ) ) {
487
486
const char * pattern = tmp + strlen ("pattern=" );
488
487
strncpy (s -> pattern , pattern , sizeof s -> pattern - 1 );
489
- } else if (strstr (tmp , "codec=" ) == tmp ) {
488
+ } else if (IS_KEY_PREFIX (tmp , "codec" ) ) {
490
489
desc .color_spec = get_codec_from_name (strchr (tmp , '=' ) + 1 );
491
490
if (desc .color_spec == VIDEO_CODEC_NONE ) {
492
491
log_msg (LOG_LEVEL_ERROR , MOD_NAME "Wrong color spec: %s\n" , strchr (tmp , '=' ) + 1 );
493
492
goto error ;
494
493
}
495
- } else if (strstr (tmp , "mode=" ) == tmp ) {
494
+ } else if (IS_KEY_PREFIX (tmp , "mode" ) ) {
496
495
codec_t saved_codec = desc .color_spec ;
497
496
desc = get_video_desc_from_string (strchr (tmp , '=' ) + 1 );
498
497
desc .color_spec = saved_codec ;
499
- } else if (strstr (tmp , "size=" ) == tmp ) {
498
+ } else if (IS_KEY_PREFIX (tmp , "size" ) ) {
500
499
tmp = strchr (tmp , '=' ) + 1 ;
501
500
if (isdigit (tmp [0 ]) && strchr (tmp , 'x' ) != NULL ) {
502
501
desc .width = atoi (tmp );
@@ -507,10 +506,12 @@ static int vidcap_testcard_init(struct vidcap_params *params, void **state)
507
506
desc .width = size_dsc .width ;
508
507
desc .height = size_dsc .height ;
509
508
}
510
- } else if (strstr (tmp , "fps=" ) == tmp ) {
509
+ } else if (IS_KEY_PREFIX (tmp , "fps" ) ) {
511
510
if (!parse_fps (strchr (tmp , '=' ) + 1 , & desc )) {
512
511
goto error ;
513
512
}
513
+ } else if (IS_KEY_PREFIX (tmp , "file" )) {
514
+ filename = strchr (tmp , '=' ) + 1 ;
514
515
} else if (strstr (tmp , "afrequency=" ) == tmp ) {
515
516
s -> audio_frequency = atoi (strchr (tmp , '=' ) + 1 );
516
517
} else {
0 commit comments