From patchwork Sat Nov 18 00:36:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 6156 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp1278969jah; Fri, 17 Nov 2017 16:45:01 -0800 (PST) X-Google-Smtp-Source: AGs4zMZMjnOKky0LprC2uQU7M89WowMmqRYgFbzoU16VoRwh/tk1PphxMe66BU+BR6sgnkz3PJDj X-Received: by 10.28.184.130 with SMTP id i124mr5281255wmf.85.1510965901316; Fri, 17 Nov 2017 16:45:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510965901; cv=none; d=google.com; s=arc-20160816; b=JoRlVgz9Dm1T+AycTP5BGrtS07mamz+cx8HLycUjWbJagLJu6Cjg8PnnHbDx5hRSLz uPS2r/SjRTx9IFgubijuzpnewL5H5kqhablbmltqollyqcgdEixdKK4mOmjzalT3nlMe M7kyDM7z17JjIRldys4B6Saks3vIVsid9j0C3USRUbI6G8vYRaDUCiJehskNqP/siwfI AiawDnlYfqo9qcLtZ99Tjhuwi8qWBv3bts3uqxy/a+bOWcNxFcB1jsvsrbniUndz88Le vNDvlj6DmCbFBiLK/7k+WX2xUwRmIT17FO3QxRnR/NI8s5GA3fQkqqceeFVVelRjxk9D In9w== 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:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=Jf23G/eJJAvebtZHWhiUedK3pitUt/XqWnpWA8Tv+Iw=; b=E10kcEbe29HJzJhzjXaln5yHR7dB/xWtT66wejJC1M1sJmKCFKAv5kFWcTxpyAqJgg 35PLCLcLhLLncb/oc8R275qVRygsy0zvmy7H/zewuDG9sfcUwj2g4vKSb9BO319IOs2U G4cGRM4z3X+jxFn+ZOfMgtt/vJ5hq67NAe+ECt1vLEvHiQwqyrF3WHYhpymFLY+2HYGh CwzF0SEft+d48BQ47JoWC/XcdT9Ce3wQEl6x8l8Flt6t6eEa2RmLpAdbkgOM+fHc72mi IvRnZN4x9MAO3WDyOKqzsbTd2kCYlpWv+H944sy1DORquH+1EpHWsn2WGf33k3xFnX3C kVLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=YTl8lM9c; 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 13si4096152wru.9.2017.11.17.16.45.00; Fri, 17 Nov 2017 16:45:01 -0800 (PST) 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=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=YTl8lM9c; 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 06617689BA0; Sat, 18 Nov 2017 02:44:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 62D27689A72 for ; Sat, 18 Nov 2017 02:44:37 +0200 (EET) Received: by mail-qt0-f196.google.com with SMTP id h42so8919258qtk.11 for ; Fri, 17 Nov 2017 16:44:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=+EQAI3xvVCxhaM0mP/wzK3vqoEHb1RF0CmfmWJw/shQ=; b=YTl8lM9cLrAkSVDfh401+GqqlRmJFzrXlhHxyi/QA7SdZnMaqLNEx6dkJ82s/a3ruY euBXC7SP5GfJ0rLIDqg55JldFc88Xsd7NtC9NiY98I5SxpRy0ka2VvGlDdoM98WOxjqb 4S6jGYKSxpWyPgntcTQfnqHuFUAV/HAX1P1XNB3cjP0bf1blbbt8iJyGgb2446JvApGg TS+L4iwVgn+q4+tixMb0Ek9CMFJgxmbsKuCOXuiCtR1KUWXXP1yv/2TPLNxmnLb3Zqte V5TyADpfArQCsXhScF/S+SEyMyMnEOvQfKRdKj7IS/scDrLqhdva1DOEpuZr3qqeyCL/ ctEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=+EQAI3xvVCxhaM0mP/wzK3vqoEHb1RF0CmfmWJw/shQ=; b=rx9iDpEOnBahs4APnayeoGJnI0OMg55+OTdBCVyqJE0diTZ0wQjaSCCRqdrQj9BIW9 Hoi+/0O1ch9Bm8AO+HsC0h4UzmLwQSwi8XqBOiHbb+aFOIIn8mgnKZcJrEKqBHyUjTVh deqfz7k9RR17JkicC1U1CbFjNYu6TIlmDb2nQdhZyaKXLuJis9/4L5ZluSCa+irz3NpI DThcTF2iYOiWp2TFAuvxyYMAUNgUD2ciOJFfgZomFhIXwe9AWseAVJxVHHOg2Jb+Q8GT +54tIlprw6khYqvizwCw31BDuiM5krcRntmeGFRRdWJFhddzJg5+7akLnBhVzOabbwe4 RObA== X-Gm-Message-State: AJaThX48pb1HFl52GKeg3URlL80CoKIIrxm54q1f0Z261UUrYKdYd9qc 1sIus8jeOdVPoN5UNPuIGIY/OVcA X-Received: by 10.237.36.23 with SMTP id r23mr11463065qtc.326.1510965419541; Fri, 17 Nov 2017 16:36:59 -0800 (PST) Received: from localhost.localdomain (c-67-160-208-228.hsd1.ca.comcast.net. [67.160.208.228]) by smtp.gmail.com with ESMTPSA id 13sm3413114qtv.67.2017.11.17.16.36.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Nov 2017 16:36:59 -0800 (PST) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 Nov 2017 16:36:46 -0800 Message-Id: <20171118003648.33514-2-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171118003648.33514-1-ffmpeg@tmm1.net> References: <20171118003648.33514-1-ffmpeg@tmm1.net> Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/j2kenc: reinitialize state if frame size changes 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 Cc: Aman Gupta MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta --- libavcodec/j2kenc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 2135ece540..1eb091af3b 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -995,7 +995,15 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, Jpeg2000EncoderContext *s = avctx->priv_data; uint8_t *chunkstart, *jp2cstart, *jp2hstart; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width*avctx->height*9 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) + if (pict->height != s->height || pict->width != s->width) { + s->height = pict->height; + s->width = pict->width; + cleanup(s); + if ((ret=init_tiles(s)) < 0) + return ret; + } + + if ((ret = ff_alloc_packet2(avctx, pkt, s->width*s->height*9 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) return ret; // init: @@ -1031,8 +1039,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, chunkstart = s->buf; bytestream_put_be32(&s->buf, 0); bytestream_put_buffer(&s->buf, "ihdr", 4); - bytestream_put_be32(&s->buf, avctx->height); - bytestream_put_be32(&s->buf, avctx->width); + bytestream_put_be32(&s->buf, s->height); + bytestream_put_be32(&s->buf, s->width); bytestream_put_be16(&s->buf, s->ncomponents); bytestream_put_byte(&s->buf, s->cbps[0]); bytestream_put_byte(&s->buf, 7);