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 2779348272 for ; Fri, 15 Dec 2023 16:40:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3FF8668D0BA; Fri, 15 Dec 2023 18:40:49 +0200 (EET) Received: from mail-4319.protonmail.ch (mail-4319.protonmail.ch [185.70.43.19]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D57B668CF9B for ; Fri, 15 Dec 2023 18:40:42 +0200 (EET) Date: Fri, 15 Dec 2023 16:40:22 +0000 To: FFmpeg development discussions and patches Message-ID: In-Reply-To: <1b72fe1f-f408-4378-a1bd-463d26b828a3@gmail.com> References: <1b72fe1f-f408-4378-a1bd-463d26b828a3@gmail.com> Feedback-ID: 28710920:user:proton MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2 1/1] avcodec/libjxlenc: Add libjxl_animated encoder 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: , From: =?utf-8?q?Zsolt_Vad=C3=A1sz_via_ffmpeg-devel?= Reply-To: FFmpeg development discussions and patches Cc: =?utf-8?Q?Zsolt_Vad=C3=A1sz?= 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: On Friday, December 15th, 2023 at 12:20 AM, Leo Izen wrote: > > + AVFrame *last; > > > I don't see the purpose of keeping this here. > The name is misleading, I should have named it `previous`, since it always contains the previous frame. I did it this way so I could call JxlEncoderCloseInput when the callback received NULL. > > + > > + if(!ctx->last && !avctx->internal->draining) { > + ctx->last = av_frame_clone(frame); > > + *got_packet = 0; > > + return AVERROR(EAGAIN); > > It looks like you're trying to emit one packet per image, rather than > one packet per encoded frame. This is fine, but you should not be > calling av_frame_clone, and there's no reason to use > avctx->internal->draining here. If you are doing this, you also have no > > reason to cache ctx->last at all. It's the opposite, I'm trying to emit a packet for each frame of the animation. > > +const FFCodec ff_libjxl_animated_encoder = { > > + .p.name = "libjxl_animated", > > + CODEC_LONG_NAME("libjxl Animated JPEG XL"), > > + .p.type = AVMEDIA_TYPE_VIDEO, > > + .p.id = AV_CODEC_ID_JPEGXL, > > + .priv_data_size = sizeof(LibJxlEncodeContext), > > + .init = libjxl_animated_encode_init, > > + FF_CODEC_ENCODE_CB(libjxl_animated_encode_frame), > > + .close = libjxl_encode_close, > > + .p.capabilities = AV_CODEC_CAP_OTHER_THREADS | > > + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE | > > + AV_CODEC_CAP_DELAY, > > + .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | > > + FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP | > > + FF_CODEC_CAP_ICC_PROFILES | FF_CODEC_CAP_EOF_FLUSH, > > > Why FF_CODEC_CAP_EOF_FLUSH? So the encoder receives a NULL after the last frame has been submitted, so JxlEncoderCloseInput can be called and the final frame properly emitted. _______________________________________________ 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".