From patchwork Fri Mar 17 16:19:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dzung Hoang X-Patchwork-Id: 2992 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp331796vsy; Fri, 17 Mar 2017 09:21:14 -0700 (PDT) X-Received: by 10.223.179.216 with SMTP id x24mr13747435wrd.171.1489767674117; Fri, 17 Mar 2017 09:21:14 -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 l73si3818765wmd.112.2017.03.17.09.21.13; Fri, 17 Mar 2017 09:21:14 -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=@yahoo.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 7371368834A; Fri, 17 Mar 2017 18:20:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nm18-vm0.bullet.mail.bf1.yahoo.com (nm18-vm0.bullet.mail.bf1.yahoo.com [98.139.213.138]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B12C46882E5 for ; Fri, 17 Mar 2017 18:20:46 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1489767662; bh=roQreX3QuCntoGEgLmUzA43LGVM5uLNnU76jqrWpb80=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=mG0lxhzdJ13TCCQSzMXCgUiYdsaeK2UkVZkmD4cFtekM164FoBB42CGNyqEto7N7atrqYZI5neszl6xAbY3259XTdknJkO7pcCf+Mz8KkBUvZkbQ50hdLxJn9AJlF5xdUuu3Oo2MR83EchmkQr2ZwlT8wdHf07v7lhHaHaIH9hzjt9iLFcTmElDwsRPxYgoE4lcFKzimI0XIcI6sdkT9YICmpleJAvTkwmoIdL+5UhQdr4pn3nVFzZzWLIm1FlOumdV9W1c9R6rnMGR8lc/nAE/Scv+lqmeotbQxn7RFw7CK1p0wqXpzp7MPeF1AjCGEzNusEMdr8lMufkXdQM63/A== Received: from [98.139.215.140] by nm18.bullet.mail.bf1.yahoo.com with NNFMP; 17 Mar 2017 16:21:02 -0000 Received: from [98.139.212.235] by tm11.bullet.mail.bf1.yahoo.com with NNFMP; 17 Mar 2017 16:21:02 -0000 Received: from [127.0.0.1] by omp1044.mail.bf1.yahoo.com with NNFMP; 17 Mar 2017 16:21:02 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 421257.87719.bm@omp1044.mail.bf1.yahoo.com X-YMail-OSG: 9yf7CIUVM1n8fCZXNaVmuSQJ0iWzrDhats0FBvB8xZ7bRhIUXOSJVobfrDts0yw bpsu1hyuf0j7lbQLTeX1uPgpINBUA_DEShgMXJvlPp6Te0lOWL5vJP4uUl6pBGBsG0rCUIOtWexq 14QgQlaUN43tikfYlPiIYxEL84ZajRHc41wADY27uCb4t3nQbZlttMyDmPCxaS0wBwC59YCNys2U cQwfm9mPY31cAkq4VUtqpm65PS.PZd2df_QJZJB02fkaCKd2hksnJIb08zbjZjnXz2QLJjGiaYyL YCT5XsTaGlWhXw.tPbUpLHTCZMVTrMFXn8KI02Ffhn7xRz9y5Rf4LEJX6n9awNv6OL_njCVUJsDY A4la4b53SZ6a6jabPU.Npmm4YWnsXVDh4e.XhnzKzwh_s.PE_mQnn8QQjtgTmz3ZZzDOFBYESKEN U6Lm103vJVls972AwnLql8hdYGXqOM0E_I4V_Tc4YnZWjLCAAfLLZNL1mMoRVSHNvV4QNwV8WCp1 QHnwfZv2qhGv0eMbz Received: from jws400009.mail.bf2.yahoo.com by sendmailws143.mail.bf1.yahoo.com; Fri, 17 Mar 2017 16:19:22 +0000; 1489767562.497 Date: Fri, 17 Mar 2017 16:19:21 +0000 (UTC) From: Dzung Hoang To: FFmpeg development discussions and patches Message-ID: <1505729381.2298662.1489767561651@mail.yahoo.com> In-Reply-To: <1386439495.5593649.1489516596376@mail.yahoo.com> References: <1386439495.5593649.1489516596376.ref@mail.yahoo.com> <1386439495.5593649.1489516596376@mail.yahoo.com> MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] avcodec/exr detect invalid line offset table and recreate table 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" Since there are no comments since March 14, I assume this patch is good to go. I tried to commit the patch and push it to the mirror on github.com, but was denied access. Can a developer please apply and commit this patch? Thanks,- Dzung Hoang From: Dzung Hoang To: FFmpeg Development Discussions and Patches Sent: Tuesday, March 14, 2017 1:36 PM Subject: [FFmpeg-devel] [PATCH] avcodec/exr detect invalid line offset table and recreate table The EXR decoder cannot handle the image files included in NVidia's HDR SDK. After debugging, I found that the line offset table in the image files contained 0's. Other EXR decoders, including the official OpenEXR decoder, can detect and reconstruct missing line offset tables, so I added some code to do so. I filed a trac ticket for this issue here: https://trac.ffmpeg.org/ticket/6220. The image files are here: http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket6220/ Dzung Hoang Signed-off-by: Dzung Hoang --- libavcodec/exr.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.1.4 diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 034920f..dec21af 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -1726,6 +1726,25 @@ static int decode_frame(AVCodecContext *avctx, void *data,     if (bytestream2_get_bytes_left(&s->gb) < nb_blocks * 8)         return AVERROR_INVALIDDATA; +    // check line offset table and recreate if first entry is 0 +    if (bytestream2_peek_le64(&s->gb) == 0) +    { +        uint64_t *table = (uint64_t *)s->gb.buffer; +        uint8_t *head = avpkt->data; +        uint8_t *marker = head + bytestream2_tell(&s->gb) + nb_blocks * 8; + +        av_log(s->avctx, AV_LOG_INFO, "Recreating invalid offset table.\n"); + +        // recreate the line offset table using the length field for each line +        // decode_block() will check for out-of-bounds offsets, so do not bother +        // to check here +        for (y = 0; y < nb_blocks; y++) +        { +            table[y] = marker - head; +            marker += ((uint32_t *)marker)[1] + 8; +        } +    } +     // save pointer we are going to use in decode_block     s->buf      = avpkt->data;     s->buf_size = avpkt->size;