Skip to content

Commit

Permalink
Fix Fast Jumps with yellow/green in Recording
Browse files Browse the repository at this point in the history
Improve Jumps over Cutpoints
  • Loading branch information
jojo61 committed Mar 9, 2023
1 parent 13892df commit d74ba03
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
7 changes: 6 additions & 1 deletion audio.c
Expand Up @@ -2059,6 +2059,11 @@ int64_t AudioGetDelay(void)
return pts;
}

int AudioGetBufferUsedbytes(void) {
return (int) RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer);
}


/**
** Set audio clock base.
**
Expand All @@ -2070,7 +2075,7 @@ void AudioSetClock(int64_t pts)
Debug(4, "audio: set clock %s -> %s pts\n", Timestamp2String(AudioRing[AudioRingWrite].PTS),
Timestamp2String(pts));
}
//printf("Audiosetclock pts %#012" PRIx64 " %d\n",pts,RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer));
//printf("Audiosetclock pts %#012" PRIx64 " %ld\n",pts,RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer));
AudioRing[AudioRingWrite].PTS = pts;
}

Expand Down
16 changes: 14 additions & 2 deletions softhddev.c
Expand Up @@ -90,6 +90,7 @@ static VideoStream *AudioSyncStream; ///< video stream for audio/video sync
/// Minimum free space in audio buffer 8 packets for 8 channels
#define AUDIO_MIN_BUFFER_FREE (3072 * 8 * 8)
#define AUDIO_BUFFER_SIZE (512 * 1024) ///< audio PES buffer default size
#define AUDIO_MAX_BUFFERS (150 * 1024)
static AVPacket AudioAvPkt[1]; ///< audio a/v packet
int AudioDelay = 0;

Expand Down Expand Up @@ -979,7 +980,7 @@ static int TsDemuxer(TsDemux * tsdx, const uint8_t * data, int size)
#endif



extern int AudioGetBufferUsedbytes(void) ;

/**
** Play audio packet.
Expand Down Expand Up @@ -1021,6 +1022,12 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
if (AudioFreeBytes() < AUDIO_MIN_BUFFER_FREE) {
return 0;
}

// dont fill audio buffers too much
if (AudioGetBufferUsedbytes() > AUDIO_MAX_BUFFERS) {
return 0;
}

#ifdef USE_SOFTLIMIT
// soft limit buffer full
if (AudioSyncStream && VideoGetBuffers(AudioSyncStream) > 3 && AudioUsedBytes() > AUDIO_MIN_BUFFER_FREE * 2) {
Expand Down Expand Up @@ -1232,7 +1239,6 @@ int PlayTsAudio(const uint8_t * data, int size)
if (StreamFreezed) { // stream freezed
return 0;
}

if (NewAudioStream) {
// this clears the audio ringbuffer indirect, open and setup does it
CodecAudioClose(MyAudioDecoder);
Expand All @@ -1248,6 +1254,12 @@ int PlayTsAudio(const uint8_t * data, int size)
if (AudioFreeBytes() < AUDIO_MIN_BUFFER_FREE) {
return 0;
}

// dont fill audio buffers too much
if (AudioGetBufferUsedbytes() > AUDIO_MAX_BUFFERS) {
return 0;
}

#ifdef USE_SOFTLIMIT
// soft limit buffer full
if (AudioSyncStream && VideoGetBuffers(AudioSyncStream) > 3 && AudioUsedBytes() > AUDIO_MIN_BUFFER_FREE * 2) {
Expand Down
2 changes: 1 addition & 1 deletion softhdodroid.cpp
Expand Up @@ -59,7 +59,7 @@ extern "C"
/// vdr-plugin version number.
/// Makefile extracts the version number for generating the file name
/// for the distribution archive.
static const char *const VERSION = "3.8.8"
static const char *const VERSION = "3.8.9"
#ifdef GIT_REV
"-GIT-" GIT_REV
#endif
Expand Down
13 changes: 11 additions & 2 deletions video.c
Expand Up @@ -364,6 +364,8 @@ uint64_t VideoGetClock(const VideoHwDecoder *decoder) {
return TrickPTS;
}
#endif
return LastPTS;
#if 0
while ((RealPTS = GetCurrentVPts(0)) == 0 && i--) {
printf("wait for Real PTS \n");
usleep(10000);
Expand All @@ -375,7 +377,7 @@ uint64_t VideoGetClock(const VideoHwDecoder *decoder) {
}
usleep(2000);
return PTS;

#endif
};


Expand Down Expand Up @@ -1957,6 +1959,8 @@ void InternalOpen(VideoHwDecoder *hwdecoder, int format, double frameRate)
vformat_t amlFormat = (vformat_t)0;
dec_sysinfo_t am_sysinfo = { 0 };

estimatedNextPts = 0;

if (!pip) {
PIP_allowed = false;
}
Expand Down Expand Up @@ -2682,7 +2686,12 @@ if (hwdecoder->TrickSpeed ) {
{
double timeStamp = av_q2d(timeBase) * pkt->pts;
pts = (uint64_t)(timeStamp * PTS_FREQ);

#if 0
if (estimatedNextPts && (abs(estimatedNextPts - pkt->pts) > 90000)) {
printf("jump in PTS: reset\n");
//amlReset();
}
#endif
estimatedNextPts = pkt->pts + 3600; // pkt->duration;
lastTimeStamp = timeStamp;
}
Expand Down

0 comments on commit d74ba03

Please sign in to comment.