Index: Makefile.in =================================================================== --- Makefile.in (revisión: 172) +++ Makefile.in (copia de trabajo) @@ -33,7 +33,7 @@ ################################################################################ CFLAGS = @CFLAGS@ -Wall -DVERSION=\"$(VERSION)\" -D_REENTRANT \ -Dsysconfdir=\"$(sysconfdir)\" -LDFLAGS = @LDFLAGS@ +LDFLAGS = @LDFLAGS@ -lmjpegutils -llavjpeg LIBS = @LIBS@ VIDEO_OBJ = @VIDEO@ OBJ = motion.o conf.o draw.o $(VIDEO_OBJ) netcam.o \ Index: video.h =================================================================== --- video.h (revisión: 172) +++ video.h (copia de trabajo) @@ -80,6 +80,7 @@ int sonix_decompress(unsigned char *outp, unsigned char *inp,int width, int height); void bayer2rgb24(unsigned char *dst, unsigned char *src, long int width, long int height); int vid_do_autobright(struct context *cnt, struct video_dev *viddev); +void mjpegtoyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height, unsigned int size); #ifndef WITHOUT_V4L /* video functions, video.c */ Index: video2.c =================================================================== --- video2.c (revisión: 172) +++ video2.c (copia de trabajo) @@ -786,25 +786,11 @@ case V4L2_PIX_FMT_YUV420: memcpy(map, the_buffer->ptr, viddev->v4l_bufsize); // ? s->buffer[s->buf.index].size; return 0; -#ifdef HAVE_FFMPEG + case V4L2_PIX_FMT_MJPEG: - { - netcam_buff temp_netcam_buff = *the_buffer; + mjpegtoyuv420p(map, (unsigned char *) the_buffer->ptr, width, height, s->buffers[s->buf.index].content_length); + return 0; - temp_netcam_buff.ptr = - (char *) MJPEGDecodeFrame((unsigned char *) the_buffer->ptr, - the_buffer->content_length, cnt->imgs.common_buffer, - (width * height << 1), s->mjpeg); - - if (temp_netcam_buff.ptr == NULL){ - motion_log(LOG_INFO,0,"Error decoding MJPEG"); - return 1; - } - memcpy(map, temp_netcam_buff.ptr, viddev->v4l_bufsize); - return 0; - - } -#endif case V4L2_PIX_FMT_JPEG: return conv_jpeg2yuv420(cnt, map, the_buffer, viddev->v4l_bufsize, width, height); Index: video_common.c =================================================================== --- video_common.c (revisión: 172) +++ video_common.c (copia de trabajo) @@ -14,6 +14,9 @@ /* for rotation */ #include "rotate.h" +#include +#include + typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; @@ -394,6 +397,44 @@ return netcam_proc_jpeg(&netcam, dst); } +void mjpegtoyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height, unsigned int size) +{ + uint8_t *yuv[3]; + unsigned char *y, *u, *v; + int loop; + + yuv[0] = malloc(width * height * sizeof(yuv[0][0])); + yuv[1] = malloc(width * height / 4 * sizeof(yuv[1][0])); + yuv[2] = malloc(width * height / 4 * sizeof(yuv[2][0])); + + + decode_jpeg_raw(cap_map, size, 0, 420, width, height, yuv[0], yuv[1], yuv[2]); + + y=map; + u=y+width*height; + v=u+(width*height)/4; + memset(y, 0, width*height); + memset(u, 0, width*height/4); + memset(v, 0, width*height/4); + + for(loop=0; loop (y) ? (x) : (y)) #define MIN2(x, y) ((x) < (y) ? (x) : (y))