ffmepgdecoder: simplify code and improve vairable name

This commit is contained in:
Thomas Wilshaw
2022-10-26 21:02:59 +01:00
parent 9bc10e8301
commit ddeab29da3
+5 -12
View File
@@ -350,14 +350,7 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
int64_t footage_duration = fmt_ctx->duration;
bool bad_duration = false;
// Catch when ffmpeg uses its inaccurate method of duration estimation so we can
// use manual calculation
if (fmt_ctx->duration_estimation_method == AVFMT_DURATION_FROM_BITRATE) {
bad_duration = true;
qWarning() << "Potentially bad duration estimation, using fallback. This could be slow.";
}
bool duration_guessed_from_bitrate = (fmt_ctx->duration_estimation_method == AVFMT_DURATION_FROM_BITRATE);
// Dump it into the Footage object
for (unsigned int i=0;i<fmt_ctx->nb_streams;i++) {
@@ -418,8 +411,8 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
if (ret >= 0) {
// Check if we need a manual duration
if (avstream->duration == AV_NOPTS_VALUE || bad_duration) {
if (footage_duration == AV_NOPTS_VALUE || bad_duration) {
if (avstream->duration == AV_NOPTS_VALUE || duration_guessed_from_bitrate) {
if (footage_duration == AV_NOPTS_VALUE || duration_guessed_from_bitrate) {
// Manually read through file for duration
int64_t new_dur;
@@ -477,9 +470,9 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
channel_layout = static_cast<uint64_t>(av_get_default_channel_layout(avstream->codecpar->channels));
}
if (avstream->duration == AV_NOPTS_VALUE || bad_duration) {
if (avstream->duration == AV_NOPTS_VALUE || duration_guessed_from_bitrate) {
// Loop through stream until we get the whole duration
if (footage_duration == AV_NOPTS_VALUE || bad_duration) {
if (footage_duration == AV_NOPTS_VALUE || duration_guessed_from_bitrate) {
Instance instance;
instance.Open(filename_c, avstream->index);