1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/parser: add fuzzy mode to ff_fetch_timestamp()

This will be needed for the following timestamp fix

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-01-07 11:52:08 +01:00
parent ddae03f69b
commit 69ee915e1c
3 changed files with 17 additions and 12 deletions

View File

@ -234,7 +234,7 @@ int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size,
}
}
if (pc->frame_start_found == 0 && s && state == PICTURE_START_CODE) {
ff_fetch_timestamp(s, i - 3, 1);
ff_fetch_timestamp(s, i - 3, 1, 0);
}
}
}

View File

@ -93,14 +93,16 @@ err_out:
return NULL;
}
void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove)
void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove, int fuzzy)
{
int i;
s->dts =
s->pts = AV_NOPTS_VALUE;
s->pos = -1;
s->offset = 0;
if (!fuzzy) {
s->dts =
s->pts = AV_NOPTS_VALUE;
s->pos = -1;
s->offset = 0;
}
for (i = 0; i < AV_PARSER_PTS_NB; i++) {
if (s->cur_offset + off >= s->cur_frame_offset[i] &&
(s->frame_offset < s->cur_frame_offset[i] ||
@ -108,10 +110,12 @@ void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove)
// check disabled since MPEG-TS does not send complete PES packets
/*s->next_frame_offset + off <*/ s->cur_frame_end[i]){
s->dts = s->cur_frame_dts[i];
s->pts = s->cur_frame_pts[i];
s->pos = s->cur_frame_pos[i];
s->offset = s->next_frame_offset - s->cur_frame_offset[i];
if (!fuzzy || s->cur_frame_dts[i] != AV_NOPTS_VALUE) {
s->dts = s->cur_frame_dts[i];
s->pts = s->cur_frame_pts[i];
s->pos = s->cur_frame_pos[i];
s->offset = s->next_frame_offset - s->cur_frame_offset[i];
}
if (remove)
s->cur_frame_offset[i] = INT64_MAX;
if (s->cur_offset + off < s->cur_frame_end[i])
@ -154,7 +158,7 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
s->last_pts = s->pts;
s->last_dts = s->dts;
s->last_pos = s->pos;
ff_fetch_timestamp(s, 0, 0);
ff_fetch_timestamp(s, 0, 0, 0);
}
/* WARNING: the returned index can be negative */
index = s->parser->parser_parse(s, avctx, (const uint8_t **) poutbuf,

View File

@ -53,7 +53,8 @@ void ff_parse_close(AVCodecParserContext *s);
* Fetch timestamps for a specific byte within the current access unit.
* @param off byte position within the access unit
* @param remove Found timestamps will be removed if set to 1, kept if set to 0.
* @param fuzzy Only use found value if it is more informative than what we already have
*/
void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove);
void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove, int fuzzy);
#endif /* AVCODEC_PARSER_H */