aml: sync with pivos upstream
authordavilla <davilla@4pi.com>
Thu, 22 Aug 2013 19:56:48 +0000 (15:56 -0400)
committerdavilla <davilla@4pi.com>
Sat, 24 Aug 2013 04:31:50 +0000 (00:31 -0400)
xbmc/cores/amlplayer/DllLibamplayer.h
xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAmlogic.h

index c82d825..897fe02 100644 (file)
 
 extern "C"
 {
-// beware, these will alter the structs
-// in player_type.h.
-#if 1
-  #define HAS_AMLPLAYER_CHAPTERS
-  #define HAS_AMLPLAYER_AUDIO_LANG
-  #define HAS_AMLPLAYER_AUDIO_SETDELAY
-  #define HAS_AMLPLAYER_AUDIO_SETVOLUME
-#else
-  #define HAS_AMLPLAYER_VIDEO_STREAMS10
-#endif
-
 #include <amplayer/player_type.h>
 #include <amplayer/player_error.h>
 }
index 514a5e1..3ff3993 100644 (file)
@@ -40,6 +40,7 @@
 #include "Video/DVDVideoCodecCrystalHD.h"
 #endif
 #if defined(HAS_LIBAMCODEC)
+#include "utils/AMLUtils.h"
 #include "Video/DVDVideoCodecAmlogic.h"
 #endif
 #include "Audio/DVDAudioCodecFFmpeg.h"
@@ -247,7 +248,7 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne
 #endif
 
 #if defined(HAS_LIBAMCODEC)
-  if (!hint.software)
+  if (!hint.software && aml_present())
   {
     CLog::Log(LOGINFO, "Amlogic Video Decoder...");
     if ( (pCodec = OpenCodec(new CDVDVideoCodecAmlogic(), hint, options)) ) return pCodec;
index 9e8ad50..200bcb5 100644 (file)
@@ -24,7 +24,6 @@
 #include "DVDClock.h"
 #include "DVDStreamInfo.h"
 #include "AMLCodec.h"
-#include "video/VideoThumbLoader.h"
 #include "utils/BitstreamConverter.h"
 #include "utils/log.h"
 
@@ -45,7 +44,9 @@ CDVDVideoCodecAmlogic::CDVDVideoCodecAmlogic() :
   m_queue_depth(0),
   m_framerate(0.0),
   m_video_rate(0),
-  m_mpeg2_sequence(NULL)
+  m_mpeg2_sequence(NULL),
+  m_parser(NULL),
+  m_bitstream(NULL)
 {
   pthread_mutex_init(&m_queue_mutex, NULL);
 }
@@ -58,7 +59,9 @@ CDVDVideoCodecAmlogic::~CDVDVideoCodecAmlogic()
 
 bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
 {
-  switch(hints.codec)
+  m_hints = hints;
+
+  switch(m_hints.codec)
   {
     case AV_CODEC_ID_MJPEG:
       m_pFormatName = "am-mjpeg";
@@ -68,19 +71,33 @@ bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &option
     case AV_CODEC_ID_MPEG2VIDEO_XVMC:
       m_mpeg2_sequence_pts = 0;
       m_mpeg2_sequence = new mpeg2_sequence;
-      m_mpeg2_sequence->width  = hints.width;
-      m_mpeg2_sequence->height = hints.height;
-      m_mpeg2_sequence->ratio  = hints.aspect;
-      if (hints.rfpsrate > 0 && hints.rfpsscale != 0)
-        m_mpeg2_sequence->rate = (float)hints.rfpsrate / hints.rfpsscale;
-      else if (hints.fpsrate > 0 && hints.fpsscale != 0)
-        m_mpeg2_sequence->rate = (float)hints.fpsrate / hints.fpsscale;
+      m_mpeg2_sequence->width  = m_hints.width;
+      m_mpeg2_sequence->height = m_hints.height;
+      m_mpeg2_sequence->ratio  = m_hints.aspect;
+      if (m_hints.rfpsrate > 0 && m_hints.rfpsscale != 0)
+        m_mpeg2_sequence->rate = (float)m_hints.rfpsrate / m_hints.rfpsscale;
+      else if (m_hints.fpsrate > 0 && m_hints.fpsscale != 0)
+        m_mpeg2_sequence->rate = (float)m_hints.fpsrate / m_hints.fpsscale;
       else
         m_mpeg2_sequence->rate = 1.0;
       m_pFormatName = "am-mpeg2";
       break;
     case AV_CODEC_ID_H264:
       m_pFormatName = "am-h264";
+      // convert h264-avcC to h264-annex-b as h264-avcC
+      // under streamers can have issues when seeking.
+      if (*(uint8_t*)m_hints.extradata == 1)
+      {
+        m_bitstream = new CBitstreamConverter;
+        m_bitstream->Open(m_hints.codec, (uint8_t*)m_hints.extradata, m_hints.extrasize, true);
+        // make sure we do not leak the existing m_hints.extradata
+        free(m_hints.extradata);
+        m_hints.extrasize = m_bitstream->GetExtraSize();
+        m_hints.extradata = malloc(m_hints.extrasize);
+        memcpy(m_hints.extradata, m_bitstream->GetExtraData(), m_hints.extrasize);
+      }
+      //m_parser = new CBitstreamParser();
+      //m_parser->Open();
       break;
     case AV_CODEC_ID_MPEG4:
     case AV_CODEC_ID_MSMPEG4V2:
@@ -112,13 +129,12 @@ bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &option
       m_pFormatName = "am-avs";
       break;
     default:
-      CLog::Log(LOGDEBUG, "%s: Unknown hints.codec(%d", __MODULE_NAME__, hints.codec);
+      CLog::Log(LOGDEBUG, "%s: Unknown hints.codec(%d", __MODULE_NAME__, m_hints.codec);
       return false;
       break;
   }
 
-  m_hints = hints;
-  m_aspect_ratio = hints.aspect;
+  m_aspect_ratio = m_hints.aspect;
   m_Codec = new CAMLCodec();
   if (!m_Codec)
   {
@@ -137,18 +153,18 @@ bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &option
   m_videobuffer.color_range  = 0;
   m_videobuffer.color_matrix = 4;
   m_videobuffer.iFlags  = DVP_FLAG_ALLOCATED;
-  m_videobuffer.iWidth  = hints.width;
-  m_videobuffer.iHeight = hints.height;
+  m_videobuffer.iWidth  = m_hints.width;
+  m_videobuffer.iHeight = m_hints.height;
 
   m_videobuffer.iDisplayWidth  = m_videobuffer.iWidth;
   m_videobuffer.iDisplayHeight = m_videobuffer.iHeight;
-  if (hints.aspect > 0.0 && !hints.forced_aspect)
+  if (m_hints.aspect > 0.0 && !m_hints.forced_aspect)
   {
-    m_videobuffer.iDisplayWidth  = ((int)lrint(m_videobuffer.iHeight * hints.aspect)) & -3;
+    m_videobuffer.iDisplayWidth  = ((int)lrint(m_videobuffer.iHeight * m_hints.aspect)) & -3;
     if (m_videobuffer.iDisplayWidth > m_videobuffer.iWidth)
     {
       m_videobuffer.iDisplayWidth  = m_videobuffer.iWidth;
-      m_videobuffer.iDisplayHeight = ((int)lrint(m_videobuffer.iWidth / hints.aspect)) & -3;
+      m_videobuffer.iDisplayHeight = ((int)lrint(m_videobuffer.iWidth / m_hints.aspect)) & -3;
     }
   }
 
@@ -165,6 +181,12 @@ void CDVDVideoCodecAmlogic::Dispose(void)
   if (m_mpeg2_sequence)
     delete m_mpeg2_sequence, m_mpeg2_sequence = NULL;
 
+  if (m_bitstream)
+    delete m_bitstream, m_bitstream = NULL;
+
+  if (m_parser)
+    delete m_parser, m_parser = NULL;
+
   while (m_queue_depth)
     FrameQueuePop();
 }
@@ -173,9 +195,22 @@ int CDVDVideoCodecAmlogic::Decode(uint8_t *pData, int iSize, double dts, double
 {
   // Handle Input, add demuxer packet to input queue, we must accept it or
   // it will be discarded as DVDPlayerVideo has no concept of "try again".
-
   if (pData)
+  {
+    if (m_bitstream)
+    {
+      if (!m_bitstream->Convert(pData, iSize))
+        return VC_ERROR;
+
+      pData = m_bitstream->GetConvertBuffer();
+      iSize = m_bitstream->GetConvertSize();
+    }
+
+    if (m_parser)
+      m_parser->FindIdrSlice(pData, iSize);
+
     FrameRateTracking( pData, iSize, dts, pts);
+  }
 
   if (!m_opened)
   {
@@ -331,7 +366,7 @@ void CDVDVideoCodecAmlogic::FrameRateTracking(uint8_t *pData, int iSize, double
       CLog::Log(LOGDEBUG, "%s: detected mpeg2 aspect ratio(%f), framerate(%f), video_rate(%d)",
         __MODULE_NAME__, m_mpeg2_sequence->ratio, m_framerate, m_video_rate);
 
-      // update hints for 1st frame fixup.
+      // update m_hints for 1st frame fixup.
       switch(m_mpeg2_sequence->rate_info)
       {
         default:
index 2cbdc93..b8a1473 100644 (file)
@@ -25,6 +25,8 @@
 class CAMLCodec;
 struct frame_queue;
 struct mpeg2_sequence;
+class CBitstreamParser;
+class CBitstreamConverter;
 
 class CDVDVideoCodecAmlogic : public CDVDVideoCodec
 {
@@ -63,4 +65,7 @@ protected:
   float           m_aspect_ratio;
   mpeg2_sequence *m_mpeg2_sequence;
   double          m_mpeg2_sequence_pts;
+
+  CBitstreamParser *m_parser;
+  CBitstreamConverter *m_bitstream;
 };