From patchwork Mon May 3 13:31:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 27572 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a10:399:0:0:0:0 with SMTP id 25csp257514pxh; Mon, 3 May 2021 06:33:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztSd+wMYVqVvDc7O1g2CpuI+qSuM4JJ5j4GNLbYxcwjF7zgbG26+zEIJuMHyndzpPiTKKG X-Received: by 2002:a17:907:11db:: with SMTP id va27mr16536812ejb.174.1620048781795; Mon, 03 May 2021 06:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620048781; cv=none; d=google.com; s=arc-20160816; b=VmnK4zVdNHPaMvWtlnxRPukvgkwHS2+udJSRqA4N69/N92aG9EFP2fC7h67ncG9CX4 dtL0VN/rGQnlt6V3albQa/RIg9KPtr1Kub7IisnBYRcxFkn8oN2yOl40C9dZFggTz2xf 22diBjS/iAREsmjHTqaocVOt4fAYuMX6geHS5F2LHtqMGTl//rtQrurYhAnJ2QFC0lRy YAB1qkoKjqZzT/VMtfCYhFc2fnI2AhNM7ZrxubAdyVWk8b4dZfqcbvx6ccQDUUyiAJF6 7GqAPCuPQBZtFq5cTqXT3JWOh3H6YzdMJAcL72XqUzBKkzaWkwXQ7kMh3zXe1a6DtR/0 rlHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=+jmeVsHGdaeQzbYsLZ//ojzqTLUl3x2XUW/SuLPPtVw=; b=paAVsxT1aDA8lqC1u4oA/kmFECCb/myBvfBmIEmxZwWIsai3S6kI8uakbJs796nRzU dXVHjqx/D32ZpOlUaEFjSJPGKiUN9veayFTR/Ja2wnHDW6qCqhGt+JKaIb3Umh5vxr7b n7ecJMm70C0MFL1iTGmMusPt8Tsxe0A2P22DFNQ/eXi0PWQ2KkOdsAUAlgQNktMXk3we GIC7VLJVkM6xwIG3Nh0XwivH3ncHw6fXymubTIzq0A4qxpKQK+kRnPMXScEcG1d9cbW9 1xtXUmH9/Fu5SUlMwhRX2m4TUBWFyO0camNWKNcWEdYzngpRFkfz2sI1KGYHioKAtx8s vehA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="GFKq/ezW"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k26si3928078edr.261.2021.05.03.06.33.01; Mon, 03 May 2021 06:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="GFKq/ezW"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C60E3687FDE; Mon, 3 May 2021 16:32:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AFD3A688051 for ; Mon, 3 May 2021 16:32:27 +0300 (EEST) Received: by mail-qk1-f182.google.com with SMTP id x8so4968677qkl.2 for ; Mon, 03 May 2021 06:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ItG0zCb62Fl0Rf/WRFfFDaME0ZPYCX/czOQYuH/nukU=; b=GFKq/ezWyGcJkNgd5+0FxyaBnxogmau1QS56AX72ZrMAlWqdirYzs+yXNoRVpygG+Z XxXhOgLZFhT5j4WVcjItiJT6sJzIGA3YBX2Vh25YqoM07k8DUIllMkcDBv0aq8cIFlzC ound7TT4CoPSvdGaWb/kwsbQooV6fw5EAhB0zGZ6WYgA9ey4eF+rtgiwR9E8T2BXB2rz 3D9D0CZarwnaA3gR+mgoz2ZeaHqA1wH5fxbfIvq8Jvs1DABaR7HS5ARu8vqrEsm2b0dB +twnGe/bl6Fu8PpjsBFyfWSKxpcxp9FFx9KKtBCU6sexSKr1ZBWdv+D0bIk4eeCsPuUL b4pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ItG0zCb62Fl0Rf/WRFfFDaME0ZPYCX/czOQYuH/nukU=; b=F1nyxiNhJ7CxlCXW7w0toQqWhcvrzAcunFcIufT2pDmApDIlcqZa79UZ+uWPNGN/zE NO2ukaEtDZbqu7JZQWmZdMHFlRgvRshYopeUKx9i9Dgx31/NMKUh9hpMl9D0BkdMXddQ ea4RU5FMb9i3a9OhM9Ygm4wpnZGN0Fc1c9qGaTx/Yd4ZfJRwHGAkZ+qaecc4kRLrbgID ggC7ohR3MElUtjaMFPq06CckAjSAWP1HhwfDW3mw5qiKOxevLIWuV0/m9BJPKyQ7Npo9 DfDZ/c3NBKaqMNupfUDtrGLmFFka90uVuW3Z7QrOk7g5AUdpzcnc1vA3vOzIHQUegQ2+ LbmA== X-Gm-Message-State: AOAM5329ACdeVKx6sTpJSoynoNMu1vvRJ758zOidAMeX/fEekP/MjwoJ by9KoDzOK4IolABKEaA9wv2nNnHU5Lg= X-Received: by 2002:ae9:f819:: with SMTP id x25mr19064790qkh.68.1620048745421; Mon, 03 May 2021 06:32:25 -0700 (PDT) Received: from localhost.localdomain ([191.83.208.172]) by smtp.gmail.com with ESMTPSA id 189sm5751929qkh.99.2021.05.03.06.32.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 06:32:24 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 May 2021 10:31:59 -0300 Message-Id: <20210503133200.1434-4-jamrial@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503133200.1434-1-jamrial@gmail.com> References: <20210503133200.1434-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] avformat: move AVStream.codec_info_nb_frames to AVStreamInternal X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +Jnla1CPoW0I It's a private field, no reason to have it exposed in a public header. Signed-off-by: James Almer --- libavformat/avformat.h | 5 ----- libavformat/dump.c | 2 +- libavformat/internal.h | 5 +++++ libavformat/utils.c | 30 +++++++++++++++--------------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 9ed6d333d3..ecf76b4bfc 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1003,11 +1003,6 @@ typedef struct AVStream { int64_t first_dts; int64_t cur_dts; - /** - * Number of frames that have been demuxed during avformat_find_stream_info() - */ - int codec_info_nb_frames; - /** * Stream Identifier * This is the MPEG-TS stream identifier +1 diff --git a/libavformat/dump.c b/libavformat/dump.c index 04c93dd7d3..cf892de107 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -544,7 +544,7 @@ static void dump_stream_format(const AVFormatContext *ic, int i, av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id); if (lang) av_log(NULL, AV_LOG_INFO, "(%s)", lang->value); - av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames, + av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->internal->codec_info_nb_frames, st->time_base.num, st->time_base.den); av_log(NULL, AV_LOG_INFO, ": %s", buf); diff --git a/libavformat/internal.h b/libavformat/internal.h index 928ec6edf2..94115960ea 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -377,6 +377,11 @@ struct AVStreamInternal { /* av_read_frame() support */ enum AVStreamParseType need_parsing; struct AVCodecParserContext *parser; + + /** + * Number of frames that have been demuxed during avformat_find_stream_info() + */ + int codec_info_nb_frames; }; #ifdef __GNUC__ diff --git a/libavformat/utils.c b/libavformat/utils.c index 3ccebce2b9..8fbb6bfc13 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1793,7 +1793,7 @@ int av_find_default_stream_index(AVFormatContext *s) if (st->codecpar->sample_rate) score += 50; } - if (st->codec_info_nb_frames) + if (st->internal->codec_info_nb_frames) score += 12; if (st->discard != AVDISCARD_ALL) @@ -2677,7 +2677,7 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic) break; } bit_rate += st->codecpar->bit_rate; - } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 1) { + } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->internal->codec_info_nb_frames > 1) { // If we have a videostream with packets but without a bitrate // then consider the sum not known bit_rate = 0; @@ -2941,7 +2941,7 @@ static int has_codec_parameters(AVStream *st, const char **errmsg_ptr) if (st->internal->info->found_decoder >= 0 && avctx->pix_fmt == AV_PIX_FMT_NONE) FAIL("unspecified pixel format"); if (st->codecpar->codec_id == AV_CODEC_ID_RV30 || st->codecpar->codec_id == AV_CODEC_ID_RV40) - if (!st->sample_aspect_ratio.num && !st->codecpar->sample_aspect_ratio.num && !st->codec_info_nb_frames) + if (!st->sample_aspect_ratio.num && !st->codecpar->sample_aspect_ratio.num && !st->internal->codec_info_nb_frames) FAIL("no frame in rv30/40 and no sar"); break; case AVMEDIA_TYPE_SUBTITLE: @@ -3018,7 +3018,7 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, while ((pkt.size > 0 || (!pkt.data && got_picture)) && ret >= 0 && (!has_codec_parameters(st, NULL) || !has_decode_delay_been_guessed(st) || - (!st->codec_info_nb_frames && + (!st->internal->codec_info_nb_frames && (avctx->codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)))) { got_picture = 0; if (avctx->codec_type == AVMEDIA_TYPE_VIDEO || @@ -3696,7 +3696,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) break; if (st->first_dts == AV_NOPTS_VALUE && !(ic->iformat->flags & AVFMT_NOTIMESTAMPS) && - st->codec_info_nb_frames < ((st->disposition & AV_DISPOSITION_ATTACHED_PIC) ? 1 : ic->max_ts_probe) && + st->internal->codec_info_nb_frames < ((st->disposition & AV_DISPOSITION_ATTACHED_PIC) ? 1 : ic->max_ts_probe) && (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)) break; @@ -3767,7 +3767,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) st->internal->avctx_inited = 1; } - if (pkt->dts != AV_NOPTS_VALUE && st->codec_info_nb_frames > 1) { + if (pkt->dts != AV_NOPTS_VALUE && st->internal->codec_info_nb_frames > 1) { /* check for non-increasing dts */ if (st->internal->info->fps_last_dts != AV_NOPTS_VALUE && st->internal->info->fps_last_dts >= pkt->dts) { @@ -3775,7 +3775,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) "Non-increasing DTS in stream %d: packet %d with DTS " "%"PRId64", packet %d with DTS %"PRId64"\n", st->index, st->internal->info->fps_last_dts_idx, - st->internal->info->fps_last_dts, st->codec_info_nb_frames, + st->internal->info->fps_last_dts, st->internal->codec_info_nb_frames, pkt->dts); st->internal->info->fps_first_dts = st->internal->info->fps_last_dts = AV_NOPTS_VALUE; @@ -3792,7 +3792,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) "DTS discontinuity in stream %d: packet %d with DTS " "%"PRId64", packet %d with DTS %"PRId64"\n", st->index, st->internal->info->fps_last_dts_idx, - st->internal->info->fps_last_dts, st->codec_info_nb_frames, + st->internal->info->fps_last_dts, st->internal->codec_info_nb_frames, pkt->dts); st->internal->info->fps_first_dts = st->internal->info->fps_last_dts = AV_NOPTS_VALUE; @@ -3801,22 +3801,22 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) /* update stored dts values */ if (st->internal->info->fps_first_dts == AV_NOPTS_VALUE) { st->internal->info->fps_first_dts = pkt->dts; - st->internal->info->fps_first_dts_idx = st->codec_info_nb_frames; + st->internal->info->fps_first_dts_idx = st->internal->codec_info_nb_frames; } st->internal->info->fps_last_dts = pkt->dts; - st->internal->info->fps_last_dts_idx = st->codec_info_nb_frames; + st->internal->info->fps_last_dts_idx = st->internal->codec_info_nb_frames; } - if (st->codec_info_nb_frames>1) { + if (st->internal->codec_info_nb_frames>1) { int64_t t = 0; int64_t limit; if (st->time_base.den > 0) t = av_rescale_q(st->internal->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q); if (st->avg_frame_rate.num > 0) - t = FFMAX(t, av_rescale_q(st->codec_info_nb_frames, av_inv_q(st->avg_frame_rate), AV_TIME_BASE_Q)); + t = FFMAX(t, av_rescale_q(st->internal->codec_info_nb_frames, av_inv_q(st->avg_frame_rate), AV_TIME_BASE_Q)); if ( t == 0 - && st->codec_info_nb_frames>30 + && st->internal->codec_info_nb_frames>30 && st->internal->info->fps_first_dts != AV_NOPTS_VALUE && st->internal->info->fps_last_dts != AV_NOPTS_VALUE) { int64_t dur = av_sat_sub64(st->internal->info->fps_last_dts, st->internal->info->fps_first_dts); @@ -3872,7 +3872,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) if (ic->flags & AVFMT_FLAG_NOBUFFER) av_packet_unref(pkt1); - st->codec_info_nb_frames++; + st->internal->codec_info_nb_frames++; count++; } @@ -4150,7 +4150,7 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, } disposition = !(st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED | AV_DISPOSITION_VISUAL_IMPAIRED)) + !! (st->disposition & AV_DISPOSITION_DEFAULT); - count = st->codec_info_nb_frames; + count = st->internal->codec_info_nb_frames; bitrate = par->bit_rate; multiframe = FFMIN(5, count); if ((best_disposition > disposition) ||