Crash calling FFMPEG routines

Started by
-1 comments, last by Pruth 15 years, 6 months ago
I just wanted to post a workaround (hack is more appropriate) that works for me to solve the crasher that can happen when calling a FFMPEG routine that expects the stack pointer to be 16 byte aligned at the time of call!. This code snippet works on my VS .Net C++ app. I got the inspiration from the original thread posted by "kek_miyu" http://www.gamedev.net/community/forums/topic.asp?topic_id=482230. So I thought I should return the favor by posting my solution and hope it works for someone else. // Adjust the stack pointer address by pushing dummy data until // it is 16 byte aligned. unsigned int stackAddress; unsigned int numDummyVariablesPushed = 0; while (true) { __asm { mov stackAddress, esp } if (stackAddress&15) { numDummyVariablesPushed ++; __asm { push eax } } else { break; } } // Call to FFMPEG routine that is being a naughty boy :) int encodedSize = avcodec_encode_video(tempStream->codec, bit_buffer, bit_buffer_size, encodedFrame); // Restore the stack pointer value back to original while (numDummyVariablesPushed --) { __asm { pop eax } }

This topic is closed to new replies.

Advertisement