@ -213,6 +213,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
if ( ret < 0 )
return ret ;
sti - > codec_desc = avcodec_descriptor_get ( sti - > avctx - > codec_id ) ;
sti - > need_context_update = 0 ;
}
return 0 ;
@ -677,10 +679,11 @@ static void compute_frame_duration(AVFormatContext *s, int *pnum, int *pden,
* pnum = st - > time_base . num ;
* pden = st - > time_base . den ;
} else if ( codec_framerate . den * 1000LL > codec_framerate . num ) {
av_assert0 ( sti - > avctx - > ticks_per_frame ) ;
int ticks_per_frame = ( sti - > codec_desc & &
( sti - > codec_desc - > props & AV_CODEC_PROP_FIELDS ) ) ? 2 : 1 ;
av_reduce ( pnum , pden ,
codec_framerate . den ,
codec_framerate . num * ( int64_t ) sti - > avctx - > ticks_per_frame ,
codec_framerate . num * ( int64_t ) ticks_per_frame ,
INT_MAX ) ;
if ( pc & & pc - > repeat_pict ) {
@ -692,7 +695,8 @@ static void compute_frame_duration(AVFormatContext *s, int *pnum, int *pden,
/* If this codec can be interlaced or progressive then we need
* a parser to compute duration of a packet . Thus if we have
* no parser in such case leave duration undefined . */
if ( sti - > avctx - > ticks_per_frame > 1 & & ! pc )
if ( sti - > codec_desc & &
( sti - > codec_desc - > props & AV_CODEC_PROP_FIELDS ) & & ! pc )
* pnum = * pden = 0 ;
}
break ;
@ -1288,6 +1292,8 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
return ret ;
}
sti - > codec_desc = avcodec_descriptor_get ( sti - > avctx - > codec_id ) ;
sti - > need_context_update = 0 ;
}
@ -2164,9 +2170,10 @@ static int get_std_framerate(int i)
static int tb_unreliable ( AVFormatContext * ic , AVStream * st )
{
FFStream * const sti = ffstream ( st ) ;
const AVCodecDescriptor * desc = sti - > codec_desc ;
AVCodecContext * c = sti - > avctx ;
AVRational time_base = c - > framerate . num ? av_inv_q ( av_mul_q ( c - > framerate ,
( AVRational ) { c - > ticks_per_frame , 1 } ) )
AVRational mul = ( AVRational ) { desc & & ( desc - > props & AV_CODEC_PROP_FIELDS ) ? 2 : 1 , 1 } ;
AVRational time_base = c - > framerate . num ? av_inv_q ( av_mul_q ( c - > framerate , mul ) )
/* NOHEADER check added to not break existing behavior */
: ( ( ( ic - > ctx_flags & AVFMTCTX_NOHEADER ) | |
st - > codecpar - > codec_type = = AVMEDIA_TYPE_AUDIO ) ? ( AVRational ) { 0 , 1 }
@ -2718,13 +2725,14 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
break ;
}
if ( pkt - > duration > 0 ) {
const int fields = sti - > codec_desc & & ( sti - > codec_desc - > props & AV_CODEC_PROP_FIELDS ) ;
if ( avctx - > codec_type = = AVMEDIA_TYPE_SUBTITLE & & pkt - > pts ! = AV_NOPTS_VALUE & & st - > start_time ! = AV_NOPTS_VALUE & & pkt - > pts > = st - > start_time
& & ( uint64_t ) pkt - > pts - st - > start_time < INT64_MAX
) {
sti - > info - > codec_info_duration = FFMIN ( pkt - > pts - st - > start_time , sti - > info - > codec_info_duration + pkt - > duration ) ;
} else
sti - > info - > codec_info_duration + = pkt - > duration ;
sti - > info - > codec_info_duration_fields + = sti - > parser & & sti - > need_parsing & & avctx - > ticks_per_frame = = 2
sti - > info - > codec_info_duration_fields + = sti - > parser & & sti - > need_parsing & & fields
? sti - > parser - > repeat_pict + 1 : 2 ;
}
}
@ -2864,15 +2872,12 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
best_fps , 12 * 1001 , INT_MAX ) ;
}
if ( ! st - > r_frame_rate . num ) {
AVRational time_base = avctx - > framerate . num ? av_inv_q ( av_mul_q ( avctx - > framerate ,
( AVRational ) { avctx - > ticks_per_frame , 1 } ) )
/* NOHEADER check added to not break existing behavior */
: ( ( ic - > ctx_flags & AVFMTCTX_NOHEADER ) ? ( AVRational ) { 0 , 1 }
: st - > time_base ) ;
if ( time_base . den * ( int64_t ) st - > time_base . num
< = time_base . num * ( uint64_t ) avctx - > ticks_per_frame * st - > time_base . den ) {
av_reduce ( & st - > r_frame_rate . num , & st - > r_frame_rate . den ,
time_base . den , ( int64_t ) time_base . num * avctx - > ticks_per_frame , INT_MAX ) ;
const AVCodecDescriptor * desc = sti - > codec_desc ;
AVRational mul = ( AVRational ) { desc & & ( desc - > props & AV_CODEC_PROP_FIELDS ) ? 2 : 1 , 1 } ;
AVRational fr = av_mul_q ( avctx - > framerate , mul ) ;
if ( fr . num & & fr . den & & av_cmp_q ( st - > time_base , av_inv_q ( fr ) ) < = 0 ) {
st - > r_frame_rate = fr ;
} else {
st - > r_frame_rate . num = st - > time_base . den ;
st - > r_frame_rate . den = st - > time_base . num ;