Re: bug in thread count calculation
Michael Militzer <[email protected]> Wed, 26 Nov 2014 00:09:50 +0100
| Newsgroups | gmane.comp.video.xvid.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Lukasz, thanks for pointing this out! I've checked in a patch based on what you suggested. Regards, Michael Quoting Lukasz Marek <[email protected]>: > Hello, > > During some tests of ffmpeg encoders (it uses libxvidcore) I noticed there > is not allocated memory in use. > Bad line is encoder.c:466 > > bug is in following code > > #ifndef HAVE_PTHREAD > int t = MAX(1, create->num_threads); > #else > int t = MIN(create->num_threads, (int) > (pEnc->mbParam.mb_height>>1)); /* at least two rows per thread */ > #endif > > For height <=16 pEnc->mbParam.mb_height is 1. (it is calculated earlier as > (height +15) /16) so it produces t = 0. > It is later used in > > pEnc->smpData = xvid_malloc(t*sizeof(SMPData), CACHE_LINE); > > Im not sure what is correct fix, but one of follows may help > > #ifndef HAVE_PTHREAD > int t = MAX(1, create->num_threads); > #else > int t = MIN(create->num_threads, (int) > (pEnc->mbParam.mb_height>>1)); /* at least two rows per thread */ > t = MAX(1, t); > #endif > > or > > #ifndef HAVE_PTHREAD > int t = MAX(1, create->num_threads); > #else > int t = MIN(create->num_threads, (int) > (pEnc->mbParam.height>>1)); /* at least two rows per thread */ > #endif > > or > > #ifndef HAVE_PTHREAD > int t = MAX(1, create->num_threads); > #else > int t = MIN(create->num_threads, (int) > (pEnc->mbParam.mb_height>>1)); /* at least two rows per thread */ > #endif > if (!t) > goto xvid_err_nosmp; > > Regards, > Lukasz Marek > _______________________________________________ > Xvid-devel mailing list > [email protected] > http://list.xvid.org/mailman/listinfo/xvid-devel > >