summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/combined/ffmpeg/ff_video_decoder.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c
index f4f7175fa..c781146a2 100644
--- a/src/combined/ffmpeg/ff_video_decoder.c
+++ b/src/combined/ffmpeg/ff_video_decoder.c
@@ -81,6 +81,7 @@ struct ff_video_decoder_s {
uint64_t pts_tag_mask;
uint64_t pts_tag;
int pts_tag_counter;
+ int pts_tag_stable_counter;
int video_step;
uint8_t decoder_ok:1;
@@ -1197,19 +1198,29 @@ static void ff_check_pts_tagging(ff_video_decoder_t *this, uint64_t pts)
{
if (this->pts_tag_mask == 0)
return; /* pts tagging inactive */
-
- if ((pts & this->pts_tag_mask) != this->pts_tag)
+ if ((pts & this->pts_tag_mask) != this->pts_tag) {
+ this->pts_tag_stable_counter = 0;
return; /* pts still outdated */
+ }
+
+ /* the tag should be stable for 100 frames */
+ this->pts_tag_stable_counter++;
if (this->pts_tag != 0) {
- /* first pass: reset pts_tag */
- this->pts_tag = 0;
+ if (this->pts_tag_stable_counter >= 100) {
+ /* first pass: reset pts_tag */
+ this->pts_tag = 0;
+ this->pts_tag_stable_counter = 0;
+ }
} else if (pts == 0)
return; /* cannot detect second pass */
else {
- /* second pass: reset pts_tag_mask and pts_tag_counter */
- this->pts_tag_mask = 0;
- this->pts_tag_counter = 0;
+ if (this->pts_tag_stable_counter >= 100) {
+ /* second pass: reset pts_tag_mask and pts_tag_counter */
+ this->pts_tag_mask = 0;
+ this->pts_tag_counter = 0;
+ this->pts_tag_stable_counter = 0;
+ }
}
}
@@ -1546,6 +1557,7 @@ static void ff_reset (video_decoder_t *this_gen) {
this->pts_tag_mask = 0;
this->pts_tag = 0;
this->pts_tag_counter = 0;
+ this->pts_tag_stable_counter = 0;
}
static void ff_discontinuity (video_decoder_t *this_gen) {
@@ -1567,9 +1579,11 @@ static void ff_discontinuity (video_decoder_t *this_gen) {
this->pts_tag_counter++;
this->pts_tag_mask = 0;
this->pts_tag = 0;
+ this->pts_tag_stable_counter = 0;
{
/* pts values typically don't use the uppermost bits. therefore we put the tag there */
int counter_mask = 1;
+ int counter = 2 * this->pts_tag_counter + 1; /* always set the uppermost bit in tag_mask */
uint64_t tag_mask = 0x8000000000000000ull;
while (this->pts_tag_counter >= counter_mask)
{
@@ -1577,7 +1591,7 @@ static void ff_discontinuity (video_decoder_t *this_gen) {
* mirror the counter into the uppermost bits. this allows us to enlarge mask as
* necessary and while previous taggings can still be detected to be outdated.
*/
- if (this->pts_tag_counter & counter_mask)
+ if (counter & counter_mask)
this->pts_tag |= tag_mask;
this->pts_tag_mask |= tag_mask;
tag_mask >>= 1;