[FFmpeg-devel] [PATCH] lavc/ffjni: replace ff_jni_{attach, detach} with ff_jni_get_env

Matthieu Bouron matthieu.bouron at gmail.com
Tue Jul 26 10:38:28 EEST 2016


On Mon, Jul 25, 2016 at 09:50:58AM +0200, Benoit Fouet wrote:
> Hi,

Hi,

> 
> On 24/07/2016 23:05, Matthieu Bouron wrote:
> > From: Matthieu Bouron<matthieu.bouron at stupeflix.com>
> > 
> > If a JNI environment is not already attached to the thread where the
> > MediaCodec calls are made the current implementation will attach /
> > detach an environment for each MediaCodec call wasting some CPU time.
> > 
> > ff_jni_get_env replaces ff_jni_{attach,detach} by permanently attaching
> > an environment (if it is not already the case) to the current thread.
> > The environment will be automatically detached at the thread destruction
> > using a pthread_key callback.
> > 
> > Saves around 5% of CPU time (out of 20%) while decoding a stream with
> > MediaCodec.
> > ---
> >   libavcodec/ffjni.c              |  43 +++++----
> >   libavcodec/ffjni.h              |  15 +--
> 
> LGTM

Thanks for the review. I will push the patch in a few hours.

Matthieu

[...]


More information about the ffmpeg-devel mailing list