aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/parser.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-01-07 11:52:08 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-01-07 11:52:08 +0100
commit69ee915e1c628fdf8b270de8c19ff357333e354a (patch)
tree25e8f7c1ded2cb0d23fb0e287dac6193ff76b32e /libavcodec/parser.c
parentddae03f69bc1c6ec97c028c91837710944427b83 (diff)
downloadffmpeg-69ee915e1c628fdf8b270de8c19ff357333e354a.tar.gz
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>
Diffstat (limited to 'libavcodec/parser.c')
-rw-r--r--libavcodec/parser.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index d1e1574a65..8a3be295aa 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -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,