From patchwork Tue Nov 14 17:20:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44663 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a5:b0:181:818d:5e7f with SMTP id q37csp2134750pzg; Tue, 14 Nov 2023 09:21:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvu5C3qVpA/FvdEFXid2gqGSUnND3eCkxNhCIhfHNBfUX9C6JWcoD9ImxFDJZspi5RL/WO X-Received: by 2002:a17:906:3615:b0:9be:834a:f80b with SMTP id q21-20020a170906361500b009be834af80bmr7879499ejb.75.1699982509080; Tue, 14 Nov 2023 09:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699982509; cv=none; d=google.com; s=arc-20160816; b=JOB+p+TGq2bVCKGKbfqpehCa+kSc0+9rE3sMNEshYR+XXFauSbJ3b24RrQyS76xgk+ shvNV6F8A1K8erkCBtR0HB6b4U8dVWKciBxvIolrEpV9w5raQ9a8GwR9V/qFrKXat1jr uiHirQAwuK8g4pw/MM8n7bVXNe134BPXMI3SDWFsB+v4DA0ZRdHWP73/pxt9HuAWvASv LZjRae9cAnqCX3ZK6p53myAoA/Jg8DSHptJ7mSHUBwIElRWm4+QGgpjdrH3p9QhNFbqn 3B9TruL51WCoge5BBoPOzk3mwsIbJwTHrkRppQbP+hp41WastgRAwvWBcJjSYDsYFdjC 7lSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=iTB44fQsJe3dIITYAXfiLHOiLwKAJGOFw1HlyXA7fMA=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=enfPoXm/fxeZ0Wroa/RjFNj5wACWCRO4nbpTTECxuTg0ToGNC9+UJ2Hc1nmgBtXWsl XOKN25Ux334DHADTpbxyfKq4+zUOLvVkiQMGyGPSG/vW0ungQyhwWCC+TJSfYamlQxB8 ZK8GVPs+Flv7Pxc5wev8I1IQo23WLe3gxV3zyduNuuQY0X0A658ZtlIn7Cfj6n3dccEL iApo0A0uW7BG+GO1mbLm6t5ehDFn9g0EC/LOp0eorTFX1ke2pMwIUGTjfoefd9m/nhW+ 4zL2o57jNqXbVJUhYprPqIttj7WnBn4EV8xhVlYrujyYYMUf1LNbMbmnDQVHoyAOpOXv axkA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g19-20020a170906395300b009ae027abbc0si4107063eje.1034.2023.11.14.09.21.48; Tue, 14 Nov 2023 09:21:49 -0800 (PST) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8766468CC56; Tue, 14 Nov 2023 19:21:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 57A1368CD70 for ; Tue, 14 Nov 2023 19:20:57 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id ACF12FF809 for ; Tue, 14 Nov 2023 17:20:56 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 14 Nov 2023 18:20:51 +0100 Message-Id: <20231114172051.13872-6-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231114172051.13872-1-michael@niedermayer.cc> References: <20231114172051.13872-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 6/6] avcodec/h264dec: Support skipping frames that used gray gap frames 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: XigWfhM3QnNZ Signed-off-by: Michael Niedermayer --- libavcodec/h264dec.c | 7 +++++++ libavcodec/h264dec.h | 1 + 2 files changed, 8 insertions(+) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index b48821db244..aa0022a3aba 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -939,6 +939,12 @@ static int finalize_frame(H264Context *h, AVFrame *dst, H264Picture *out, int *g (h->avctx->flags2 & AV_CODEC_FLAG2_SHOW_ALL) || out->recovered)) { + if (h->skip_gray > 0 && + h->non_gray && out->gray && + !(h->avctx->flags2 & AV_CODEC_FLAG2_SHOW_ALL) + ) + return 0; + if (!h->avctx->hwaccel && (out->field_poc[0] == INT_MAX || out->field_poc[1] == INT_MAX) @@ -1091,6 +1097,7 @@ static const AVOption h264_options[] = { { "nal_length_size", "nal_length_size", OFFSET(nal_length_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VDX }, { "enable_er", "Enable error resilience on damaged frames (unsafe)", OFFSET(enable_er), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VD }, { "x264_build", "Assume this x264 version if no x264 version found in any SEI", OFFSET(x264_build), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VD }, + { "skip_gray", "Do not return gray gap frames", OFFSET(skip_gray), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VD }, { "noref_gray", "Avoid using gray gap frames as references", OFFSET(noref_gray), AV_OPT_TYPE_INT, {.i64 = 1}, -1, 1, VD }, { NULL }, }; diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 591769ab258..447c2499d97 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -572,6 +572,7 @@ typedef struct H264Context { int non_gray; ///< Did we encounter a intra frame after a gray gap frame int noref_gray; + int skip_gray; } H264Context; extern const uint16_t ff_h264_mb_sizes[4];