blob: 5dbe6d7a972667b8e168fcffe9d9e6668cca265a (
plain)
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
|
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "video_decode.h"
static int64_t
frame_average(struct video_frame *frame)
{
int64_t average = 0;
uint8_t *row = frame->data;
uint8_t *col = NULL;
for (int y = 0; y < frame->height; ++y) {
col = row;
for (int x = 0; x < frame->width; ++x) {
average += *col;
col++;
}
row += frame->stride;
}
return average / (frame->width * frame->height);
}
int
main(int argc, char **argv)
{
struct video_decode *vd;
struct video_frame *frame;
int ret;
int64_t timestamp = 0;
if (argc < 2)
return 1;
if (argc == 3 && strtol(argv[2], NULL, 10) > 0)
timestamp = strtol(argv[2], NULL, 10);
ret = video_decode_init(&vd, argv[1], timestamp);
if (ret < 0)
return -ret;
while (video_decode_get_frame(vd, &frame) == 0) {
printf("%ld\n", frame_average(frame));
video_decode_free_frame(&frame);
}
// pgm_save(frame->data, frame->stride, frame->width, frame->height,
// argv[2]);
video_decode_uninit(&vd);
}
|