From patchwork Wed Dec 5 17:40:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 11287 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 B6DFE44C7CC for ; Wed, 5 Dec 2018 19:40:28 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 58E9D68A65F; Wed, 5 Dec 2018 19:40:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D405C68A628 for ; Wed, 5 Dec 2018 19:40:12 +0200 (EET) Received: by mail-io1-f65.google.com with SMTP id k7so17367641iob.6 for ; Wed, 05 Dec 2018 09:40:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Gd21HKEDsto7aNr7RGaFk0/Yk5nJmbM/RdgGDYND52c=; b=YSU8jiR7O70NTPQ+KMFW27fQMHh77qr/oh+KxNrW+roq0+X+LQ4+so/f98Ke3uKEFO ilpl4RyKVJIOfcAAD8Qz1Hx2YLXY2IOv9nZUJdSmreB/OUhGvUUZPkXDKT4TFnI7BHM7 1ob9MB9lKHPTeSA4GMR8US3O7exV9SMhKTxA95QoWEL4L1COXJacUDjnf9jKcNkNwPKL nCAFUHaXDxM99Lec+8piB+pA7u24eOg0x/jEO9c30jwl4rpBXjcjxsY1Y7/KA4bkr2Ut NJEG6lu/3ojwnxp9J3iUmGBe9csbgTmqb5Iy5kL1vAfgam8TLiPsjmN9lqwu9UC8LilM GvCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Gd21HKEDsto7aNr7RGaFk0/Yk5nJmbM/RdgGDYND52c=; b=UTchlwhxU7OZbfatlUGECJG/TWIzRBz0n5skv2IH1BMChurEsFF8ejtIQv690cI9Mj Ht8torSYcKBjf0r/cdVOYN1+IQA5hUF4nM8SkycnG4fxugN8oaglC56SZeRniybRIfHm FXndtDmWhBChMQ0veG1wBPingYXyDuE6AfAFwCNy7ntP25t3J22ee6GYEY8Lo95jtb76 zqfni2t33SPlIe+B6Nvk5hQCGTpSyVGC26bAYyQlWXAVHhjYyoQrqbcIPNL6NQPS/aKj JWBCTUOzbjf9cTtv809FTfv6XuCPq2qaVoRsk8BXU5PFzkwvMAeBL3Tf5+FZq/XkhvWP yqOQ== X-Gm-Message-State: AA+aEWa2t1U2+SVIsdHbyp+fXLDK56z4AG8cbwCy2eivon/ve4XgaQw4 pA+9nIV3SUPm6XlGLXp3W5lYmGBARvSXqPdPG8p6hg== X-Google-Smtp-Source: AFSGD/VwQux09a5DGzgyYeWBWmML+rB4lD+l07x5HWZHbtRFFLRZo/ZtuJwiBJzQ6aC6XNHdtlo4iUo4qDCcJiMxGtw= X-Received: by 2002:a5e:c70d:: with SMTP id f13mr22894710iop.55.1544031620115; Wed, 05 Dec 2018 09:40:20 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:5f11:0:0:0:0:0 with HTTP; Wed, 5 Dec 2018 09:40:19 -0800 (PST) In-Reply-To: References: <20181205132758.11233-1-onemda@gmail.com> From: Carl Eugen Hoyos Date: Wed, 5 Dec 2018 18:40:19 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH] avcodec/dpx: do not reset n_datum to 0 at end of row for packing 2 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" 2018-12-05 18:19 GMT+01:00, Paul B Mahol : > On 12/5/18, Carl Eugen Hoyos wrote: >> 2018-12-05 17:33 GMT+01:00, Paul B Mahol : >>> On 12/5/18, Carl Eugen Hoyos wrote: >>>> 2018-12-05 14:27 GMT+01:00, Paul B Mahol : >>>>> Fixes #4409. >>>>> >>>>> Signed-off-by: Paul B Mahol >>>>> --- >>>>> libavcodec/dpx.c | 3 ++- >>>>> 1 file changed, 2 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c >>>>> index 538a1b9943..04b55ffadf 100644 >>>>> --- a/libavcodec/dpx.c >>>>> +++ b/libavcodec/dpx.c >>>>> @@ -378,7 +378,8 @@ static int decode_frame(AVCodecContext *avctx, >>>>> read10in32(&buf, &rgbBuffer, >>>>> &n_datum, endian, shift); >>>>> } >>>>> - n_datum = 0; >>>>> + if (packing != 2) >>>>> + n_datum = 0; >>>>> for (i = 0; i < elements; i++) >>>>> ptr[i] += p->linesize[i]; >>>>> } >>>> >>>> This breaks decoding the output of the following command: >>>> $ gm convert converted_image_gets_skewed.dpx -define >>>> dpx:packing-method=b out.dpx >>> >>> I do not trust that app, its full of bugs. >> >> What is the reference for dpx in your opinion? > > ImageTragick certainly not. That's not ImageMagick above. The sample in question looks better with attached poc, breaks four component sample, also attaching other samples that show the difference. Carl Eugen diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 538a1b9..b9e02e5 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -50,6 +50,8 @@ static unsigned int read32(const uint8_t **ptr, int is_big) return temp; } +static int counter = 0; + static uint16_t read10in32(const uint8_t **ptr, uint32_t * lbuf, int * n_datum, int is_big, int shift) { @@ -60,9 +62,11 @@ static uint16_t read10in32(const uint8_t **ptr, uint32_t * lbuf, *n_datum = 2; } - *lbuf = *lbuf << 10 | *lbuf >> shift & 0x3FFFFF; - - return *lbuf & 0x3FF; + if (*n_datum < 2) + *lbuf = *lbuf >> 10; +if (counter++<30) +printf("%x \n", *lbuf >> shift & 0x3FF); + return *lbuf >> shift & 0x3FF; } static uint16_t read12in32(const uint8_t **ptr, uint32_t * lbuf, @@ -168,6 +172,7 @@ static int decode_frame(AVCodecContext *avctx, bits_per_color = buf[0]; buf++; packing = read16(&buf, endian); +printf("packing: %d, endian: %d, descriptor: %d, bpc: %d \n", packing, endian, descriptor, bits_per_color); encoding = read16(&buf, endian); if (encoding) { @@ -310,6 +315,7 @@ static int decode_frame(AVCodecContext *avctx, case 51121: avctx->pix_fmt = AV_PIX_FMT_GBRAP12; break; + case 6100: case 6101: avctx->pix_fmt = AV_PIX_FMT_GRAY10; break; @@ -363,20 +369,20 @@ static int decode_frame(AVCodecContext *avctx, (uint16_t*)ptr[1], (uint16_t*)ptr[2], (uint16_t*)ptr[3]}; - int shift = packing == 1 ? 22 : 20; + int shift = packing == 1 ? 2 : 0; for (y = 0; y < avctx->width; y++) { - if (elements >= 3) - *dst[2]++ = read10in32(&buf, &rgbBuffer, - &n_datum, endian, shift); - *dst[0]++ = read10in32(&buf, &rgbBuffer, - &n_datum, endian, shift); - if (elements >= 2) - *dst[1]++ = read10in32(&buf, &rgbBuffer, - &n_datum, endian, shift); if (elements == 4) *dst[3]++ = read10in32(&buf, &rgbBuffer, &n_datum, endian, shift); + if (elements >= 2) + *dst[1]++ = read10in32(&buf, &rgbBuffer, + &n_datum, endian, shift); + *dst[/*elements == 4 ? 2 :*/ 0]++ = read10in32(&buf, &rgbBuffer, + &n_datum, endian, shift); + if (elements >= 3) + *dst[/*elements == 4 ? 0 :*/ 2]++ = read10in32(&buf, &rgbBuffer, + &n_datum, endian, shift); } n_datum = 0; for (i = 0; i < elements; i++)