1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

fftools/ffmpeg: stop accessing input format from decoding code

Export the corresponding flag in InputFile instead. This will allow
making the demuxer AVFormatContext private in future commits, similarly
to what was previously done for muxers.
This commit is contained in:
Anton Khirnov 2023-05-07 18:50:15 +02:00
parent 2ab9f247f7
commit ab223a4d8c
3 changed files with 7 additions and 3 deletions

View File

@ -976,7 +976,6 @@ static int decode_audio(InputStream *ist, const AVPacket *pkt, int *got_output,
static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *frame)
{
const InputFile *ifile = input_files[ist->file_index];
const int container_nots = !!(ifile->ctx->iformat->flags & AVFMT_NOTIMESTAMPS);
int64_t codec_duration = 0;
// XXX lavf currently makes up frame durations when they are not provided by
@ -986,7 +985,7 @@ static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *fr
// durations, then this should be simplified.
// prefer frame duration for containers with timestamps
if (frame->duration > 0 && !container_nots)
if (frame->duration > 0 && !ifile->format_nots)
return frame->duration;
if (ist->dec_ctx->framerate.den && ist->dec_ctx->framerate.num) {
@ -998,7 +997,7 @@ static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *fr
}
// prefer codec-layer duration for containers without timestamps
if (codec_duration > 0 && container_nots)
if (codec_duration > 0 && ifile->format_nots)
return codec_duration;
// when timestamps are available, repeat last frame's actual duration

View File

@ -442,6 +442,9 @@ typedef struct InputFile {
int index;
// input format has no timestamps
int format_nots;
AVFormatContext *ctx;
int eof_reached; /* true if eof reached */
int eagain; /* true if last read attempt returned EAGAIN */

View File

@ -1504,6 +1504,8 @@ int ifile_open(const OptionsContext *o, const char *filename)
d->duration = 0;
d->time_base = (AVRational){ 1, 1 };
f->format_nots = !!(ic->iformat->flags & AVFMT_NOTIMESTAMPS);
f->readrate = o->readrate ? o->readrate : 0.0;
if (f->readrate < 0.0f) {
av_log(d, AV_LOG_ERROR, "Option -readrate is %0.3f; it must be non-negative.\n", f->readrate);