Skip to content
This repository
Browse code

aml: sync with pivos upstream

  • Loading branch information...
commit 9caf83ca93135dc29493ff5af4f354f63c1c703b 1 parent 6191e52
authored August 22, 2013
11  xbmc/cores/amlplayer/DllLibamplayer.h
@@ -25,17 +25,6 @@
25 25
 
26 26
 extern "C"
27 27
 {
28  
-// beware, these will alter the structs
29  
-// in player_type.h.
30  
-#if 1
31  
-  #define HAS_AMLPLAYER_CHAPTERS
32  
-  #define HAS_AMLPLAYER_AUDIO_LANG
33  
-  #define HAS_AMLPLAYER_AUDIO_SETDELAY
34  
-  #define HAS_AMLPLAYER_AUDIO_SETVOLUME
35  
-#else
36  
-  #define HAS_AMLPLAYER_VIDEO_STREAMS10
37  
-#endif
38  
-
39 28
 #include <amplayer/player_type.h>
40 29
 #include <amplayer/player_error.h>
41 30
 }
3  xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp
@@ -40,6 +40,7 @@
40 40
 #include "Video/DVDVideoCodecCrystalHD.h"
41 41
 #endif
42 42
 #if defined(HAS_LIBAMCODEC)
  43
+#include "utils/AMLUtils.h"
43 44
 #include "Video/DVDVideoCodecAmlogic.h"
44 45
 #endif
45 46
 #include "Audio/DVDAudioCodecFFmpeg.h"
@@ -247,7 +248,7 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne
247 248
 #endif
248 249
 
249 250
 #if defined(HAS_LIBAMCODEC)
250  
-  if (!hint.software)
  251
+  if (!hint.software && aml_present())
251 252
   {
252 253
     CLog::Log(LOGINFO, "Amlogic Video Decoder...");
253 254
     if ( (pCodec = OpenCodec(new CDVDVideoCodecAmlogic(), hint, options)) ) return pCodec;
75  xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp
@@ -24,7 +24,6 @@
24 24
 #include "DVDClock.h"
25 25
 #include "DVDStreamInfo.h"
26 26
 #include "AMLCodec.h"
27  
-#include "video/VideoThumbLoader.h"
28 27
 #include "utils/BitstreamConverter.h"
29 28
 #include "utils/log.h"
30 29
 
@@ -45,7 +44,9 @@ CDVDVideoCodecAmlogic::CDVDVideoCodecAmlogic() :
45 44
   m_queue_depth(0),
46 45
   m_framerate(0.0),
47 46
   m_video_rate(0),
48  
-  m_mpeg2_sequence(NULL)
  47
+  m_mpeg2_sequence(NULL),
  48
+  m_parser(NULL),
  49
+  m_bitstream(NULL)
49 50
 {
50 51
   pthread_mutex_init(&m_queue_mutex, NULL);
51 52
 }
@@ -58,7 +59,9 @@ CDVDVideoCodecAmlogic::~CDVDVideoCodecAmlogic()
58 59
 
59 60
 bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
60 61
 {
61  
-  switch(hints.codec)
  62
+  m_hints = hints;
  63
+
  64
+  switch(m_hints.codec)
62 65
   {
63 66
     case AV_CODEC_ID_MJPEG:
64 67
       m_pFormatName = "am-mjpeg";
@@ -68,19 +71,33 @@ bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &option
68 71
     case AV_CODEC_ID_MPEG2VIDEO_XVMC:
69 72
       m_mpeg2_sequence_pts = 0;
70 73
       m_mpeg2_sequence = new mpeg2_sequence;
71  
-      m_mpeg2_sequence->width  = hints.width;
72  
-      m_mpeg2_sequence->height = hints.height;
73  
-      m_mpeg2_sequence->ratio  = hints.aspect;
74  
-      if (hints.rfpsrate > 0 && hints.rfpsscale != 0)
75  
-        m_mpeg2_sequence->rate = (float)hints.rfpsrate / hints.rfpsscale;
76  
-      else if (hints.fpsrate > 0 && hints.fpsscale != 0)
77  
-        m_mpeg2_sequence->rate = (float)hints.fpsrate / hints.fpsscale;
  74
+      m_mpeg2_sequence->width  = m_hints.width;
  75
+      m_mpeg2_sequence->height = m_hints.height;
  76
+      m_mpeg2_sequence->ratio  = m_hints.aspect;
  77
+      if (m_hints.rfpsrate > 0 && m_hints.rfpsscale != 0)
  78
+        m_mpeg2_sequence->rate = (float)m_hints.rfpsrate / m_hints.rfpsscale;
  79
+      else if (m_hints.fpsrate > 0 && m_hints.fpsscale != 0)
  80
+        m_mpeg2_sequence->rate = (float)m_hints.fpsrate / m_hints.fpsscale;
78 81
       else
79 82
         m_mpeg2_sequence->rate = 1.0;
80 83
       m_pFormatName = "am-mpeg2";
81 84
       break;
82 85
     case AV_CODEC_ID_H264:
83 86
       m_pFormatName = "am-h264";
  87
+      // convert h264-avcC to h264-annex-b as h264-avcC
  88
+      // under streamers can have issues when seeking.
  89
+      if (*(uint8_t*)m_hints.extradata == 1)
  90
+      {
  91
+        m_bitstream = new CBitstreamConverter;
  92
+        m_bitstream->Open(m_hints.codec, (uint8_t*)m_hints.extradata, m_hints.extrasize, true);
  93
+        // make sure we do not leak the existing m_hints.extradata
  94
+        free(m_hints.extradata);
  95
+        m_hints.extrasize = m_bitstream->GetExtraSize();
  96
+        m_hints.extradata = malloc(m_hints.extrasize);
  97
+        memcpy(m_hints.extradata, m_bitstream->GetExtraData(), m_hints.extrasize);
  98
+      }
  99
+      //m_parser = new CBitstreamParser();
  100
+      //m_parser->Open();
84 101
       break;
85 102
     case AV_CODEC_ID_MPEG4:
86 103
     case AV_CODEC_ID_MSMPEG4V2:
@@ -112,13 +129,12 @@ bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &option
112 129
       m_pFormatName = "am-avs";
113 130
       break;
114 131
     default:
115  
-      CLog::Log(LOGDEBUG, "%s: Unknown hints.codec(%d", __MODULE_NAME__, hints.codec);
  132
+      CLog::Log(LOGDEBUG, "%s: Unknown hints.codec(%d", __MODULE_NAME__, m_hints.codec);
116 133
       return false;
117 134
       break;
118 135
   }
119 136
 
120  
-  m_hints = hints;
121  
-  m_aspect_ratio = hints.aspect;
  137
+  m_aspect_ratio = m_hints.aspect;
122 138
   m_Codec = new CAMLCodec();
123 139
   if (!m_Codec)
124 140
   {
@@ -137,18 +153,18 @@ bool CDVDVideoCodecAmlogic::Open(CDVDStreamInfo &hints, CDVDCodecOptions &option
137 153
   m_videobuffer.color_range  = 0;
138 154
   m_videobuffer.color_matrix = 4;
139 155
   m_videobuffer.iFlags  = DVP_FLAG_ALLOCATED;
140  
-  m_videobuffer.iWidth  = hints.width;
141  
-  m_videobuffer.iHeight = hints.height;
  156
+  m_videobuffer.iWidth  = m_hints.width;
  157
+  m_videobuffer.iHeight = m_hints.height;
142 158
 
143 159
   m_videobuffer.iDisplayWidth  = m_videobuffer.iWidth;
144 160
   m_videobuffer.iDisplayHeight = m_videobuffer.iHeight;
145  
-  if (hints.aspect > 0.0 && !hints.forced_aspect)
  161
+  if (m_hints.aspect > 0.0 && !m_hints.forced_aspect)
146 162
   {
147  
-    m_videobuffer.iDisplayWidth  = ((int)lrint(m_videobuffer.iHeight * hints.aspect)) & -3;
  163
+    m_videobuffer.iDisplayWidth  = ((int)lrint(m_videobuffer.iHeight * m_hints.aspect)) & -3;
148 164
     if (m_videobuffer.iDisplayWidth > m_videobuffer.iWidth)
149 165
     {
150 166
       m_videobuffer.iDisplayWidth  = m_videobuffer.iWidth;
151  
-      m_videobuffer.iDisplayHeight = ((int)lrint(m_videobuffer.iWidth / hints.aspect)) & -3;
  167
+      m_videobuffer.iDisplayHeight = ((int)lrint(m_videobuffer.iWidth / m_hints.aspect)) & -3;
152 168
     }
153 169
   }
154 170
 
@@ -165,6 +181,12 @@ void CDVDVideoCodecAmlogic::Dispose(void)
165 181
   if (m_mpeg2_sequence)
166 182
     delete m_mpeg2_sequence, m_mpeg2_sequence = NULL;
167 183
 
  184
+  if (m_bitstream)
  185
+    delete m_bitstream, m_bitstream = NULL;
  186
+
  187
+  if (m_parser)
  188
+    delete m_parser, m_parser = NULL;
  189
+
168 190
   while (m_queue_depth)
169 191
     FrameQueuePop();
170 192
 }
@@ -173,9 +195,22 @@ int CDVDVideoCodecAmlogic::Decode(uint8_t *pData, int iSize, double dts, double
173 195
 {
174 196
   // Handle Input, add demuxer packet to input queue, we must accept it or
175 197
   // it will be discarded as DVDPlayerVideo has no concept of "try again".
176  
-
177 198
   if (pData)
  199
+  {
  200
+    if (m_bitstream)
  201
+    {
  202
+      if (!m_bitstream->Convert(pData, iSize))
  203
+        return VC_ERROR;
  204
+
  205
+      pData = m_bitstream->GetConvertBuffer();
  206
+      iSize = m_bitstream->GetConvertSize();
  207
+    }
  208
+
  209
+    if (m_parser)
  210
+      m_parser->FindIdrSlice(pData, iSize);
  211
+
178 212
     FrameRateTracking( pData, iSize, dts, pts);
  213
+  }
179 214
 
180 215
   if (!m_opened)
181 216
   {
@@ -331,7 +366,7 @@ void CDVDVideoCodecAmlogic::FrameRateTracking(uint8_t *pData, int iSize, double
331 366
       CLog::Log(LOGDEBUG, "%s: detected mpeg2 aspect ratio(%f), framerate(%f), video_rate(%d)",
332 367
         __MODULE_NAME__, m_mpeg2_sequence->ratio, m_framerate, m_video_rate);
333 368
 
334  
-      // update hints for 1st frame fixup.
  369
+      // update m_hints for 1st frame fixup.
335 370
       switch(m_mpeg2_sequence->rate_info)
336 371
       {
337 372
         default:
5  xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAmlogic.h
@@ -25,6 +25,8 @@
25 25
 class CAMLCodec;
26 26
 struct frame_queue;
27 27
 struct mpeg2_sequence;
  28
+class CBitstreamParser;
  29
+class CBitstreamConverter;
28 30
 
29 31
 class CDVDVideoCodecAmlogic : public CDVDVideoCodec
30 32
 {
@@ -63,4 +65,7 @@ class CDVDVideoCodecAmlogic : public CDVDVideoCodec
63 65
   float           m_aspect_ratio;
64 66
   mpeg2_sequence *m_mpeg2_sequence;
65 67
   double          m_mpeg2_sequence_pts;
  68
+
  69
+  CBitstreamParser *m_parser;
  70
+  CBitstreamConverter *m_bitstream;
66 71
 };

0 notes on commit 9caf83c

Please sign in to comment.
Something went wrong with that request. Please try again.