diff --git a/CHANGELOG b/CHANGELOG index ddcb585b..94e8fb3a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -85,6 +85,7 @@ Features * Revise version.sh to put out the git commit. * Rollback revision to allow for a formal pull request. * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 + * Implement requirement of modulo 16 to avoid seg fault when opening stream Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) diff --git a/netcam.c b/netcam.c index 3c2b4812..700009f5 100644 --- a/netcam.c +++ b/netcam.c @@ -2909,15 +2909,15 @@ int netcam_start(struct context *cnt) * Motion currently requires that image height and width is a * multiple of 16. So we check for this. */ - if (netcam->width % 8) { + if (netcam->width % 16) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image width (%d)" - " is not modulo 8", netcam->width); + " is not modulo 16", netcam->width); return -3; } - if (netcam->height % 8) { + if (netcam->height % 16) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image height (%d)" - " is not modulo 8", netcam->height); + " is not modulo 16", netcam->height); return -3; } diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 4e5a55fd..1c90a81d 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -850,6 +850,20 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ netcam->rtsp->readingframe = 0; netcam->rtsp->status = RTSP_NOTCONNECTED; + /* + * Warn and fix dimensions as needed. + */ + if (netcam->cnt->conf.width % 16) { + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image width (%d) requested is not modulo 16.", netcam->cnt->conf.width); + netcam->cnt->conf.width = netcam->cnt->conf.width - (netcam->cnt->conf.width % 16) + 16; + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting width to next higher multiple of 16 (%d).", netcam->cnt->conf.width); + } + if (netcam->cnt->conf.height % 16) { + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image height (%d) requested is not modulo 16.", netcam->cnt->conf.height); + netcam->cnt->conf.height = netcam->cnt->conf.height - (netcam->cnt->conf.height % 16) + 16; + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting height to next higher multiple of 16 (%d).", netcam->cnt->conf.height); + } + av_register_all(); avformat_network_init(); avcodec_register_all();