diff --git a/libs/libmythtv/dvbrecorder.cpp b/libs/libmythtv/dvbrecorder.cpp
index 09174b8..e6ba852 100644
a
|
b
|
using namespace std;
|
64 | 64 | #include "cardutil.h" |
65 | 65 | #include "tv_rec.h" |
66 | 66 | |
| 67 | extern "C" { |
| 68 | // from libavcodec |
| 69 | extern const uint8_t *ff_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state); |
| 70 | } |
| 71 | |
67 | 72 | // MythTV DVB includes |
68 | 73 | #include "dvbtypes.h" |
69 | 74 | #include "dvbchannel.h" |
… |
… |
void DVBRecorder::ProcessTSPacket2(const TSPacket& tspacket)
|
1192 | 1197 | void DVBRecorder::GetTimeStamp(const TSPacket& tspacket) |
1193 | 1198 | { |
1194 | 1199 | const uint pid = tspacket.PID(); |
1195 | | if (pid != _audio_pid) |
| 1200 | if (pid != _audio_pid || tspacket.PayloadStart()) |
| 1201 | { |
1196 | 1202 | _audio_header_pos = 0; |
| 1203 | _audio_start_code = 0xffffffff; |
| 1204 | } |
1197 | 1205 | |
1198 | | // Find the current audio time stamp. This code is based on |
1199 | | // DTVRecorder::FindMPEG2Keyframes. |
1200 | | if (tspacket.PayloadStart()) |
1201 | | _audio_header_pos = 0; |
1202 | | for (uint i = tspacket.AFCOffset(); i < TSPacket::SIZE; i++) |
| 1206 | const uint8_t *bufptr = tspacket.data() + tspacket.AFCOffset(); |
| 1207 | const uint8_t *bufend = tspacket.data() + TSPacket::SIZE; |
| 1208 | |
| 1209 | while (bufptr < bufend) |
1203 | 1210 | { |
1204 | | const unsigned char k = tspacket.data()[i]; |
| 1211 | if (!_audio_header_pos) |
| 1212 | bufptr = ff_find_start_code(bufptr, bufend, &_audio_start_code); |
| 1213 | |
| 1214 | if ((_audio_start_code & 0xffffff00) != 0x00000100) |
| 1215 | { |
| 1216 | _audio_header_pos = 0; |
| 1217 | continue; |
| 1218 | } |
| 1219 | else |
| 1220 | { |
| 1221 | _audio_header_pos = _audio_header_pos ? _audio_header_pos : 3; |
| 1222 | bufptr++; |
| 1223 | } |
| 1224 | |
| 1225 | const unsigned char k = *(bufptr - 2); |
| 1226 | |
1205 | 1227 | switch (_audio_header_pos) |
1206 | 1228 | { |
1207 | | case 0: |
1208 | | _audio_header_pos = (k == 0x00) ? 1 : 0; |
1209 | | break; |
1210 | | case 1: |
1211 | | _audio_header_pos = (k == 0x00) ? 2 : 0; |
1212 | | break; |
1213 | | case 2: |
1214 | | _audio_header_pos = (k == 0x00) ? 2 : ((k == 0x01) ? 3 : 0); |
1215 | | break; |
1216 | 1229 | case 3: |
1217 | 1230 | if ((k >= PESStreamID::MPEGAudioStreamBegin) && |
1218 | 1231 | (k <= PESStreamID::MPEGAudioStreamEnd)) |
diff --git a/libs/libmythtv/dvbrecorder.h b/libs/libmythtv/dvbrecorder.h
index 6f59014..d131d43 100644
a
|
b
|
class DVBRecorder :
|
170 | 170 | int _ts_packets_until_psip_sync; |
171 | 171 | |
172 | 172 | // Fake video for streams without video |
| 173 | uint32_t _audio_start_code; |
173 | 174 | uint _audio_header_pos; |
174 | 175 | uint _video_header_pos; |
175 | 176 | uint _audio_pid; |