Ticket #2984: dvbrecorder.audio_scan_code2.diff

File dvbrecorder.audio_scan_code2.diff, 2.7 KB (added by gnome42@…, 19 years ago)

Use ff_find_start_code() on audio pkts too

  • libs/libmythtv/dvbrecorder.cpp

    diff --git a/libs/libmythtv/dvbrecorder.cpp b/libs/libmythtv/dvbrecorder.cpp
    index 09174b8..e6ba852 100644
    a b using namespace std;  
    6464#include "cardutil.h"
    6565#include "tv_rec.h"
    6666
     67extern "C" {
     68// from libavcodec
     69extern const uint8_t *ff_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state);
     70}
     71
    6772// MythTV DVB includes
    6873#include "dvbtypes.h"
    6974#include "dvbchannel.h"
    void DVBRecorder::ProcessTSPacket2(const TSPacket& tspacket)  
    11921197void DVBRecorder::GetTimeStamp(const TSPacket& tspacket)
    11931198{
    11941199    const uint pid = tspacket.PID();
    1195     if (pid != _audio_pid)
     1200    if (pid != _audio_pid || tspacket.PayloadStart())
     1201    {
    11961202        _audio_header_pos = 0;
     1203        _audio_start_code = 0xffffffff;
     1204    }
    11971205
    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)
    12031210    {
    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
    12051227        switch (_audio_header_pos)
    12061228        {
    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;
    12161229            case 3:
    12171230                if ((k >= PESStreamID::MPEGAudioStreamBegin) &&
    12181231                    (k <= PESStreamID::MPEGAudioStreamEnd))
  • libs/libmythtv/dvbrecorder.h

    diff --git a/libs/libmythtv/dvbrecorder.h b/libs/libmythtv/dvbrecorder.h
    index 6f59014..d131d43 100644
    a b class DVBRecorder :  
    170170    int             _ts_packets_until_psip_sync;
    171171
    172172    // Fake video for streams without video
     173    uint32_t        _audio_start_code;
    173174    uint            _audio_header_pos;
    174175    uint            _video_header_pos;
    175176    uint            _audio_pid;