int out_size, ret;
int64_t delta;
- /* buffer data until we get the first timestamp */
- if (s->pts == AV_NOPTS_VALUE) {
+ /* buffer data until we get the next timestamp */
+ if (s->pts == AV_NOPTS_VALUE || pts == AV_NOPTS_VALUE) {
if (pts != AV_NOPTS_VALUE) {
s->pts = pts - get_delay(s);
}
return write_to_fifo(s, buf);
}
- /* now wait for the next timestamp */
- if (pts == AV_NOPTS_VALUE) {
- return write_to_fifo(s, buf);
- }
-
if (s->first_pts != AV_NOPTS_VALUE) {
handle_trimming(ctx);
if (!avresample_available(s->avr))
delta = pts - s->pts - get_delay(s);
out_size = avresample_available(s->avr);
- if (labs(delta) > s->min_delta || (s->first_frame && delta)) {
+ if (labs(delta) > s->min_delta ||
+ (s->first_frame && delta && s->first_pts != AV_NOPTS_VALUE)) {
av_log(ctx, AV_LOG_VERBOSE, "Discontinuity - %"PRId64" samples.\n", delta);
out_size = av_clipl_int32((int64_t)out_size + delta);
} else {