commit 8f16e67c0b30b8104f592b4b87dc7348d0c1fb6a
Author: leigh123linux <leigh123linux(a)googlemail.com>
Date: Sun Jul 17 11:30:32 2016 +0100
patch for ffmpeg-3
api-update_copy-old-API-items.patch | 76 ++++++++++++++
api-update_ffmpeg-2.9.patch | 202 ++++++++++++++++++++++++++++++++++++
api-update_libav10.patch | 51 +++++++++
motion.spec | 13 ++-
4 files changed, 341 insertions(+), 1 deletion(-)
---
diff --git a/api-update_copy-old-API-items.patch b/api-update_copy-old-API-items.patch
new file mode 100644
index 0000000..b384c1f
--- /dev/null
+++ b/api-update_copy-old-API-items.patch
@@ -0,0 +1,76 @@
+Description: Copy old API items we still depend on
+ As per doc/APIchanges in libav/ffmpeg, URLContext/URLProtocol were dropped
+ from the public API of libavformat since 52.107.0. Pending a better solution
+ from motion upstream, we copy the definitions here.
+Author: Ximin Luo <infinity0(a)pwned.gg>
+Bug:
https://github.com/sackmotion/motion/issues/16
+
+--- a/ffmpeg.c
++++ b/ffmpeg.c
+@@ -15,6 +15,66 @@
+ #include "ffmpeg.h"
+ #include "motion.h"
+
++#if LIBAVFORMAT_BUILD >= AV_VERSION_INT(52,107,0)
++/*
++ * URLContext, URLProtocol have been removed from avio.h
++ *
++ */
++
++typedef struct URLContext {
++ const AVClass *av_class; /**< information for av_log(). Set by url_open(). */
++ struct URLProtocol *prot;
++ void *priv_data;
++ char *filename; /**< specified URL */
++ int flags;
++ int max_packet_size; /**< if non zero, the stream is packetized with this
max packet size */
++ int is_streamed; /**< true if streamed (no seek possible), default =
false */
++ int is_connected;
++ AVIOInterruptCB interrupt_callback;
++ int64_t rw_timeout; /**< maximum time to wait for (network) read/write
operation completion, in mcs */
++} URLContext;
++
++typedef struct URLProtocol {
++ const char *name;
++ int (*url_open)( URLContext *h, const char *url, int flags);
++ /**
++ * This callback is to be used by protocols which open further nested
++ * protocols. options are then to be passed to ffurl_open()/ffurl_connect()
++ * for those nested protocols.
++ */
++ int (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary
**options);
++
++ /**
++ * Read data from the protocol.
++ * If data is immediately available (even less than size), EOF is
++ * reached or an error occurs (including EINTR), return immediately.
++ * Otherwise:
++ * In non-blocking mode, return AVERROR(EAGAIN) immediately.
++ * In blocking mode, wait for data/EOF/error with a short timeout (0.1s),
++ * and return AVERROR(EAGAIN) on timeout.
++ * Checking interrupt_callback, looping on EINTR and EAGAIN and until
++ * enough data has been read is left to the calling function; see
++ * retry_transfer_wrapper in avio.c.
++ */
++ int (*url_read)( URLContext *h, unsigned char *buf, int size);
++ int (*url_write)(URLContext *h, const unsigned char *buf, int size);
++ int64_t (*url_seek)( URLContext *h, int64_t pos, int whence);
++ int (*url_close)(URLContext *h);
++ struct URLProtocol *next;
++ int (*url_read_pause)(URLContext *h, int pause);
++ int64_t (*url_read_seek)(URLContext *h, int stream_index,
++ int64_t timestamp, int flags);
++ int (*url_get_file_handle)(URLContext *h);
++ int (*url_get_multi_file_handle)(URLContext *h, int **handles,
++ int *numhandles);
++ int (*url_shutdown)(URLContext *h, int flags);
++ int priv_data_size;
++ const AVClass *priv_data_class;
++ int flags;
++ int (*url_check)(URLContext *h, int mask);
++} URLProtocol;
++#endif
++
+ #if LIBAVCODEC_BUILD > 4680
+ /*
+ * FFmpeg after build 4680 doesn't have support for mpeg1 videos with
diff --git a/api-update_ffmpeg-2.9.patch b/api-update_ffmpeg-2.9.patch
new file mode 100644
index 0000000..28a2694
--- /dev/null
+++ b/api-update_ffmpeg-2.9.patch
@@ -0,0 +1,202 @@
+Description: Replace deprecated FFmpeg API
+Author: Andreas Cadhalpun <Andreas.Cadhalpun(a)googlemail.com>
+Forwarded: yes
+Last-Update: 2015-11-02
+
+--- a/configure.in
++++ b/configure.in
+@@ -522,7 +522,7 @@
+ #
+
+ if test "${FFMPEG_OK}" = "found"; then
+- TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} -lavformat -lavcodec -lavutil -lm
-lz"
++ TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} -lavfilter -lavformat -lavcodec
-lavutil -lm -lz"
+ TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}"
+ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}"
+
+--- a/ffmpeg.c
++++ b/ffmpeg.c
+@@ -655,7 +655,7 @@
+ }
+
+ /* Set the picture format - need in ffmpeg starting round April-May 2005 */
+- c->pix_fmt = PIX_FMT_YUV420P;
++ c->pix_fmt = AV_PIX_FMT_YUV420P;
+
+ /* Get a mutex lock. */
+ pthread_mutex_lock(&global_lock);
+@@ -692,10 +692,10 @@
+ }
+
+ /* Allocate the encoded raw picture. */
+- ffmpeg->picture = avcodec_alloc_frame();
++ ffmpeg->picture = av_frame_alloc();
+
+ if (!ffmpeg->picture) {
+- MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: avcodec_alloc_frame -"
++ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: av_frame_alloc -"
+ " could not alloc frame");
+ ffmpeg_cleanups(ffmpeg);
+ return NULL;
+@@ -801,7 +801,7 @@
+ #endif
+ avcodec_close(AVSTREAM_CODEC_PTR(ffmpeg->video_st));
+ pthread_mutex_unlock(&global_lock);
+- av_freep(&ffmpeg->picture);
++ av_frame_free(&ffmpeg->picture);
+ free(ffmpeg->video_outbuf);
+ }
+
+@@ -833,7 +833,7 @@
+ pthread_mutex_lock(&global_lock);
+ avcodec_close(AVSTREAM_CODEC_PTR(ffmpeg->video_st));
+ pthread_mutex_unlock(&global_lock);
+- av_freep(&ffmpeg->picture);
++ av_frame_free(&ffmpeg->picture);
+ free(ffmpeg->video_outbuf);
+ }
+
+@@ -897,7 +897,7 @@
+ if (picture) {
+ ret = ffmpeg_put_frame(ffmpeg, picture);
+ if (!ret)
+- av_free(picture);
++ av_frame_free(&picture);
+ }
+
+ return ret;
+@@ -1009,7 +1009,7 @@
+ {
+ AVFrame *picture;
+
+- picture = avcodec_alloc_frame();
++ picture = av_frame_alloc();
+
+ if (!picture) {
+ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Could not alloc
frame");
+@@ -1031,6 +1031,81 @@
+ return picture;
+ }
+
++AVFilterContext *buffersink_ctx;
++AVFilterContext *buffersrc_ctx;
++AVFilterGraph *filter_graph;
++AVFrame *filter_frame;
++int last_width = -1;
++int last_height = -1;
++enum AVPixelFormat last_pixfmt = AV_PIX_FMT_NONE;
++
++static void delete_filter_graph() {
++ if (filter_graph) {
++ av_frame_free(&filter_frame);
++ avfilter_graph_free(&filter_graph);
++ }
++}
++
++static int init_filter_graph(enum AVPixelFormat pixfmt, int width, int height) {
++ AVFilterInOut *inputs = NULL, *outputs = NULL;
++ char args[512];
++ int res;
++
++ delete_filter_graph();
++ filter_graph = avfilter_graph_alloc();
++ snprintf(args, sizeof(args),
++
"buffer=video_size=%dx%d:pix_fmt=%d:time_base=1/1:pixel_aspect=0/1[in];"
++ "[in]yadif[out];"
++ "[out]buffersink",
++ width, height, pixfmt);
++ res = avfilter_graph_parse2(filter_graph, args, &inputs, &outputs);
++ if (res < 0)
++ return res;
++ if(inputs || outputs)
++ return -1;
++ res = avfilter_graph_config(filter_graph, NULL);
++ if (res < 0)
++ return res;
++
++ buffersrc_ctx = avfilter_graph_get_filter(filter_graph,
"Parsed_buffer_0");
++ buffersink_ctx = avfilter_graph_get_filter(filter_graph,
"Parsed_buffersink_2");
++ if (!buffersrc_ctx || !buffersink_ctx)
++ return -1;
++ filter_frame = av_frame_alloc();
++ last_width = width;
++ last_height = height;
++ last_pixfmt = pixfmt;
++
++ return 0;
++}
++
++static int process_filter_graph(AVPicture *dst, const AVPicture *src,
++ enum AVPixelFormat pixfmt, int width, int height) {
++ int res;
++
++ if (!filter_graph || width != last_width ||
++ height != last_height || pixfmt != last_pixfmt) {
++ res = init_filter_graph(pixfmt, width, height);
++ if (res < 0)
++ return res;
++ }
++
++ memcpy(filter_frame->data, src->data, sizeof(src->data));
++ memcpy(filter_frame->linesize, src->linesize, sizeof(src->linesize));
++ filter_frame->width = width;
++ filter_frame->height = height;
++ filter_frame->format = pixfmt;
++ res = av_buffersrc_add_frame(buffersrc_ctx, filter_frame);
++ if (res < 0)
++ return res;
++ res = av_buffersink_get_frame(buffersink_ctx, filter_frame);
++ if (res < 0)
++ return res;
++ av_picture_copy(dst, (const AVPicture *) filter_frame, pixfmt, width, height);
++ av_frame_unref(filter_frame);
++
++ return 0;
++}
+
+ /**
+ * ffmpeg_deinterlace
+@@ -1057,8 +1132,8 @@
+ picture.linesize[1] = width2;
+ picture.linesize[2] = width2;
+
+- /* We assume using 'PIX_FMT_YUV420P' always */
+- avpicture_deinterlace(&picture, &picture, PIX_FMT_YUV420P, width, height);
++ /* We assume using 'AV_PIX_FMT_YUV420P' always */
++ process_filter_graph(&picture, &picture, AV_PIX_FMT_YUV420P, width,
height);
+
+ #if !defined(__SSE_MATH__) && (defined(__i386__) || defined(__x86_64__))
+ __asm__ __volatile__ ( "emms");
+
+--- a/ffmpeg.h
++++ b/ffmpeg.h
+@@ -6,6 +6,9 @@
+
+ #ifdef FFMPEG_NEW_INCLUDES
+ #include <libavformat/avformat.h>
++#include <libavfilter/avfilter.h>
++#include <libavfilter/buffersrc.h>
++#include <libavfilter/buffersink.h>
+ #else
+ #include <avformat.h>
+ #endif
+--- a/netcam_rtsp.c
++++ b/netcam_rtsp.c
+@@ -233,7 +233,7 @@
+ buffer = netcam->receiving;
+ buffer->used = 0;
+
+- AVFrame *frame = avcodec_alloc_frame();
++ AVFrame *frame = av_frame_alloc();
+
+ AVPacket packet;
+
+@@ -268,7 +268,7 @@
+
+ // at this point, we are finished with the packet and frame, so free them.
+ av_free_packet(&packet);
+- av_free(frame);
++ av_frame_free(&frame);
+
+ struct timeval curtime;
+
diff --git a/api-update_libav10.patch b/api-update_libav10.patch
new file mode 100644
index 0000000..b33f0d8
--- /dev/null
+++ b/api-update_libav10.patch
@@ -0,0 +1,51 @@
+Description: Update for libav10 API
+Author: Ximin Luo <infinity0(a)pwned.gg>
+Bug:
https://github.com/sackmotion/motion/pull/17
+
+--- a/ffmpeg.c
++++ b/ffmpeg.c
+@@ -434,7 +434,7 @@
+ #endif
+ /* Manually override the codec id. */
+ if (of)
+- of->video_codec = CODEC_ID_MSMPEG4V2;
++ of->video_codec = AV_CODEC_ID_MSMPEG4V2;
+
+ } else if (strcmp(codec, "swf") == 0) {
+ ext = ".swf";
+@@ -450,7 +450,7 @@
+ #else
+ of = av_guess_format("flv", NULL, NULL);
+ #endif
+- of->video_codec = CODEC_ID_FLV1;
++ of->video_codec = AV_CODEC_ID_FLV1;
+ } else if (strcmp(codec, "ffv1") == 0) {
+ ext = ".avi";
+ #ifdef GUESS_NO_DEPRECATED
+@@ -463,7 +463,7 @@
+ * Requires strict_std_compliance to be <= -2
+ */
+ if (of)
+- of->video_codec = CODEC_ID_FFV1;
++ of->video_codec = AV_CODEC_ID_FFV1;
+
+ } else if (strcmp(codec, "mov") == 0) {
+ ext = ".mov";
+@@ -559,7 +559,7 @@
+
+ /* Create a new video stream and initialize the codecs. */
+ ffmpeg->video_st = NULL;
+- if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) {
++ if (ffmpeg->oc->oformat->video_codec != AV_CODEC_ID_NONE) {
+ #if defined FF_API_NEW_AVIO
+ ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /* Codec */);
+ #else
+@@ -586,7 +586,7 @@
+ #else
+ c->codec_type = AVMEDIA_TYPE_VIDEO;
+ #endif
+- is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO;
++ is_mpeg1 = c->codec_id == AV_CODEC_ID_MPEG1VIDEO;
+
+ if (strcmp(ffmpeg_video_codec, "ffv1") == 0)
+ c->strict_std_compliance = -2;
diff --git a/motion.spec b/motion.spec
index 26af501..c888ab0 100644
--- a/motion.spec
+++ b/motion.spec
@@ -22,7 +22,7 @@
%global nextver 3.3.0
Name: motion
Version: %{nextver}.trunkREV561
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: A motion detection system
Group: Applications/Multimedia
@@ -33,6 +33,11 @@ Source1: motion.service
Source2: motion.tmpfiles
Patch1: motion-0002-there-is-no-bin-service-in-Fedora-use-systemctl.patch
Patch2: motion-version.patch
+# patches from Debian
+#
https://anonscm.debian.org/git/users/infinity0/motion.git/tree/debian/pat...
+Patch3: api-update_copy-old-API-items.patch
+Patch4: api-update_ffmpeg-2.9.patch
+Patch5: api-update_libav10.patch
BuildRequires: libjpeg-devel zlib-devel ffmpeg-devel
Buildrequires: pkgconfig(sqlite3)
@@ -56,6 +61,9 @@ without MySQL and PostgreSQL support.
%prep
%setup -q -n %{name}-%{nextver}
%patch1 -p1
+%patch3 -p1 -b .copy-old-API-items
+%patch4 -p1 -b .ffmpeg-2.9
+%patch5 -p1 -b .libav10
autoreconf
%patch2 -p1 -b .version
@@ -141,6 +149,9 @@ rm -rf %{buildroot}
%attr(0755,root,root) %{_tmpfilesdir}/%{name}.conf
%changelog
+* Sun Jul 17 2016 Leigh Scott <leigh123linux(a)googlemail.com> - 3.3.0.trunkREV561-2
+- patch for ffmpeg-3
+
* Wed Nov 18 2015 Sérgio Basto <sergio(a)serjux.com> - 3.3.0.trunkREV561-1
- Update motion to runkREV561 .
- Use only ffmpeg-devel, drop ffmpeg-compat-devel.