[FFmpeg-devel] Allow interrupt callback for AVCodecContext

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Jan 6 10:46:48 CET 2014

On 06.01.2014, at 09:53, "Don Moir" <donmoir at comcast.net> wrote:
> I am open to other suggestions. I just can't think of any that works more efficiently than a callback. What I have now with cached context works ok but just expensive in terms of memory and thread resources. 

Please define "expensive". Threads very much should not be expensive at all (we are not talking about many thousands of threaads), and contexts ideally should not be that large either, but we might have some fixing to do there.
Also, for the threads a thread pool shared across contexts would solve it, though tricky to implement.
In addition I have no problem thinking of vastly more efficient methods, though they are more hackish: using signals + longjump (or some other exception system that allows injecting them from outside) or just killing the decode thread. The problem is that this usually results in the context having inconsistent state, so it's risky to reuse it anyway if done like this.
Also the big thing here is testability: how could any such code be reliably tested? I wouldn't recommend using code that nobody except you is ever going to test, it's almost as costly as keeping a custom local patch.

More information about the ffmpeg-devel mailing list