From patchwork Tue Mar 14 18:36:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzung Hoang X-Patchwork-Id: 2926 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp1726119vsy; Tue, 14 Mar 2017 11:38:53 -0700 (PDT) X-Received: by 10.28.222.4 with SMTP id v4mr1015676wmg.75.1489516733820; Tue, 14 Mar 2017 11:38:53 -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 g38si6099189wrg.312.2017.03.14.11.38.53; Tue, 14 Mar 2017 11:38:53 -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 E956C680A84; Tue, 14 Mar 2017 20:38:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nm49-vm10.bullet.mail.bf1.yahoo.com (nm49-vm10.bullet.mail.bf1.yahoo.com [216.109.114.251]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D36166809A1 for ; Tue, 14 Mar 2017 20:38:27 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1489516722; bh=jtIe72fVajdxumB5HEfNwUm2IwyrBT4lyqZGi6/a3Ys=; h=Date:From:Reply-To:To:Subject:References:From:Subject; b=VDYzdUxlthVpBM5er6BNkReXZF0ygLNOZeeg2CvdrT27CyfQnI3FScWeR8nLiwkTY0kGK/kM+bBJW3kD1ZactVLinn2IlbGjCioc5QdY6D946ANXVmmi6bh+Z+PzUjLj+fc2d+PLzF5s3oi9wa4qkx/rAA1/0mJcJNWsFnnOf8gdlFdUvn1J63G4rpkkiqdJQ7m0NhQxDAabc/D04sRHonzoUVCJib24OLDVLeR/yzxkO+dle17Ar5BQ4AvMQXbetI6mJXxKu5JOs1SpbL9syadjInQl7BFhrlnJk/Z92UftDapZN3TNdRyJ21wruTJnNgIyVKoODFhgaXd+nIL5Aw== Received: from [66.196.81.174] by nm49.bullet.mail.bf1.yahoo.com with NNFMP; 14 Mar 2017 18:38:42 -0000 Received: from [98.139.212.193] by tm20.bullet.mail.bf1.yahoo.com with NNFMP; 14 Mar 2017 18:38:42 -0000 Received: from [127.0.0.1] by omp1002.mail.bf1.yahoo.com with NNFMP; 14 Mar 2017 18:38:42 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 380429.45050.bm@omp1002.mail.bf1.yahoo.com X-YMail-OSG: zAxpjbsVM1nVIjvOgy1YGGMDosGbtxX_A_WClndsTio_G9IqJ1J.r4e.mP4fFAX kMuCL5F8QhCOuaScKwAPkMOt8uTSphp762LncW.DdxcvYE52N6T2T3BP8KROLtHGwZYtwe_un_ji hC5Zfr1GqCqO__YF6tOhNPzGkkcqzuVrUUVV3zo5g5pl0WTsPStHTHf4JBVG37E8DoqA.p4TZB_p mLotFv5h08Dnebww8NF.Hu6Jv.L5yMks60fiSg2cjlBzXFyVaJpk9K8yWD3TrYmBq06qkcbzuvSl jEXRxDvB0j523XtytK43ka8ttX0NUjoIbF1Hzg9Ds.JdrPMn2rOUnc9dkzX5N4do3hJYczMWPPsM NDeO8Iz9u4jtZMHODm4pU.eXePuLxkNFGcyHirdhIKfW_iQjlSLPDfyfPPf56NL1oxJ119v5ifWM 16UxXQQfoYa4XccnFSKPI4CVtjPNY3gbyLLJPdCY884iYqanvfkFqruA3f5xWtF2H6hEkOlukRX0 rmb3.1BqqTS50uDdV Received: from jws400125.mail.bf2.yahoo.com by sendmailws101.mail.bf1.yahoo.com; Tue, 14 Mar 2017 18:37:02 +0000; 1489516622.326 Date: Tue, 14 Mar 2017 18:36:36 +0000 (UTC) From: Dzung Hoang To: FFmpeg Development Discussions and Patches Message-ID: <1386439495.5593649.1489516596376@mail.yahoo.com> MIME-Version: 1.0 References: <1386439495.5593649.1489516596376.ref@mail.yahoo.com> Subject: [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" 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;