[AML] Be rid of damned cpu type magic numbers
[vuplus_xbmc] / xbmc / cores / dvdplayer / DVDCodecs / Video / AMLCodec.cpp
index 87ea050..36efc67 100644 (file)
@@ -244,7 +244,9 @@ public:
 // AppContext - Application state
 #define MODE_3D_DISABLE         0x00000000
 #define MODE_3D_LR              0x00000101
+#define MODE_3D_LR_SWITCH       0x00000501
 #define MODE_3D_BT              0x00000201
+#define MODE_3D_BT_SWITCH       0x00000601
 #define MODE_3D_TO_2D_L         0x00000102
 #define MODE_3D_TO_2D_R         0x00000902
 #define MODE_3D_TO_2D_T         0x00000202
@@ -1067,7 +1069,7 @@ int pre_header_feeding(am_private_t *para, am_packet_t *pkt)
             }
         }
 
-        if (VFORMAT_H264 == para->video_format /*|| VFORMAT_H264MVC == para->video_format*/) {
+        if (VFORMAT_H264 == para->video_format || VFORMAT_H264_4K2K == para->video_format) {
             ret = h264_write_header(para, pkt);
             if (ret != PLAYER_SUCCESS) {
                 return ret;
@@ -1510,6 +1512,11 @@ bool CAMLCodec::OpenDecoder(CDVDStreamInfo &hints)
     am_private->video_rotation_degree = 3;
   // handle extradata
   am_private->video_format      = codecid_to_vformat(hints.codec);
+  if (am_private->video_format == VFORMAT_H264) {
+      if (hints.width > 1920 || hints.height > 1088) {
+        am_private->video_format = VFORMAT_H264_4K2K;
+      }
+  }
   switch (am_private->video_format)
   {
     default:
@@ -1572,6 +1579,18 @@ bool CAMLCodec::OpenDecoder(CDVDStreamInfo &hints)
       if (m_hints.ptsinvalid)
         am_private->gcodec.param = (void*)(EXTERNAL_PTS | SYNC_OUTSIDE);
       break;
+    case VFORMAT_H264_4K2K:
+      if (aml_get_cputype() >= AML_DEVICE_TYPE_M8) {
+        am_private->gcodec.format = VIDEO_DEC_FORMAT_H264_4K2K;
+        am_private->gcodec.param  = (void*)EXTERNAL_PTS;
+        // h264 in an avi file
+        if (m_hints.ptsinvalid)
+          am_private->gcodec.param = (void*)(EXTERNAL_PTS | SYNC_OUTSIDE);
+      } else {
+        CLog::Log(LOGDEBUG, "CAMLCodec::OpenDecoder codec init failed, 4K supported only on Meson8.");
+        return false;
+      }
+      break; 
     case VFORMAT_REAL:
       am_private->stream_type = AM_STREAM_RM;
       am_private->vcodec.noblock = 1;
@@ -1612,6 +1631,7 @@ bool CAMLCodec::OpenDecoder(CDVDStreamInfo &hints)
     CLog::Log(LOGDEBUG, "CAMLCodec::OpenDecoder codec init failed, ret=0x%x", -ret);
     return false;
   }
+
   am_private->dumpdemux = false;
   dumpfile_open(am_private);
 
@@ -1838,10 +1858,21 @@ bool CAMLCodec::GetPicture(DVDVideoPicture *pDvdVideoPicture)
   pDvdVideoPicture->iDuration = (double)(am_private->video_rate * DVD_TIME_BASE) / UNIT_FREQ;
 
   pDvdVideoPicture->dts = DVD_NOPTS_VALUE;
-  pDvdVideoPicture->pts = GetPlayerPtsSeconds() * (double)DVD_TIME_BASE;
-  // video pts cannot be late or dvdplayer goes nuts,
-  // so run it one frame ahead
-  pDvdVideoPicture->pts += 1 * pDvdVideoPicture->iDuration;
+  if (m_speed == DVD_PLAYSPEED_NORMAL)
+  {
+    pDvdVideoPicture->pts = GetPlayerPtsSeconds() * (double)DVD_TIME_BASE;
+    // video pts cannot be late or dvdplayer goes nuts,
+    // so run it one frame ahead
+    pDvdVideoPicture->pts += 1 * pDvdVideoPicture->iDuration;
+  }
+  else
+  {
+    // We are FF/RW; Do not use the Player clock or it just doesn't work
+    if (m_cur_pts == 0)
+      pDvdVideoPicture->pts = (double)m_1st_pts / PTS_FREQ * DVD_TIME_BASE;
+    else
+      pDvdVideoPicture->pts = (double)m_cur_pts / PTS_FREQ * DVD_TIME_BASE;
+  }
 
   return true;
 }
@@ -1869,7 +1900,7 @@ void CAMLCodec::SetSpeed(int speed)
       break;
     default:
       m_dll->codec_resume(&am_private->vcodec);
-      if (am_private->video_format == VFORMAT_H264)
+      if ((am_private->video_format == VFORMAT_H264) || (am_private->video_format == VFORMAT_H264_4K2K))
         m_dll->codec_set_cntl_mode(&am_private->vcodec, TRICKMODE_FFFB);
       else
         m_dll->codec_set_cntl_mode(&am_private->vcodec, TRICKMODE_I);
@@ -2063,6 +2094,7 @@ void CAMLCodec::GetRenderFeatures(Features &renderFeatures)
 
 void CAMLCodec::SetVideo3dMode(const int mode3d)
 {
+  CLog::Log(LOGDEBUG, "CAMLCodec::SetVideo3dMode:mode3d(0x%x)", mode3d);
   aml_set_sysfs_int("/sys/class/ppmgr/ppmgr_3d_mode", mode3d);
 }
 
@@ -2184,7 +2216,6 @@ void CAMLCodec::SetVideoRect(const CRect &SrcRect, const CRect &DestRect)
   if (m_stereo_mode == RENDER_STEREO_MODE_MONO)
   {
     std::string mode = GetStereoMode();
-    CLog::Log(LOGDEBUG, "CAMLCodec::SetVideoRect:mode(%s)", mode.c_str());
     if (mode == "left_right")
       SetVideo3dMode(MODE_3D_TO_2D_L);
     else if (mode == "right_left")
@@ -2199,15 +2230,27 @@ void CAMLCodec::SetVideoRect(const CRect &SrcRect, const CRect &DestRect)
   else if (m_stereo_mode == RENDER_STEREO_MODE_SPLIT_VERTICAL)
   {
     dst_rect.x2 *= 2.0;
-    //SetVideo3dMode(MODE_3D_LR);
     SetVideo3dMode(MODE_3D_DISABLE);
   }
   else if (m_stereo_mode == RENDER_STEREO_MODE_SPLIT_HORIZONTAL)
   {
     dst_rect.y2 *= 2.0;
-    //SetVideo3dMode(MODE_3D_BT);
     SetVideo3dMode(MODE_3D_DISABLE);
   }
+  else if (m_stereo_mode == RENDER_STEREO_MODE_INTERLACED)
+  {
+    std::string mode = GetStereoMode();
+    if (mode == "left_right")
+      SetVideo3dMode(MODE_3D_LR);
+    else if (mode == "right_left")
+      SetVideo3dMode(MODE_3D_LR_SWITCH);
+    else if (mode == "row_interleaved_lr")
+      SetVideo3dMode(MODE_3D_LR);
+    else if (mode == "row_interleaved_rl")
+      SetVideo3dMode(MODE_3D_LR_SWITCH);
+    else
+      SetVideo3dMode(MODE_3D_DISABLE);
+  }
   else
   {
     SetVideo3dMode(MODE_3D_DISABLE);