Skip to content

Commit

Permalink
Playback: Improved triggers for low bitrate optimisations.
Browse files Browse the repository at this point in the history
The optimisations added in d207a0b are being triggered
unnecessarily. This is due to a combination of different initial
thresholds in that commit and lowering the acceptable bitrate in
a1022c6.

The fix is twofold:-

- adjust the initial bitrate thresholds to ensure any optimisations are
only triggerred for streams with a bitrate below 500Kb/s.
- any video codec scanned in AvFormatDecoder that has a zero bitrate is
forced to 500Kb/s. This is an extension of the previous hack for H.264
streams.

Overall, this ensures that the previous behaviour (initial fill size of
32KB, rising as needed) is preserved for anything with a video stream
and generally in the vast majority of cases.

Fixes recent playback of avi files and, amongst others, BB HD (both
detected as zero bitrate).

Refs #9824.
  • Loading branch information
Mark Kendall committed Nov 21, 2011
1 parent 7b2eb25 commit f6d8c69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 6 additions & 6 deletions mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -1768,14 +1768,14 @@ int AvFormatDecoder::ScanStreams(bool novideo)

codec_is_mpeg = CODEC_IS_FFMPEG_MPEG(enc->codec_id);

// ffmpeg does not return a bitrate for several codecs and
// formats. Forcing it to 500000 ensures the ringbuffer does not
// use optimisations for low bitrate (audio and data) streams.
if (enc->bit_rate == 0)
unknownbitrate = true;

// HACK -- begin
// ffmpeg is unable to compute H.264 bitrates in mpegts?
if (CODEC_IS_H264(enc->codec_id) && enc->bit_rate == 0)
{
enc->bit_rate = 500000;
// HACK -- end
unknownbitrate = true;
}

StreamInfo si(i, 0, 0, 0, 0);
tracks[kTrackTypeVideo].push_back(si);
Expand Down
4 changes: 1 addition & 3 deletions mythtv/libs/libmythtv/ringbuffer.cpp
Expand Up @@ -352,7 +352,6 @@ void RingBuffer::CalcReadAheadThresh(void)
const uint KB2 = 2*1024;
const uint KB4 = 4*1024;
const uint KB8 = 8*1024;
const uint KB16 = 16*1024;
const uint KB32 = 32*1024;
const uint KB64 = 64*1024;
const uint KB128 = 128*1024;
Expand All @@ -366,8 +365,7 @@ void RingBuffer::CalcReadAheadThresh(void)
(estbitrate > 9000) ? KB256 :
(estbitrate > 5000) ? KB128 :
(estbitrate > 2500) ? KB64 :
(estbitrate > 1000) ? KB32 :
(estbitrate > 500) ? KB16 :
(estbitrate >= 500) ? KB32 :
(estbitrate > 250) ? KB8 :
(estbitrate > 125) ? KB4 : KB2;
if (rbs < CHUNK)
Expand Down

0 comments on commit f6d8c69

Please sign in to comment.