From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 1C88B4286E for ; Tue, 5 Apr 2022 10:50:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D135168B120; Tue, 5 Apr 2022 13:50:11 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B94A868A59A for ; Tue, 5 Apr 2022 13:50:05 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 367D1240179; Tue, 5 Apr 2022 12:50:05 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Ma0d6NG1FNf6; Tue, 5 Apr 2022 12:50:04 +0200 (CEST) Received: from lain.red.khirnov.net (lain.red.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.red.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 9A3422400F5; Tue, 5 Apr 2022 12:50:04 +0200 (CEST) Received: by lain.red.khirnov.net (Postfix, from userid 1000) id C74E61601AD; Tue, 5 Apr 2022 12:50:04 +0200 (CEST) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20220402201210.86308-3-leo.izen@gmail.com> References: <20220402201210.86308-1-leo.izen@gmail.com> <20220402201210.86308-3-leo.izen@gmail.com> Mail-Followup-To: FFmpeg development discussions and patches , Leo Izen Date: Tue, 05 Apr 2022 12:50:04 +0200 Message-ID: <164915580478.21047.15063529421341494996@lain.red.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v12 2/4] avcodec/libjxl: add Jpeg XL decoding via libjxl X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Leo Izen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Quoting Leo Izen (2022-04-02 22:12:08) > + case JXL_DEC_COLOR_ENCODING: > + av_log(avctx, AV_LOG_DEBUG, "COLOR_ENCODING event emitted\n"); > + jret = JxlDecoderGetICCProfileSize(ctx->decoder, &ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_ORIGINAL, &ctx->iccp_len); Does iccp_len need to be a context variable? Seems to me it's only used in this block. > + if (jret == JXL_DEC_SUCCESS && ctx->iccp_len > 0) { > + av_buffer_unref(&ctx->iccp); > + av_assert2(!ctx->iccp); Useless assert, you can rely on basic functions to do what they should. > + ctx->iccp = av_buffer_alloc(ctx->iccp_len); > + if (!ctx->iccp) > + return AVERROR(ENOMEM); > + jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, &ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_ORIGINAL, ctx->iccp->data, ctx->iccp_len); > + if (jret != JXL_DEC_SUCCESS) > + av_freep(&ctx->iccp); av_buffer_unref? > + } > + continue; > + case JXL_DEC_FRAME: > + case JXL_DEC_NEED_IMAGE_OUT_BUFFER: > + /* > + * We don't do this at basic info time > + * because it will happen again when we > + * rewind anyway > + */ > + av_log(avctx, AV_LOG_DEBUG, "%s event emitted\n", jret == JXL_DEC_FRAME ? "FRAME" : "NEED_IMAGE_OUT_BUFFER"); > + ret = ff_get_buffer(avctx, frame, 0); Is it absolutely guaranteed that this will always happen before JXL_DEC_FULL_IMAGE in the same libjxl_decode_frame() invocation? Can it happen that you get JXL_DEC_NEED_IMAGE_OUT_BUFFER/JXL_DEC_FRAME, then JXL_DEC_NEED_MORE_INPUT, which causes you to return, then JXL_DEC_FULL_IMAGE on the next libjxl_decode_frame() call? > + case JXL_DEC_SUCCESS: > + av_log(avctx, AV_LOG_DEBUG, "SUCCESS event emitted\n"); > + /* > + * The file has finished decoding > + * reset the decoder to let us > + * reuse it again for the next image > + */ > + JxlDecoderReset(ctx->decoder); > + libjxl_init_jxl_decoder(avctx); > + buf = avpkt->data; > + remaining = avpkt->size; Why reset buf? The same data is not going to be decoded again, is it? -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".