From 003cfd21d5dd40a89094946f6377b3b686cf6d30 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Wed, 18 Jan 2012 13:05:04 +0200 Subject: Simplify --- src/combined/ffmpeg/Makefile.am | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/combined/ffmpeg/Makefile.am b/src/combined/ffmpeg/Makefile.am index 24cab7577..6dfc55de4 100644 --- a/src/combined/ffmpeg/Makefile.am +++ b/src/combined/ffmpeg/Makefile.am @@ -29,16 +29,14 @@ EXTRA_DIST = ffmpeg_encoder.c \ xineplug_LTLIBRARIES = xineplug_decode_ff.la xineplug_decode_dvaudio.la +xineplug_decode_ff_la_SOURCES = ffmpeg_decoder.c ff_audio_decoder.c ff_video_decoder.c \ + ff_mpeg_parser.c ffmpeg_decoder.h ff_mpeg_parser.h if HAVE_DXR3 AM_CPPFLAGS = -I$(top_srcdir)/src/dxr3 $(X_CFLAGS) $(ff_cppflags) \ $(ZLIB_CPPFLAGS) -xineplug_decode_ff_la_SOURCES = ffmpeg_decoder.c ff_audio_decoder.c ff_video_decoder.c \ - ffmpeg_encoder.c ff_mpeg_parser.c ffmpeg_decoder.h \ - ff_mpeg_parser.h +xineplug_decode_ff_la_SOURCES += ffmpeg_encoder.c else AM_CPPFLAGS = $(ff_cppflags) $(ZLIB_CPPFLAGS) -xineplug_decode_ff_la_SOURCES = ffmpeg_decoder.c ff_audio_decoder.c ff_video_decoder.c \ - ff_mpeg_parser.c ffmpeg_decoder.h ff_mpeg_parser.h endif xineplug_decode_ff_la_CFLAGS = $(VISIBILITY_FLAG) $(AM_CFLAGS) -- cgit v1.2.3 From 0c50f90e9a9172cfd850a0fe6e8d24cd9b378ab2 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Wed, 18 Jan 2012 13:13:37 +0200 Subject: Moved ffmpeg API version checks to single header --- src/combined/ffmpeg/Makefile.am | 3 +- src/combined/ffmpeg/ff_audio_decoder.c | 13 ++---- src/combined/ffmpeg/ff_video_decoder.c | 20 +--------- src/combined/ffmpeg/ffmpeg_compat.h | 73 ++++++++++++++++++++++++++++++++++ src/combined/ffmpeg/ffmpeg_decoder.h | 4 -- 5 files changed, 81 insertions(+), 32 deletions(-) create mode 100644 src/combined/ffmpeg/ffmpeg_compat.h diff --git a/src/combined/ffmpeg/Makefile.am b/src/combined/ffmpeg/Makefile.am index 6dfc55de4..86200d718 100644 --- a/src/combined/ffmpeg/Makefile.am +++ b/src/combined/ffmpeg/Makefile.am @@ -30,7 +30,8 @@ EXTRA_DIST = ffmpeg_encoder.c \ xineplug_LTLIBRARIES = xineplug_decode_ff.la xineplug_decode_dvaudio.la xineplug_decode_ff_la_SOURCES = ffmpeg_decoder.c ff_audio_decoder.c ff_video_decoder.c \ - ff_mpeg_parser.c ffmpeg_decoder.h ff_mpeg_parser.h + ff_mpeg_parser.c ffmpeg_decoder.h ff_mpeg_parser.h \ + ffmpeg_compat.h if HAVE_DXR3 AM_CPPFLAGS = -I$(top_srcdir)/src/dxr3 $(X_CFLAGS) $(ff_cppflags) \ $(ZLIB_CPPFLAGS) diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c index e4a9c16bf..7ecf8290d 100644 --- a/src/combined/ffmpeg/ff_audio_decoder.c +++ b/src/combined/ffmpeg/ff_audio_decoder.c @@ -43,15 +43,10 @@ #include "xineutils.h" #include "bswap.h" #include "ffmpeg_decoder.h" +#include "ffmpeg_compat.h" #define AUDIOBUFSIZE (64 * 1024) -#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32) -# define AVAUDIO 3 -#else -# define AVAUDIO 2 -#endif - typedef struct { audio_decoder_class_t decoder_class; } ff_audio_class_t; @@ -173,7 +168,7 @@ static void ff_audio_init_codec(ff_audio_decoder_t *this, unsigned int codec_typ * - DVB streams where multiple AAC LATM frames are packed to single PES * - DVB streams where MPEG audio frames do not follow PES packet boundaries */ -#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 94) +#if AVPARSE > 1 if (codec_type == BUF_AUDIO_AAC_LATM || codec_type == BUF_AUDIO_MPEG) { @@ -356,7 +351,7 @@ static int ff_audio_decode(xine_t *xine, int consumed; int parser_consumed = 0; -#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 94) +#if AVPARSE > 1 if (parser_ctx) { uint8_t *outbuf; int outsize; @@ -383,7 +378,7 @@ static int ff_audio_decode(xine_t *xine, buf = outbuf; size = outsize; } -#endif /* LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 94) */ +#endif /* AVPARSE > 1 */ #if AVAUDIO > 2 AVPacket avpkt; diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c index 50357182a..90eeadffe 100644 --- a/src/combined/ffmpeg/ff_video_decoder.c +++ b/src/combined/ffmpeg/ff_video_decoder.c @@ -51,6 +51,8 @@ # include #endif +#include "ffmpeg_compat.h" + #define VIDEOBUFSIZE (128*1024) #define SLICE_BUFFER_SIZE (1194*1024) @@ -58,24 +60,6 @@ #define ENABLE_DIRECT_RENDERING -#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32) -# define AVVIDEO 2 -#else -# define AVVIDEO 1 -# define pp_context pp_context_t -# define pp_mode pp_mode_t -#endif - -#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 112) -# define DEPRECATED_AVCODEC_THREAD_INIT 1 -#endif - -/* reordered_opaque appeared in libavcodec 51.68.0 */ -#define AVCODEC_HAS_REORDERED_OPAQUE -#if LIBAVCODEC_VERSION_INT < 0x334400 -# undef AVCODEC_HAS_REORDERED_OPAQUE -#endif - typedef struct ff_video_decoder_s ff_video_decoder_t; typedef struct ff_video_class_s { diff --git a/src/combined/ffmpeg/ffmpeg_compat.h b/src/combined/ffmpeg/ffmpeg_compat.h new file mode 100644 index 000000000..9a8aaf203 --- /dev/null +++ b/src/combined/ffmpeg/ffmpeg_compat.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2000-2012 the xine project + * + * This file is part of xine, a unix video player. + * + * xine 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. + * + * xine 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Compability macros for various ffmpeg versions + */ + +#ifndef XINE_AVCODEC_COMPAT_H +#define XINE_AVCODEC_COMPAT_H + +#ifndef LIBAVCODEC_VERSION_MAJOR +# error ffmpeg headers must be included first ! +#endif + + +#if LIBAVCODEC_VERSION_MAJOR > 51 +# define bits_per_sample bits_per_coded_sample +#endif + +#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32) +# define pp_context pp_context_t +# define pp_mode pp_mode_t +#endif + +/* reordered_opaque appeared in libavcodec 51.68.0 */ +#define AVCODEC_HAS_REORDERED_OPAQUE +#if LIBAVCODEC_VERSION_INT < 0x334400 +# undef AVCODEC_HAS_REORDERED_OPAQUE +#endif + +/* avcodec_thread_init() */ +#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 112) +# define DEPRECATED_AVCODEC_THREAD_INIT 1 +#endif + +/* av_parser_parse() */ +#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 94) +# define AVPARSE 2 +#else +# define AVPARSE 1 +#endif + +/* avcodec_decode_video() */ +#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32) +# define AVVIDEO 2 +#else +# define AVVIDEO 1 +#endif + +/* avcodec_decode_audio() */ +#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32) +# define AVAUDIO 3 +#else +# define AVAUDIO 2 +#endif + + +#endif /* XINE_AVCODEC_COMPAT_H */ diff --git a/src/combined/ffmpeg/ffmpeg_decoder.h b/src/combined/ffmpeg/ffmpeg_decoder.h index 0aeb71271..957a25231 100644 --- a/src/combined/ffmpeg/ffmpeg_decoder.h +++ b/src/combined/ffmpeg/ffmpeg_decoder.h @@ -33,10 +33,6 @@ # include "../../libffmpeg/libavcodec/avcodec.h" #endif -#if LIBAVCODEC_VERSION_MAJOR > 51 -#define bits_per_sample bits_per_coded_sample -#endif - typedef struct ff_codec_s { uint32_t type; enum CodecID id; -- cgit v1.2.3 From cd3a4d6e8236825a7c41490782e643e6cb514763 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Wed, 18 Jan 2012 13:32:29 +0200 Subject: avcodec_init(), avcodec_alloc_context() and avcodec_open() are depreated --- src/combined/ffmpeg/ffmpeg_compat.h | 21 +++++++++++++++++++++ src/combined/ffmpeg/ffmpeg_decoder.c | 1 + src/combined/ffmpeg/ffmpeg_encoder.c | 2 ++ 3 files changed, 24 insertions(+) diff --git a/src/combined/ffmpeg/ffmpeg_compat.h b/src/combined/ffmpeg/ffmpeg_compat.h index 9a8aaf203..10205c84f 100644 --- a/src/combined/ffmpeg/ffmpeg_compat.h +++ b/src/combined/ffmpeg/ffmpeg_compat.h @@ -43,6 +43,27 @@ # undef AVCODEC_HAS_REORDERED_OPAQUE #endif +/**/ +#if LIBAVCODEC_VERSION_MAJOR > 53 || (LIBAVCODEC_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 8) +# define avcodec_init() do {} while(0) +#endif + +/* avcodec_alloc_context() */ +#if LIBAVCODEC_VERSION_MAJOR >= 54 || (LIBAVCODEC_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 6) +# define AVCONTEXT 3 +# define avcodec_alloc_context() avcodec_alloc_context3(NULL) +#else +# define AVCONTEXT 1 +#endif + +/* avcodec_open() */ +#if LIBAVCODEC_VERSION_MAJOR >= 54 || (LIBAVCODEC_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 6) +# define AVOPEN 2 +# define avcodec_open(ctx,codec) avcodec_open2(ctx, codec, NULL) +#else +# define AVOPEN 1 +#endif + /* avcodec_thread_init() */ #if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 112) # define DEPRECATED_AVCODEC_THREAD_INIT 1 diff --git a/src/combined/ffmpeg/ffmpeg_decoder.c b/src/combined/ffmpeg/ffmpeg_decoder.c index b50633053..879df5387 100644 --- a/src/combined/ffmpeg/ffmpeg_decoder.c +++ b/src/combined/ffmpeg/ffmpeg_decoder.c @@ -28,6 +28,7 @@ #include "xine_internal.h" #include "ffmpeg_decoder.h" +#include "ffmpeg_compat.h" /* * common initialisation diff --git a/src/combined/ffmpeg/ffmpeg_encoder.c b/src/combined/ffmpeg/ffmpeg_encoder.c index d41023675..8e0b03d9b 100644 --- a/src/combined/ffmpeg/ffmpeg_encoder.c +++ b/src/combined/ffmpeg/ffmpeg_encoder.c @@ -46,6 +46,8 @@ # include "../../libffmpeg/libavcodec/avcodec.h" #endif +#include "ffmpeg_compat.h" + /* buffer size for encoded mpeg1 stream; will hold one intra frame * at 640x480 typical sizes are <50 kB. 512 kB should be plenty */ #define DEFAULT_BUFFER_SIZE 512*1024 -- cgit v1.2.3 From c2ffae7ba0ec07f30e1887ff7ba4612c19e2dce4 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Wed, 18 Jan 2012 14:41:34 +0200 Subject: Fixed pp_context and pp_mode --- src/combined/ffmpeg/ffmpeg_compat.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/combined/ffmpeg/ffmpeg_compat.h b/src/combined/ffmpeg/ffmpeg_compat.h index 10205c84f..371b5ccdb 100644 --- a/src/combined/ffmpeg/ffmpeg_compat.h +++ b/src/combined/ffmpeg/ffmpeg_compat.h @@ -33,6 +33,7 @@ #endif #if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32) +#else # define pp_context pp_context_t # define pp_mode pp_mode_t #endif -- cgit v1.2.3 From 7c873b0529321eafb2968903dfcfd4258fcf6005 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 18 Jan 2012 21:48:29 +0000 Subject: Hack to avoid xine-list-* causing catalog.cache to be written. --- misc/xine-list.c | 10 ++++++++++ src/xine-engine/load_plugins.c | 3 ++- src/xine-engine/xine.c | 10 ++++++++++ src/xine-engine/xine_internal.h | 6 ++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/misc/xine-list.c b/misc/xine-list.c index ec7b7f694..c9e160b2f 100644 --- a/misc/xine-list.c +++ b/misc/xine-list.c @@ -107,6 +107,16 @@ to the extent permitted by law.\n", return 0; xine_t *xine = xine_new (); + + /* Avoid writing catalog.cache if possible */ + int major, minor, sub; + xine_get_version (&major, &minor, &sub); + if ((major == 1 && minor == 1 && sub > 20) || + (major == 1 && minor == 2 && sub > 0) || + (major == 1 && minor > 2) || + (major > 1)) + xine_set_flags (xine, XINE_FLAG_NO_WRITE_CACHE); + xine_init (xine); char *text = NULL; diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 06ff719e0..206f259e5 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -1201,7 +1201,8 @@ void _x_scan_plugins (xine_t *this) { xine_list_delete (plugindirs); free(homedir); - save_catalog (this); + if ((_x_flags & XINE_FLAG_NO_WRITE_CACHE) == 0) + save_catalog (this); load_required_plugins (this); diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index b95a14292..5a180c212 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -78,6 +78,10 @@ #endif /* WIN32 */ +/* FIXME-ABI Global variable. Done this way for ABI & API reasons... */ +int _x_flags = 0; + + static void mutex_cleanup (void *mutex) { pthread_mutex_unlock ((pthread_mutex_t *) mutex); } @@ -1695,6 +1699,12 @@ static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) { this->save_path = entry->str_value; } +void xine_set_flags (xine_t *this, int flags) +{ + this = this; /* FIXME-ABI: one day, these will be in xine_t...? */ + _x_flags = flags; +} + void xine_init (xine_t *this) { static const char *demux_strategies[] = {"default", "reverse", "content", "extension", NULL}; diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 939876ebe..af8817ac5 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -123,6 +123,12 @@ struct xine_s { #endif }; +/* FIXME-ABI Some global flag bits */ +/* See xine_set_flags() */ +#ifdef XINE_ENGINE_INTERNAL +extern int _x_flags XINE_PROTECTED; +#endif + /* * xine thread tickets */ -- cgit v1.2.3 From a5d426c371ba02f6065a19dd9707cf248df245d5 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 18 Jan 2012 22:01:28 +0000 Subject: And define/declare the new stuff... --- include/xine.h.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/xine.h.in b/include/xine.h.in index 29d4da58c..422029754 100644 --- a/include/xine.h.in +++ b/include/xine.h.in @@ -134,6 +134,12 @@ int xine_check_version (int major, int minor, int sub) XINE_PROTECTED; */ xine_t *xine_new (void) XINE_PROTECTED; +/* allow the setting of some flags before xine_init + * FIXME-ABI: this is currently GLOBAL + */ +void xine_set_flags (xine_t *, int) XINE_PROTECTED __attribute__((weak)); +#define XINE_FLAG_NO_WRITE_CACHE 1 + /* * post_init the xine engine */ -- cgit v1.2.3