Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
tests: move from skip/trim_duration to start_time/end_time
Browse files Browse the repository at this point in the history
  • Loading branch information
ubitux committed Mar 15, 2022
1 parent 0672db6 commit f9ece03
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
24 changes: 12 additions & 12 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ if get_option('tests')
'Audio seek': {'test': 'audio_seek', 'args': [media]},
'Audio': {'test': 'audio', 'args': [media]},
'Combination audio': {'test': 'comb', 'args': [media, 0b100.to_string()]},
'Combination audio+duration': {'test': 'comb', 'args': [media, 0b110.to_string()]},
'Combination audio+duration+skip': {'test': 'comb', 'args': [media, 0b111.to_string()]},
'Combination audio+skip': {'test': 'comb', 'args': [media, 0b101.to_string()]},
'Combination audio+end': {'test': 'comb', 'args': [media, 0b110.to_string()]},
'Combination audio+end+start': {'test': 'comb', 'args': [media, 0b111.to_string()]},
'Combination audio+start': {'test': 'comb', 'args': [media, 0b101.to_string()]},
'Combination video': {'test': 'comb', 'args': [media, 0b000.to_string()]},
'Combination video+duration': {'test': 'comb', 'args': [media, 0b010.to_string()]},
'Combination video+duration+skip': {'test': 'comb', 'args': [media, 0b011.to_string()]},
'Combination video+skip': {'test': 'comb', 'args': [media, 0b001.to_string()]},
'Combination video+end': {'test': 'comb', 'args': [media, 0b010.to_string()]},
'Combination video+end+start': {'test': 'comb', 'args': [media, 0b011.to_string()]},
'Combination video+start': {'test': 'comb', 'args': [media, 0b001.to_string()]},
'File not available': {'test': 'notavail_file'},
'High refresh rate': {'test': 'high_refresh_rate', 'args': [media]},
'Image Seek': {'test': 'image_seek', 'args': [image]},
Expand All @@ -220,13 +220,13 @@ if get_option('tests')
'Misc events media': {'test': 'misc_events', 'args': [media]},
'Next frame': {'test': 'next_frame', 'args': [media]},
'Seek after EOS audio': {'test': 'seek_after_eos', 'args': [media, 0b000.to_string()]},
'Seek after EOS audio+duration': {'test': 'seek_after_eos', 'args': [media, 0b010.to_string()]},
'Seek after EOS audio+duration+skip': {'test': 'seek_after_eos', 'args': [media, 0b001.to_string()]},
'Seek after EOS audio+skip': {'test': 'seek_after_eos', 'args': [media, 0b011.to_string()]},
'Seek after EOS audio+end': {'test': 'seek_after_eos', 'args': [media, 0b010.to_string()]},
'Seek after EOS audio+end+start': {'test': 'seek_after_eos', 'args': [media, 0b001.to_string()]},
'Seek after EOS audio+start': {'test': 'seek_after_eos', 'args': [media, 0b011.to_string()]},
'Seek after EOS video': {'test': 'seek_after_eos', 'args': [media, 0b100.to_string()]},
'Seek after EOS video+duration': {'test': 'seek_after_eos', 'args': [media, 0b110.to_string()]},
'Seek after EOS video+duration+skip': {'test': 'seek_after_eos', 'args': [media, 0b101.to_string()]},
'Seek after EOS video+skip': {'test': 'seek_after_eos', 'args': [media, 0b111.to_string()]},
'Seek after EOS video+end': {'test': 'seek_after_eos', 'args': [media, 0b110.to_string()]},
'Seek after EOS video+end+start': {'test': 'seek_after_eos', 'args': [media, 0b101.to_string()]},
'Seek after EOS video+start': {'test': 'seek_after_eos', 'args': [media, 0b111.to_string()]},
}

foreach use_pkt_duration : [0, 1]
Expand Down
44 changes: 22 additions & 22 deletions tests/test_comb.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ static int action_prefetch(struct sxplayer_ctx *s, int opt_test_flags)
return sxplayer_start(s);
}

#define FLAG_SKIP (1<<0)
#define FLAG_TRIM_DURATION (1<<1)
#define FLAG_START_TIME (1<<0)
#define FLAG_END_TIME (1<<1)
#define FLAG_AUDIO (1<<2)

static int action_fetch_info(struct sxplayer_ctx *s, int opt_test_flags)
Expand All @@ -46,17 +46,17 @@ static int action_fetch_info(struct sxplayer_ctx *s, int opt_test_flags)
#define SOURCE_SPF 1024 /* samples per frame, must match AUDIO_NBSAMPLES */
#define SOURCE_FREQ 44100

#define TESTVAL_SKIP 7.12
#define TESTVAL_TRIM_DURATION 53.43
#define TESTVAL_START_TIME 7.12
#define TESTVAL_END_TIME 60.43

static int check_frame(struct sxplayer_frame *f, double t, int opt_test_flags)
{
const double skip = (opt_test_flags & FLAG_SKIP) ? TESTVAL_SKIP : 0;
const double trim_duration = (opt_test_flags & FLAG_TRIM_DURATION) ? TESTVAL_TRIM_DURATION : -1;
const double playback_time = av_clipd(t, 0, trim_duration < 0 ? DBL_MAX : trim_duration);
const double start_time = (opt_test_flags & FLAG_START_TIME) ? TESTVAL_START_TIME : 0;
const double end_time = (opt_test_flags & FLAG_END_TIME) ? TESTVAL_END_TIME : -1;
const double playback_time = av_clipd(t, 0, end_time < 0 ? DBL_MAX : end_time);

const double frame_ts = f ? f->ts : -1;
const double estimated_time_from_ts = frame_ts - skip;
const double estimated_time_from_ts = frame_ts - start_time;
const double diff_ts = fabs(playback_time - estimated_time_from_ts);

if (!f) {
Expand All @@ -72,25 +72,25 @@ static int check_frame(struct sxplayer_frame *f, double t, int opt_test_flags)
const int frame_id = r<<(N*2) | g<<N | b;

const double video_ts = frame_id * 1. / SOURCE_FPS;
const double estimated_time_from_color = video_ts - skip;
const double estimated_time_from_color = video_ts - start_time;
const double diff_color = fabs(playback_time - estimated_time_from_color);

if (diff_color > 1./SOURCE_FPS) {
fprintf(stderr, "requested t=%f (clipped to %f with trim_duration=%f),\n"
"got video_ts=%f (frame id #%d), corresponding to t=%f (with skip=%f)\n"
fprintf(stderr, "requested t=%f (clipped to %f with end_time=%f),\n"
"got video_ts=%f (frame id #%d), corresponding to t=%f (with start_time=%f)\n"
"diff_color: %f\n",
t, playback_time, trim_duration,
video_ts, frame_id, estimated_time_from_color, skip,
t, playback_time, end_time,
video_ts, frame_id, estimated_time_from_color, start_time,
diff_color);
return -1;
}
}
if (diff_ts > 1./SOURCE_FPS) {
fprintf(stderr, "requested t=%f (clipped to %f with trim_duration=%f),\n"
"got frame_ts=%f, corresponding to t=%f (with skip=%f)\n"
fprintf(stderr, "requested t=%f (clipped to %f with end_time=%f),\n"
"got frame_ts=%f, corresponding to t=%f (with start_time=%f)\n"
"diff_ts: %f\n",
t, playback_time, trim_duration,
frame_ts, estimated_time_from_ts, skip,
t, playback_time, end_time,
frame_ts, estimated_time_from_ts, start_time,
diff_ts);
return -1;
}
Expand Down Expand Up @@ -188,8 +188,8 @@ static const struct {
static void print_comb_name(uint64_t comb, int opt_test_flags)
{
printf(":: test-%s-", (opt_test_flags & FLAG_AUDIO) ? "audio" : "video");
if (opt_test_flags & FLAG_SKIP) printf("skip-");
if (opt_test_flags & FLAG_TRIM_DURATION) printf("trimdur-");
if (opt_test_flags & FLAG_START_TIME) printf("start_time-");
if (opt_test_flags & FLAG_END_TIME) printf("end_time-");
for (int i = 0; i < NB_ACTIONS; i++) {
const int action = GET_ACTION(comb, i);
if (!action)
Expand All @@ -211,9 +211,9 @@ static int exec_comb(const char *filename, uint64_t comb, int opt_test_flags, in

print_comb_name(comb, opt_test_flags);

if (opt_test_flags & FLAG_SKIP) sxplayer_set_option(s, "skip", TESTVAL_SKIP);
if (opt_test_flags & FLAG_TRIM_DURATION) sxplayer_set_option(s, "trim_duration", TESTVAL_TRIM_DURATION);
if (opt_test_flags & FLAG_AUDIO) sxplayer_set_option(s, "avselect", SXPLAYER_SELECT_AUDIO);
if (opt_test_flags & FLAG_START_TIME) sxplayer_set_option(s, "start_time", TESTVAL_START_TIME);
if (opt_test_flags & FLAG_END_TIME) sxplayer_set_option(s, "end_time", TESTVAL_END_TIME);
if (opt_test_flags & FLAG_AUDIO) sxplayer_set_option(s, "avselect", SXPLAYER_SELECT_AUDIO);

for (int i = 0; i < NB_ACTIONS; i++) {
const int action = GET_ACTION(comb, i);
Expand Down
14 changes: 7 additions & 7 deletions tests/test_seek_after_eos.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <sxplayer.h>

#define FLAG_SKIP (1<<0)
#define FLAG_TRIM_DURATION (1<<1)
#define FLAG_END_TIME (1<<1)
#define FLAG_AUDIO (1<<2)

int main(int ac, char **av)
Expand All @@ -26,18 +26,18 @@ int main(int ac, char **av)
if (!s)
return -1;

const double skip = (flags & FLAG_SKIP) ? 60.0 : 0.0;
const double duration = (flags & FLAG_TRIM_DURATION) ? 10.0 : -1.0;
const int avselect = (flags & FLAG_AUDIO) ? SXPLAYER_SELECT_AUDIO : SXPLAYER_SELECT_VIDEO;
const double skip = (flags & FLAG_SKIP) ? 60.0 : 0.0;
const double end_time = (flags & FLAG_END_TIME) ? 70.0 : -1.0;
const int avselect = (flags & FLAG_AUDIO) ? SXPLAYER_SELECT_AUDIO : SXPLAYER_SELECT_VIDEO;

sxplayer_set_option(s, "auto_hwaccel", 0);
sxplayer_set_option(s, "avselect", avselect);
sxplayer_set_option(s, "audio_texture", 0);
sxplayer_set_option(s, "skip", skip);
sxplayer_set_option(s, "trim_duration", duration);
sxplayer_set_option(s, "end_time", end_time);
sxplayer_set_option(s, "use_pkt_duration", use_pkt_duration);

printf("run #1 (avselect=%d duration=%f)\n", avselect, duration);
printf("run #1 (avselect=%d end_time=%f)\n", avselect, end_time);
for (;;) {
frame = sxplayer_get_next_frame(s);
if (!frame) {
Expand All @@ -59,7 +59,7 @@ int main(int ac, char **av)
sxplayer_set_option(s, "avselect", avselect);
sxplayer_set_option(s, "audio_texture", 0);
sxplayer_set_option(s, "skip", skip);
sxplayer_set_option(s, "trim_duration", duration);
sxplayer_set_option(s, "end_time", end_time);

for (int i = 0; i < nb_frames; i++) {
frame = sxplayer_get_next_frame(s);
Expand Down

0 comments on commit f9ece03

Please sign in to comment.