Implement modulo 16 for netcams to avoid seg fault in stream

This commit is contained in:
MrDave
2014-09-06 09:39:55 -07:00
parent a869057374
commit bd730643ef
3 changed files with 19 additions and 4 deletions

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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();