[FFmpeg-devel] [PATCH] lavc: make compilation of frame_thread_encoder.o optional.

Ronald S. Bultje rsbultje at gmail.com
Wed Mar 13 19:14:15 CET 2013


Hi,

On Wed, Mar 13, 2013 at 11:01 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Wed, Mar 13, 2013 at 08:21:28AM -0700, Ronald S. Bultje wrote:
>> Hi,
>>
>> On Wed, Mar 13, 2013 at 7:57 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
>> > On Tue, Mar 12, 2013 at 09:24:08PM -0700, Ronald S. Bultje wrote:
>> >> From: "Ronald S. Bultje" <rsbultje at gmail.com>
>> >>
>> >> Only compile if CONFIG_ENCODERS is enabled, i.e. if at least one
>> >> encoder is to be compiled. This prevents it from being includes in
>> >> a decoder-only build.
>> >> ---
>> >>  libavcodec/Makefile | 12 +++++++++---
>> >>  libavcodec/utils.c  |  8 +++++---
>> >>  2 files changed, 14 insertions(+), 6 deletions(-)
>> >>
>> >> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>> >> index 69f9b83..3b4bba4 100644
>> >> --- a/libavcodec/Makefile
>> >> +++ b/libavcodec/Makefile
>> >> @@ -771,9 +771,15 @@ OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF)       += remove_extradata_bsf.o
>> >>  OBJS-$(CONFIG_TEXT2MOVSUB_BSF)            += movsub_bsf.o
>> >>
>> >>  # thread libraries
>> >> -OBJS-$(HAVE_PTHREADS)                  += pthread.o frame_thread_encoder.o
>> >> -OBJS-$(HAVE_W32THREADS)                += pthread.o frame_thread_encoder.o
>> >> -OBJS-$(HAVE_OS2THREADS)                += pthread.o frame_thread_encoder.o
>> >> +OBJS-$(HAVE_PTHREADS)                  += pthread.o
>> >> +OBJS-$(HAVE_W32THREADS)                += pthread.o
>> >> +OBJS-$(HAVE_OS2THREADS)                += pthread.o
>> >> +
>> >> +ifdef CONFIG_ENCODERS
>> >> +OBJS-$(HAVE_PTHREADS)                  += frame_thread_encoder.o
>> >> +OBJS-$(HAVE_W32THREADS)                += frame_thread_encoder.o
>> >> +OBJS-$(HAVE_OS2THREADS)                += frame_thread_encoder.o
>> >> +endif
>> >>
>> >>  SKIPHEADERS                            += %_tablegen.h                  \
>> >>                                            %_tables.h                    \
>> >> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
>> >> index 13f8d0f..90b02b8 100644
>> >> --- a/libavcodec/utils.c
>> >> +++ b/libavcodec/utils.c
>> >> @@ -1126,7 +1126,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
>> >>      if (!HAVE_THREADS)
>> >>          av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
>> >>
>> >> -    if (HAVE_THREADS) {
>> >> +    if (HAVE_THREADS && CONFIG_ENCODERS) {
>> >>          ff_unlock_avcodec(); //we will instanciate a few encoders thus kick the counter to prevent false detection of a problem
>> >>          ret = ff_frame_thread_encoder_init(avctx, options ? *options : NULL);
>> >>          ff_lock_avcodec(avctx);
>> >> @@ -1688,7 +1688,8 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
>> >>
>> >>      *got_packet_ptr = 0;
>> >>
>> >> -    if(HAVE_THREADS && avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))
>> >> +    if(HAVE_THREADS && CONFIG_ENCODERS &&
>> >> +       avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))
>> >>          return ff_thread_video_encode_frame(avctx, avpkt, frame, got_packet_ptr);
>> >>
>> >>      if ((avctx->flags&CODEC_FLAG_PASS1) && avctx->stats_out)
>> >> @@ -2263,7 +2264,8 @@ av_cold int avcodec_close(AVCodecContext *avctx)
>> >>      if (avcodec_is_open(avctx)) {
>> >>          FramePool *pool = avctx->internal->pool;
>> >>          int i;
>> >> -        if (HAVE_THREADS && avctx->internal->frame_thread_encoder && avctx->thread_count > 1) {
>> >> +        if (HAVE_THREADS && CONFIG_ENCODERS &&
>> >
>> > these could be simplified with a CONFIG_FRAME_THREAD_ENCODER
>>
>> Hm, yeah, probably. Is anyone sufficiently proficient in understanding
>> our configure script to write something like that? I barely understand
>> how it works.
>
> something like below may work
>
> diff --git a/configure b/configure
> index 4afe0dc..352ab05 100755
> --- a/configure
> +++ b/configure
> @@ -1228,6 +1228,7 @@ CONFIG_LIST="
>      dwt
>      fast_unaligned
>      fft
> +    frame_thread_enco
>      ftrapv
>      gpl
>      gray
> @@ -1671,6 +1672,7 @@ log2_deps="!msvcrt"
>  # subsystems
>  dct_select="rdft"
>  error_resilience_select="dsputil"
> +frame_thread_enco_deps="encoders pthreads"
>  mdct_select="fft"
>  rdft_select="fft"
>  mpegaudio_select="mpegaudiodsp"
> @@ -2191,6 +2193,7 @@ enable stripping
>  enable asm
>  enable debug
>  enable doc
> +enable frame_thread_enco
>  enable optimizations
>  enable runtime_cpudetect
>  enable safe_bitstream_reader

I don't think that turns it on automatically when I do
--disable-everything --enable-encoder=something - I'd like that to be
automatic.

Ronald


More information about the ffmpeg-devel mailing list