summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2558084)
raw | patch | inline | side by side (parent: 2558084)
author | Josh Elliott <jelliott@ti.com> | |
Mon, 14 Jul 2014 09:51:08 +0000 (04:51 -0500) | ||
committer | Josh Elliott <jelliott@ti.com> | |
Mon, 14 Jul 2014 09:51:08 +0000 (04:51 -0500) |
jpeg.cpp | patch | blob | history | |
jpeg.h | patch | blob | history | |
loopback.cpp | patch | blob | history |
diff --git a/jpeg.cpp b/jpeg.cpp
index e65792badbb9a070339401ddac35e905e292d7b7..e8f879bfdddccf781eb74485d82cd76f7a6bcb83 100644 (file)
--- a/jpeg.cpp
+++ b/jpeg.cpp
#include <sys/mman.h>
#include <jpeglib.h>
-void jpegWrite(unsigned char* yuv, int index)
+void jpegWrite(unsigned char* yuv, int index, int width, int height)
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
- unsigned char *img = (unsigned char *)malloc(800*600*3*sizeof(char));
+ unsigned char *img = (unsigned char *)malloc(width*height*3*sizeof(char));
char jpegFilename[256];
jpeg_stdio_dest(&cinfo, outfile);
// set image parameters
- cinfo.image_width = 800;
- cinfo.image_height = 600;
+ cinfo.image_width = width;
+ cinfo.image_height = height;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_YCbCr;
// close output file
fclose(outfile);
- munmap(img, 800*600*3*sizeof(char));
+ munmap(img, width*height*3*sizeof(char));
return;
}
index cc3b2b36136b2ffc02713dc55f612176b520e4b5..775212f64f8280f036956323d429762104b31775 100644 (file)
--- a/jpeg.h
+++ b/jpeg.h
#ifndef JPEG_H
#define JPEG_H
-void jpegWrite(unsigned char* yuv, int index);
+void jpegWrite(unsigned char* yuv, int index, int width, int height);
#endif // JPEG_H
diff --git a/loopback.cpp b/loopback.cpp
index ce833a8e35e540dd4f7909e0b45832cee76b121d..18a1cf352feaa7046715a34531d8d01c7cae0969 100644 (file)
--- a/loopback.cpp
+++ b/loopback.cpp
status.display_xres = device->di.xres;
status.display_yres = device->di.yres;
+ if (device->di.xres < 640) {
+ device->width = 640;
+ device->height = 480;
+ }
+
/* Set the input resolution of the video framebuffer to be the size
* of the camera image. Later, the output size will be matched to
* the display to allow for up/down scaling */
v4l2_dequeue_buffer(v4l2_device);
jpegWrite((unsigned char *)v4l2_device->buffers[cap0_device.buf.index].start,
- status.num_jpeg);
+ status.num_jpeg, v4l2_device->width, v4l2_device->height);
/* Give the buffer back to the driver so it can be filled again */
v4l2_queue_buffer(v4l2_device);
/* Declare properties for video and capture devices */
default_parameters();
+ /* Initialize the fbdev display devices */
+ if (fbdev_init_device(&fb1_device)) goto Error;
+ if (fbdev_init_device(&fb2_device)) goto Error;
+
+ /* Check to see if the display resolution is very small. If so, the
+ * camera capture resolution needs to be lowered so that the scaling
+ * limits of the DSS are not reached */
+ if (fb1_device.di.xres < 640) {
+ /* Set capture 0 device resolution */
+ cap0_device.width = 640;
+ cap0_device.height = 480;
+
+ /* Set capture 1 device resolution */
+ cap1_device.width = 640;
+ cap1_device.height = 480;
+ }
+
/* Initialize the v4l2 capture devices */
if (v4l2_init_device(&cap0_device) < 0) goto Error;
if (v4l2_init_device(&cap1_device) < 0) {
if (v4l2_stream_on(&cap1_device) < 0) goto Error;
}
- /* Initialize the fbdev display devices */
- if (fbdev_init_device(&fb1_device)) goto Error;
- if (fbdev_init_device(&fb2_device)) goto Error;
-
/* Configure the DSS to blend video and graphics layers */
if (fbdev_init_dss() < 0 ) goto Error;