From patchwork Mon Sep 10 09:30:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 10289 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp2249610jap; Mon, 10 Sep 2018 02:30:37 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda9s5VVGlrMWFSs0dLxOFAks2fBn79lCKGBW+YO0db7oTk5ADMxkdvNThcOB7gtQSnSemCN X-Received: by 2002:a05:6000:c:: with SMTP id h12mr14993435wrx.103.1536571837010; Mon, 10 Sep 2018 02:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536571836; cv=none; d=google.com; s=arc-20160816; b=ursy6LVOoFdbqlEeN02rRiHXioYlwxFh+eTa29yV5LVGszarGbxQKo26tVjggvMszn g2sa0IdoqA26300zA6pqeVTlg/NyBln/4ualkDJjv+nETKtPXLyIRIX3cnK7+2eiIdXE 8j1OHoLqPUnpfJwi2rqzXiFUtPYGgXCM/BByF9EKnEwxK6tgoaFbJ2z5vdyrYRRNQkwF 9a2EMHMbHZPAEkBu9BuBH7wAlGmnbnLpAbLr29IOQsTKqaJjTYnE/Pn7+a9r21b1sN6K h7rR1Tr/m8gTx3R92JgHOpKIsxATnHeWKb9nIMUF2YBjUm5PTEndP2+ClYSolTXR/4oB 6X6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to; bh=NF+KZ4dIBNAhu84gPh7Dj7O3wRZfoyWKyfXYdNhmXSQ=; b=noZaQH7EewwTYrhqv8HJW1d+M8WpnxN375Kfc1hm02AAD/YzpV0nYA+Vvrih5sYZl1 gIsXCme9P5WlT6lxRZazazFY6cbmBzMAY6K9hkHtV3Of/5aDcPr4C3vAUdtBj0R9WMLs RQ8YZMSWQHTwe/0y66UkSp4xZksX8L/qpxU0gxuOJOrxm8fNjDuYJHKNhYao0jR7ufYS tMkf3QhQenyXE9PMGWbfqmvj4za5h1Iz9jy4PDAgIo8/RSKdvPmXoO8THTQBsTuAjW2O SM4ISoAb4iZjjFZI2uMTg3RTNr8xMF6q2Jzgrr0tmReGXOhoHIJ4HLpJV3uHkwiC23xl nbpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ZjH0qYLi; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i4-v6si15748869wme.10.2018.09.10.02.30.36; Mon, 10 Sep 2018 02:30:36 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ZjH0qYLi; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EEC2E689E9C; Mon, 10 Sep 2018 12:30:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 472996882CF for ; Mon, 10 Sep 2018 12:30:18 +0300 (EEST) Received: by mail-ed1-f65.google.com with SMTP id h33-v6so15953273edb.5 for ; Mon, 10 Sep 2018 02:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=Y+Wx15MN09wY4fLAydAjsHlCTi2rWKub9n6R9efTi9U=; b=ZjH0qYLiro4J37MV97nFbLT/2cfA+KlCmpGRql8esc5JGxYVzsHByQqIhy9BRtZ+5r mWpYTa+aIVhluaxeJCjoImDfkWt7EqcrNKe8yP9EyDv4xDBBy7+JnABefSj5xUIqlhFQ twROuUvpM/QrK37TY3HJO6Mz8Oo+733vLhnsFuyp21cu9cEQ1eawSVQqPUQc/10yjgFf PkcCxXTsuRKQxOmEs0n917tH3kp1hrkWYleB/KvKOJ91PXZzoP2LOcqxk5M5AccYxYWy +TWtPqrp7D6WcbRxPP2YyymYbEyyY+ei89keo8MaQ1iqgwarYtI1jPaq/x4peK8xqIr9 diIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=Y+Wx15MN09wY4fLAydAjsHlCTi2rWKub9n6R9efTi9U=; b=Wp5qTlPrKklvjYOVtJg/kls5XAZ8cY0HDwYl7YjuZODS6sKd/rhZBFEU6Yzjynfmyb 7bzGlQaThISTCmn5bZtV5tbAiMKJ1QZbplDaOmbz3oJ8e6+0lUvrNJATxkgeL+t3LFUy Cz5RuD1H/KXkEVBEBDYRmu5R24uM7zxGxmB/zGivFMiyeAGVwZFnJ/CeZ+bVgGMVQnUn b61jAAoL7ZJYavjhDXgk5CuO4MYeJpglCJB4X0xi1ItrLHL8ntTxecwXctss8qYLECzd UHqvSA8iJ+CD6MugwQFRhPqv0ElMWYZ+GE3kFWiTYwG/LhWZSdnsGVT6uI02ezHEfvVU MOKg== X-Gm-Message-State: APzg51CY/ipQmNAoGKDSsLDQ80bmxvxtMwRD4X7Fd8dLmbS3zhCTyKdb WDozXydDaTESn7/KRwL5UIVARwJR X-Received: by 2002:a50:9e85:: with SMTP id a5-v6mr22647311edf.92.1536571826856; Mon, 10 Sep 2018 02:30:26 -0700 (PDT) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id f7-v6sm11801377edd.6.2018.09.10.02.30.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Sep 2018 02:30:26 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Mon, 10 Sep 2018 11:30:03 +0200 Message-Id: <20180910093003.5776-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avcodec/loco: switch to planar rgb format 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Remove now unused step variable. Signed-off-by: Paul B Mahol --- libavcodec/loco.c | 69 ++++++++++++++++++++--------------------- tests/ref/fate/loco-rgb | 10 +++--- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/libavcodec/loco.c b/libavcodec/loco.c index 9d0f144451..f91d8709b0 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -114,19 +114,19 @@ static inline int loco_get_rice(RICEContext *r) } /* LOCO main predictor - LOCO-I/JPEG-LS predictor */ -static inline int loco_predict(uint8_t* data, int stride, int step) +static inline int loco_predict(uint8_t* data, int stride) { int a, b, c; a = data[-stride]; - b = data[-step]; - c = data[-stride - step]; + b = data[-1]; + c = data[-stride - 1]; return mid_pred(a, a + b - c, b); } static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int height, - int stride, const uint8_t *buf, int buf_size, int step) + int stride, const uint8_t *buf, int buf_size) { RICEContext rc; int val; @@ -153,7 +153,7 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh /* restore top line */ for (i = 1; i < width; i++) { val = loco_get_rice(&rc); - data[i * step] = data[i * step - step] + val; + data[i] = data[i - 1] + val; } data += stride; for (j = 1; j < height; j++) { @@ -163,7 +163,7 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh /* restore all other pixels */ for (i = 1; i < width; i++) { val = loco_get_rice(&rc); - data[i * step] = loco_predict(&data[i * step], stride, step) + val; + data[i] = loco_predict(&data[i], stride) + val; } data += stride; } @@ -171,19 +171,18 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh return (get_bits_count(&rc.gb) + 7) >> 3; } -static void rotate_faulty_loco(uint8_t *data, int width, int height, int stride, int step) +static void rotate_faulty_loco(uint8_t *data, int width, int height, int stride) { int y; for (y=1; y=y) { memmove(data + y*stride, - data + y*(stride + step), - step*(width-y)); + data + y*(stride + 1), + (width-y)); if (y+1 < height) - memmove(data + y*stride + step*(width-y), - data + (y+1)*stride, - step*y); + memmove(data + y*stride + (width-y), + data + (y+1)*stride, y); } } } @@ -209,49 +208,49 @@ static int decode_frame(AVCodecContext *avctx, switch(l->mode) { case LOCO_CYUY2: case LOCO_YUY2: case LOCO_UYVY: decoded = loco_decode_plane(l, p->data[0], avctx->width, avctx->height, - p->linesize[0], buf, buf_size, 1); + p->linesize[0], buf, buf_size); ADVANCE_BY_DECODED; decoded = loco_decode_plane(l, p->data[1], avctx->width / 2, avctx->height, - p->linesize[1], buf, buf_size, 1); + p->linesize[1], buf, buf_size); ADVANCE_BY_DECODED; decoded = loco_decode_plane(l, p->data[2], avctx->width / 2, avctx->height, - p->linesize[2], buf, buf_size, 1); + p->linesize[2], buf, buf_size); break; case LOCO_CYV12: case LOCO_YV12: decoded = loco_decode_plane(l, p->data[0], avctx->width, avctx->height, - p->linesize[0], buf, buf_size, 1); + p->linesize[0], buf, buf_size); ADVANCE_BY_DECODED; decoded = loco_decode_plane(l, p->data[2], avctx->width / 2, avctx->height / 2, - p->linesize[2], buf, buf_size, 1); + p->linesize[2], buf, buf_size); ADVANCE_BY_DECODED; decoded = loco_decode_plane(l, p->data[1], avctx->width / 2, avctx->height / 2, - p->linesize[1], buf, buf_size, 1); + p->linesize[1], buf, buf_size); break; case LOCO_CRGB: case LOCO_RGB: - decoded = loco_decode_plane(l, p->data[0] + p->linesize[0]*(avctx->height-1), avctx->width, avctx->height, - -p->linesize[0], buf, buf_size, 3); + decoded = loco_decode_plane(l, p->data[1] + p->linesize[1]*(avctx->height-1), avctx->width, avctx->height, + -p->linesize[1], buf, buf_size); ADVANCE_BY_DECODED; - decoded = loco_decode_plane(l, p->data[0] + p->linesize[0]*(avctx->height-1) + 1, avctx->width, avctx->height, - -p->linesize[0], buf, buf_size, 3); + decoded = loco_decode_plane(l, p->data[0] + p->linesize[0]*(avctx->height-1), avctx->width, avctx->height, + -p->linesize[0], buf, buf_size); ADVANCE_BY_DECODED; - decoded = loco_decode_plane(l, p->data[0] + p->linesize[0]*(avctx->height-1) + 2, avctx->width, avctx->height, - -p->linesize[0], buf, buf_size, 3); + decoded = loco_decode_plane(l, p->data[2] + p->linesize[2]*(avctx->height-1), avctx->width, avctx->height, + -p->linesize[2], buf, buf_size); if (avctx->width & 1) - rotate_faulty_loco(p->data[0] + p->linesize[0]*(avctx->height-1), avctx->width, avctx->height, -p->linesize[0], 3); + rotate_faulty_loco(p->data[1] + p->linesize[1]*(avctx->height-1), avctx->width, avctx->height, -p->linesize[1]); break; case LOCO_CRGBA: case LOCO_RGBA: - decoded = loco_decode_plane(l, p->data[0] + p->linesize[0]*(avctx->height-1), avctx->width, avctx->height, - -p->linesize[0], buf, buf_size, 4); + decoded = loco_decode_plane(l, p->data[1] + p->linesize[1]*(avctx->height-1), avctx->width, avctx->height, + -p->linesize[1], buf, buf_size); ADVANCE_BY_DECODED; - decoded = loco_decode_plane(l, p->data[0] + p->linesize[0]*(avctx->height-1) + 1, avctx->width, avctx->height, - -p->linesize[0], buf, buf_size, 4); + decoded = loco_decode_plane(l, p->data[0] + p->linesize[0]*(avctx->height-1), avctx->width, avctx->height, + -p->linesize[0], buf, buf_size); ADVANCE_BY_DECODED; - decoded = loco_decode_plane(l, p->data[0] + p->linesize[0]*(avctx->height-1) + 2, avctx->width, avctx->height, - -p->linesize[0], buf, buf_size, 4); + decoded = loco_decode_plane(l, p->data[2] + p->linesize[2]*(avctx->height-1), avctx->width, avctx->height, + -p->linesize[2], buf, buf_size); ADVANCE_BY_DECODED; - decoded = loco_decode_plane(l, p->data[0] + p->linesize[0]*(avctx->height-1) + 3, avctx->width, avctx->height, - -p->linesize[0], buf, buf_size, 4); + decoded = loco_decode_plane(l, p->data[3] + p->linesize[3]*(avctx->height-1), avctx->width, avctx->height, + -p->linesize[3], buf, buf_size); break; default: av_assert0(0); @@ -302,7 +301,7 @@ static av_cold int decode_init(AVCodecContext *avctx) break; case LOCO_CRGB: case LOCO_RGB: - avctx->pix_fmt = AV_PIX_FMT_BGR24; + avctx->pix_fmt = AV_PIX_FMT_GBRP; break; case LOCO_CYV12: case LOCO_YV12: @@ -310,7 +309,7 @@ static av_cold int decode_init(AVCodecContext *avctx) break; case LOCO_CRGBA: case LOCO_RGBA: - avctx->pix_fmt = AV_PIX_FMT_BGRA; + avctx->pix_fmt = AV_PIX_FMT_GBRAP; break; default: av_log(avctx, AV_LOG_INFO, "Unknown colorspace, index = %i\n", l->mode); diff --git a/tests/ref/fate/loco-rgb b/tests/ref/fate/loco-rgb index 289e73f7ed..446f5d83cb 100644 --- a/tests/ref/fate/loco-rgb +++ b/tests/ref/fate/loco-rgb @@ -3,8 +3,8 @@ #codec_id 0: rawvideo #dimensions 0: 188x128 #sar 0: 0/1 -0, 0, 0, 1, 72192, 0x1847500c -0, 1, 1, 1, 72192, 0x1b0e2e87 -0, 2, 2, 1, 72192, 0x293276c8 -0, 3, 3, 1, 72192, 0x743b9705 -0, 4, 4, 1, 72192, 0xcc1b2530 +0, 0, 0, 1, 72192, 0xbe9f500c +0, 1, 1, 1, 72192, 0xafc82e87 +0, 2, 2, 1, 72192, 0x3a2476c8 +0, 3, 3, 1, 72192, 0x1fda9705 +0, 4, 4, 1, 72192, 0x46b82530