From patchwork Tue Apr 10 19:41:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Martinez X-Patchwork-Id: 8379 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp1447344jad; Tue, 10 Apr 2018 12:41:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Vhmucer6D4MFBP2v9E8AqDBQ8+ab6uXTq9tvc3oJFOXGEvVMGOrGBbDomkiIsKCpWBwj7 X-Received: by 10.28.124.14 with SMTP id x14mr571177wmc.86.1523389275892; Tue, 10 Apr 2018 12:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523389275; cv=none; d=google.com; s=arc-20160816; b=w6KfFevpRdu7xE1vFA+L/l5Qiu9rU5TOBHK79gu9A1IkVdA9xIK4I8jUSSkd/Vtpmx nzaHSsqEx5VzJuwJXEk5W63HoTDVxDI+1gMMaQ78/JPt9VNKlZyi1gLD78gkH/9L5wKn k8nFRTf05ZTSWuHKq+CUM3Mey5TvmQHnDMwxnmp4IhV5ZlsnBU+iSW5Khi+2JMtOcXRw i0pZSuPdHLw29TP3sh+PvYtguz/cM7eCuMADxt03fJNQu/mAwWXW2EwL1A7VCeKavfP0 OQO7XHQHswB1leuyZa5yuIn2+dy4TZ8zXVYNBsOBx2d5i3HW4OXLVf35y8f3lSc6JS9Q uZVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:delivered-to :arc-authentication-results; bh=n66NRaCNFRENfYy9k9n/oXRMF2UMDXx7smTiGbzWvf0=; b=hdLFrkKBwTqbWbqWrDh3Hb5y9JxJVcauvSkrUwc6VXZeu6igyxqL0pne6s/Z1+tXLF TbMU7ccS0WBOIfyRq47pLMiyzHjNnaSPNUNDS8ftl0LsmCbMnLPYLiRnUE4FNswB88ds cNyaLZioowbgCdLVHcx0EwFzinIJX1auzJb1tr/Trk//lDZsGoyy/GdzOdqOPHGAPM3i bA/d3J9YRlhIv/eTnbcoiIFw9txgHNCKQx4Ry/d6m31h/F7hV+bQihPPjIwBKFDMi0jU C32eeI+NNrmfokQurqCgZ3aLgfph6C4M82agerQhRWdx8PGrMnuWT4KfRMaohgfluuP2 CvxA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e186si1663983wmd.259.2018.04.10.12.41.14; Tue, 10 Apr 2018 12:41:15 -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 90C4B689FF2; Tue, 10 Apr 2018 22:40:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from 10.mo179.mail-out.ovh.net (10.mo179.mail-out.ovh.net [46.105.79.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B5051689C71 for ; Tue, 10 Apr 2018 22:40:43 +0300 (EEST) Received: from player762.ha.ovh.net (unknown [10.109.120.102]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id D2748B5498 for ; Tue, 10 Apr 2018 21:41:06 +0200 (CEST) Received: from [192.168.2.120] (p5DDB4961.dip0.t-ipconnect.de [93.219.73.97]) (Authenticated sender: zen-lists@mediaarea.net) by player762.ha.ovh.net (Postfix) with ESMTPSA id 57B7CE00A1 for ; Tue, 10 Apr 2018 21:41:06 +0200 (CEST) To: ffmpeg-devel@ffmpeg.org References: <1d1e3171-771f-7e1d-0dd6-6bf04430ba5c@mediaarea.net> <133b22e5-2849-4cde-8da7-8332b4ae8a77@mediaarea.net> From: Jerome Martinez Message-ID: Date: Tue, 10 Apr 2018 21:41:05 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Ovh-Tracer-Id: 1392175236503048381 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtgedrheeigddugeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenuc Subject: Re: [FFmpeg-devel] [PATCH] avcodec/dpx: Support for RGB 12-bit packed decoding 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" On 10/04/2018 12:34, Carl Eugen Hoyos wrote: > 2018-04-10 12:28 GMT+02:00, Kieran O Leary : >> I just tested this patch non packed to 16-bit gbrp12le DPX from DaVinci >> Resolve. > Testing is good, apart I thought the patch was "technically" OK, as I answered to all change requests and there was no additional feedback IIRC. > from more brackets Not sure I understand, as the only "missing" brackets I see are for the 1 line code after a "if", and I see that 1 line code has no brackets in other parts of the file. Anyway, I added more brackets, except for "if (*n_datum) (*n_datum)--;" as I copied/pasted it from another part of the file. Did I miss something else? > (and less comments) I thought it would be better for someone willing to add alpha support in the future, as the alpha support was tested and "just" rejected for the moment. Anyway, I removed the commented code. Modified patch attached. Note that I personally prefer to use the previous patch (or this patch without the additional brackets). > it would > be better if Jerome sends his public keys to Michael and pushes the patch. If it is the only solution for having the patch pushed, I'll do that, even if I am not convinced that I deserve for the moment write rights on FFmpeg repository (especially because Git and me are not good friends :) ). Jérôme From 02286a07f920b8d15bf5f031a21fc9080fc4fa32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Martinez?= Date: Tue, 10 Apr 2018 18:20:23 +0200 Subject: [PATCH] avcodec/dpx: Support for RGB 12-bit packed decoding Limited to widths multiple of 8 (RGB) due to lack of test files for such corner case This partially fixes ticket #5639 --- libavcodec/dpx.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 1aa2cbd1c8..026fb10e90 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -65,6 +65,38 @@ static uint16_t read10in32(const uint8_t **ptr, uint32_t * lbuf, return *lbuf & 0x3FF; } +static uint16_t read12in32(const uint8_t **ptr, uint32_t * lbuf, + int * n_datum, int is_big) +{ + if (*n_datum) + (*n_datum)--; + else { + *lbuf = read32(ptr, is_big); + *n_datum = 7; + } + + switch (*n_datum){ + case 7: return *lbuf & 0xFFF; + case 6: return (*lbuf >> 12) & 0xFFF; + case 5: { + uint32_t c = *lbuf >> 24; + *lbuf = read32(ptr, is_big); + c |= *lbuf << 8; + return c & 0xFFF; + } + case 4: return (*lbuf >> 4) & 0xFFF; + case 3: return (*lbuf >> 16) & 0xFFF; + case 2: { + uint32_t c = *lbuf >> 28; + *lbuf = read32(ptr, is_big); + c |= *lbuf << 4; + return c & 0xFFF; + } + case 1: return (*lbuf >> 8) & 0xFFF; + default: return *lbuf >> 20; + } +} + static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, @@ -201,10 +233,27 @@ static int decode_frame(AVCodecContext *avctx, break; case 12: if (!packing) { - av_log(avctx, AV_LOG_ERROR, "Packing to 16bit required\n"); - return -1; + int tested = 0; + if (descriptor == 50 && endian && (avctx->width%8) == 0) { // Little endian and widths not a multiple of 8 need tests + tested = 1; + } + if (!tested) { + av_log(avctx, AV_LOG_ERROR, "Packing to 16bit required\n"); + return -1; + } + } + stride = avctx->width * elements; + if (packing) { + stride *= 2; + } else { + stride *= 3; + if (stride % 8) { + stride /= 8; + stride++; + stride *= 8; + } + stride /= 2; } - stride = 2 * avctx->width * elements; break; case 16: stride = 2 * avctx->width * elements; @@ -349,6 +398,7 @@ static int decode_frame(AVCodecContext *avctx, (uint16_t*)ptr[2], (uint16_t*)ptr[3]}; for (y = 0; y < avctx->width; y++) { + if (packing) { if (elements >= 3) *dst[2]++ = read16(&buf, endian) >> 4; *dst[0] = read16(&buf, endian) >> 4; @@ -357,6 +407,17 @@ static int decode_frame(AVCodecContext *avctx, *dst[1]++ = read16(&buf, endian) >> 4; if (elements == 4) *dst[3]++ = read16(&buf, endian) >> 4; + } else { + *dst[2]++ = read12in32(&buf, &rgbBuffer, + &n_datum, endian); + *dst[0]++ = read12in32(&buf, &rgbBuffer, + &n_datum, endian); + *dst[1]++ = read12in32(&buf, &rgbBuffer, + &n_datum, endian); + if (elements == 4) + *dst[3]++ = read12in32(&buf, &rgbBuffer, + &n_datum, endian); + } } for (i = 0; i < elements; i++) ptr[i] += p->linesize[i];