mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
ffmpeg/avformat: factor av_guess_frame_rate() out
This will be used in ffplay Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
c81d2fa96d
commit
ef7b6b489a
@ -15,6 +15,9 @@ libavutil: 2012-10-22
|
||||
|
||||
API changes, most recent first:
|
||||
|
||||
2013-03-29 - xxxxxxx - lavf 55.1.100 - avformat.h
|
||||
Add av_guess_frame_rate()
|
||||
|
||||
2013-03-20 - xxxxxxx - lavu 52.22.100 - opt.h
|
||||
Add AV_OPT_TYPE_DURATION value to AVOptionType enum.
|
||||
|
||||
|
@ -542,22 +542,15 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
InputStream *ist = ifilter->ist;
|
||||
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
|
||||
ist->st->time_base;
|
||||
AVRational fr = ist->framerate.num ? ist->framerate :
|
||||
ist->st->r_frame_rate;
|
||||
AVRational fr = ist->framerate;
|
||||
AVRational sar;
|
||||
AVBPrint args;
|
||||
char name[255];
|
||||
int pad_idx = in->pad_idx;
|
||||
int ret;
|
||||
|
||||
if (!ist->framerate.num && ist->st->codec->ticks_per_frame>1) {
|
||||
AVRational codec_fr = av_inv_q(ist->st->codec->time_base);
|
||||
AVRational avg_fr = ist->st->avg_frame_rate;
|
||||
codec_fr.den *= ist->st->codec->ticks_per_frame;
|
||||
if ( codec_fr.num>0 && codec_fr.den>0 && av_q2d(codec_fr) < av_q2d(fr)*0.7
|
||||
&& fabs(1.0 - av_q2d(av_div_q(avg_fr, fr)))>0.1)
|
||||
fr = codec_fr;
|
||||
}
|
||||
if (!fr.num)
|
||||
fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL);
|
||||
|
||||
if (ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
||||
ret = sub2video_prepare(ist);
|
||||
|
@ -2107,6 +2107,16 @@ const struct AVCodecTag *avformat_get_riff_audio_tags(void);
|
||||
*/
|
||||
AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame);
|
||||
|
||||
/**
|
||||
* Guess the frame rate, based on both the container and codec information.
|
||||
*
|
||||
* @param ctx the format context which the stream is part of
|
||||
* @param stream the stream which the frame is part of
|
||||
* @param frame the frame for which the frame rate should be determined, may be NULL
|
||||
* @return the guessed (valid) frame rate, 0/1 if no idea
|
||||
*/
|
||||
AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, AVFrame *frame);
|
||||
|
||||
/**
|
||||
* Check if the stream st contained in s is matched by the stream specifier
|
||||
* spec.
|
||||
|
@ -4278,6 +4278,22 @@ AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *strea
|
||||
return frame_sample_aspect_ratio;
|
||||
}
|
||||
|
||||
AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *frame)
|
||||
{
|
||||
AVRational fr = st->r_frame_rate;
|
||||
|
||||
if (st->codec->ticks_per_frame > 1) {
|
||||
AVRational codec_fr = av_inv_q(st->codec->time_base);
|
||||
AVRational avg_fr = st->avg_frame_rate;
|
||||
codec_fr.den *= st->codec->ticks_per_frame;
|
||||
if ( codec_fr.num > 0 && codec_fr.den > 0 && av_q2d(codec_fr) < av_q2d(fr)*0.7
|
||||
&& fabs(1.0 - av_q2d(av_div_q(avg_fr, fr))) > 0.1)
|
||||
fr = codec_fr;
|
||||
}
|
||||
|
||||
return fr;
|
||||
}
|
||||
|
||||
int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
|
||||
const char *spec)
|
||||
{
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVFORMAT_VERSION_MAJOR 55
|
||||
#define LIBAVFORMAT_VERSION_MINOR 0
|
||||
#define LIBAVFORMAT_VERSION_MINOR 1
|
||||
#define LIBAVFORMAT_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
|
Loading…
Reference in New Issue
Block a user