Merge branch 'master' of github.com:ZoneMinder/ZoneMinder

This commit is contained in:
Isaac Connor 2015-11-10 14:45:24 -05:00
commit b123de3b54
13 changed files with 269 additions and 171 deletions

View File

@ -24,7 +24,7 @@ before_install:
- sudo apt-get update -qq
- sudo apt-get install -y -qq libpolkit-gobject-1-dev zlib1g-dev apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf cmake libjpeg-turbo8-dev apache2-mpm-prefork libapache2-mod-php5 php5-cli libtheora-dev libvorbis-dev libvpx-dev libx264-dev libvlccore-dev libvlc-dev libvlccore5 libvlc5 2>&1 > /dev/null
install:
- git clone -b n2.7.2 --depth=1 git://source.ffmpeg.org/ffmpeg.git
- git clone -b n2.8.1 --depth=1 git://source.ffmpeg.org/ffmpeg.git
- cd ffmpeg
- ./configure --enable-shared --enable-swscale --enable-gpl --enable-libx264 --enable-libvpx --enable-libvorbis --enable-libtheora
- make -j `grep processor /proc/cpuinfo|wc -l`

View File

@ -24,8 +24,8 @@
#if HAVE_LIBAVCODEC || HAVE_LIBAVUTIL || HAVE_LIBSWSCALE
#if HAVE_LIBAVUTIL
enum PixelFormat GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder) {
enum PixelFormat pf;
enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder) {
enum _AVPIXELFORMAT pf;
Debug(8,"Colours: %d SubpixelOrder: %d",p_colours,p_subpixelorder);
@ -34,10 +34,10 @@ enum PixelFormat GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixe
{
if(p_subpixelorder == ZM_SUBPIX_ORDER_BGR) {
/* BGR subpixel order */
pf = PIX_FMT_BGR24;
pf = AV_PIX_FMT_BGR24;
} else {
/* Assume RGB subpixel order */
pf = PIX_FMT_RGB24;
pf = AV_PIX_FMT_RGB24;
}
break;
}
@ -45,25 +45,25 @@ enum PixelFormat GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixe
{
if(p_subpixelorder == ZM_SUBPIX_ORDER_ARGB) {
/* ARGB subpixel order */
pf = PIX_FMT_ARGB;
pf = AV_PIX_FMT_ARGB;
} else if(p_subpixelorder == ZM_SUBPIX_ORDER_ABGR) {
/* ABGR subpixel order */
pf = PIX_FMT_ABGR;
pf = AV_PIX_FMT_ABGR;
} else if(p_subpixelorder == ZM_SUBPIX_ORDER_BGRA) {
/* BGRA subpixel order */
pf = PIX_FMT_BGRA;
pf = AV_PIX_FMT_BGRA;
} else {
/* Assume RGBA subpixel order */
pf = PIX_FMT_RGBA;
pf = AV_PIX_FMT_RGBA;
}
break;
}
case ZM_COLOUR_GRAY8:
pf = PIX_FMT_GRAY8;
pf = AV_PIX_FMT_GRAY8;
break;
default:
Panic("Unexpected colours: %d",p_colours);
pf = PIX_FMT_GRAY8; /* Just to shush gcc variable may be unused warning */
pf = AV_PIX_FMT_GRAY8; /* Just to shush gcc variable may be unused warning */
break;
}
@ -99,11 +99,19 @@ SWScale::SWScale() : gotdefaults(false), swscale_ctx(NULL), input_avframe(NULL),
SWScale::~SWScale() {
/* Free up everything */
av_free(input_avframe);
input_avframe = NULL;
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &input_avframe );
#else
av_freep( &input_avframe );
#endif
//input_avframe = NULL;
av_free(output_avframe);
output_avframe = NULL;
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &output_avframe );
#else
av_freep( &output_avframe );
#endif
//output_avframe = NULL;
if(swscale_ctx) {
sws_freeContext(swscale_ctx);
@ -113,7 +121,7 @@ SWScale::~SWScale() {
Debug(4,"SWScale object destroyed");
}
int SWScale::SetDefaults(enum PixelFormat in_pf, enum PixelFormat out_pf, unsigned int width, unsigned int height) {
int SWScale::SetDefaults(enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height) {
/* Assign the defaults */
default_input_pf = in_pf;
@ -126,7 +134,7 @@ int SWScale::SetDefaults(enum PixelFormat in_pf, enum PixelFormat out_pf, unsign
return 0;
}
int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size, enum PixelFormat in_pf, enum PixelFormat out_pf, unsigned int width, unsigned int height) {
int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height) {
/* Parameter checking */
if(in_buffer == NULL || out_buffer == NULL) {
Error("NULL Input or output buffer");
@ -189,7 +197,7 @@ int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint
return 0;
}
int SWScale::Convert(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size, enum PixelFormat in_pf, enum PixelFormat out_pf, unsigned int width, unsigned int height) {
int SWScale::Convert(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height) {
if(img->Width() != width) {
Error("Source image width differs. Source: %d Output: %d",img->Width(), width);
return -12;

View File

@ -54,6 +54,57 @@ extern "C" {
#include <ffmpeg/opt.h>
#endif /* HAVE_LIBAVUTIL_AVUTIL_H */
#if defined(HAVE_LIBAVUTIL_AVUTIL_H)
#if LIBAVUTIL_VERSION_CHECK(51, 42, 0, 74, 100)
#define _AVPIXELFORMAT AVPixelFormat
#else
#define _AVPIXELFORMAT PixelFormat
#define AV_PIX_FMT_NONE PIX_FMT_NONE
#define AV_PIX_FMT_RGB444 PIX_FMT_RGB444
#define AV_PIX_FMT_RGB555 PIX_FMT_RGB555
#define AV_PIX_FMT_RGB565 PIX_FMT_RGB565
#define AV_PIX_FMT_BGR24 PIX_FMT_BGR24
#define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
#define AV_PIX_FMT_BGRA PIX_FMT_BGRA
#define AV_PIX_FMT_ARGB PIX_FMT_ARGB
#define AV_PIX_FMT_ABGR PIX_FMT_ABGR
#define AV_PIX_FMT_RGBA PIX_FMT_RGBA
#define AV_PIX_FMT_GRAY8 PIX_FMT_GRAY8
#define AV_PIX_FMT_YUYV422 PIX_FMT_YUYV422
#define AV_PIX_FMT_YUV422P PIX_FMT_YUV422P
#define AV_PIX_FMT_YUV411P PIX_FMT_YUV411P
#define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P
#define AV_PIX_FMT_YUV410P PIX_FMT_YUV410P
#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
#define AV_PIX_FMT_YUVJ444P PIX_FMT_YUVJ444P
#define AV_PIX_FMT_UYVY422 PIX_FMT_UYVY422
#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
#define AV_PIX_FMT_YUVJ422P PIX_FMT_YUVJ422P
#define AV_PIX_FMT_UYVY422 PIX_FMT_UYVY422
#define AV_PIX_FMT_UYYVYY411 PIX_FMT_UYYVYY411
#define AV_PIX_FMT_BGR565 PIX_FMT_BGR565
#define AV_PIX_FMT_BGR555 PIX_FMT_BGR555
#define AV_PIX_FMT_BGR8 PIX_FMT_BGR8
#define AV_PIX_FMT_BGR4 PIX_FMT_BGR4
#define AV_PIX_FMT_BGR4_BYTE PIX_FMT_BGR4_BYTE
#define AV_PIX_FMT_RGB8 PIX_FMT_RGB8
#define AV_PIX_FMT_RGB4 PIX_FMT_RGB4
#define AV_PIX_FMT_RGB4_BYTE PIX_FMT_RGB4_BYTE
#define AV_PIX_FMT_NV12 PIX_FMT_NV12
#define AV_PIX_FMT_NV21 PIX_FMT_NV21
#define AV_PIX_FMT_RGB32_1 PIX_FMT_RGB32_1
#define AV_PIX_FMT_BGR32_1 PIX_FMT_BGR32_1
#define AV_PIX_FMT_GRAY16BE PIX_FMT_GRAY16BE
#define AV_PIX_FMT_GRAY16LE PIX_FMT_GRAY16LE
#define AV_PIX_FMT_YUV440P PIX_FMT_YUV440P
#define AV_PIX_FMT_YUVJ440P PIX_FMT_YUVJ440P
#define AV_PIX_FMT_YUVA420P PIX_FMT_YUVA420P
//#define AV_PIX_FMT_VDPAU_H264 PIX_FMT_VDPAU_H264
//#define AV_PIX_FMT_VDPAU_MPEG1 PIX_FMT_VDPAU_MPEG1
//#define AV_PIX_FMT_VDPAU_MPEG2 PIX_FMT_VDPAU_MPEG2
#endif
#endif /* HAVE_LIBAVUTIL_AVUTIL_H */
// AVCODEC
#if HAVE_LIBAVCODEC_AVCODEC_H
#include <libavcodec/avcodec.h>
@ -143,14 +194,8 @@ extern "C" {
#endif
#endif
/* Fix for not having SWS_CPU_CAPS_SSE2 defined */
#ifndef SWS_CPU_CAPS_SSE2
#define SWS_CPU_CAPS_SSE2 0x02000000
#endif
#if HAVE_LIBAVUTIL
enum PixelFormat GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder);
enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder);
#endif // HAVE_LIBAVUTIL
@ -160,19 +205,19 @@ class SWScale {
public:
SWScale();
~SWScale();
int SetDefaults(enum PixelFormat in_pf, enum PixelFormat out_pf, unsigned int width, unsigned int height);
int SetDefaults(enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height);
int ConvertDefaults(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size);
int ConvertDefaults(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size);
int Convert(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size, enum PixelFormat in_pf, enum PixelFormat out_pf, unsigned int width, unsigned int height);
int Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size, enum PixelFormat in_pf, enum PixelFormat out_pf, unsigned int width, unsigned int height);
int Convert(const Image* img, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height);
int Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint8_t* out_buffer, const size_t out_buffer_size, enum _AVPIXELFORMAT in_pf, enum _AVPIXELFORMAT out_pf, unsigned int width, unsigned int height);
protected:
bool gotdefaults;
struct SwsContext* swscale_ctx;
AVFrame* input_avframe;
AVFrame* output_avframe;
enum PixelFormat default_input_pf;
enum PixelFormat default_output_pf;
enum _AVPIXELFORMAT default_input_pf;
enum _AVPIXELFORMAT default_output_pf;
unsigned int default_width;
unsigned int default_height;
};

View File

@ -62,13 +62,13 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri
/* Has to be located inside the constructor so other components such as zma will receive correct colours and subpixel order */
if(colours == ZM_COLOUR_RGB32) {
subpixelorder = ZM_SUBPIX_ORDER_RGBA;
imagePixFormat = PIX_FMT_RGBA;
imagePixFormat = AV_PIX_FMT_RGBA;
} else if(colours == ZM_COLOUR_RGB24) {
subpixelorder = ZM_SUBPIX_ORDER_RGB;
imagePixFormat = PIX_FMT_RGB24;
imagePixFormat = AV_PIX_FMT_RGB24;
} else if(colours == ZM_COLOUR_GRAY8) {
subpixelorder = ZM_SUBPIX_ORDER_NONE;
imagePixFormat = PIX_FMT_GRAY8;
imagePixFormat = AV_PIX_FMT_GRAY8;
} else {
Panic("Unexpected colours: %d",colours);
}
@ -187,11 +187,8 @@ int FfmpegCamera::Capture( Image &image )
#if HAVE_LIBSWSCALE
if(mConvertContext == NULL) {
if(config.cpu_extensions && sseversion >= 20) {
mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL );
} else {
mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL );
}
mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL );
if(mConvertContext == NULL)
Fatal( "Unable to create conversion context for %s", mPath.c_str() );
}
@ -205,7 +202,11 @@ int FfmpegCamera::Capture( Image &image )
frameCount++;
}
}
#if LIBAVCODEC_VERSION_CHECK(57, 8, 0, 12, 100)
av_packet_unref( &packet);
#else
av_free_packet( &packet );
#endif
}
return (0);
}
@ -389,8 +390,13 @@ int FfmpegCamera::CloseFfmpeg(){
mCanCapture = false;
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &mFrame );
av_frame_free( &mRawFrame );
#else
av_freep( &mFrame );
av_freep( &mRawFrame );
#endif
#if HAVE_LIBSWSCALE
if ( mConvertContext )

View File

@ -46,7 +46,7 @@ protected:
AVCodec *mCodec;
AVFrame *mRawFrame;
AVFrame *mFrame;
PixelFormat imagePixFormat;
_AVPIXELFORMAT imagePixFormat;
int OpenFfmpeg();
int ReopenFfmpeg();

View File

@ -52,67 +52,67 @@ static int vidioctl( int fd, int request, void *arg )
}
#if HAVE_LIBSWSCALE
static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette )
static _AVPIXELFORMAT getFfPixFormatFromV4lPalette( int v4l_version, int palette )
{
PixelFormat pixFormat = PIX_FMT_NONE;
_AVPIXELFORMAT pixFormat = AV_PIX_FMT_NONE;
#if ZM_HAS_V4L2
if ( v4l_version == 2 )
{
switch( palette )
{
#if defined(V4L2_PIX_FMT_RGB444) && defined(PIX_FMT_RGB444)
#if defined(V4L2_PIX_FMT_RGB444) && defined(AV_PIX_FMT_RGB444)
case V4L2_PIX_FMT_RGB444 :
pixFormat = PIX_FMT_RGB444;
pixFormat = AV_PIX_FMT_RGB444;
break;
#endif // V4L2_PIX_FMT_RGB444
case V4L2_PIX_FMT_RGB555 :
pixFormat = PIX_FMT_RGB555;
pixFormat = AV_PIX_FMT_RGB555;
break;
case V4L2_PIX_FMT_RGB565 :
pixFormat = PIX_FMT_RGB565;
pixFormat = AV_PIX_FMT_RGB565;
break;
case V4L2_PIX_FMT_BGR24 :
pixFormat = PIX_FMT_BGR24;
pixFormat = AV_PIX_FMT_BGR24;
break;
case V4L2_PIX_FMT_RGB24 :
pixFormat = PIX_FMT_RGB24;
pixFormat = AV_PIX_FMT_RGB24;
break;
case V4L2_PIX_FMT_BGR32 :
pixFormat = PIX_FMT_BGRA;
pixFormat = AV_PIX_FMT_BGRA;
break;
case V4L2_PIX_FMT_RGB32 :
pixFormat = PIX_FMT_ARGB;
pixFormat = AV_PIX_FMT_ARGB;
break;
case V4L2_PIX_FMT_GREY :
pixFormat = PIX_FMT_GRAY8;
pixFormat = AV_PIX_FMT_GRAY8;
break;
case V4L2_PIX_FMT_YUYV :
pixFormat = PIX_FMT_YUYV422;
pixFormat = AV_PIX_FMT_YUYV422;
break;
case V4L2_PIX_FMT_YUV422P :
pixFormat = PIX_FMT_YUV422P;
pixFormat = AV_PIX_FMT_YUV422P;
break;
case V4L2_PIX_FMT_YUV411P :
pixFormat = PIX_FMT_YUV411P;
pixFormat = AV_PIX_FMT_YUV411P;
break;
#ifdef V4L2_PIX_FMT_YUV444
case V4L2_PIX_FMT_YUV444 :
pixFormat = PIX_FMT_YUV444P;
pixFormat = AV_PIX_FMT_YUV444P;
break;
#endif // V4L2_PIX_FMT_YUV444
case V4L2_PIX_FMT_YUV410 :
pixFormat = PIX_FMT_YUV410P;
pixFormat = AV_PIX_FMT_YUV410P;
break;
case V4L2_PIX_FMT_YUV420 :
pixFormat = PIX_FMT_YUV420P;
pixFormat = AV_PIX_FMT_YUV420P;
break;
case V4L2_PIX_FMT_JPEG :
case V4L2_PIX_FMT_MJPEG :
pixFormat = PIX_FMT_YUVJ444P;
pixFormat = AV_PIX_FMT_YUVJ444P;
break;
case V4L2_PIX_FMT_UYVY :
pixFormat = PIX_FMT_UYVY422;
pixFormat = AV_PIX_FMT_UYVY422;
break;
// These don't seem to have ffmpeg equivalents
// See if you can match any of the ones in the default clause below!?
@ -154,32 +154,30 @@ static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette )
Fatal( "Can't find swscale format for palette %d", palette );
break;
// These are all spare and may match some of the above
pixFormat = PIX_FMT_YUVJ420P;
pixFormat = PIX_FMT_YUVJ422P;
pixFormat = PIX_FMT_XVMC_MPEG2_MC;
pixFormat = PIX_FMT_XVMC_MPEG2_IDCT;
pixFormat = PIX_FMT_UYVY422;
pixFormat = PIX_FMT_UYYVYY411;
pixFormat = PIX_FMT_BGR565;
pixFormat = PIX_FMT_BGR555;
pixFormat = PIX_FMT_BGR8;
pixFormat = PIX_FMT_BGR4;
pixFormat = PIX_FMT_BGR4_BYTE;
pixFormat = PIX_FMT_RGB8;
pixFormat = PIX_FMT_RGB4;
pixFormat = PIX_FMT_RGB4_BYTE;
pixFormat = PIX_FMT_NV12;
pixFormat = PIX_FMT_NV21;
pixFormat = PIX_FMT_RGB32_1;
pixFormat = PIX_FMT_BGR32_1;
pixFormat = PIX_FMT_GRAY16BE;
pixFormat = PIX_FMT_GRAY16LE;
pixFormat = PIX_FMT_YUV440P;
pixFormat = PIX_FMT_YUVJ440P;
pixFormat = PIX_FMT_YUVA420P;
//pixFormat = PIX_FMT_VDPAU_H264;
//pixFormat = PIX_FMT_VDPAU_MPEG1;
//pixFormat = PIX_FMT_VDPAU_MPEG2;
pixFormat = AV_PIX_FMT_YUVJ420P;
pixFormat = AV_PIX_FMT_YUVJ422P;
pixFormat = AV_PIX_FMT_UYVY422;
pixFormat = AV_PIX_FMT_UYYVYY411;
pixFormat = AV_PIX_FMT_BGR565;
pixFormat = AV_PIX_FMT_BGR555;
pixFormat = AV_PIX_FMT_BGR8;
pixFormat = AV_PIX_FMT_BGR4;
pixFormat = AV_PIX_FMT_BGR4_BYTE;
pixFormat = AV_PIX_FMT_RGB8;
pixFormat = AV_PIX_FMT_RGB4;
pixFormat = AV_PIX_FMT_RGB4_BYTE;
pixFormat = AV_PIX_FMT_NV12;
pixFormat = AV_PIX_FMT_NV21;
pixFormat = AV_PIX_FMT_RGB32_1;
pixFormat = AV_PIX_FMT_BGR32_1;
pixFormat = AV_PIX_FMT_GRAY16BE;
pixFormat = AV_PIX_FMT_GRAY16LE;
pixFormat = AV_PIX_FMT_YUV440P;
pixFormat = AV_PIX_FMT_YUVJ440P;
pixFormat = AV_PIX_FMT_YUVA420P;
//pixFormat = AV_PIX_FMT_VDPAU_H264;
//pixFormat = AV_PIX_FMT_VDPAU_MPEG1;
//pixFormat = AV_PIX_FMT_VDPAU_MPEG2;
}
}
}
@ -191,67 +189,65 @@ static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette )
{
case VIDEO_PALETTE_RGB32 :
if(BigEndian)
pixFormat = PIX_FMT_ARGB;
pixFormat = AV_PIX_FMT_ARGB;
else
pixFormat = PIX_FMT_BGRA;
pixFormat = AV_PIX_FMT_BGRA;
break;
case VIDEO_PALETTE_RGB24 :
if(BigEndian)
pixFormat = PIX_FMT_RGB24;
pixFormat = AV_PIX_FMT_RGB24;
else
pixFormat = PIX_FMT_BGR24;
pixFormat = AV_PIX_FMT_BGR24;
break;
case VIDEO_PALETTE_GREY :
pixFormat = PIX_FMT_GRAY8;
pixFormat = AV_PIX_FMT_GRAY8;
break;
case VIDEO_PALETTE_RGB555 :
pixFormat = PIX_FMT_RGB555;
pixFormat = AV_PIX_FMT_RGB555;
break;
case VIDEO_PALETTE_RGB565 :
pixFormat = PIX_FMT_RGB565;
pixFormat = AV_PIX_FMT_RGB565;
break;
case VIDEO_PALETTE_YUYV :
case VIDEO_PALETTE_YUV422 :
pixFormat = PIX_FMT_YUYV422;
pixFormat = AV_PIX_FMT_YUYV422;
break;
case VIDEO_PALETTE_YUV422P :
pixFormat = PIX_FMT_YUV422P;
pixFormat = AV_PIX_FMT_YUV422P;
break;
case VIDEO_PALETTE_YUV420P :
pixFormat = PIX_FMT_YUV420P;
pixFormat = AV_PIX_FMT_YUV420P;
break;
default :
{
Fatal( "Can't find swscale format for palette %d", palette );
break;
// These are all spare and may match some of the above
pixFormat = PIX_FMT_YUVJ420P;
pixFormat = PIX_FMT_YUVJ422P;
pixFormat = PIX_FMT_YUVJ444P;
pixFormat = PIX_FMT_XVMC_MPEG2_MC;
pixFormat = PIX_FMT_XVMC_MPEG2_IDCT;
pixFormat = PIX_FMT_UYVY422;
pixFormat = PIX_FMT_UYYVYY411;
pixFormat = PIX_FMT_BGR565;
pixFormat = PIX_FMT_BGR555;
pixFormat = PIX_FMT_BGR8;
pixFormat = PIX_FMT_BGR4;
pixFormat = PIX_FMT_BGR4_BYTE;
pixFormat = PIX_FMT_RGB8;
pixFormat = PIX_FMT_RGB4;
pixFormat = PIX_FMT_RGB4_BYTE;
pixFormat = PIX_FMT_NV12;
pixFormat = PIX_FMT_NV21;
pixFormat = PIX_FMT_RGB32_1;
pixFormat = PIX_FMT_BGR32_1;
pixFormat = PIX_FMT_GRAY16BE;
pixFormat = PIX_FMT_GRAY16LE;
pixFormat = PIX_FMT_YUV440P;
pixFormat = PIX_FMT_YUVJ440P;
pixFormat = PIX_FMT_YUVA420P;
//pixFormat = PIX_FMT_VDPAU_H264;
//pixFormat = PIX_FMT_VDPAU_MPEG1;
//pixFormat = PIX_FMT_VDPAU_MPEG2;
pixFormat = AV_PIX_FMT_YUVJ420P;
pixFormat = AV_PIX_FMT_YUVJ422P;
pixFormat = AV_PIX_FMT_YUVJ444P;
pixFormat = AV_PIX_FMT_UYVY422;
pixFormat = AV_PIX_FMT_UYYVYY411;
pixFormat = AV_PIX_FMT_BGR565;
pixFormat = AV_PIX_FMT_BGR555;
pixFormat = AV_PIX_FMT_BGR8;
pixFormat = AV_PIX_FMT_BGR4;
pixFormat = AV_PIX_FMT_BGR4_BYTE;
pixFormat = AV_PIX_FMT_RGB8;
pixFormat = AV_PIX_FMT_RGB4;
pixFormat = AV_PIX_FMT_RGB4_BYTE;
pixFormat = AV_PIX_FMT_NV12;
pixFormat = AV_PIX_FMT_NV21;
pixFormat = AV_PIX_FMT_RGB32_1;
pixFormat = AV_PIX_FMT_BGR32_1;
pixFormat = AV_PIX_FMT_GRAY16BE;
pixFormat = AV_PIX_FMT_GRAY16LE;
pixFormat = AV_PIX_FMT_YUV440P;
pixFormat = AV_PIX_FMT_YUVJ440P;
pixFormat = AV_PIX_FMT_YUVA420P;
//pixFormat = AV_PIX_FMT_VDPAU_H264;
//pixFormat = AV_PIX_FMT_VDPAU_MPEG1;
//pixFormat = AV_PIX_FMT_VDPAU_MPEG2;
}
}
}
@ -376,7 +372,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel,
#if HAVE_LIBSWSCALE
/* Get ffmpeg pixel format based on capture palette and endianness */
capturePixFormat = getFfPixFormatFromV4lPalette( v4l_version, palette );
imagePixFormat = PIX_FMT_NONE;
imagePixFormat = AV_PIX_FMT_NONE;
#endif // HAVE_LIBSWSCALE
}
@ -423,13 +419,13 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel,
Debug(2,"Using swscale for image conversion");
if(colours == ZM_COLOUR_RGB32) {
subpixelorder = ZM_SUBPIX_ORDER_RGBA;
imagePixFormat = PIX_FMT_RGBA;
imagePixFormat = AV_PIX_FMT_RGBA;
} else if(colours == ZM_COLOUR_RGB24) {
subpixelorder = ZM_SUBPIX_ORDER_RGB;
imagePixFormat = PIX_FMT_RGB24;
imagePixFormat = AV_PIX_FMT_RGB24;
} else if(colours == ZM_COLOUR_GRAY8) {
subpixelorder = ZM_SUBPIX_ORDER_NONE;
imagePixFormat = PIX_FMT_GRAY8;
imagePixFormat = AV_PIX_FMT_GRAY8;
} else {
Panic("Unexpected colours: %d",colours);
}
@ -541,13 +537,13 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel,
Debug(2,"Using swscale for image conversion");
if(colours == ZM_COLOUR_RGB32) {
subpixelorder = ZM_SUBPIX_ORDER_RGBA;
imagePixFormat = PIX_FMT_RGBA;
imagePixFormat = AV_PIX_FMT_RGBA;
} else if(colours == ZM_COLOUR_RGB24) {
subpixelorder = ZM_SUBPIX_ORDER_RGB;
imagePixFormat = PIX_FMT_RGB24;
imagePixFormat = AV_PIX_FMT_RGB24;
} else if(colours == ZM_COLOUR_GRAY8) {
subpixelorder = ZM_SUBPIX_ORDER_NONE;
imagePixFormat = PIX_FMT_GRAY8;
imagePixFormat = AV_PIX_FMT_GRAY8;
} else {
Panic("Unexpected colours: %d",colours);
}
@ -635,14 +631,11 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel,
Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize);
}
if(config.cpu_extensions && sseversion >= 20) {
imgConversionContext = sws_getContext(width, height, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL );
} else {
imgConversionContext = sws_getContext(width, height, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL );
}
imgConversionContext = sws_getContext(width, height, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL );
if ( !imgConversionContext )
if ( !imgConversionContext ) {
Fatal( "Unable to initialise image scaling context" );
}
}
#endif
@ -659,8 +652,11 @@ LocalCamera::~LocalCamera()
sws_freeContext(imgConversionContext);
imgConversionContext = NULL;
av_free(tmpPicture);
tmpPicture = NULL;
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &tmpPicture );
#else
av_freep( &tmpPicture );
#endif
}
#endif
}
@ -1089,8 +1085,11 @@ void LocalCamera::Terminate()
for ( unsigned int i = 0; i < v4l2_data.reqbufs.count; i++ ) {
#if HAVE_LIBSWSCALE
/* Free capture pictures */
av_free(capturePictures[i]);
capturePictures[i] = NULL;
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &capturePictures[i] );
#else
av_freep( &capturePictures[i] );
#endif
#endif
if ( munmap( v4l2_data.buffers[i].start, v4l2_data.buffers[i].length ) < 0 )
Error( "Failed to munmap buffer %d: %s", i, strerror(errno) );
@ -1107,8 +1106,11 @@ void LocalCamera::Terminate()
#if HAVE_LIBSWSCALE
for(int i=0; i < v4l1_data.frames.frames; i++) {
/* Free capture pictures */
av_free(capturePictures[i]);
capturePictures[i] = NULL;
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &capturePictures[i] );
#else
av_freep( &capturePictures[i] );
#endif
}
#endif

View File

@ -107,8 +107,8 @@ protected:
#if HAVE_LIBSWSCALE
static AVFrame **capturePictures;
PixelFormat imagePixFormat;
PixelFormat capturePixFormat;
_AVPIXELFORMAT imagePixFormat;
_AVPIXELFORMAT capturePixFormat;
struct SwsContext *imgConversionContext;
AVFrame *tmpPicture;
#endif // HAVE_LIBSWSCALE

View File

@ -131,10 +131,10 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
{
if(subpixelorder == ZM_SUBPIX_ORDER_BGR) {
/* BGR subpixel order */
pf = PIX_FMT_BGR24;
pf = AV_PIX_FMT_BGR24;
} else {
/* Assume RGB subpixel order */
pf = PIX_FMT_RGB24;
pf = AV_PIX_FMT_RGB24;
}
break;
}
@ -142,21 +142,21 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
{
if(subpixelorder == ZM_SUBPIX_ORDER_ARGB) {
/* ARGB subpixel order */
pf = PIX_FMT_ARGB;
pf = AV_PIX_FMT_ARGB;
} else if(subpixelorder == ZM_SUBPIX_ORDER_ABGR) {
/* ABGR subpixel order */
pf = PIX_FMT_ABGR;
pf = AV_PIX_FMT_ABGR;
} else if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) {
/* BGRA subpixel order */
pf = PIX_FMT_BGRA;
pf = AV_PIX_FMT_BGRA;
} else {
/* Assume RGBA subpixel order */
pf = PIX_FMT_RGBA;
pf = AV_PIX_FMT_RGBA;
}
break;
}
case ZM_COLOUR_GRAY8:
pf = PIX_FMT_GRAY8;
pf = AV_PIX_FMT_GRAY8;
break;
default:
Panic("Unexpected colours: %d",colours);
@ -234,7 +234,7 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
c->codec_id = codec->id;
c->codec_type = codec->type;
c->pix_fmt = strcmp( "mjpeg", ofc->oformat->name ) == 0 ? PIX_FMT_YUVJ422P : PIX_FMT_YUV420P;
c->pix_fmt = strcmp( "mjpeg", ofc->oformat->name ) == 0 ? AV_PIX_FMT_YUVJ422P : AV_PIX_FMT_YUV420P;
if ( bitrate <= 100 )
{
// Quality based bitrate control (VBR). Scale is 1..31 where 1 is best.
@ -337,7 +337,11 @@ void VideoStream::OpenStream( )
uint8_t *opicture_buf = (uint8_t *)av_malloc( size );
if ( !opicture_buf )
{
av_free( opicture );
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &opicture );
#else
av_freep( &opicture );
#endif
Panic( "Could not allocate opicture_buf" );
}
avpicture_fill( (AVPicture *)opicture, opicture_buf, c->pix_fmt, c->width, c->height );
@ -361,7 +365,11 @@ void VideoStream::OpenStream( )
uint8_t *tmp_opicture_buf = (uint8_t *)av_malloc( size );
if ( !tmp_opicture_buf )
{
av_free( tmp_opicture );
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &tmp_opicture );
#else
av_freep( &tmp_opicture );
#endif
Panic( "Could not allocate tmp_opicture_buf" );
}
avpicture_fill( (AVPicture *)tmp_opicture, tmp_opicture_buf, pf, c->width, c->height );
@ -512,11 +520,19 @@ VideoStream::~VideoStream( )
{
avcodec_close( ost->codec );
av_free( opicture->data[0] );
av_free( opicture );
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &opicture );
#else
av_freep( &opicture );
#endif
if ( tmp_opicture )
{
av_free( tmp_opicture->data[0] );
av_free( tmp_opicture );
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &tmp_opicture );
#else
av_freep( &tmp_opicture );
#endif
}
av_free( video_outbuf );
}
@ -694,7 +710,11 @@ int VideoStream::SendPacket(AVPacket *packet) {
{
Fatal( "Error %d while writing video frame: %s", ret, av_err2str( errno ) );
}
av_free_packet(packet);
#if LIBAVCODEC_VERSION_CHECK(57, 8, 0, 12, 100)
av_packet_unref( packet );
#else
av_free_packet( packet );
#endif
return ret;
}
@ -735,7 +755,11 @@ void *VideoStream::StreamingThreadCallback(void *ctx){
if (packet->size) {
videoStream->SendPacket(packet);
}
av_free_packet(packet);
#if LIBAVCODEC_VERSION_CHECK(57, 8, 0, 12, 100)
av_packet_unref( packet);
#else
av_free_packet( packet );
#endif
videoStream->packet_index = videoStream->packet_index ? 0 : 1;
// Lock buffer and render next frame.

View File

@ -42,7 +42,7 @@ protected:
const char *filename;
const char *format;
const char *codec_name;
enum PixelFormat pf;
enum _AVPIXELFORMAT pf;
AVOutputFormat *of;
AVFormatContext *ofc;
AVStream *ost;

View File

@ -30,8 +30,9 @@
RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, bool p_rtsp_describe, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
RemoteCamera( p_id, "rtsp", p_host, p_port, p_path, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture ),
rtspThread( 0 ),
rtsp_describe( p_rtsp_describe )
rtsp_describe( p_rtsp_describe ),
rtspThread( 0 )
{
if ( p_method == "rtpUni" )
method = RtspThread::RTP_UNICAST;
@ -63,13 +64,13 @@ RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const
/* Has to be located inside the constructor so other components such as zma will receive correct colours and subpixel order */
if(colours == ZM_COLOUR_RGB32) {
subpixelorder = ZM_SUBPIX_ORDER_RGBA;
imagePixFormat = PIX_FMT_RGBA;
imagePixFormat = AV_PIX_FMT_RGBA;
} else if(colours == ZM_COLOUR_RGB24) {
subpixelorder = ZM_SUBPIX_ORDER_RGB;
imagePixFormat = PIX_FMT_RGB24;
imagePixFormat = AV_PIX_FMT_RGB24;
} else if(colours == ZM_COLOUR_GRAY8) {
subpixelorder = ZM_SUBPIX_ORDER_NONE;
imagePixFormat = PIX_FMT_GRAY8;
imagePixFormat = AV_PIX_FMT_GRAY8;
} else {
Panic("Unexpected colours: %d",colours);
}
@ -78,8 +79,13 @@ RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const
RemoteCameraRtsp::~RemoteCameraRtsp()
{
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free( &mFrame );
av_frame_free( &mRawFrame );
#else
av_freep( &mFrame );
av_freep( &mRawFrame );
#endif
#if HAVE_LIBSWSCALE
if ( mConvertContext )
@ -328,11 +334,8 @@ int RemoteCameraRtsp::Capture( Image &image )
#if HAVE_LIBSWSCALE
if(mConvertContext == NULL) {
if(config.cpu_extensions && sseversion >= 20) {
mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL );
} else {
mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL );
}
mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL );
if(mConvertContext == NULL)
Fatal( "Unable to create conversion context");
}
@ -347,7 +350,11 @@ int RemoteCameraRtsp::Capture( Image &image )
} /* frame complete */
av_free_packet( &packet );
#if LIBAVCODEC_VERSION_CHECK(57, 8, 0, 12, 100)
av_packet_unref( &packet);
#else
av_free_packet( &packet );
#endif
} /* getFrame() */
if(frameComplete)

View File

@ -59,7 +59,7 @@ protected:
AVCodec *mCodec;
AVFrame *mRawFrame;
AVFrame *mFrame;
PixelFormat imagePixFormat;
_AVPIXELFORMAT imagePixFormat;
#endif // HAVE_LIBAVFORMAT
#if HAVE_LIBSWSCALE

View File

@ -50,12 +50,13 @@ private:
private:
int mId;
bool mRtspDescribe;
RtspMethod mMethod;
std::string mProtocol;
std::string mHost;
std::string mPort;
std::string mPath;
bool mRtspDescribe;
std::string mUrl;
// Reworked authentication system

View File

@ -58,7 +58,12 @@ else
$protocol = 'http';
}
define( "ZM_BASE_PROTOCOL", $protocol );
define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_HOST'] );
// Absolute URL's are unnecessary and break compatibility with reverse proxies
// define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_HOST'] );
// Use relative URL's instead
define( "ZM_BASE_URL", "" );
// Check time zone is set
if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone'))) {