From patchwork Sat Feb 6 17:39:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 25469 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D3CAF44BE96 for ; Sat, 6 Feb 2021 19:48:41 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A2E57688385; Sat, 6 Feb 2021 19:48:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E6BEB687F75 for ; Sat, 6 Feb 2021 19:48:34 +0200 (EET) Received: by mail-qk1-f170.google.com with SMTP id t63so10352377qkc.1 for ; Sat, 06 Feb 2021 09:48:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=S46DxqP6ERnJRJK2ObZL7aQAbjChEs1VYMxXL+SUbsU=; b=cYY01Vw7RB+hAniJUg37g3uSSxAA0i3d9CboOGhZYjRL+l6EhfNrv4InOXsGl09bh3 4JAlAGbPHPWelhhHER6eEaztqghZ5aetsdBabFGwTZSUjCKGkIzSwpAJcBxz3BOOsfpR WwWvnJywEu7l34cdvRBwHacEENj0hsdSuzjFho3YhTtxB6VhV8f/8QzGgddsrQc4WCpL FYJwLbC4saRV4GPH1A4bMAfDj0TBqrJhccfVlb8aoRvaYl/Qo+hrAeJvjd2geZZYNFyq 1ozUMYhdeCR5oRPUO8E//O34StUpCnJD3NdfpKbRk+uTCOTKsvQ2qnkWaVA0zrhQlv7t M9ZQ== 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:mime-version :content-transfer-encoding; bh=S46DxqP6ERnJRJK2ObZL7aQAbjChEs1VYMxXL+SUbsU=; b=XgssIsMKAsde/6QoWgqP41YRvK1wWKSDEAvPtayLDPO+XW9t1sgl0fgULWHKaTPTLe 4NWs93pGs/VjMkeGuwgRpNBXyeJh0Cv65ZBEyE7u3puq0/I9s84df2G6Jj9PXlf6lREh y8EqxFARmniSsJIs3RGyvJZFkcTQUvWOsf3+suzO2g1dOZ0WqxGfXfZ/gqjF8spRub/o JPNWpwZUcuOFrgX0xSJXXwHtMGSHzxsKuLKVlwjy9aDF52A0Ksl3wXno3chF4kHTTtb1 xG2p1QOVb/hsWQn1347N9scoqFJKjc3c0YdpetrQM5nAwl0DswyEdCXRx4buTDKW4+aX nIWw== X-Gm-Message-State: AOAM532YxvHxxut2K36ikiCLhvAzuqKUXCT0L5M2hvOSr/knj2Cj4IvL U7v86V+/+fQHI+J22k47+y+Uu/4YVT4= X-Google-Smtp-Source: ABdhPJw64IFGr7OWZrl/yYyvvBpsDbMNl56f0bTWrVMi3JcIkVQ7t9g8+66WXtedsPEl9YDhlf+afA== X-Received: by 2002:a05:620a:2225:: with SMTP id n5mr1413917qkh.97.1612633263301; Sat, 06 Feb 2021 09:41:03 -0800 (PST) Received: from localhost.localdomain ([181.23.64.183]) by smtp.gmail.com with ESMTPSA id j11sm13117917qkm.47.2021.02.06.09.41.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Feb 2021 09:41:02 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 Feb 2021 14:39:24 -0300 Message-Id: <20210206173924.53030-1-jamrial@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/utils: force lowres to 0 in avformat_find_stream_info() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Instead of applying it and then restoring the original codecpar dimensions. Signed-off-by: James Almer --- Alternative to "[PATCH] avformat/utils: always preserve container dimensions for all streams" while we figure out and decide how to properly make avformat_find_stream_info() export the container dimensions and not what the probing decoder uses internally. libavformat/utils.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index fb3299503e..3e955b85bc 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3021,6 +3021,10 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, /* Force thread count to 1 since the H.264 decoder will not extract * SPS and PPS to extradata during multi-threaded decoding. */ av_dict_set(options ? options : &thread_opt, "threads", "1", 0); + /* Force lowres to 0. The decoder might reduce the video size by the + * lowres factor, and we don't want that propagated to the stream's + * codecpar */ + av_dict_set(options ? options : &thread_opt, "lowres", "0", 0); if (s->codec_whitelist) av_dict_set(options ? options : &thread_opt, "codec_whitelist", s->codec_whitelist, 0); ret = avcodec_open2(avctx, codec, options ? options : &thread_opt); @@ -3662,6 +3666,10 @@ FF_ENABLE_DEPRECATION_WARNINGS /* Force thread count to 1 since the H.264 decoder will not extract * SPS and PPS to extradata during multi-threaded decoding. */ av_dict_set(options ? &options[i] : &thread_opt, "threads", "1", 0); + /* Force lowres to 0. The decoder might reduce the video size by the + * lowres factor, and we don't want that propagated to the stream's + * codecpar */ + av_dict_set(options ? &options[i] : &thread_opt, "lowres", "0", 0); if (ic->codec_whitelist) av_dict_set(options ? &options[i] : &thread_opt, "codec_whitelist", ic->codec_whitelist, 0); @@ -4108,21 +4116,12 @@ FF_ENABLE_DEPRECATION_WARNINGS st = ic->streams[i]; if (st->internal->avctx_inited) { - int orig_w = st->codecpar->width; - int orig_h = st->codecpar->height; ret = avcodec_parameters_from_context(st->codecpar, st->internal->avctx); if (ret < 0) goto find_stream_info_err; ret = add_coded_side_data(st, st->internal->avctx); if (ret < 0) goto find_stream_info_err; -#if FF_API_LOWRES - // The decoder might reduce the video size by the lowres factor. - if (st->internal->avctx->lowres && orig_w) { - st->codecpar->width = orig_w; - st->codecpar->height = orig_h; - } -#endif } #if FF_API_LAVF_AVCTX