Merge pull request #4791 from jmarshallnz/playlist_settings
[vuplus_xbmc] / lib / DllAvUtil.h
index 937ba9e..0fcdf10 100644 (file)
@@ -1,7 +1,7 @@
 #pragma once
 /*
  *      Copyright (C) 2005-2013 Team XBMC
- *      http://www.xbmc.org
+ *      http://xbmc.org
  *
  *  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
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with XBMC; see the file COPYING.  If not, write to the Free
- *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- *  Boston, MA  02110-1301, USA.
- *  http://www.gnu.org/copyleft/gpl.html
+ *  along with XBMC; see the file COPYING.  If not, see
+ *  <http://www.gnu.org/licenses/>.
  *
  */
 
@@ -46,6 +44,9 @@ extern "C" {
   #include <libavutil/opt.h>
   #include <libavutil/mem.h>
   #include <libavutil/mathematics.h>
+  #if (defined USE_LIBAV_HACKS)
+    #include "xbmc-libav-hacks/libav_hacks.h"
+  #endif
 #else
   #include "libavutil/avutil.h"
   //for av_get_default_channel_layout
@@ -59,6 +60,10 @@ extern "C" {
 #endif
 }
 
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(52,29,100)
+#define AVFRAME_IN_LAVU
+#endif
+
 #ifndef __GNUC__
 #pragma warning(pop)
 #endif
@@ -102,9 +107,16 @@ public:
   virtual int av_get_channel_layout_channel_index (uint64_t channel_layout, uint64_t channel) = 0;
   virtual int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0;
   virtual int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt) = 0;
+  virtual uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index) = 0;
+#if defined(AVFRAME_IN_LAVU)
+  virtual void av_frame_free(AVFrame **frame)=0;
+  virtual AVFrame *av_frame_alloc(void)=0;
+  virtual void av_frame_unref(AVFrame *frame)=0;
+  virtual void av_frame_move_ref(AVFrame *dst, AVFrame *src)=0;
+#endif
 };
 
-#if defined (USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
+#if defined (USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG)
 // Use direct layer
 class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
 {
@@ -147,14 +159,22 @@ public:
   virtual int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt) { return ::av_sample_fmt_is_planar(sample_fmt); }
   virtual int av_get_channel_layout_channel_index (uint64_t channel_layout, uint64_t channel) { return ::av_get_channel_layout_channel_index(channel_layout, channel); }
   virtual int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
-    { return ::av_samples_fill_arrays(audio_data, linesize, buf, nb_channels, nb_samples, AVSampleFormat sample_fmt, align); }
+    { return ::av_samples_fill_arrays(audio_data, linesize, buf, nb_channels, nb_samples, sample_fmt, align); }
   virtual int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
     { return ::av_samples_copy(dst, src, dst_offset, src_offset, nb_samples, nb_channels, sample_fmt); }
+  virtual uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
+    { return ::av_channel_layout_extract_channel(channel_layout, index); }
+#if defined(AVFRAME_IN_LAVU)
+  virtual void av_frame_free(AVFrame **frame) { return ::av_frame_free(frame); }
+  virtual AVFrame *av_frame_alloc() { return ::av_frame_alloc(); }
+  virtual void av_frame_unref(AVFrame *frame) { return ::av_frame_unref(frame); }
+  virtual void av_frame_move_ref(AVFrame *dst, AVFrame *src) { return ::av_frame_move_ref(dst,src); }
+#endif
 
    // DLL faking.
    virtual bool ResolveExports() { return true; }
    virtual bool Load() {
-#if !defined(TARGET_DARWIN)
+#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG)
      CLog::Log(LOGDEBUG, "DllAvUtilBase: Using libavutil system library");
 #endif
      return true;
@@ -202,6 +222,13 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
   DEFINE_METHOD2(int, av_get_channel_layout_channel_index, (uint64_t p1, uint64_t p2))
   DEFINE_METHOD7(int, av_samples_fill_arrays, (uint8_t **p1, int *p2, const uint8_t *p3, int p4, int p5, enum AVSampleFormat p6, int p7))
   DEFINE_METHOD7(int, av_samples_copy, (uint8_t **p1, uint8_t *const *p2, int p3, int p4, int p5, int p6, enum AVSampleFormat p7))
+  DEFINE_METHOD2(uint64_t, av_channel_layout_extract_channel, (uint64_t p1, int p2))
+#if defined(AVFRAME_IN_LAVU)
+  DEFINE_METHOD1(void, av_frame_free, (AVFrame **p1))
+  DEFINE_METHOD0(AVFrame *, av_frame_alloc)
+  DEFINE_METHOD1(void, av_frame_unref, (AVFrame *p1))
+  DEFINE_METHOD2(void, av_frame_move_ref, (AVFrame *p1, AVFrame* p2))
+#endif
 
   public:
   BEGIN_METHOD_RESOLVE()
@@ -237,6 +264,13 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
     RESOLVE_METHOD(av_get_channel_layout_channel_index)
     RESOLVE_METHOD(av_samples_fill_arrays)
     RESOLVE_METHOD(av_samples_copy)
+    RESOLVE_METHOD(av_channel_layout_extract_channel)
+#if defined(AVFRAME_IN_LAVU)
+    RESOLVE_METHOD(av_frame_free)
+    RESOLVE_METHOD(av_frame_alloc)
+    RESOLVE_METHOD(av_frame_unref)
+    RESOLVE_METHOD(av_frame_move_ref)
+#endif
   END_METHOD_RESOLVE()
 };