diff --git a/veejay-current/veejay-server/libel/Makefile.am b/veejay-current/veejay-server/libel/Makefile.am index b9d42192..5e0f1fa0 100644 --- a/veejay-current/veejay-server/libel/Makefile.am +++ b/veejay-current/veejay-server/libel/Makefile.am @@ -7,9 +7,9 @@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir) -I$(includedir) \ -I$(top_srcdir)/thirdparty -AM_CPPFLAGS += $(FFMPEG_CFLAGS) $(PIXBUF_CFLAGS) $(LIBQUICKTIME_CFLAGS) - +AM_CPPFLAGS += $(FFMPEG_CFLAGS) $(PIXBUF_CFLAGS) $(LIBQUICKTIME_CFLAGS) $(VEEJAYCORE_CFLAGS) + VJEL_LIB_FILE = libel.la noinst_LTLIBRARIES = $(VJEL_LIB_FILE) -libel_la_SOURCES = vj-mmap.c elcache.c avilib.c lav_io.c vj-dv.c rawdv.c pixbuf.c vj-avcodec.c vj-el.c +libel_la_SOURCES = avhelper.c vj-mmap.c elcache.c avilib.c lav_io.c vj-dv.c rawdv.c pixbuf.c vj-avcodec.c vj-el.c diff --git a/veejay-current/veejay-server/libel/avcommon.h b/veejay-current/veejay-server/libel/avcommon.h deleted file mode 100644 index 7e6eb2c8..00000000 --- a/veejay-current/veejay-server/libel/avcommon.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef AVCOMMON_H -#define AVCOMMON_H -#include -#define LIBAVUTIL_VERSION_CHECK( a, b, c, d, e ) \ - ( (LIBAVUTIL_VERSION_MICRO < 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( a, b, c ) ) || \ - (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( a, d, e ) ) ) - -#if LIBAVUTIL_VERSION_CHECK(51,45,0,74,100) -#ifndef PIX_FMT_YUVA422P -#define PIX_FMT_YUVA422P AV_PIX_FMT_YUVA422P -#endif -#ifndef PIX_FMT_YUVA444P -#define PIX_FMT_YUVA444P AV_PIX_FMT_YUVA444P -#endif -#ifndef PIX_FMT_YUVA420P -#define PIX_FMT_YUVA420P AV_PIX_FMT_YUVA420P -#endif -#ifndef PIX_FMT_YUV422P -#define PIX_FMT_YUV422P AV_PIX_FMT_YUV422P -#endif -#ifndef PIX_FMT_YUV420P -#define PIX_FMT_YUV420P AV_PIX_FMT_YUV420P -#endif -#ifndef PIX_FMT_YUVJ420P -#define PIX_FMT_YUVJ420P AV_PIX_FMT_YUVJ420P -#endif -#ifndef PIX_FMT_YUV444P -#define PIX_FMT_YUV444P AV_PIX_FMT_YUV444P -#endif -#ifndef PIX_FMT_RGB24 -#define PIX_FMT_RGB24 AV_PIX_FMT_RGB24 -#endif -#ifndef PIX_FMT_YUVJ444P -#define PIX_FMT_YUVJ444P AV_PIX_FMT_YUVJ444P -#endif -#ifndef PIX_FMT_YUVJ422P -#define PIX_FMT_YUVJ422P AV_PIX_FMT_YUVJ422P -#endif -#ifndef PIX_FMT_RGB32 -#define PIX_FMT_RGB32 AV_PIX_FMT_RGB32 -#endif -#ifndef PIX_FMT_BGR32 -#define PIX_FMT_BGR32 AV_PIX_FMT_BGR32 -#endif -#ifndef PIX_FMT_RGBA -#define PIX_FMT_RGBA AV_PIX_FMT_RGBA -#endif -#ifndef PIX_FMT_BGRA -#define PIX_FMT_BGRA AV_PIX_FMT_BGRA -#endif -#ifndef PIX_FMT_BGR24 -#define PIX_FMT_BGR24 AV_PIX_FMT_BGR24 -#endif -#ifndef PIX_FMT_GRAY8 -#define PIX_FMT_GRAY8 AV_PIX_FMT_GRAY8 -#endif -#ifndef PIX_FMT_RB32_1 -#define PIX_FMT_RGB32_1 AV_PIX_FMT_RGB32_1 -#endif -#ifndef PIX_FMT_YUYV422 -#define PIX_FMT_YUYV422 AV_PIX_FMT_YUYV422 -#endif -#ifndef PIX_FMT_UYVY422 -#define PIX_FMT_UYVY422 AV_PIX_FMT_UYVY422 -#endif -#ifndef PIX_FMT_ARGB -#define PIX_FMT_ARGB AV_PIX_FMT_ARGB -#endif -#ifndef PIX_FMT_ABGR -#define PIX_FMT_ABGR AV_PIX_FMT_ABGR -#endif -#ifndef PIX_FMT_YUV411P -#define PIX_FMT_YUV411P AV_PIX_FMT_YUV411P -#endif - -#ifndef CODEC_FLAG_QSCALE -#define CODEC_FLAG_QSCALE AV_CODEC_FLAG_QSCALE -#endif -#ifndef CODEC_CAP_TRUNCATED -#define CODEC_CAP_TRUNCATED AV_CODEC_CAP_TRUNCATED -#endif -#ifndef CODEC_FLAG_TRUNCATED -#define CODEC_FLAG_TRUNCATED AV_CODEC_FLAG_TRUNCATED -#endif - -#endif -#endif diff --git a/veejay-current/veejay-server/libel/avhelper.c b/veejay-current/veejay-server/libel/avhelper.c index f79bebdd..748d32e9 100644 --- a/veejay-current/veejay-server/libel/avhelper.c +++ b/veejay-current/veejay-server/libel/avhelper.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -33,7 +35,7 @@ #include #include #include -#include +#include #include #include @@ -138,6 +140,26 @@ static int key_compare(const void *key1, const void *key2) return ((const int) key1 == (const int) key2 ? 0 : 1); } +static int avhelper_set_num_decoders() { + int n_threads = 0; + + char *num_decode_threads = getenv( "VEEJAY_NUM_DECODE_THREADS" ); + if( num_decode_threads ) { + n_threads = atoi(num_decode_threads); + } + else { + veejay_msg(VEEJAY_MSG_DEBUG, "env VEEJAY_NUM_DECODE_THREADS not set!"); + int n = task_num_cpus(); + if( n > 1 ) + n_threads = 2; + if( n > 3 ) + n_threads = 4; + } + + veejay_msg(VEEJAY_MSG_DEBUG, "Using %d decoding threads (ffmpeg)", n_threads); + return n_threads; +} + int avhelper_get_codec_by_id(int id) { int i; @@ -254,6 +276,14 @@ void *avhelper_get_mjpeg_decoder(VJFrame *output) { #if LIBAVCODEC_BUILD > 5400 x->codec_ctx = avcodec_alloc_context3(x->codec); + + int n_threads = avhelper_set_num_decoders(); + + if( n_threads > 0 ) { + x->codec_ctx->thread_count = n_threads; + x->codec_ctx->thread_type = FF_THREAD_FRAME; + } + if ( avcodec_open2( x->codec_ctx, x->codec, NULL ) < 0 ) #else x->codec_ctx = avcodec_alloc_context(); @@ -504,6 +534,14 @@ further: } #if LIBAVCODEC_BUILD > 5400 + + int n_threads = avhelper_set_num_decoders(); + + if( n_threads > 0 ) { + x->codec_ctx->thread_count = n_threads; + x->codec_ctx->thread_type = FF_THREAD_FRAME; + } + if ( avcodec_open2( x->codec_ctx, x->codec, NULL ) < 0 ) #else if ( avcodec_open( x->codec_ctx, x->codec ) < 0 ) diff --git a/veejay-current/veejay-server/libel/avhelper.h b/veejay-current/veejay-server/libel/avhelper.h deleted file mode 100644 index fdf739e4..00000000 --- a/veejay-current/veejay-server/libel/avhelper.h +++ /dev/null @@ -1,73 +0,0 @@ -/* veejay - Linux VeeJay - * (C) 2002-2015 Niels Elburg - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details//. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef AVHELPER_H -#define AVHELPER_H - -#define CODEC_ID_YUV420 999 -#define CODEC_ID_YUV422 998 -#define CODEC_ID_YUV422F 997 -#define CODEC_ID_YUV420F 996 -#define CODEC_ID_YUVLZO 900 - -// This is not a library, it is a collection of helper functions for various purposes - -void *avhelper_alloc_frame(); - -int avhelper_get_codec_by_id(int id); - -int avhelper_get_codec_by_key( int key ); - -void *avhelper_get_codec_ctx( void *ptr ); - -void *avhelper_get_codec( void *ptr ); - -void avhelper_close_decoder( void *ptr ); - -int avhelper_decode_video( void *ptr, uint8_t *data, int len); - -void avhelper_rescale_video(void *ptr, uint8_t *dst[4]); - -void *avhelper_get_decoder( const char *filename, int dst_pixfmt, int dst_width, int dst_height ); - -void *avhelper_get_stream_decoder( const char *filename, int dst_pixfmt, int dst_width, int dst_height ); - -VJFrame *avhelper_get_decoded_video(void *ptr); - -void avhelper_free_context(AVCodecContext **avctx); - -void avhelper_frame_unref(AVFrame *ptr); - -void *avhelper_get_mjpeg_decoder(VJFrame *output_info); - -int avhelper_get_frame( void *decoder, int *got_picture ); - -VJFrame *avhelper_get_input_frame( void *ptr ); - -VJFrame *avhelper_get_output_frame( void *ptr); - -int avhelper_recv_decode( void *decoder, int *got_picture ); - -int avhelper_recv_frame_packet( void *decoder ); - -int avhelper_decode_video_buffer( void *ptr, uint8_t *data, int len ); - -double avhelper_get_spvf( void *decoder ); - -#endif diff --git a/veejay-current/veejay-server/libel/lav_io.c b/veejay-current/veejay-server/libel/lav_io.c index 78650f93..b2704fcf 100644 --- a/veejay-current/veejay-server/libel/lav_io.c +++ b/veejay-current/veejay-server/libel/lav_io.c @@ -49,8 +49,8 @@ #include #include #include -#include -#include +#include +#include #define QUICKTIME_MJPG_TAG 0x6d6a7067 extern int get_ffmpeg_pixfmt(int p); diff --git a/veejay-current/veejay-server/libel/pixbuf.c b/veejay-current/veejay-server/libel/pixbuf.c index 5067447c..74e9a4bc 100644 --- a/veejay-current/veejay-server/libel/pixbuf.c +++ b/veejay-current/veejay-server/libel/pixbuf.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #define RUP8(num)(((num)+8)&~8) typedef struct diff --git a/veejay-current/veejay-server/libel/vj-avcodec.c b/veejay-current/veejay-server/libel/vj-avcodec.c index e3c066eb..8ecbacda 100644 --- a/veejay-current/veejay-server/libel/vj-avcodec.c +++ b/veejay-current/veejay-server/libel/vj-avcodec.c @@ -37,8 +37,8 @@ #include #include #include -#include -#include +#include +#include //from gst-ffmpeg, round up a number #define GEN_MASK(x) ((1<<(x))-1) @@ -180,6 +180,29 @@ static vj_encoder *vj_avcodec_new_encoder( int id, VJFrame *frame, char *filenam #endif #if LIBAVCODEC_BUILD > 5400 e->context = avcodec_alloc_context3(e->codec); + + int n_threads = 0; + + char *num_decode_threads = getenv( "VEEJAY_NUM_DECODE_THREADS" ); + if( num_decode_threads ) { + n_threads = atoi(num_decode_threads); + } + else { + veejay_msg(VEEJAY_MSG_DEBUG, "env VEEJAY_NUM_DECODE_THREADS not set!"); + int n = task_num_cpus(); + if( n > 1 ) + n_threads = 2; + if( n > 3 ) + n_threads = 4; + } + + veejay_msg(VEEJAY_MSG_DEBUG, "Using %d decoding threads (ffmpeg)", n_threads); + + if( n_threads > 0 ) { + e->context->thread_count = n_threads; + e->context->thread_type = FF_THREAD_FRAME; + } + #else e->context = avcodec_alloc_context(); #endif diff --git a/veejay-current/veejay-server/libel/vj-dv.c b/veejay-current/veejay-server/libel/vj-dv.c index 38c71f22..cb0f6802 100644 --- a/veejay-current/veejay-server/libel/vj-dv.c +++ b/veejay-current/veejay-server/libel/vj-dv.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include diff --git a/veejay-current/veejay-server/libel/vj-el.c b/veejay-current/veejay-server/libel/vj-el.c index 10f008eb..2f4fb21f 100644 --- a/veejay-current/veejay-server/libel/vj-el.c +++ b/veejay-current/veejay-server/libel/vj-el.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/veejay-current/veejay-server/libplugger/freeframe-loader.c b/veejay-current/veejay-server/libplugger/freeframe-loader.c index 9f191930..4b87811c 100644 --- a/veejay-current/veejay-server/libplugger/freeframe-loader.c +++ b/veejay-current/veejay-server/libplugger/freeframe-loader.c @@ -40,7 +40,7 @@ #define V_BITS 24 #include #include -#include +#include typedef struct { diff --git a/veejay-current/veejay-server/libplugger/frei0r-loader.c b/veejay-current/veejay-server/libplugger/frei0r-loader.c index efd9a8d0..885359d2 100644 --- a/veejay-current/veejay-server/libplugger/frei0r-loader.c +++ b/veejay-current/veejay-server/libplugger/frei0r-loader.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #define RUP8(num)(((num)+8)&~8) #define _VJ_MAX_PARAMS 32 diff --git a/veejay-current/veejay-server/libplugger/livido-loader.c b/veejay-current/veejay-server/libplugger/livido-loader.c index 5274a873..1324b01a 100644 --- a/veejay-current/veejay-server/libplugger/livido-loader.c +++ b/veejay-current/veejay-server/libplugger/livido-loader.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #define LIVIDO_COPY 1 diff --git a/veejay-current/veejay-server/libstream/v4l2utils.c b/veejay-current/veejay-server/libstream/v4l2utils.c index 4f5d0f6f..c9d864bd 100644 --- a/veejay-current/veejay-server/libstream/v4l2utils.c +++ b/veejay-current/veejay-server/libstream/v4l2utils.c @@ -78,8 +78,8 @@ #include #include #include -#include -#include +#include +#include #define RUP8(num)(((num)+8)&~8) //#include @@ -578,6 +578,29 @@ static int v4l2_setup_avcodec_capture( v4l2info *v, int wid, int hei, int codec_ #if LIBAVCODEC_BUILD > 5400 v->c = avcodec_alloc_context3( v->codec ); + + int n_threads = 0; + + char *num_decode_threads = getenv( "VEEJAY_NUM_DECODE_THREADS" ); + if( num_decode_threads ) { + n_threads = atoi(num_decode_threads); + } + else { + veejay_msg(VEEJAY_MSG_DEBUG, "env VEEJAY_NUM_DECODE_THREADS not set!"); + int n = task_num_cpus(); + if( n > 1 ) + n_threads = 2; + if( n > 3 ) + n_threads = 4; + } + + veejay_msg(VEEJAY_MSG_DEBUG, "Using %d decoding threads (ffmpeg)", n_threads); + + if( n_threads > 0 ) { + v->c->thread_count = n_threads; + v->c->thread_type = FF_THREAD_FRAME; + } + #else v->c = avcodec_alloc_context(); #endif diff --git a/veejay-current/veejay-server/libstream/vj-avformat.c b/veejay-current/veejay-server/libstream/vj-avformat.c index 9c661e6e..24bc0757 100644 --- a/veejay-current/veejay-server/libstream/vj-avformat.c +++ b/veejay-current/veejay-server/libstream/vj-avformat.c @@ -33,8 +33,8 @@ #include #include #include -#include -#include +#include +#include typedef struct { diff --git a/veejay-current/veejay-server/libstream/vj-net.c b/veejay-current/veejay-server/libstream/vj-net.c index ec142311..71ad545b 100644 --- a/veejay-current/veejay-server/libstream/vj-net.c +++ b/veejay-current/veejay-server/libstream/vj-net.c @@ -32,8 +32,8 @@ #include #include #include -#include -#include +#include +#include #include typedef struct diff --git a/veejay-current/veejay-server/libstream/vj-vloopback.c b/veejay-current/veejay-server/libstream/vj-vloopback.c index 0bc80f91..911592e9 100644 --- a/veejay-current/veejay-server/libstream/vj-vloopback.c +++ b/veejay-current/veejay-server/libstream/vj-vloopback.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include diff --git a/veejay-current/veejay-server/libvje/effects/shapewipe.c b/veejay-current/veejay-server/libvje/effects/shapewipe.c index 967bfcaf..57e884f0 100644 --- a/veejay-current/veejay-server/libvje/effects/shapewipe.c +++ b/veejay-current/veejay-server/libvje/effects/shapewipe.c @@ -29,7 +29,7 @@ #include #include "../effects/common.h" #include "../libel/pixbuf.h" -#include "../libel/avcommon.h" +#include #include #include #include "shapewipe.h" diff --git a/veejay-current/veejay-server/veejay/liblavplayvj.c b/veejay-current/veejay-server/veejay/liblavplayvj.c index a7507e51..dc45fcf0 100644 --- a/veejay-current/veejay-server/veejay/liblavplayvj.c +++ b/veejay-current/veejay-server/veejay/liblavplayvj.c @@ -84,7 +84,7 @@ #include #include #include -#include +#include #include #ifdef HAVE_JACK #include diff --git a/veejay-current/veejay-server/veejay/vj-composite.c b/veejay-current/veejay-server/veejay/vj-composite.c index 0f429627..f50a87e4 100644 --- a/veejay-current/veejay-server/veejay/vj-composite.c +++ b/veejay-current/veejay-server/veejay/vj-composite.c @@ -42,7 +42,7 @@ #ifdef HAVE_GL #include #endif -#include +#include typedef struct { diff --git a/veejay-current/veejay-server/veejay/vj-misc.c b/veejay-current/veejay-server/veejay/vj-misc.c index d05e211c..9e28e2c6 100644 --- a/veejay-current/veejay-server/veejay/vj-misc.c +++ b/veejay-current/veejay-server/veejay/vj-misc.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/veejay-current/veejay-server/veejay/vj-perform.c b/veejay-current/veejay-server/veejay/vj-perform.c index d6afa8f4..eeec792f 100644 --- a/veejay-current/veejay-server/veejay/vj-perform.c +++ b/veejay-current/veejay-server/veejay/vj-perform.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/veejay-current/veejay-server/veejay/vj-sdl.c b/veejay-current/veejay-server/veejay/vj-sdl.c index cbd26cf7..68dd1cf9 100644 --- a/veejay-current/veejay-server/veejay/vj-sdl.c +++ b/veejay-current/veejay-server/veejay/vj-sdl.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include diff --git a/veejay-current/veejay-server/veejay/vj-shm.c b/veejay-current/veejay-server/veejay/vj-shm.c index e8eefc1f..900e5858 100644 --- a/veejay-current/veejay-server/veejay/vj-shm.c +++ b/veejay-current/veejay-server/veejay/vj-shm.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #define HEADER_LENGTH 4096 #ifndef PATH_MAX diff --git a/veejay-current/veejay-server/veejay/vj-viewport.c b/veejay-current/veejay-server/veejay/vj-viewport.c index 24dca8d8..b1cec8d5 100644 --- a/veejay-current/veejay-server/veejay/vj-viewport.c +++ b/veejay-current/veejay-server/veejay/vj-viewport.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #define X0 0 #define Y0 1