MythTV  master
mythdvdcontext.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QString>
3 
4 // MythTV
5 #include "mythdvdcontext.h"
6 
7 MythDVDContext::MythDVDContext(const dsi_t& DSI, const pci_t& PCI)
8  : ReferenceCounter("MythDVDContext"),
9  m_dsi(DSI),
10  m_pci(PCI)
11 {
12 }
13 
14 int64_t MythDVDContext::GetStartPTS(void) const
15 {
16  return static_cast<int64_t>(m_pci.pci_gi.vobu_s_ptm);
17 }
18 
19 int64_t MythDVDContext::GetEndPTS(void) const
20 {
21  return static_cast<int64_t>(m_pci.pci_gi.vobu_e_ptm);
22 }
23 
24 int64_t MythDVDContext::GetSeqEndPTS(void) const
25 {
26  return static_cast<int64_t>(m_pci.pci_gi.vobu_se_e_ptm);
27 }
28 
29 uint32_t MythDVDContext::GetLBA(void) const
30 {
31  return m_pci.pci_gi.nv_pck_lbn;
32 }
33 
38 {
39  return static_cast<int>(((GetEndPTS() - GetStartPTS()) * GetFPS()) / 90000);
40 }
41 
46 {
47  int frames = 0;
48 
49  if (GetSeqEndPTS())
50  {
51  // Sequence end PTS is set. This means that video frames
52  // are not present all the way to 'End PTS'
53  frames = static_cast<int>(((GetSeqEndPTS() - GetStartPTS()) * GetFPS()) / 90000);
54  }
55  else if (m_dsi.dsi_gi.vobu_1stref_ea != 0)
56  {
57  // At least one video frame is present
58  frames = GetNumFrames();
59  }
60 
61  return frames;
62 }
63 
64 int MythDVDContext::GetFPS(void) const
65 {
66  return (m_pci.pci_gi.e_eltm.frame_u & 0x80) ? 30 : 25;
67 }
68 
74 {
75  uint32_t lba = m_dsi.vobu_sri.prev_video;
76 
77  if (lba != 0xbfffffff)
78  {
79  // If there is a previous video frame in this
80  // cell, calculate the absolute LBA from the
81  // offset
82  lba = GetLBA() - (lba & 0x7ffffff);
83  }
84 
85  return lba;
86 }
MythDVDContext::GetLBA
uint32_t GetLBA(void) const
Definition: mythdvdcontext.cpp:29
MythDVDContext::GetNumFrames
int GetNumFrames(void) const
Returns the duration of this VOBU in frames.
Definition: mythdvdcontext.cpp:37
MythDVDContext::GetEndPTS
int64_t GetEndPTS(void) const
Definition: mythdvdcontext.cpp:19
MythDVDContext::GetSeqEndPTS
int64_t GetSeqEndPTS(void) const
Definition: mythdvdcontext.cpp:24
MythDVDContext::GetNumFramesPresent
int GetNumFramesPresent(void) const
Returns the number of video frames present in this VOBU.
Definition: mythdvdcontext.cpp:45
MythDVDContext::m_pci
pci_t m_pci
Definition: mythdvdcontext.h:38
MythDVDContext::GetStartPTS
int64_t GetStartPTS(void) const
Definition: mythdvdcontext.cpp:14
MythDVDContext::GetFPS
int GetFPS(void) const
Definition: mythdvdcontext.cpp:64
MythDVDContext::m_dsi
dsi_t m_dsi
Definition: mythdvdcontext.h:37
MythDVDContext::GetLBAPrevVideoFrame
uint32_t GetLBAPrevVideoFrame(void) const
Returns the logical block address of the previous VOBU containing video.
Definition: mythdvdcontext.cpp:73
mythdvdcontext.h
MythDVDContext::MythDVDContext
MythDVDContext()=delete
ReferenceCounter
General purpose reference counter.
Definition: referencecounter.h:27