From patchwork Thu Oct 10 01:47:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15647 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 AFFDD4487D1 for ; Thu, 10 Oct 2019 04:48:14 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8A8D9688100; Thu, 10 Oct 2019 04:48:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1D1C06880DD for ; Thu, 10 Oct 2019 04:48:08 +0300 (EEST) Received: by mail-pf1-f196.google.com with SMTP id q12so2815027pff.9 for ; Wed, 09 Oct 2019 18:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gNUNEUtKIoj7WtQxciFlm4wuRwyie6eobzQxx/TWO+c=; b=ftTXfzh4N/sMNDSJ5htfrB70TeFH15IUI3hb5VIXXDFbiGzJK/4bRiSBRMzX4P1jOo Y3SMnbX6/bUVYRiAGvGjzyw/jCKpxOygFAj68CaVpFDSVczTA86GyQqO+Corp/JqNC1p ng/wT5+9Y3UZ7hdLZov2u+WEDE7iexAc8Yaz3wUN6HBYJF6sXD8LXbXfMOjQrRQKt2Q+ cRa3U5fMSCZ5a6SLQuSp9NCabmezT59QQvv11iT5e4xb5u/uzcZRwktkODRci56fKhT1 vn2lVUmEulMJwDXSMH4Nk/axkhR6R0P0wcPRByujB4NRRSR3lq36S4O+d/lSdB3GNuEW c1nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gNUNEUtKIoj7WtQxciFlm4wuRwyie6eobzQxx/TWO+c=; b=L+vNeNk56RrGgB1DwnaXLJGMIto0KnpTz9v6yofF3xmALlZ5cK9GOhaXwy5KGIEvCM tAHNNTnYO1Cowo9qiftjFOqUqrT7fd2E2DcPNBfcib20oFhPzGg5iE3OtCOVDD/gGSzv LzN+JlqVvtj23fDPdxYOXuWeoaS/BK0WBl3a/trKoREmNQyw0rO8E5aF1+OEsPYBXro/ LnHkT0kxS4Vkd8piCVZfOwmLqtBrgXqbNJohrAfyz7eLpLfjailozGjB7KWQtJOZ+YdS Xply0nnEdSgWtT6YWFegXTvMw48Mt7USbczA6jmgajGwkruIYZvpmVqyA/9UPO8agLXz IjnA== X-Gm-Message-State: APjAAAVfQO9a4oVbmsC1+Yj7L/4dWbCUvri/HHvfoDNm5OcGry9/Sh1B /ougundA+uP/ALmZWX031lUmZTAn X-Google-Smtp-Source: APXvYqzz3eurWytMHeG7n8Vc/lFtr5Z4f8YOrkOGd7g+peEuAcjSYQBTh6Cg7vrw7TpTrV7V+IzEPA== X-Received: by 2002:a63:e055:: with SMTP id n21mr7523506pgj.411.1570672085881; Wed, 09 Oct 2019 18:48:05 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id y36sm3288051pgk.66.2019.10.09.18.48.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Oct 2019 18:48:05 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Oct 2019 09:47:59 +0800 Message-Id: <20191010014759.1430-1-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20190924011352.12712-1-lance.lmwang@gmail.com> References: <20190924011352.12712-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v1] avcodec/magicyuv: remove duplicate code 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Reviewed-by: Paul B Mahol Signed-off-by: Limin Wang --- Paul, I have updated with Reviewed-by, please help to push it if have time. libavcodec/magicyuv.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index f4fb2a7809..21a32785bc 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -547,10 +547,7 @@ static int magy_decode_frame(AVCodecContext *avctx, void *data, s->hshift[2] = s->vshift[2] = 0; s->decorrelate = 0; - s->max = 256; s->bps = 8; - s->huff_build = huff_build; - s->magy_decode_slice = magy_decode_slice; format = bytestream2_get_byte(&gbyte); switch (format) { @@ -587,61 +584,46 @@ static int magy_decode_frame(AVCodecContext *avctx, void *data, avctx->pix_fmt = AV_PIX_FMT_YUV422P10; s->hshift[1] = s->hshift[2] = 1; - s->max = 1024; - s->huff_build = huff_build10; - s->magy_decode_slice = magy_decode_slice10; s->bps = 10; break; case 0x76: avctx->pix_fmt = AV_PIX_FMT_YUV444P10; - s->max = 1024; - s->huff_build = huff_build10; - s->magy_decode_slice = magy_decode_slice10; s->bps = 10; break; case 0x6d: avctx->pix_fmt = AV_PIX_FMT_GBRP10; s->decorrelate = 1; - s->max = 1024; - s->huff_build = huff_build10; - s->magy_decode_slice = magy_decode_slice10; s->bps = 10; break; case 0x6e: avctx->pix_fmt = AV_PIX_FMT_GBRAP10; s->decorrelate = 1; - s->max = 1024; - s->huff_build = huff_build10; - s->magy_decode_slice = magy_decode_slice10; s->bps = 10; break; case 0x6f: avctx->pix_fmt = AV_PIX_FMT_GBRP12; s->decorrelate = 1; - s->max = 4096; - s->huff_build = huff_build12; - s->magy_decode_slice = magy_decode_slice10; s->bps = 12; break; case 0x70: avctx->pix_fmt = AV_PIX_FMT_GBRAP12; s->decorrelate = 1; - s->max = 4096; - s->huff_build = huff_build12; - s->magy_decode_slice = magy_decode_slice10; s->bps = 12; break; case 0x73: avctx->pix_fmt = AV_PIX_FMT_GRAY10; - s->max = 1024; - s->huff_build = huff_build10; - s->magy_decode_slice = magy_decode_slice10; s->bps = 10; break; default: avpriv_request_sample(avctx, "Format 0x%X", format); return AVERROR_PATCHWELCOME; } + s->max = 1 << s->bps; + s->magy_decode_slice = s->bps == 8 ? magy_decode_slice : magy_decode_slice10; + if ( s->bps == 8) + s->huff_build = huff_build; + else + s->huff_build = s->bps == 10 ? huff_build10 : huff_build12; s->planes = av_pix_fmt_count_planes(avctx->pix_fmt); bytestream2_skip(&gbyte, 1);