[Xvid-devel] Division by Zero

Cédric OCHS kervala at gmail.com
Mon Jul 25 12:04:26 CEST 2011


Hi Michael,

Thanks a lot !

I now set both fincr and fbase, and it doesn't crash anymore, so it was  
the problem (both of them were set to 0) :)

Have a nice day and thanks again.

Cédric


Le Mon, 25 Jul 2011 11:41:20 +0200, Michael Militzer <michael at xvid.org> a  
écrit:

> Hi Cédric,
>
> actually, TRD should never be zero in BVOP ME. Have you set a proper
> framerate for your input?
>
> You can either specify a constant framerate by filling "fincr"/"fbase" in
> the xvid_enc_create_t struct or a variable one by setting "fincr" per
> input frame in xvid_enc_frame_t...
>
> Best regards,
> Michael
>
>
> Quoting Cédric OCHS <kervala at gmail.com>:
>
>> Hi there,
>>
>> I compiled the last revision of xvidcore from SVN in a x64 static  
>> library
>> under Windows with MS VC++ 2010 Express.
>>
>> I declared a 320x240 RGB24 format for image and initialized its buffer
>> with :
>>
>> size_t buffer_size = 320*240*3;
>>
>> uint8_t *buffer = new uint8_t[buffer_size];
>>
>> for(size_t i = 0; i < buffer_size; ++i)
>> {
>> 	buffer[i] = i % 256;
>> }
>>
>> And when I try to encode this RGB24 buffer to a XVid video (in fact, a
>> still image), it generates a Division by Zero exception at the 4th frame
>> (a B Frame apparently).
>>
>> The exception occurs in SearchDirect_initial function of
>> xvidcore/src/motion/estimation_bvop.c especially at the lines :
>>
>> Data->directmvF[k].x = ((TRB * Data->referencemv[k].x) / TRD);
>> Data->directmvB[k].x = ((TRB - TRD) * Data->referencemv[k].x) / TRD;
>> Data->directmvF[k].y = ((TRB * Data->referencemv[k].y) / TRD);
>> Data->directmvB[k].y = ((TRB - TRD) * Data->referencemv[k].y) / TRD;
>>
>> Because both TRD and TRB are set to 0.
>>
>> I tried with a full white image (all bytes set to 255), it doesn't
>> generate any exception and it works fine.
>>
>> Please someone could check if it's reproducible ?
>>
>> Currently, I fixed it replacing it by :
>>
>> if (TRD)
>> {
>> 	Data->directmvF[k].x = ((TRB * Data->referencemv[k].x) / TRD);
>> 	Data->directmvB[k].x = ((TRB - TRD) * Data->referencemv[k].x) / TRD;
>> 	Data->directmvF[k].y = ((TRB * Data->referencemv[k].y) / TRD);
>> 	Data->directmvB[k].y = ((TRB - TRD) * Data->referencemv[k].y) / TRD;
>> }
>> else
>> {
>> 	Data->directmvF[k].x = 0;
>> 	Data->directmvB[k].x = 0;
>> 	Data->directmvF[k].y = 0;
>> 	Data->directmvB[k].y = 0;
>> }
>>
>> Thanks a lot :)
>>
>> Cédric
>> _______________________________________________
>> Xvid-devel mailing list
>> Xvid-devel at xvid.org
>> http://list.xvid.org/mailman/listinfo/xvid-devel
>>
>
>
>
> _______________________________________________
> Xvid-devel mailing list
> Xvid-devel at xvid.org
> http://list.xvid.org/mailman/listinfo/xvid-devel


More information about the Xvid-devel mailing list