|
|
|
@ -2276,9 +2276,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (i=0; i<ic->nb_streams; i++) { |
|
|
|
|
#if FF_API_R_FRAME_RATE |
|
|
|
|
ic->streams[i]->info->last_dts = AV_NOPTS_VALUE; |
|
|
|
|
#endif |
|
|
|
|
ic->streams[i]->info->fps_first_dts = AV_NOPTS_VALUE; |
|
|
|
|
ic->streams[i]->info->fps_last_dts = AV_NOPTS_VALUE; |
|
|
|
|
} |
|
|
|
@ -2427,31 +2424,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#if FF_API_R_FRAME_RATE |
|
|
|
|
{ |
|
|
|
|
int64_t last = st->info->last_dts; |
|
|
|
|
|
|
|
|
|
if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && pkt->dts > last){ |
|
|
|
|
int64_t duration= pkt->dts - last; |
|
|
|
|
double dur= duration * av_q2d(st->time_base); |
|
|
|
|
|
|
|
|
|
if (st->info->duration_count < 2) |
|
|
|
|
memset(st->info->duration_error, 0, sizeof(st->info->duration_error)); |
|
|
|
|
for (i=1; i<FF_ARRAY_ELEMS(st->info->duration_error); i++) { |
|
|
|
|
int framerate= get_std_framerate(i); |
|
|
|
|
int ticks= lrintf(dur*framerate/(1001*12)); |
|
|
|
|
double error = dur - (double)ticks*1001*12 / framerate; |
|
|
|
|
st->info->duration_error[i] += error*error; |
|
|
|
|
} |
|
|
|
|
st->info->duration_count++; |
|
|
|
|
// ignore the first 4 values, they might have some random jitter
|
|
|
|
|
if (st->info->duration_count > 3) |
|
|
|
|
st->info->duration_gcd = av_gcd(st->info->duration_gcd, duration); |
|
|
|
|
} |
|
|
|
|
if (last == AV_NOPTS_VALUE || st->info->duration_count <= 1) |
|
|
|
|
st->info->last_dts = pkt->dts; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
if(st->parser && st->parser->parser->split && !st->codec->extradata){ |
|
|
|
|
int i= st->parser->parser->split(st->codec, pkt->data, pkt->size); |
|
|
|
|
if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) { |
|
|
|
@ -2514,30 +2486,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) |
|
|
|
|
best_fps, 12*1001, INT_MAX); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#if FF_API_R_FRAME_RATE |
|
|
|
|
// the check for tb_unreliable() is not completely correct, since this is not about handling
|
|
|
|
|
// a unreliable/inexact time base, but a time base that is finer than necessary, as e.g.
|
|
|
|
|
// ipmovie.c produces.
|
|
|
|
|
if (tb_unreliable(st->codec) && st->info->duration_count > 15 && st->info->duration_gcd > 1 && !st->r_frame_rate.num) |
|
|
|
|
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * st->info->duration_gcd, INT_MAX); |
|
|
|
|
if (st->info->duration_count && !st->r_frame_rate.num |
|
|
|
|
&& tb_unreliable(st->codec)) { |
|
|
|
|
int num = 0; |
|
|
|
|
double best_error= 2*av_q2d(st->time_base); |
|
|
|
|
best_error = best_error*best_error*st->info->duration_count*1000*12*30; |
|
|
|
|
|
|
|
|
|
for (j=1; j<FF_ARRAY_ELEMS(st->info->duration_error); j++) { |
|
|
|
|
double error = st->info->duration_error[j] * get_std_framerate(j); |
|
|
|
|
if(error < best_error){ |
|
|
|
|
best_error= error; |
|
|
|
|
num = get_std_framerate(j); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// do not increase frame rate by more than 1 % in order to match a standard rate.
|
|
|
|
|
if (num && (!st->r_frame_rate.num || (double)num/(12*1001) < 1.01 * av_q2d(st->r_frame_rate))) |
|
|
|
|
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
}else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { |
|
|
|
|
if(!st->codec->bits_per_coded_sample) |
|
|
|
|
st->codec->bits_per_coded_sample= av_get_bits_per_sample(st->codec->codec_id); |
|
|
|
@ -2766,9 +2714,6 @@ AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c) |
|
|
|
|
|
|
|
|
|
st->sample_aspect_ratio = (AVRational){0,1}; |
|
|
|
|
|
|
|
|
|
#if FF_API_R_FRAME_RATE |
|
|
|
|
st->info->last_dts = AV_NOPTS_VALUE; |
|
|
|
|
#endif |
|
|
|
|
st->info->fps_first_dts = AV_NOPTS_VALUE; |
|
|
|
|
st->info->fps_last_dts = AV_NOPTS_VALUE; |
|
|
|
|
|
|
|
|
@ -2903,10 +2848,6 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out |
|
|
|
|
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ |
|
|
|
|
if(st->avg_frame_rate.den && st->avg_frame_rate.num) |
|
|
|
|
print_fps(av_q2d(st->avg_frame_rate), "fps"); |
|
|
|
|
#if FF_API_R_FRAME_RATE |
|
|
|
|
if(st->r_frame_rate.den && st->r_frame_rate.num) |
|
|
|
|
print_fps(av_q2d(st->r_frame_rate), "tbr"); |
|
|
|
|
#endif |
|
|
|
|
if(st->time_base.den && st->time_base.num) |
|
|
|
|
print_fps(1/av_q2d(st->time_base), "tbn"); |
|
|
|
|
if(st->codec->time_base.den && st->codec->time_base.num) |
|
|
|
|