[Ffmpeg-devel] DV decoding crash

Steven M. Schultz sms
Thu Dec 29 20:34:11 CET 2005

Hi -

	It looks like the massive changes over the last couple days
	broke DV decoding.

	In libavcodec/dv.c  the 'dv_anchor' array was made part of
	'DVVideoContext' - a "per context" (thread?) structure.  However,
	'dv_anchor' is only initialized in the "global" context.

	In 'dvvideo_init()' the logic is:

	static int done=0;
	if (!done) {
	   s->dv_anchor = av_malloc(12*27*sizeof(void*));

	Thus dv_anchor is only initialized once on the first call to
	dvvideo_init() which would come from calling avcodec_open.

	After that, further calls to avcodec_open() will NOT initialize
	dv_anchor leaving it NULL and causing a crash.

	I'm not sure which is the correct fix - put 'dv_anchor' back to being
	a static as it was (which worked ;)) OR moving the initialization of
	dv_anchor outside the 'if (!done)' block so that it gets initialized
	for each context.

	It almost makes some sense, seeing how dv_anchor is used, to make it
	a static common to all threads/contexts.  All that dv_anchor holds
	is a once computed array:

	   for (i=0; i<12*27; i++)
		       s->dv_anchor[i] = (void*)(size_t)i;

	I'll experiment a bit when I get back from lunch ;)

	Steven Schultz

More information about the ffmpeg-devel mailing list