From patchwork Mon Jan 24 17:00:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 33807 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:e71a:0:0:0:0:0 with SMTP id b26csp496889ioh; Mon, 24 Jan 2022 09:02:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzaTk0HASnQZsWGhc8X9Q2S6Q6Ui3xVAUHpXGoI7RI5j/d1RjyCdOEbULZqTVdK5TEr6xRJ X-Received: by 2002:a05:6402:5174:: with SMTP id d20mr16885683ede.21.1643043769285; Mon, 24 Jan 2022 09:02:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643043769; cv=none; d=google.com; s=arc-20160816; b=NyIZAZDYHR9/YoMkbh43u74DGVqlTeUbLH2FWKxFq2IRFz8gffLLfRlcImPhnp/px9 U3oXjgJu12QF8k04IJT8qnWBNJTuZplnPVDTatrwFkktZGgpQnrGrrvvYYP5dkx1vXDn QlWvJhjASG8w3gsG4KUGVVkQevOIw/RbUuWNQpnQjul6ZJxmZMUyVohiufbpjA2XjdpF kn9mgDL/NiicPsLMlweR95A+FnLYRxPR2GoMK7C/KCfNuZF/4VV5/lD9VfrcdOca+rz2 HJI2W10l4B/eKG5K2ORFr4l016DhCDjVdGnorPlcxoh9v0oL8MSJVR+csCybrkPUDEn6 jthA== 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:delivered-to; bh=0spLpmjfllYG5lzcQrPDCjkfqwtbQCt3fCgKj6KTCNc=; b=cEgie9B96Mc49tMY8mIWL774coxQV+cYSbtTez7buIUP1XTHyrBmfrKIYpppkZBrts 2rRtlXjNhaiZxU1usGf6xsBLCMu5fXqO4dycvnW3tlJRrUN1H18b0Sd8PAWn5T5SvSSG 4kCzhL2gijPYHNDNbaPGfUT4MirDZW9NeiRsMqy2KhuZ6gZpTaK4eCGX+kkBFC6cyJGV Pon/8W1QX+/UMABN0mRVQR0ONDKXf0pVYzIXV71au8QW+8ZUCPXM0RKeXTdFTpE/xrB5 SQLnKHWS0Wsw/dkVVKm0cTspCUinNiTSCJMHLV77ejjTN4LiUucN9kRRmtrZ75IfzSfG 96iw== 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 gt31si555802ejc.194.2022.01.24.09.02.47; Mon, 24 Jan 2022 09:02: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 07FDB68B119; Mon, 24 Jan 2022 19:00:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DF76968B14F for ; Mon, 24 Jan 2022 19:00:37 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 991B924055A for ; Mon, 24 Jan 2022 18:00:36 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 3MemYBuPwtTn for ; Mon, 24 Jan 2022 18:00:32 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 1799D24050B for ; Mon, 24 Jan 2022 18:00:30 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id A6FAF3A06CD; Mon, 24 Jan 2022 18:00:26 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Jan 2022 18:00:08 +0100 Message-Id: <20220124170014.17189-7-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124170014.17189-1-anton@khirnov.net> References: <20220124170014.17189-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/13] lavc/h264: move some shared code from h264dec to h264_parse 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: ZUexMaJCN54Y --- libavcodec/h264_parse.h | 37 +++++++++++++++++++++++++++++++++++++ libavcodec/h264dec.h | 35 ----------------------------------- tests/checkasm/h264dsp.c | 1 + 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/libavcodec/h264_parse.h b/libavcodec/h264_parse.h index 9f329db77a..95a80c425f 100644 --- a/libavcodec/h264_parse.h +++ b/libavcodec/h264_parse.h @@ -24,6 +24,8 @@ #ifndef AVCODEC_H264_PARSE_H #define AVCODEC_H264_PARSE_H +#include "config.h" + #include #include "libavutil/common.h" @@ -32,6 +34,23 @@ #include "h264_ps.h" #include "internal.h" +// This table must be here because scan8[constant] must be known at compiletime +static const uint8_t scan8[16 * 3 + 3] = { + 4 + 1 * 8, 5 + 1 * 8, 4 + 2 * 8, 5 + 2 * 8, + 6 + 1 * 8, 7 + 1 * 8, 6 + 2 * 8, 7 + 2 * 8, + 4 + 3 * 8, 5 + 3 * 8, 4 + 4 * 8, 5 + 4 * 8, + 6 + 3 * 8, 7 + 3 * 8, 6 + 4 * 8, 7 + 4 * 8, + 4 + 6 * 8, 5 + 6 * 8, 4 + 7 * 8, 5 + 7 * 8, + 6 + 6 * 8, 7 + 6 * 8, 6 + 7 * 8, 7 + 7 * 8, + 4 + 8 * 8, 5 + 8 * 8, 4 + 9 * 8, 5 + 9 * 8, + 6 + 8 * 8, 7 + 8 * 8, 6 + 9 * 8, 7 + 9 * 8, + 4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8, + 6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8, + 4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8, + 6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 8, + 0 + 0 * 8, 0 + 5 * 8, 0 + 10 * 8 +}; + /** * Memory management control operation opcode. */ @@ -118,4 +137,22 @@ static inline int find_start_code(const uint8_t *buf, int buf_size, return FFMIN(buf_index, buf_size); } +static av_always_inline uint32_t pack16to32(unsigned a, unsigned b) +{ +#if HAVE_BIGENDIAN + return (b & 0xFFFF) + (a << 16); +#else + return (a & 0xFFFF) + (b << 16); +#endif +} + +static av_always_inline uint16_t pack8to16(unsigned a, unsigned b) +{ +#if HAVE_BIGENDIAN + return (b & 0xFF) + (a << 8); +#else + return (a & 0xFF) + (b << 8); +#endif +} + #endif /* AVCODEC_H264_PARSE_H */ diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 4a56463340..4441cf6613 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -643,41 +643,6 @@ void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl, int mb_x, int #define LUMA_DC_BLOCK_INDEX 48 #define CHROMA_DC_BLOCK_INDEX 49 -// This table must be here because scan8[constant] must be known at compiletime -static const uint8_t scan8[16 * 3 + 3] = { - 4 + 1 * 8, 5 + 1 * 8, 4 + 2 * 8, 5 + 2 * 8, - 6 + 1 * 8, 7 + 1 * 8, 6 + 2 * 8, 7 + 2 * 8, - 4 + 3 * 8, 5 + 3 * 8, 4 + 4 * 8, 5 + 4 * 8, - 6 + 3 * 8, 7 + 3 * 8, 6 + 4 * 8, 7 + 4 * 8, - 4 + 6 * 8, 5 + 6 * 8, 4 + 7 * 8, 5 + 7 * 8, - 6 + 6 * 8, 7 + 6 * 8, 6 + 7 * 8, 7 + 7 * 8, - 4 + 8 * 8, 5 + 8 * 8, 4 + 9 * 8, 5 + 9 * 8, - 6 + 8 * 8, 7 + 8 * 8, 6 + 9 * 8, 7 + 9 * 8, - 4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8, - 6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8, - 4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8, - 6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 8, - 0 + 0 * 8, 0 + 5 * 8, 0 + 10 * 8 -}; - -static av_always_inline uint32_t pack16to32(unsigned a, unsigned b) -{ -#if HAVE_BIGENDIAN - return (b & 0xFFFF) + (a << 16); -#else - return (a & 0xFFFF) + (b << 16); -#endif -} - -static av_always_inline uint16_t pack8to16(unsigned a, unsigned b) -{ -#if HAVE_BIGENDIAN - return (b & 0xFF) + (a << 8); -#else - return (a & 0xFF) + (b << 8); -#endif -} - /** * Get the chroma qp. */ diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c index 7392452957..3c95f9d74d 100644 --- a/tests/checkasm/h264dsp.c +++ b/tests/checkasm/h264dsp.c @@ -23,6 +23,7 @@ #include "libavcodec/avcodec.h" #include "libavcodec/h264dsp.h" #include "libavcodec/h264data.h" +#include "libavcodec/h264_parse.h" #include "libavutil/common.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h"