summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorOneric <oneric@oneric.stub>2022-05-07 01:45:57 +0200
committerOneric <oneric@oneric.stub>2022-05-07 22:18:50 +0200
commita6ae1d2fb30551570bd2fee094e1eb9e5c632afe (patch)
treeae4257f0fa846cf4dcc9608814cbcc2a2447537b /test
parentb77c58cd43281a05cd242888a8aac39668d67266 (diff)
downloadlibass-a6ae1d2fb30551570bd2fee094e1eb9e5c632afe.tar.bz2
libass-a6ae1d2fb30551570bd2fee094e1eb9e5c632afe.tar.xz
profile, test: set storage size before rendering
As programs provided with the library's source code they also serve as examples for how to correctly use the API, which usually means setting a storage size. compare already sets the storage size. profile can continue using a fixed size, it never outputs the rendering. test already had issues before if either the guessed storage size was incorrect or the frame size didn't match the intended aspect ratio. To fix both, add new optional arguments for storage and frame size.
Diffstat (limited to 'test')
-rw-r--r--test/test.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/test/test.c b/test/test.c
index b099a9a..f1de28f 100644
--- a/test/test.c
+++ b/test/test.c
@@ -107,6 +107,7 @@ static void init(int frame_w, int frame_h)
exit(1);
}
+ ass_set_storage_size(ass_renderer, frame_w, frame_h);
ass_set_frame_size(ass_renderer, frame_w, frame_h);
ass_set_fonts(ass_renderer, NULL, "sans-serif",
ASS_FONTPROVIDER_AUTODETECT, NULL, 1);
@@ -192,16 +193,26 @@ static void print_font_providers(ASS_Library *ass_library)
int main(int argc, char *argv[])
{
- const int frame_w = 1280;
- const int frame_h = 720;
+ int frame_w = 1280;
+ int frame_h = 720;
- if (argc < 4) {
- printf("usage: %s <image file> <subtitle file> <time>\n", argv[0]);
+ if (argc != 4 && argc != 6) {
+ printf("usage: %s <image file> <subtitle file> <time> "
+ "[<storage width> <storage height>]\n",
+ argv[0]);
exit(1);
}
char *imgfile = argv[1];
char *subfile = argv[2];
double tm = strtod(argv[3], 0);
+ if (argc == 6) {
+ frame_w = atoi(argv[4]);
+ frame_h = atoi(argv[5]);
+ if (frame_w <= 0 || frame_h <= 0) {
+ printf("storage size must be non-zero and positive!\n");
+ exit(1);
+ }
+ }
print_font_providers(ass_library);