aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c59
1 files changed, 18 insertions, 41 deletions
diff --git a/main.c b/main.c
index c6f4458..d562338 100644
--- a/main.c
+++ b/main.c
@@ -34,11 +34,13 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
+#include <stdlib.h>
#include "args.h"
#include "common.h"
#include "fileops.h"
#include "video.h"
+#include "gentest.h"
/* This is the size of the buffer for the compressed stream.
* It limits the maximum compressed frame size. */
@@ -119,14 +121,15 @@ int save_encoded(struct instance *i, const void *buf, unsigned int size)
int ret;
struct output *out = &i->out;
ssize_t written;
+ const char *ext = i->codec_name;
if (!i->save_encoded)
return 0;
if (!i->save_path)
- ret = sprintf(filename, "/mnt/sdcard/encoded.h264");
+ ret = sprintf(filename, "/mnt/sdcard/encoded.%s", ext);
else
- ret = sprintf(filename, "%s/encoded.h264", i->save_path);
+ ret = sprintf(filename, "%s/encoded.%s", i->save_path, ext);
if (ret < 0) {
err("sprintf fail (%s)", strerror(errno));
return -1;
@@ -158,39 +161,15 @@ write:
}
static int input_read(struct instance *inst, unsigned int index,
- unsigned int *used, unsigned int *fs)
+ unsigned int *used, unsigned int *fs)
{
struct video *vid = &inst->video;
- uint8_t *to = vid->out_buf_addr[index];
- int ret;
- char filename[64];
- static int num = 1;
+ unsigned char *to = vid->out_buf_addr[index];
*used = vid->out_buf_size;
*fs = vid->out_buf_size;
- ret = sprintf(filename, "/mnt/sdcard/frame%04d.nv12", num++);
- if (ret < 0) {
- err("sprintf fail (%s)", strerror(errno));
- return -1;
- }
-
- dbg("open %s", filename);
-
- ret = input_open(inst, filename);
- if (ret)
- return ret;
-
- dbg("input nv12 size:%d, sizeimage:%d", inst->in.size, *fs);
-
- memcpy(to, inst->in.p, inst->in.size);
-
- input_close(inst);
-
- usleep(33 * 1000);
-
- if (num > 14)
- num = 1;
+ gentest_fill(inst->width, inst->height, to, vid->out_buf_size);
return 0;
}
@@ -291,7 +270,7 @@ void *main_thread_func(void *args)
vid->total_encoded++;
- save_encoded(i, (void *)vid->cap_buf_addr[n][0],
+ save_encoded(i, (const void *)vid->cap_buf_addr[n][0],
bytesused);
ret = video_queue_buf_cap(i, n);
@@ -345,19 +324,13 @@ int main(int argc, char **argv)
vid->total_encoded = 0;
-// ret = input_open(&inst, inst.in.name);
-// if (ret)
-// goto err;
-
ret = video_open(&inst, inst.video.name);
if (ret)
goto err;
-#if 1
- /* TODO: */
+
ret = subscribe_for_events(vid->fd);
if (ret)
goto err;
-#endif
if (inst.use_dmabuf)
ret = video_setup_capture_dmabuf(&inst, 2, inst.width,
@@ -371,11 +344,14 @@ int main(int argc, char **argv)
if (ret)
goto err;
+ ret = gentest_init(inst.width, inst.height, vid->out_buf_size);
+ if (ret)
+ goto err;
+
ret = video_set_control(&inst);
if (ret)
goto err;
- /* queue all capture buffers */
for (n = 0; n < vid->cap_buf_cnt; n++) {
ret = video_queue_buf_cap(&inst, n);
if (ret)
@@ -422,13 +398,14 @@ int main(int argc, char **argv)
info("Total frames encoded %ld", vid->total_encoded);
- cleanup(&inst);
-
pthread_mutex_destroy(&inst.lock);
+ cleanup(&inst);
+ gentest_deinit();
return 0;
err:
+ pthread_mutex_destroy(&inst.lock);
cleanup(&inst);
+ gentest_deinit();
return 1;
}
-