Merge branch 'storageareas' of github.com:ConnorTechnology/ZoneMinder into storageareas

pull/2077/head
Isaac Connor 2017-08-21 11:03:47 -04:00
commit a534a9e5a9
5 changed files with 25 additions and 4 deletions

View File

@ -557,6 +557,7 @@ if(NOT ZM_NO_FFMPEG)
mark_as_advanced(FORCE AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIR)
check_include_file("libavutil/avutil.h" HAVE_LIBAVUTIL_AVUTIL_H)
check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H)
check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H)
set(optlibsfound "${optlibsfound} AVUtil")
else(AVUTIL_LIBRARIES)
set(optlibsnotfound "${optlibsnotfound} AVUtil")

View File

@ -25,8 +25,10 @@
extern "C" {
#include "libavutil/time.h"
#if HAVE_AVUTIL_HWCONTEXT_H
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_qsv.h"
#endif
}
#ifndef AV_ERROR_MAX_STRING_SIZE
#define AV_ERROR_MAX_STRING_SIZE 64
@ -39,6 +41,7 @@ extern "C" {
#endif
#if HAVE_AVUTIL_HWCONTEXT_H
static AVPixelFormat get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts) {
while (*pix_fmts != AV_PIX_FMT_NONE) {
if (*pix_fmts == AV_PIX_FMT_QSV) {
@ -76,6 +79,7 @@ static AVPixelFormat get_format(AVCodecContext *avctx, const enum AVPixelFormat
return AV_PIX_FMT_NONE;
}
#endif
FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ) :
Camera( p_id, FFMPEG_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ),
@ -88,8 +92,10 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::stri
}
hwaccel = false;
#if HAVE_AVUTIL_HWCONTEXT_H
decode = { NULL };
hwFrame = NULL;
#endif
mFormatContext = NULL;
mVideoStreamId = -1;
@ -234,6 +240,7 @@ int FfmpegCamera::Capture( Image &image ) {
continue;
}
#if HAVE_AVUTIL_HWCONTEXT_H
if ( hwaccel ) {
ret = avcodec_receive_frame( mVideoCodecContext, hwFrame );
if ( ret < 0 ) {
@ -250,6 +257,7 @@ int FfmpegCamera::Capture( Image &image ) {
continue;
}
} else {
#endif
ret = avcodec_receive_frame( mVideoCodecContext, mRawFrame );
if ( ret < 0 ) {
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
@ -258,7 +266,9 @@ int FfmpegCamera::Capture( Image &image ) {
continue;
}
#if HAVE_AVUTIL_HWCONTEXT_H
}
#endif
frameComplete = 1;
# else
@ -461,6 +471,7 @@ int FfmpegCamera::OpenFfmpeg() {
//mVideoCodecContext->flags2 |= CODEC_FLAG2_FAST | CODEC_FLAG2_CHUNKS | CODEC_FLAG_LOW_DELAY; // Enable faster H264 decode.
mVideoCodecContext->flags2 |= CODEC_FLAG2_FAST | CODEC_FLAG_LOW_DELAY;
#if HAVE_AVUTIL_HWCONTEXT_H
if ( mVideoCodecContext->codec_id == AV_CODEC_ID_H264 ) {
//vaapi_decoder = new VAAPIDecoder();
@ -497,6 +508,7 @@ int FfmpegCamera::OpenFfmpeg() {
}
} // end if h264
#endif
if ( (!mVideoCodec) and ( (mVideoCodec = avcodec_find_decoder(mVideoCodecContext->codec_id)) == NULL ) ) {
// Try and get the codec from the codec context

View File

@ -27,9 +27,11 @@
#include "zm_videostore.h"
#include "zm_packetqueue.h"
#if HAVE_AVUTIL_HWCONTEXT_H
typedef struct DecodeContext {
AVBufferRef *hw_device_ref;
} DecodeContext;
#endif
//
// Class representing 'ffmpeg' cameras, i.e. those which are
// accessed using ffmpeg multimedia framework
@ -55,8 +57,10 @@ class FfmpegCamera : public Camera {
_AVPIXELFORMAT imagePixFormat;
bool hwaccel;
#if HAVE_AVUTIL_HWCONTEXT_H
AVFrame *hwFrame;
DecodeContext decode;
#endif
// Need to keep track of these because apparently the stream can start with values for pts/dts and then subsequent packets start at zero.
int64_t audio_last_pts;

View File

@ -623,7 +623,7 @@ bool VideoStore::setup_resampler() {
void VideoStore::dumpPacket( AVPacket *pkt ){
char b[10240];
snprintf(b, sizeof(b), " pts: %" PRId64 ", dts: %" PRId64 ", data: %p, size: %d, sindex: %d, dflags: %04x, s-pos: %" PRId64 ", c-duration: %" PRId64 "\n"
snprintf(b, sizeof(b), " pts: %" PRId64 ", dts: %" PRId64 ", data: %p, size: %d, sindex: %d, dflags: %04x, s-pos: %" PRId64 ", c-duration: %d\n"
, pkt->pts
, pkt->dts
, pkt->data
@ -643,12 +643,15 @@ int VideoStore::writeVideoFramePacket( AVPacket *ipkt ) {
opkt.dts = video_next_dts;
opkt.duration = 0;
unsigned int duration;
int duration;
if ( ! video_last_pts ) {
duration = 0;
} else {
duration = av_rescale_q( ipkt->pts - video_last_pts, video_input_stream->time_base, video_output_stream->time_base);
Debug(1, "duration calc: pts(%d) - last_pts(%d) = (%d)", ipkt->pts, video_last_pts, duration );
if ( duration < 0 ) {
duration = ipkt->duration;
}
}
//#if ( 0 && video_last_pts && ( ipkt->duration == AV_NOPTS_VALUE || ! ipkt->duration ) ) {

View File

@ -51,6 +51,7 @@
#cmakedefine HAVE_LIBAVUTIL 1
#cmakedefine HAVE_LIBAVUTIL_AVUTIL_H 1
#cmakedefine HAVE_LIBAVUTIL_MATHEMATICS_H 1
#cmakedefine HAVE_LIBAVUTIL_HWCONTEXT_H 0
#cmakedefine HAVE_LIBSWSCALE 1
#cmakedefine HAVE_LIBSWSCALE_SWSCALE_H 1
#cmakedefine HAVE_LIBAVRESAMPLE 1