From patchwork Sun Sep 25 12:31:41 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: 714 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp1438250vsd; Sun, 25 Sep 2016 05:31:52 -0700 (PDT) X-Received: by 10.28.69.85 with SMTP id s82mr10994805wma.37.1474806712741; Sun, 25 Sep 2016 05:31:52 -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 hr7si15262809wjb.178.2016.09.25.05.31.52; Sun, 25 Sep 2016 05:31:52 -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 960C4689E10; Sun, 25 Sep 2016 15:31:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-1.mx.upcmail.net (vie01a-dmta-pe02-1.mx.upcmail.net [62.179.121.157]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F2F69689CEA for ; Sun, 25 Sep 2016 15:31:26 +0300 (EEST) Received: from [172.31.216.44] (helo=vie01a-pemc-psmtp-pe02) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1bo8as-0002RV-R6 for ffmpeg-devel@ffmpeg.org; Sun, 25 Sep 2016 14:31:42 +0200 Received: from [192.168.1.3] ([80.110.105.150]) by vie01a-pemc-psmtp-pe02 with SMTP @ mailcloud.upcmail.net id noXh1t00R3Eipyg01oXioK; Sun, 25 Sep 2016 14:31:42 +0200 X-SourceIP: 80.110.105.150 From: Carl Eugen Hoyos To: FFmpeg development discussions and patches Date: Sun, 25 Sep 2016 14:31:41 +0200 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Message-Id: <201609251431.41406.cehoyos@ag.or.at> Subject: [FFmpeg-devel] [PATCH]lavc/8bps: Fix 32bit output of 24bit video 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 a long-time regression. Please comment, Carl Eugen From 2b991a66c4bf14774210e2c7bfb0bb5f0e4f1b8f Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 25 Sep 2016 14:27:43 +0200 Subject: [PATCH] lavc/8bps: Fix 32bit output of 24bit video. Regression since / partial revert of ba3bb53b --- libavcodec/8bps.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index 46344e0..49fd445 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -41,7 +41,7 @@ static const enum AVPixelFormat pixfmt_rgb24[] = { - AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE }; + AV_PIX_FMT_BGR24, AV_PIX_FMT_0RGB32, AV_PIX_FMT_NONE }; typedef struct EightBpsContext { AVCodecContext *avctx; @@ -65,6 +65,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, unsigned int dlen, p, row; const unsigned char *lp, *dp, *ep; unsigned char count; + unsigned int px_inc; unsigned int planes = c->planes; unsigned char *planemap = c->planemap; int ret; @@ -77,6 +78,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, /* Set data pointer after line lengths */ dp = encoded + planes * (height << 1); + px_inc = planes + (avctx->pix_fmt == AV_PIX_FMT_0RGB32); + for (p = 0; p < planes; p++) { /* Lines length pointer for this plane */ lp = encoded + p * (height << 1); @@ -95,21 +98,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, if ((count = *dp++) <= 127) { count++; dlen -= count + 1; - if (pixptr_end - pixptr < count * planes) + if (pixptr_end - pixptr < count * px_inc) break; if (ep - dp < count) return AVERROR_INVALIDDATA; while (count--) { *pixptr = *dp++; - pixptr += planes; + pixptr += px_inc; } } else { count = 257 - count; - if (pixptr_end - pixptr < count * planes) + if (pixptr_end - pixptr < count * px_inc) break; while (count--) { *pixptr = *dp; - pixptr += planes; + pixptr += px_inc; } dp++; dlen -= 2;