Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Crashing when using H264 compression
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crashing when using H264 compression



Does anyone have any more information on crashes when using H264 and ICM?
I'm seeing the crash even though I don't set the number of keyframes in the ICM session (as stated earlier, if I do set the keyframe rate, then I get a crash within about 2 minutes)


The stack is:
Thread 18 Crashed:
0 QuickTimeH264.scalar 0x98abe4fe JVTLibDecoDispose + 117130
1 QuickTimeH264.scalar 0x98ab411e JVTLibDecoDispose + 75178
2 QuickTimeH264.scalar 0x98aa20b6 JVTLibDecoDispose + 1346
3 QuickTimeH264.scalar 0x98a9215c JVTCompExtendedFrameOptionsSetProperty + 3105
4 QuickTimeH264.scalar 0x98a955f0 JVTCompEncodeFrame + 63
5 ...ple.CoreServices.CarbonCore 0x90ccad57 CallComponentFunctionCommon + 513
6 ...ple.QuickTimeH264.component 0x98a87fad JVTCompComponentDispatch + 163
7 ...ple.CoreServices.CarbonCore 0x90ccaa3c CallComponentDispatch + 34
8 com.apple.QuickTime 0x943d17c4 ImageCodecEncodeFrame + 49
9 com.apple.QuickTime 0x943d1147 icmCompressionSessionEncodeSourceFrame + 201
10 com.apple.QuickTime 0x943d0a66 icmCompressionSessionEncodeFrameInternal + 1251
11 com.apple.QuickTime 0x943d0576 ICMCompressionSessionEncodeFrame + 88


The ICM session is setup as follows (error checking removed for clarity):
ICMEncodedFrameOutputRecord encodedFrameOutputRecord = {0};
ICMCompressionSessionOptionsRef sessionOptions = NULL;
err = ICMCompressionSessionOptionsCreate( NULL, &sessionOptions );


// We must set this flag to enable P or B frames.
err = ICMCompressionSessionOptionsSetAllowTemporalCompression ( sessionOptions, true );
err = ICMCompressionSessionOptionsSetAllowFrameReordering ( sessionOptions, true );
err = ICMCompressionSessionOptionsSetAllowFrameTimeChanges ( sessionOptions, true );


	BOOL boolean = YES;
	err = ICMCompressionSessionOptionsSetProperty(sessionOptions,
		kQTPropertyClass_ICMCompressionSessionOptions,
		kICMCompressionSessionOptionsPropertyID_AllowAsyncCompletion,
		sizeof(Boolean), &boolean);

// Set the average data rate.
long averageDataRate = size.width * size.height * 4 * expectedFrameRate;
err = ICMCompressionSessionOptionsSetProperty(sessionOptions,
kQTPropertyClass_ICMCompressionSessionOptions,
kICMCompressionSessionOptionsPropertyID_AverageDataRate,
sizeof( averageDataRate ),
&averageDataRate );


	err = ICMCompressionSessionOptionsSetProperty(sessionOptions,
												  kQTPropertyClass_ICMCompressionSessionOptions,
												  kICMCompressionSessionOptionsPropertyID_Quality,
												  sizeof(quality), &quality);
	int value = 0;
	err = ICMCompressionSessionOptionsSetProperty(sessionOptions,
												  kQTPropertyClass_ICMCompressionSessionOptions,
												  kICMCompressionSessionOptionsPropertyID_CPUTimeBudget,
												  sizeof(value), &value);

	err = ICMCompressionSessionOptionsSetProperty(sessionOptions,
												  kQTPropertyClass_ICMCompressionSessionOptions,
												  kICMCompressionSessionOptionsPropertyID_ExpectedFrameRate,
												  sizeof(expectedFrameRate), &expectedFrameRate);

encodedFrameOutputRecord.encodedFrameOutputCallback = writeEncodedFrameToMovie;
encodedFrameOutputRecord.encodedFrameOutputRefCon = self;
encodedFrameOutputRecord.frameDataAllocator = NULL;

err = ICMCompressionSessionCreate( NULL, size.width, size.height, codecType, timeScale,
sessionOptions, NULL, &encodedFrameOutputRecord, &compressionSession );


	ICMCompressionSessionOptionsRelease( sessionOptions );

Each frame is compressed using:

	ICMSourceTrackingCallbackRecord callback;
	callback.sourceTrackingCallback = EncodingCallback;
	callback.sourceTrackingRefCon = self;

// While computing frame times, synchronize so that only one thread does it at once
@synchronized(self) {
TimeValue64 displayTime = WideToSInt64(frameTime->value);

// long displayDuration = displayTime - lastFrameTime;
wide duration = SInt64ToWide(displayTime);
WideSubtract(&duration, &lastFrameTime);
TimeValue64 displayDuration = WideToSInt64(duration);
if(displayDuration <= 0) {
[self log:kLoggingVideo message:@"Duration less than or equal to zero - setting to 1"];
displayDuration = 1;
}

lastFrameTime = SInt64ToWide(displayTime);
int validFlags = kICMValidTime_DisplayDurationIsValid | kICMValidTime_DisplayTimeStampIsValid;
if(compressionSession) {
encoded++;
return ICMCompressionSessionEncodeFrame(compressionSession, pixelBuffer, displayTime, displayDuration, validFlags, NULL, &callback, reference);
}
}



On 7/10/2006, at 7:08 AM, Neil Clayton wrote:

Hi,

I'm seeing the same bug as mentioned in the first email on the QT lists with the subject "Crashing when using H264 compression".
The original author had the problem when encoding the second frame. I'm seeing the problem about 1 or 2 minutes into an encoding session. Specifically, I see a EXC_ARITHMETIC within JVTLibDecoDispose.


It seems related to the number of keyframes in use (if I set that to about 100, I didn't see a crash after 4 minutes of recording. I didn't leave it longer to see if it would eventually crash). If I set keyframes to be 5, the crash occurs in about 2m. If I set keyframes to 1, it doesn't seem to occur (well, didn't occur within 3m). Setting keyframes to 2 causes a crash in 1m 45s.

I've searched the newsgroup but I don't see any other reply to this. Google does report a number of other applications (including QT/iChat) that experience the problem in one way or the other, but there doesn't seem to be any concrete information on how to fix it.

Has anyone here come across this?
Is there a common fix? or a common thing that us people using ICM compression sessions might be doing wrong?


Regards,
Neil Clayton
_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40cloudnine.net.nz


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. QuickTime-API mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Crashing when using H264 compression (From: Neil Clayton <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.