[Armadeus-commitlog] armadeus branch, master, updated. armadeus-4.0-2566-gc58511a
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2011-10-23 10:45:57
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via c58511a69dd1358473973e5ba357e402c9db11b1 (commit)
via 82439fe13fd2d52b996d7e0a50038477c8086103 (commit)
via 36d1c352fd2501f4d6ce9778d907f030b792daa8 (commit)
from 3820de59d5a21a799be86b7491745f72f96f7857 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c58511a69dd1358473973e5ba357e402c9db11b1
Merge: 82439fe 3820de5
Author: Julien Boibessot <jul...@ar...>
Date: Sun Oct 23 12:45:01 2011 +0200
Merge branch 'master' of ssh://armadeus.git.sourceforge.net/gitroot/armadeus/armadeus
commit 82439fe13fd2d52b996d7e0a50038477c8086103
Author: Julien Boibessot <jul...@ar...>
Date: Sun Oct 23 12:44:25 2011 +0200
[DEMOS] Capture: add rgb565_to_yuv420 convertion and IP addr command line option
commit 36d1c352fd2501f4d6ce9778d907f030b792daa8
Author: Julien Boibessot <jul...@ar...>
Date: Sun Oct 23 12:41:19 2011 +0200
[BUILDROOT] Add VPU option to capture menuconfig
-----------------------------------------------------------------------
Summary of changes:
buildroot/package/armadeus/demos/Config.in | 7 ++
buildroot/package/armadeus/demos/demos.mk | 10 ++-
target/demos/camera/capture/Makefile | 4 +-
target/demos/camera/capture/capture.c | 99 +++++++++++++++++++++++----
target/demos/camera/capture/rtp.c | 25 +++++---
target/demos/camera/capture/rtp.h | 14 +---
target/demos/camera/capture/vpu_codec.c | 6 +-
target/demos/camera/capture/vpu_codec.h | 19 +-----
8 files changed, 124 insertions(+), 60 deletions(-)
diff --git a/buildroot/package/armadeus/demos/Config.in b/buildroot/package/armadeus/demos/Config.in
index 8e7db54..e0bc226 100644
--- a/buildroot/package/armadeus/demos/Config.in
+++ b/buildroot/package/armadeus/demos/Config.in
@@ -48,6 +48,13 @@ config BR2_PACKAGE_ARMADEUS_DEMOS_CAPTURE
help
Capture and display camera (V4L) video stream.
+config BR2_PACKAGE_ARMADEUS_DEMOS_CAPTURE_VPU
+ bool "use VPU"
+ depends on BR2_PACKAGE_ARMADEUS_DEMOS_CAPTURE
+# select FREESCALE_TOOLS
+ help
+ Use i.MX27/i.MX51 VPU to encode stream in H.264
+
config BR2_PACKAGE_ARMADEUS_DEMOS_OSCILLO
bool "Oscilloscope"
help
diff --git a/buildroot/package/armadeus/demos/demos.mk b/buildroot/package/armadeus/demos/demos.mk
index eda3163..20f318e 100644
--- a/buildroot/package/armadeus/demos/demos.mk
+++ b/buildroot/package/armadeus/demos/demos.mk
@@ -26,8 +26,12 @@ ARMADEUS-DEMOS_SUBDIRS+=gpio
endif
ifeq ($(BR2_PACKAGE_ARMADEUS_DEMOS_CAPTURE),y)
-ARMADEUS-DEMOS_SUBDIRS+=camera/capture
-ARMADEUS-DEMOS_DEPS=sdl
+ARMADEUS-DEMOS_SUBDIRS += camera/capture
+ARMADEUS-DEMOS_DEPS = sdl
+ifeq ($(BR2_PACKAGE_ARMADEUS_DEMOS_CAPTURE_VPU),y)
+ARMADEUS-DEMOS_DEPS += freescale-tools
+ARMADEUS-DEMOS_PARAMS = "VPU=yes"
+endif
endif
ifeq ($(BR2_PACKAGE_ARMADEUS_DEMOS_GPS),y)
@@ -79,7 +83,7 @@ $(ARMADEUS-DEMOS_DIR)/.compiled: $(ARMADEUS-DEMOS_DIR)/.unpacked
echo -e "\n >>> Compiling $$dir demo <<<" ; \
dir=$(ARMADEUS-DEMOS_DIR)/$$dir ; \
if [ -d "$$dir" ]; then \
- (cd $$dir && $(MAKE) CC="$(TARGET_CC)" STAGING_DIR=$(STAGING_DIR) ARMADEUS_BOARD_NAME=$(BR2_BOARD_NAME)) || exit 1 ; \
+ (cd $$dir && $(MAKE) CC="$(TARGET_CC)" STAGING_DIR=$(STAGING_DIR) ARMADEUS_BOARD_NAME=$(BR2_BOARD_NAME) $(ARMADEUS-DEMOS_PARAMS)) || exit 1 ; \
fi \
done
touch $@
diff --git a/target/demos/camera/capture/Makefile b/target/demos/camera/capture/Makefile
index a1f50d4..35c19b8 100644
--- a/target/demos/camera/capture/Makefile
+++ b/target/demos/camera/capture/Makefile
@@ -12,8 +12,8 @@ CFLAGS=$(shell STAGING_DIR=$(STAGING_DIR) sh $(STAGING_DIR)/usr/bin/sdl-config -
#CFLAGS+=-Wall -g
LDFLAGS= -lSDL -lpthread
ifeq ($(VPU),yes)
-CFLAGS+=-I$(ARMADEUS_STAGING_DIR)/usr/include/ -DUSE_VPU
-LDFLAGS+= -L$(ARMADEUS_STAGING_DIR)/usr/lib/ -lvpu
+CFLAGS += -I$(STAGING_DIR)/usr/include/ -DUSE_VPU
+LDFLAGS += -L$(STAGING_DIR)/usr/lib/ -lvpu
endif
EXEC= capture
diff --git a/target/demos/camera/capture/capture.c b/target/demos/camera/capture/capture.c
index c7cb29d..767facb 100644
--- a/target/demos/camera/capture/capture.c
+++ b/target/demos/camera/capture/capture.c
@@ -61,7 +61,8 @@ struct buffer {
size_t offset;
};
-static char * dev_name = NULL;
+static char *dev_name = NULL;
+static char *ip_addr = "192.168.0.2";
static io_method io = IO_METHOD_MMAP;
static int fd = -1;
struct buffer * buffers = NULL;
@@ -220,6 +221,69 @@ static void yuv420_to_rgb565(void *yuv, int size, void *rgb)
}
}
+#if 0
+static void rgb565_to_yuv420(void *rgb, int size, void *yuv)
+{
+ int Y, U, V;
+ int R, G, B;
+ int i, index = 1;
+ int nbpix = mycamera.width * mycamera.height;
+ Uint16 *src = (Uint16*) rgb;
+ Uint8 *dest = (Uint8*) yuv;
+
+ for (i = 0; i < nbpix; i++) {
+ R = (src[i] & 0xf800) >> 8;
+ G = (src[i] & 0x07c0) >> 3;
+ B = (src[i] & 0x001f) << 3;
+ Y = 0.299 * R + 0.587 * G + 0.114 * B;
+ dest[i] = Y;
+ if ((index == 1) || (index == 3) || (index == 5)) {
+ U = -0.169 * R - 0.331 * G + 0.449 * B + 128;
+ V = 0.499 * R - 0.418 * G - 0.0813 * B + 128;
+ dest[i + nbpix / 2] = U;
+ dest[i + 3 * nbpix / 4] = V;
+ }
+ index++;
+ if (index >= 12)
+ index = 1;
+ }
+}
+#endif
+
+static void rgb565_to_yuv420(void *rgb, int size, void *yuv)
+{
+ int Y, U, V;
+ int R, G, B;
+ int i, index = 0;
+ int x, y, u = 0, v = 0;
+ int nbpix = mycamera.width * mycamera.height;
+ Uint16 *src = (Uint16*) rgb;
+ Uint8 *dest = (Uint8*) yuv;
+
+ for (i = 0; i < nbpix; i++) {
+ R = (src[i] & 0xf800) >> 8;
+ G = (src[i] & 0x07c0) >> 3;
+ B = (src[i] & 0x001f) << 3;
+ Y = 0.299 * R + 0.587 * G + 0.114 * B;
+ dest[i] = Y;
+ }
+ for (y = 0; y < mycamera.height ; y++) {
+ if ((y & 0x00000001) == 0) {
+ for (x = 0; x < mycamera.width ; x = x + 2) {
+ R = (src[x] & 0xf800) >> 8;
+ G = (src[x] & 0x07c0) >> 3;
+ B = (src[x] & 0x001f) << 3;
+ U = -0.169 * R - 0.331 * G + 0.449 * B + 128;
+ V = 0.499 * R - 0.418 * G - 0.0813 * B + 128;
+ dest[nbpix + u] = U;
+ u++;
+ dest[nbpix + nbpix / 4 + v] = V;
+ v++;
+ }
+ }
+ }
+}
+
static void simple_copy(void *yuv, int size, void* rgb)
{
memcpy(rgb, yuv, size);
@@ -301,8 +365,12 @@ static int read_frame(void)
assert (buf.index < n_buffers);
#ifdef USE_VPU
- if (g_use_codec)
- vpu_codec_encode_next_frame(buffers[buf.index].offset, buffers[buf.index].start);
+ if (g_use_codec) {
+ if (mycamera.pixelformat == V4L2_PIX_FMT_RGB565) {
+ rgb565_to_yuv420(buffers[buf.index].start, mycamera.sizeimage, image->pixels);
+ }
+ vpu_codec_encode_next_frame(buffers[buf.index].offset, /*buffers[buf.index].start*/ image->pixels);
+ }
#endif
// else
process_image(buffers[buf.index].start, buf.length);
@@ -827,16 +895,16 @@ static void usage(FILE *fp, int argc, char **argv)
fprintf (fp,
"Usage: %s [options]\n\n"
"Options:\n"
- "-d | --device name Video device name [/dev/video0]\n"
- "-h | --help Print this message\n"
- "-m | --mmap Use memory mapped buffers\n"
- "-r | --read Use read() calls\n"
- "-u | --userp Use application allocated buffers\n"
- "--width W Use W as screen width (instead of %d)\n"
- "--height H Use H as screen height (instead of %d)\n"
- "--cam_width W Use W as camera picture width (instead of %d)\n"
- "--cam_height H Use H as camera picture height (instead of %d)\n"
- "--use_vpu Uses processor VPU to encode video (at camera size)\n"
+ " -d | --device name Video device name [/dev/video0]\n"
+ " -h | --help Print this message\n"
+ " -m | --mmap Use memory mapped buffers\n"
+ " -r | --read Use read() calls\n"
+ " -u | --userp Use application allocated buffers\n"
+ " --width W Use W as screen width (instead of %d)\n"
+ " --height H Use H as screen height (instead of %d)\n"
+ " --cam_width W Use W as camera picture width (instead of %d)\n"
+ " --cam_height H Use H as camera picture height (instead of %d)\n"
+ " --use_vpu IP Uses processor VPU to encode video (at camera size) and send it to IP addr\n"
"",
argv[0], SCREEN_WIDTH, SCREEN_HEIGHT, CAM_WIDTH, CAM_HEIGHT);
}
@@ -853,7 +921,7 @@ static const struct option long_options [] = {
{ "height", required_argument, NULL, 't' },
{ "cam_width", required_argument, NULL, 'y' },
{ "cam_height", required_argument, NULL, 'z' },
- { "use_vpu", no_argument, NULL, 'v' },
+ { "use_vpu", required_argument, NULL, 'v' },
{ 0, 0, 0, 0 }
};
@@ -927,6 +995,7 @@ int main(int argc, char **argv)
case 'v':
g_use_codec = 1;
+ ip_addr = optarg;
break;
case 'w':
@@ -970,7 +1039,7 @@ int main(int argc, char **argv)
}
#ifdef USE_VPU
if (g_use_codec)
- vpu_codec_init(2, camwidth, camheight, 0 /* bitrate */, 2);
+ vpu_codec_init(2, camwidth, camheight, 0 /* bitrate */, 2, ip_addr);
#endif
open_capture_device();
diff --git a/target/demos/camera/capture/rtp.c b/target/demos/camera/capture/rtp.c
index 15666d3..c64bb88 100644
--- a/target/demos/camera/capture/rtp.c
+++ b/target/demos/camera/capture/rtp.c
@@ -47,7 +47,7 @@ typedef struct {
} __attribute__((packed)) rtph_t;
-int rtp_init(rtp_t * t, int bufsize)
+static int rtp_init(rtp_t * t, int bufsize)
{
rtph_t *h;
int rt;
@@ -80,7 +80,7 @@ int rtp_init(rtp_t * t, int bufsize)
return 0;
}
-int rtp_exit(rtp_t * t)
+static int rtp_exit(rtp_t * t)
{
free(t->rxbuf);
close(t->sock);
@@ -103,7 +103,7 @@ static inline int min(int a, int b)
#define IS_ACCESS_UNIT(x) (((x) > 0x00) && ((x) < 0x06))
-int rtp_tx(rtp_t * t, char *buf, int len)
+static int rtp_tx(rtp_t * t, char *buf, int len)
{
rtph_t *h;
int tlen, hlen;
@@ -188,7 +188,7 @@ int rtp_tx(rtp_t * t, char *buf, int len)
}
}
-int rtp_rx(rtp_t * t, char *buf, int len)
+static int rtp_rx(rtp_t * t, char *buf, int len)
{
rtph_t *h;
int tlen;
@@ -264,25 +264,32 @@ int rtp_rx(rtp_t * t, char *buf, int len)
return tlen;
}
-rtp_t* rtp_session_open()
+static rtp_t* rtp_session_open(char *ip_addr)
{
rtp_t *rtp = (rtp_t *) malloc(sizeof(rtp_t));
memset(rtp, 0, sizeof(rtp_t));
rtp->name = "rec";
- rtp->ip = RTP_ADDRESS;
+ if (ip_addr)
+ rtp->ip = ip_addr;
+ else
+ rtp->ip = RTP_ADDRESS;
rtp->port = RTP_PORT;
rtp->type = RTP_TYPE_DYNAMIC;
rtp->size = 512;
rtp->clock = 1000000;
rtp_init(rtp, 0);
+ printf("rtp: sending to IP @: %s\n", ip_addr);
+
return rtp;
}
-void rtp_send(char *packet, int size)
+void rtp_send(char *packet, int size, char *ip_addr)
{
static rtp_t* rtp_session = NULL;
- if (rtp_session==NULL)
- rtp_session = rtp_session_open();
+
+ if (rtp_session == NULL)
+ rtp_session = rtp_session_open(ip_addr);
+
rtp_tx(rtp_session, packet, size);
}
diff --git a/target/demos/camera/capture/rtp.h b/target/demos/camera/capture/rtp.h
index d745132..46a3f17 100644
--- a/target/demos/camera/capture/rtp.h
+++ b/target/demos/camera/capture/rtp.h
@@ -31,7 +31,7 @@
#define RTP_TYPE_DYNAMIC 96
#define RTP_PORT 6666
-#define RTP_ADDRESS "192.168.0.2"
+#define RTP_ADDRESS "192.168.0.2" /* Default address to send packet */
typedef struct {
char *name; /* local session id */
@@ -53,16 +53,8 @@ typedef struct {
} rtp_t;
/*
- bufsize is in # of RTP pkts to buffer in rx (to cut delays)
- 0 - default socket buffer size
+rtp_t* rtp_session_open(char *ip_addr);
*/
-/*int rtp_init(rtp_t *, int bufsize);
-int rtp_tx(rtp_t *, char *buf, int len);
-int rtp_rx(rtp_t *, char *buf, int len);
-int rtp_exit(rtp_t *);
-*/
-
-rtp_t* rtp_session_open();
-void rtp_send(char *packet, int size);
+void rtp_send(char *packet, int size, char *ip_addr);
#endif
diff --git a/target/demos/camera/capture/vpu_codec.c b/target/demos/camera/capture/vpu_codec.c
index 4c6166f..47917d4 100644
--- a/target/demos/camera/capture/vpu_codec.c
+++ b/target/demos/camera/capture/vpu_codec.c
@@ -313,11 +313,12 @@ static void set_encoder_opening_parameters(EncOpenParam * enc_op_params, vpu_mem
}
int gdest = PATH_NET;
+static char *g_ip_addr = "0.0.0.0";
static void export_bitstream(char *packet, int size)
{
if (gdest & PATH_NET) {
- rtp_send(packet, size);
+ rtp_send(packet, size, g_ip_addr);
}
}
@@ -351,7 +352,7 @@ int g_initialized = 0;
/* for this test, only 1 reference */ /* no rotation */
-int vpu_codec_init(int mode, int picWidth, int picHeight, int bitRate, Uint32 dest)
+int vpu_codec_init(int mode, int picWidth, int picHeight, int bitRate, Uint32 dest, char *ip_addr)
{
EncInitialInfo initialInfo = { 0 };
SearchRamParam searchPa = { 0 };
@@ -363,6 +364,7 @@ int vpu_codec_init(int mode, int picWidth, int picHeight, int bitRate, Uint32 de
int i;
struct v4l2_buffer prp_buffer;
+ g_ip_addr = ip_addr;
image_size = picWidth * picHeight; /* in pixels */
memset(&encParam, 0, sizeof(EncParam));
diff --git a/target/demos/camera/capture/vpu_codec.h b/target/demos/camera/capture/vpu_codec.h
index 3bec2cc..e5cb167 100644
--- a/target/demos/camera/capture/vpu_codec.h
+++ b/target/demos/camera/capture/vpu_codec.h
@@ -24,8 +24,6 @@
#ifndef __VPU__VOIP__TEST__H
#define __VPU__VOIP__TEST__H
-// #include "../../lib/vpu/vpu_io.h"
-// #include "../../lib/vpu/vpu_lib.h"
#define Uint32 unsigned int
#define PAL_MODE 0
@@ -96,21 +94,8 @@ struct codec_config {
Uint32 mirror_angle;
};
-// void *DecodeTest(void *param);
-int vpu_codec_init(int mode, int picWidth, int picHeight, int bitRate, Uint32 dest);
-// void *sig_thread(void *arg); /* the thread is used to monitor signal */
-
-int FillBsBufMulti(int src, char *src_name, int targetAddr,
- int bsBufStartAddr, int bsBufEndAddr, int size,
- int index, int checkeof, int *streameof, int read_flag);
-/* Read/Write one frame raw data each time, for Encoder/Decoder respectively */
-int FillYuvImageMulti(int src, char *src_name, int buf, void *emma_buf,
- int inwidth, int inheight, int index, int read_flag,
- int rot_en, int output_ratio, int frame_num);
-
+int vpu_codec_init(int mode, int picWidth, int picHeight, int bitRate, Uint32 dest, char *ip_addr);
int vpu_codec_encode_next_frame(Uint32 frame_offset, unsigned char* image);
-
-int vpu_SystemShutdown(void);
void vpu_codec_stop(void);
void vpu_codec_pause(void);
@@ -123,8 +108,6 @@ void vpu_codec_pause(void);
#define PATH_EMMA 1
#define PATH_NET 2
-// pthread_t codec_thread[MAX_NUM_INSTANCE];
-
#ifdef DEBUG
#define DPRINTF(fmt, args...) printf("%s: " fmt , __FUNCTION__, ## args)
#else
hooks/post-receive
--
armadeus
|