From patchwork Sat Feb 25 20:04:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: u-9iep@aetey.se X-Patchwork-Id: 2675 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.149 with SMTP id x21csp386350vsf; Sat, 25 Feb 2017 12:05:19 -0800 (PST) X-Received: by 10.223.163.213 with SMTP id m21mr8788410wrb.66.1488053119771; Sat, 25 Feb 2017 12:05:19 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b49si3737710wra.308.2017.02.25.12.05.19; Sat, 25 Feb 2017 12:05:19 -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; dkim=neutral (body hash did not verify) header.i=@fripost.org; 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 3B9CF6883CC; Sat, 25 Feb 2017 22:05:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from outgoing.fripost.org (giraff.fripost.org [178.16.208.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 21E616882F1 for ; Sat, 25 Feb 2017 22:05:00 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by outgoing.fripost.org (Postfix) with ESMTP id 200F5AB250D for ; Sat, 25 Feb 2017 21:05:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fripost.org; h= in-reply-to:content-disposition:content-type:content-type :mime-version:message-id:subject:subject:from:from:date:date; s= 20140703; t=1488053108; x=1489867509; bh=xA5tcnHB5ADLLid8SAsP0xr OW8e+Fa5F1fpJOMc0LLA=; b=lq6MGrfVkWash8X5QKVMMZLPL7NhmCCaJGVyBwr Res5VvrFiYOIhXiRTfYHFsQZsE2lU/6lUmf8yf0rI/w8dc33b6E7TAh8s6QoL6cj DxxAx0RgAPYvMuZ/5Iiw6jReVhIWDq+E8NQo3ZhmBCPvskOVjzMKFV0mXBnqDN1j n/9g= X-Virus-Scanned: Debian amavisd-new at fripost.org Received: from outgoing.fripost.org ([127.0.0.1]) by localhost (giraff.fripost.org [127.0.0.1]) (amavisd-new, port 10040) with LMTP id wqwjlhZYTZlN for ; Sat, 25 Feb 2017 21:05:08 +0100 (CET) Received: from smtp.fripost.org (unknown [172.16.0.6]) by outgoing.fripost.org (Postfix) with ESMTP id E4038AB2506 for ; Sat, 25 Feb 2017 21:05:08 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by smtp.fripost.org (Postfix) with ESMTPSA id 1A3F62A62C38 for ; Sat, 25 Feb 2017 21:05:07 +0100 (CET) Received: (qmail 14660 invoked from network); 25 Feb 2017 19:40:17 -0000 Received: from localhost (HELO aetey.se) (eh1ba719@127.0.0.1) by mail with ESMTPA; 25 Feb 2017 19:40:17 -0000 Date: Sat, 25 Feb 2017 21:04:51 +0100 From: u-9iep@aetey.se To: FFmpeg development discussions and patches Message-ID: <20170225200449.GH32749@example.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170215110155.GG32749@example.net> Subject: [FFmpeg-devel] [PATCH 2/2] Re: deduplicated [PATCH] Cinepak: speed up decoding several-fold, depending on the scenario, by supporting multiple output pixel formats. 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" Support for conditional compilation, a simple non-intrusive means to avoid binary bloat when this is relevant. OTOH this change adds some extra lines to the source, which may be acceptable or not. Regards, Rune From 11b5906e5161748b77bbad242ac28a49851c8b4f Mon Sep 17 00:00:00 2001 From: Rl Date: Sat, 25 Feb 2017 19:14:18 +0100 Subject: [PATCH 2/2] Cinepak decoding: allow selective build of support for output pixel formats. A simple non-intrusive means to avoid bloat if the library is being built for some specific scenario. --- libavcodec/cinepak.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c index 97836b3ab1..e32b07ce8a 100644 --- a/libavcodec/cinepak.c +++ b/libavcodec/cinepak.c @@ -46,6 +46,20 @@ #include "avcodec.h" #include "internal.h" +/* allow to choose which output formats are to be supported, + * if nothing specific is enabled explicitly, activate all */ +#if !defined(CINEPAK_ENABLE_DECODE_TO_RGB32) && \ + !defined(CINEPAK_ENABLE_DECODE_TO_RGB24) && \ + !defined(CINEPAK_ENABLE_DECODE_TO_RGB565) && \ + !defined(CINEPAK_ENABLE_DECODE_TO_YUV420P) && \ + !defined(CINEPAK_ENABLE_DECODE_TO_PAL8) +#define CINEPAK_ENABLE_DECODE_TO_RGB32 +#define CINEPAK_ENABLE_DECODE_TO_RGB24 +#define CINEPAK_ENABLE_DECODE_TO_RGB565 +#define CINEPAK_ENABLE_DECODE_TO_YUV420P +#define CINEPAK_ENABLE_DECODE_TO_PAL8 +#endif + /* rounding to nearest; truncation would be slightly faster * but it noticeably affects the picture quality; * unless we become extremely desperate to use every single cycle @@ -64,11 +78,21 @@ */ typedef union cvid_codebook { +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB32 uint32_t rgb32[256][ 4]; +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB24 uint8_t rgb24[256][12]; +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB565 uint16_t rgb565[256][ 4]; +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P uint8_t yuv420p[256][ 6]; +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_PAL8 uint8_t pal8[256][ 4]; +#endif } cvid_codebook; #define MAX_STRIPS 32 /* an arbitrary limit -- rl */ @@ -233,6 +257,7 @@ static int cinepak_decode_vectors_##pixel_format (CinepakContext *s, cvid_strip * (instead of in-loop checking) */\ VECTOR_STREAM_PARSING\ +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB32 DECODE_CODEBOOK(rgb32) uint32_t *p = codebook->rgb32[0]; @@ -320,7 +345,9 @@ DECODE_VECTORS(rgb32) return 0; } +#endif /* #ifdef CINEPAK_ENABLE_DECODE_TO_RGB32 */ +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB24 DECODE_CODEBOOK(rgb24) uint8_t *p = codebook->rgb24[0]; @@ -411,7 +438,9 @@ DECODE_VECTORS(rgb24) return 0; } +#endif /* #ifdef CINEPAK_ENABLE_DECODE_TO_RGB24 */ +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB565 DECODE_CODEBOOK(rgb565) uint16_t *p = codebook->rgb565[0]; @@ -498,7 +527,9 @@ DECODE_VECTORS(rgb565) return 0; } +#endif /* #ifdef CINEPAK_ENABLE_DECODE_TO_RGB565 */ +#ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P /* a simplistic version to begin with, it is also fast -- rl */ DECODE_CODEBOOK(yuv420p) uint8_t *p = codebook->yuv420p[0]; @@ -620,7 +651,9 @@ DECODE_VECTORS(yuv420p) return 0; } +#endif /* #ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P */ +#ifdef CINEPAK_ENABLE_DECODE_TO_PAL8 /* here we do not expect anything besides palettized video, * nor check the data for validity, which should be ok, * to the best of our knowledge we do not write beyond the bounds */ @@ -702,6 +735,7 @@ DECODE_VECTORS(pal8) return 0; } +#endif /* #ifdef CINEPAK_ENABLE_DECODE_TO_PAL8 */ static int cinepak_decode_strip (CinepakContext *s, cvid_strip *strip, const uint8_t *data, int size) @@ -844,20 +878,38 @@ static int cinepak_decode (CinepakContext *s) /* given a palettized input */ static const enum AVPixelFormat pixfmt_list[] = { +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB24 AV_PIX_FMT_RGB24, +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB32 AV_PIX_FMT_RGB32, +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB565 AV_PIX_FMT_RGB565, +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P AV_PIX_FMT_YUV420P, +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_PAL8 AV_PIX_FMT_PAL8, /* only when input is palettized */ +#endif AV_PIX_FMT_NONE }; /* given a non-palettized input */ static const enum AVPixelFormat pixfmt_list_2[] = { +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB24 AV_PIX_FMT_RGB24, +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB32 AV_PIX_FMT_RGB32, +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB565 AV_PIX_FMT_RGB565, +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P AV_PIX_FMT_YUV420P, +#endif AV_PIX_FMT_NONE }; @@ -891,16 +943,26 @@ static av_cold int cinepak_decode_init(AVCodecContext *avctx) break;\ switch (avctx->pix_fmt) { +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB32 case AV_PIX_FMT_RGB32: DECODE_TO(rgb32) +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB24 case AV_PIX_FMT_RGB24: DECODE_TO(rgb24) +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_RGB565 case AV_PIX_FMT_RGB565: DECODE_TO(rgb565) +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_YUV420P case AV_PIX_FMT_YUV420P: DECODE_TO(yuv420p) +#endif +#ifdef CINEPAK_ENABLE_DECODE_TO_PAL8 case AV_PIX_FMT_PAL8: if (!s->palette_video) { av_log(avctx, AV_LOG_ERROR, "Palettized output not supported without palettized input\n"); return AVERROR(EINVAL); } DECODE_TO(pal8) +#endif default: av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format %s\n", av_get_pix_fmt_name(avctx->pix_fmt)); return AVERROR(EINVAL);