/usr/share/doc/libsimage-dev/examples/img2avi.c is in libsimage-dev 1.7.1~2c958a6.dfsg-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /*
* Copyright (c) Kongsberg Oil & Gas Technologies
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/* MSVC: link with setargv.obj to process wildcard arguments */
#include <simage.h>
int main(int argc, char *argv[])
{
int i;
char *filename;
int fps;
int first;
int width;
int height;
s_movie * movie;
s_params * params;
s_image *image;
char formatbuf[20];
first = 1;
if (argc < 4) {
printf("USAGE: IMG2AVI <filename.avi> <fps> <imagefile1> <imagefile2> ...\n"
"All images must have the same width and height, and both must be divisible by 4\n");
return 0;
}
filename = argv[1];
fps = atoi(argv[2]);
sprintf(formatbuf, "%%%dd/%%%dd \"%%s\"", (int)ceil(log10(argc-3)), (int)ceil(log10(argc-3)));
for (i=3; i<argc; i++) {
/* read image */
printf(formatbuf, i-2, argc-3, argv[i]);
printf(" ");
image = s_image_load(argv[i], NULL);
if (image==NULL) {
fprintf(stderr, "\nError: Couldn't read image from file '%s'.\n", argv[i]);
exit(1);
}
printf("(%dx%dx%d)\n", s_image_width(image), s_image_height(image), s_image_components(image));
if (first) {
/* Create movie file */
first = 0;
width = s_image_width(image);
height = s_image_height(image);
if ( (width % 4 != 0) || (height % 4 != 0) ) {
fprintf(stderr, "\nError: Image ('%s') width (%d) and height (%d) must be divisible by 4\n", filename, width, height);
exit(1);
}
params = s_params_create();
s_params_set(params,
"mime-type", S_STRING_PARAM_TYPE, "video/avi",
"width", S_INTEGER_PARAM_TYPE, width,
"height", S_INTEGER_PARAM_TYPE, height,
"fps", S_INTEGER_PARAM_TYPE, fps,
"parameter file", S_STRING_PARAM_TYPE, "",
/* NULL means no more params */
NULL);
movie = s_movie_create(filename, params);
if (movie == NULL) {
fprintf(stderr, "\nError: Could not create movie file '%s'\n", filename);
exit(1);
}
}
if ( (s_image_width(image) != width) || (s_image_height(image) != height) ) {
fprintf(stderr, "\nError: All images must have the same width and height.\n", width, height);
exit(1);
}
/* Encode image */
s_movie_put_image(movie, image, NULL);
s_image_destroy(image);
}
/* Clean up */
if (movie != NULL) {
s_movie_close(movie);
s_movie_destroy(movie);
}
return 0;
};
|