[XviD-devel] Floating point exception in xvid_decore()

Stephan Assmus superstippi at gmx.de
Tue Jun 26 12:10:08 CEST 2007


Hi Chris,

Chris Watt wrote (2007-06-26, 02:22:49 [+0200]):
> In my application linked against libxvidcore 1.1.2, calling
> xvid_decore() sometimes causes a "Floating point exception" resulting in
> a core dump. I have included an ugly, but fairly portable workaround
> below for the next person searching the list archives.
> 
> I am using a simple decoder loop based on the example in xvid_decraw.c,
> fed data parsed out of an Ogg stream. About 5-10% of the time after an
> error in the input stream the next call to xvid_decraw() results in a
> floating point exception (SIGFPE).
> 
> I'm not sure if this is a bug in Xvid or incorrect usage. My program
> currently responds to an error or gap in the bitstream (e.g. because we
> missed part of a live Ogg stream) by resuming calls to xvid_decore()
> with the payload of the first valid Ogg packet after the error. Is there
> a better way to way to handle a known error in the input bitstream?
> 
> Any suggestions would be helpful.

I have just succeeded in writing an xvid decoder for BeOS. When the user is 
seeking in the input stream, I'm informing the xvid decoder about the 
discontinuity of the stream like this... you will notice this is almost the 
decode function from the xvid_decraw example:

int
XvidDecoder::_XvidDecode(uchar* istream, uchar* ostream, int inStreamSize,
	xvid_dec_stats_t* xvidDecoderStats, bool hurryUp)
{
	PRINT(("XvidDecoder::_XvidDecode(%p, %p, %d)\n", istream, ostream,
		inStreamSize));

	if (istream == NULL || inStreamSize == 0)
		return -1;

	xvid_dec_frame_t xvid_dec_frame;

	// reset all structures
	memset(&xvid_dec_frame, 0, sizeof(xvid_dec_frame_t));
	memset(xvidDecoderStats, 0, sizeof(xvid_dec_stats_t));

	// set version
	xvid_dec_frame.version = XVID_VERSION;
	xvidDecoderStats->version = XVID_VERSION;

	// general flags for decoder
	xvid_dec_frame.general = 0; //XVID_DEBLOCKY | XVID_DEBLOCKUV;
	if (hurryUp)
		xvid_dec_frame.general |= XVID_LOWDELAY;

	// inform about discontinuity of stream:
	if (fDiscontinuity) {
		xvid_dec_frame.general |= XVID_DISCONTINUITY;
		fDiscontinuity = false;
	}

	// input stream
	xvid_dec_frame.bitstream = istream;
	xvid_dec_frame.length = inStreamSize;

	// output frame structure
	xvid_dec_frame.output.plane[0] = ostream;
	xvid_dec_frame.output.stride[0] = ostream ?
		fOutputVideoFormat.display.bytes_per_row : 0;
	xvid_dec_frame.output.csp = fXvidColorspace;

	return xvid_decore(fXvidDecoderHandle, XVID_DEC_DECODE,
		&xvid_dec_frame, xvidDecoderStats);
}


"fDiscontinuity" is just a flag of the object that feeds the stream to xvid.

It may well be, that - even if my suggestion would fix your particular 
problem in that situation - that your work around is still valid, since the 
stream could be broken without you knowing it.

Best regards,
-Stephan


More information about the XviD-devel mailing list