From patchwork Mon Sep 19 17:14:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 648 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp1085326vsd; Mon, 19 Sep 2016 10:14:39 -0700 (PDT) X-Received: by 10.28.132.71 with SMTP id g68mr9453707wmd.20.1474305279770; Mon, 19 Sep 2016 10:14:39 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id qe3si19543256wjc.196.2016.09.19.10.14.38; Mon, 19 Sep 2016 10:14:39 -0700 (PDT) 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 A8A6A689D9D; Mon, 19 Sep 2016 20:14:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-3.mx.upcmail.net (vie01a-dmta-pe03-3.mx.upcmail.net [62.179.121.162]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BD1D4689BAA for ; Mon, 19 Sep 2016 20:14:15 +0300 (EEST) Received: from [172.31.216.44] (helo=vie01a-pemc-psmtp-pe02) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1bm29F-0000QO-Oh for ffmpeg-devel@ffmpeg.org; Mon, 19 Sep 2016 19:14:29 +0200 Received: from [192.168.1.3] ([80.110.110.42]) by vie01a-pemc-psmtp-pe02 with SMTP @ mailcloud.upcmail.net id lVEU1t00l0uvkXC01VEVXj; Mon, 19 Sep 2016 19:14:29 +0200 X-SourceIP: 80.110.110.42 From: Carl Eugen Hoyos To: FFmpeg development discussions and patches Date: Mon, 19 Sep 2016 19:14:28 +0200 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Message-Id: <201609191914.28478.cehoyos@ag.or.at> Subject: [FFmpeg-devel] [PATCH]lavc/rscc: Support pal8 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" Hi! Attached patch fixes the colours for the sample in ticket #5611. Please comment, Carl Eugen From 7af0c224f5c0fd8dec095ba5333a87257ffccd85 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 19 Sep 2016 19:12:12 +0200 Subject: [PATCH] lavc/rscc: Support pal8 in rscc. Fixes the colours for the sample in ticket #5611. --- libavcodec/rscc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c index 3b3703c..6d4b5af 100644 --- a/libavcodec/rscc.c +++ b/libavcodec/rscc.c @@ -31,7 +31,7 @@ * and it can be deflated or not. Similarly, pixel data comes after the header * and a variable size value, and it can be deflated or just raw. * - * Supports: GRAY8, BGRA, BGR24, RGB555, RGB8 + * Supports: PAL8, BGRA, BGR24, RGB555, RGB8 */ #include @@ -58,6 +58,8 @@ typedef struct RsccContext { Tile *tiles; unsigned int tiles_size; int component_size; + uint32_t pal[AVPALETTE_COUNT]; + int pal_size; /* zlib interaction */ uint8_t *inflated_buf; @@ -86,10 +88,18 @@ static av_cold int rscc_init(AVCodecContext *avctx) avctx->pix_fmt = AV_PIX_FMT_BGRA; ctx->component_size = 4; } else if (avctx->codec_tag == MKTAG('R', 'S', 'C', 'C')) { + int i; + uint8_t *pal; ctx->component_size = avctx->bits_per_coded_sample / 8; switch (avctx->bits_per_coded_sample) { case 8: - avctx->pix_fmt = AV_PIX_FMT_GRAY8; + avctx->pix_fmt = AV_PIX_FMT_PAL8; + pal = avctx->extradata; + ctx->pal_size = FFMIN(avctx->extradata_size, AVPALETTE_SIZE); + for (i = 0; i < ctx->pal_size / 4; i++) { + ctx->pal[i] = 0xFFU << 24 | AV_RL32(pal); + pal += 4; + } break; case 16: avctx->pix_fmt = AV_PIX_FMT_RGB555LE; @@ -308,6 +318,8 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data, } else { frame->pict_type = AV_PICTURE_TYPE_P; } + if (avctx->pix_fmt == AV_PIX_FMT_PAL8) + memcpy(frame->data[1], ctx->pal, ctx->pal_size); *got_frame = 1; end: