[FFmpeg-devel] Allow interrupt callback for AVCodecContext

Don Moir donmoir at comcast.net
Mon Jan 6 09:53:45 CET 2014


Le septidi 17 nivôse, an CCXXII, Don Moir a écrit :
>> Yeah callback needs to be called but that is negligible. It does not
>> need additional memory resources that matter and no additional
>> threads. The default is a noop and always a very quick return (up to
>> user but common sense dictates return immediately otherwise user is
>> at fault for slowness). It does not seem to matter to you though,
>> that av_log is called very often..

>Please update your common sense to work with modern CPUs with long pipelines
>and branch predictions.

>You want low-latency multitasking, that is something inherently expensive.
>You can not expect to put that expense to all libavcodec users, whether they
>need it or not.

The default could be a NULL callback or:

int av_default_interrupt_callback (void *opaque)
{
    return 0;
}

user would probably do something like this if interested:

int interrupt_callback (void *opaque)
{
    return ((Player*)opaque)->interrupt;
}

>Ronald suggested you a way of implementing it. It puts that expense on your
>program, in terms of memory and a bit CPU time during the overlap.

I did do this and it works but I bring it back up after implementing to suggest that it's not without quite abit of cost that seems 
unnecessary. You want to keep it to a minimal of open context so saying don't go at without paying attention.

>I can suggest another one: run the decoder in a separate process, rather than
>thread, so you can kill it immediately without leaking.

Don't think that would help much. A process per media item ? which they can be several.

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. 



More information about the ffmpeg-devel mailing list