1 | #! /bin/sh /usr/share/dpatch/dpatch-run |
---|
2 | ## 29_dvb_seektable.dpatch by <adrian@motoko> |
---|
3 | ## |
---|
4 | ## All lines beginning with `## DP:' are a description of the patch. |
---|
5 | ## DP: Backports 17826, 18852, 19242 from trunk to fix DVB seektable issues |
---|
6 | |
---|
7 | @DPATCH@ |
---|
8 | |
---|
9 | diff -Nru mythtv-0.21.0+fixes18722-original/libs/libmythtv/avformatdecoder.cpp mythtv-0.21.0+fixes18722-patch/libs/libmythtv/avformatdecoder.cpp |
---|
10 | --- mythtv-0.21.0+fixes18722-original/libs/libmythtv/avformatdecoder.cpp 2008-10-10 22:16:10.000000000 +0100 |
---|
11 | +++ mythtv-0.21.0+fixes18722-patch/libs/libmythtv/avformatdecoder.cpp 2009-03-12 11:44:03.000000000 +0000 |
---|
12 | @@ -982,13 +982,12 @@ |
---|
13 | // set the gop interval to 15 frames. if we guess wrong, the |
---|
14 | // auto detection will change it. |
---|
15 | keyframedist = 15; |
---|
16 | - positionMapType = MARK_GOP_START; |
---|
17 | + positionMapType = MARK_GOP_BYFRAME; |
---|
18 | |
---|
19 | if (!strcmp(fmt->name, "avi")) |
---|
20 | { |
---|
21 | // avi keyframes are too irregular |
---|
22 | keyframedist = 1; |
---|
23 | - positionMapType = MARK_GOP_BYFRAME; |
---|
24 | } |
---|
25 | |
---|
26 | dontSyncPositionMap = true; |
---|
27 | @@ -2248,10 +2247,6 @@ |
---|
28 | keyframedist = tempKeyFrameDist; |
---|
29 | maxkeyframedist = max(keyframedist, maxkeyframedist); |
---|
30 | |
---|
31 | - // FIXME: this needs to go |
---|
32 | - bool is_ivtv = (keyframedist == 15) || (keyframedist == 12); |
---|
33 | - positionMapType = (is_ivtv) ? MARK_GOP_START : MARK_GOP_BYFRAME; |
---|
34 | - |
---|
35 | GetNVP()->SetKeyframeDistance(keyframedist); |
---|
36 | |
---|
37 | #if 0 |
---|
38 | @@ -2274,8 +2269,6 @@ |
---|
39 | long long last_frame = 0; |
---|
40 | if (!m_positionMap.empty()) |
---|
41 | last_frame = m_positionMap.back().index; |
---|
42 | - if (keyframedist > 1) |
---|
43 | - last_frame *= keyframedist; |
---|
44 | |
---|
45 | //cerr << "framesRead: " << framesRead << " last_frame: " << last_frame |
---|
46 | // << " keyframedist: " << keyframedist << endl; |
---|
47 | @@ -2287,11 +2280,9 @@ |
---|
48 | |
---|
49 | VERBOSE(VB_PLAYBACK|VB_TIMESTAMP, LOC + |
---|
50 | QString("positionMap[ %1 ] == %2.") |
---|
51 | - .arg(prevgoppos / keyframedist) |
---|
52 | - .arg(startpos)); |
---|
53 | + .arg(framesRead).arg(startpos)); |
---|
54 | |
---|
55 | - PosMapEntry entry = {prevgoppos / keyframedist, |
---|
56 | - prevgoppos, startpos}; |
---|
57 | + PosMapEntry entry = {framesRead, framesRead, startpos}; |
---|
58 | m_positionMap.push_back(entry); |
---|
59 | } |
---|
60 | |
---|
61 | diff -Nru mythtv-0.21.0+fixes18722-original/libs/libmythtv/dtvrecorder.cpp mythtv-0.21.0+fixes18722-patch/libs/libmythtv/dtvrecorder.cpp |
---|
62 | --- mythtv-0.21.0+fixes18722-original/libs/libmythtv/dtvrecorder.cpp 2008-10-02 18:29:55.000000000 +0100 |
---|
63 | +++ mythtv-0.21.0+fixes18722-patch/libs/libmythtv/dtvrecorder.cpp 2009-03-12 11:44:03.000000000 +0000 |
---|
64 | @@ -394,11 +394,11 @@ |
---|
65 | nextRingBufferLock.unlock(); |
---|
66 | } |
---|
67 | |
---|
68 | -/** \fn DTVRecorder::HandleKeyframe(void) |
---|
69 | +/** \fn DTVRecorder::HandleKeyframe(uint64_t) |
---|
70 | * \brief This save the current frame to the position maps |
---|
71 | * and handles ringbuffer switching. |
---|
72 | */ |
---|
73 | -void DTVRecorder::HandleKeyframe(void) |
---|
74 | +void DTVRecorder::HandleKeyframe(uint64_t extra) |
---|
75 | { |
---|
76 | if (!ringBuffer) |
---|
77 | return; |
---|
78 | @@ -413,7 +413,7 @@ |
---|
79 | { |
---|
80 | long long startpos = ringBuffer->GetWritePosition(); |
---|
81 | // FIXME: handle keyframes with start code spanning over two ts packets |
---|
82 | - startpos += _payload_buffer.size(); |
---|
83 | + startpos += _payload_buffer.size() + extra; |
---|
84 | positionMapDelta[frameNum] = startpos; |
---|
85 | positionMap[frameNum] = startpos; |
---|
86 | } |
---|
87 | diff -Nru mythtv-0.21.0+fixes18722-original/libs/libmythtv/dtvrecorder.h mythtv-0.21.0+fixes18722-patch/libs/libmythtv/dtvrecorder.h |
---|
88 | --- mythtv-0.21.0+fixes18722-original/libs/libmythtv/dtvrecorder.h 2008-02-18 16:01:43.000000000 +0000 |
---|
89 | +++ mythtv-0.21.0+fixes18722-patch/libs/libmythtv/dtvrecorder.h 2009-03-12 11:44:03.000000000 +0000 |
---|
90 | @@ -51,7 +51,7 @@ |
---|
91 | void FinishRecording(void); |
---|
92 | void ResetForNewFile(void); |
---|
93 | |
---|
94 | - void HandleKeyframe(); |
---|
95 | + void HandleKeyframe(uint64_t extra = 0); |
---|
96 | |
---|
97 | void BufferedWrite(const TSPacket &tspacket); |
---|
98 | |
---|
99 | diff -Nru mythtv-0.21.0+fixes18722-original/libs/libmythtv/ivtvdecoder.cpp mythtv-0.21.0+fixes18722-patch/libs/libmythtv/ivtvdecoder.cpp |
---|
100 | --- mythtv-0.21.0+fixes18722-original/libs/libmythtv/ivtvdecoder.cpp 2007-11-08 18:13:50.000000000 +0000 |
---|
101 | +++ mythtv-0.21.0+fixes18722-patch/libs/libmythtv/ivtvdecoder.cpp 2009-03-12 11:44:03.000000000 +0000 |
---|
102 | @@ -351,12 +351,7 @@ |
---|
103 | if ((firstgoppos > 0) && (keyframedist != 1)) |
---|
104 | { |
---|
105 | keyframedist = frameNum - firstgoppos; |
---|
106 | - |
---|
107 | - if ((keyframedist == 15) || |
---|
108 | - (keyframedist == 12)) |
---|
109 | - positionMapType = MARK_GOP_START; |
---|
110 | - else |
---|
111 | - positionMapType = MARK_GOP_BYFRAME; |
---|
112 | + positionMapType = MARK_GOP_BYFRAME; |
---|
113 | |
---|
114 | gopset = true; |
---|
115 | GetNVP()->SetKeyframeDistance(keyframedist); |
---|
116 | @@ -373,17 +368,12 @@ |
---|
117 | { |
---|
118 | long long last_frame = 0; |
---|
119 | if (!m_positionMap.empty()) |
---|
120 | - last_frame = |
---|
121 | - m_positionMap[m_positionMap.size() - 1].index; |
---|
122 | - if (keyframedist > 1) |
---|
123 | - last_frame *= keyframedist; |
---|
124 | + last_frame = m_positionMap[m_positionMap.size() - 1].index; |
---|
125 | if (framesRead > last_frame && keyframedist > 0) |
---|
126 | - { |
---|
127 | - if (m_positionMap.capacity() == |
---|
128 | - m_positionMap.size()) |
---|
129 | + { |
---|
130 | + if (m_positionMap.capacity() == m_positionMap.size()) |
---|
131 | m_positionMap.reserve(m_positionMap.size() + 60); |
---|
132 | - PosMapEntry entry = {lastKey / keyframedist, |
---|
133 | - lastKey, laststartpos}; |
---|
134 | + PosMapEntry entry = {lastKey, lastKey, laststartpos}; |
---|
135 | m_positionMap.push_back(entry); |
---|
136 | } |
---|
137 | |
---|
138 | @@ -391,17 +381,12 @@ |
---|
139 | (!recordingHasPositionMap) && |
---|
140 | (!livetv)) |
---|
141 | { |
---|
142 | - int bitrate = (int)((laststartpos * 8 * fps) / |
---|
143 | - (framesRead - 1)); |
---|
144 | + int bitrate = (int)(laststartpos * 8 * fps / (framesRead - 1)); |
---|
145 | float bytespersec = (float)bitrate / 8; |
---|
146 | - float secs = ringBuffer->GetRealFileSize() * 1.0 / |
---|
147 | - bytespersec; |
---|
148 | - GetNVP()->SetFileLength((int)(secs), |
---|
149 | - (int)(secs * fps)); |
---|
150 | + float secs = ringBuffer->GetRealFileSize() * 1.0 / bytespersec; |
---|
151 | + GetNVP()->SetFileLength((int)(secs), (int)(secs * fps)); |
---|
152 | } |
---|
153 | - |
---|
154 | } |
---|
155 | - |
---|
156 | break; |
---|
157 | } |
---|
158 | case PICTURE_START: |
---|
159 | diff -Nru mythtv-0.21.0+fixes18722-original/libs/libmythtv/mpegrecorder.cpp mythtv-0.21.0+fixes18722-patch/libs/libmythtv/mpegrecorder.cpp |
---|
160 | --- mythtv-0.21.0+fixes18722-original/libs/libmythtv/mpegrecorder.cpp 2008-02-26 21:13:09.000000000 +0000 |
---|
161 | +++ mythtv-0.21.0+fixes18722-patch/libs/libmythtv/mpegrecorder.cpp 2009-03-12 11:44:03.000000000 +0000 |
---|
162 | @@ -110,7 +110,6 @@ |
---|
163 | buildbuffer(new unsigned char[kBuildBufferMaxSize + 1]), |
---|
164 | buildbuffersize(0) |
---|
165 | { |
---|
166 | - SetPositionMapType(MARK_GOP_START); |
---|
167 | } |
---|
168 | |
---|
169 | MpegRecorder::~MpegRecorder() |
---|
170 | @@ -578,8 +577,6 @@ |
---|
171 | return false; |
---|
172 | } |
---|
173 | |
---|
174 | - keyframedist = (ivtvcodec.framerate) ? 12 : keyframedist; |
---|
175 | - |
---|
176 | return true; |
---|
177 | } |
---|
178 | |
---|
179 | @@ -662,23 +659,6 @@ |
---|
180 | } |
---|
181 | } |
---|
182 | |
---|
183 | - // Get controls |
---|
184 | - ext_ctrl[0].id = V4L2_CID_MPEG_VIDEO_GOP_SIZE; |
---|
185 | - ext_ctrl[0].value = 0; |
---|
186 | - |
---|
187 | - ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; |
---|
188 | - ctrls.count = 1; |
---|
189 | - ctrls.controls = ext_ctrl; |
---|
190 | - |
---|
191 | - if (ioctl(chanfd, VIDIOC_G_EXT_CTRLS, &ctrls) < 0) |
---|
192 | - { |
---|
193 | - VERBOSE(VB_IMPORTANT, LOC_WARN + "Unable to get " |
---|
194 | - "V4L2_CID_MPEG_VIDEO_GOP_SIZE, defaulting to 12" + ENO); |
---|
195 | - ext_ctrl[0].value = 12; |
---|
196 | - } |
---|
197 | - |
---|
198 | - keyframedist = ext_ctrl[0].value; |
---|
199 | - |
---|
200 | return true; |
---|
201 | } |
---|
202 | |
---|
203 | @@ -1050,7 +1034,9 @@ |
---|
204 | buildbuffersize = 0; |
---|
205 | |
---|
206 | if (curRecording) |
---|
207 | - curRecording->ClearPositionMap(MARK_GOP_START); |
---|
208 | + { |
---|
209 | + curRecording->ClearPositionMap(MARK_GOP_BYFRAME); |
---|
210 | + } |
---|
211 | } |
---|
212 | |
---|
213 | void MpegRecorder::Pause(bool clear) |
---|