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 7231940F42 for ; Fri, 13 May 2022 02:10:49 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4AEE868B441; Fri, 13 May 2022 05:10:46 +0300 (EEST) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0A7268B34E for ; Fri, 13 May 2022 05:10:39 +0300 (EEST) Received: by mail-pf1-f179.google.com with SMTP id y41so6413196pfw.12 for ; Thu, 12 May 2022 19:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=V1Vtgs7/TR/00MEIgZ2q9qgtS8lT9wupo1umanIlrgM=; b=itA+bXI91St2ZGhVDShln/jWn/LdmYm33Jxh4aazFmk7ZrRliDspw2K/5QErVzOBW7 aYzNQWZOD4era4qg/5KfnY/dnJr+CeQHQjfTElGHjjcqy/PdCW8x8GsiEH6JZN++DZ56 OpYohGF9NtnIc4LEM9Fqk/rHqkrgx4HUwIBjIbh0sJNvapWe+F80yWm6yxy3oxGibgCy KNZYlQ4cznzB0HErTd005SI4mb3sEbPWOrZJj1jYn4fQcDoj7oYxUW9RyTFH5N5wFEkE n0FrNoBG56+xqx2ac1ivTygj80afV7nFNn7GfdKru4e2je75srWeCwBVq9IHeWkVFWSg 1krw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to; bh=V1Vtgs7/TR/00MEIgZ2q9qgtS8lT9wupo1umanIlrgM=; b=IO11C9jfZkVnHSluVQlB+5te4UzpTIU8Ow9Npvl7gK+BLmYLS9k6SLIS3H8pKE6Rv9 /8QLOJQELkGySJJZFYlWFlqBB0f8rqKdTwMbh6gGqpBG8ABL8l6UhCd/nFesbwy1lcwc Uf2mNUl5iV4sV2s3g6KabcNN0ZTi6T9Fg1hoixSpp37f0s4c9R1oQ/0CqGkPj8r4PD90 rV4orSUrUMX0/RCmfAEXqTDk9/dDYf8DWulg6eGCS97QmwOJSRwNc5iyw4Kn5xffH1ld 1DhIA09psAHeWj+zTtBQQvgYxnw38tYNQnGKZEs06grjsd3XKKjAxS17sGGlpwv3Of2F gYkg== X-Gm-Message-State: AOAM5306TXIq6YEEiWKFK0SjHnDN0rJtu+bRkMAAv3rAHd04MvQpVboI oN2RUNvpcs4cTaUHrsygzogB8uqfOsY= X-Google-Smtp-Source: ABdhPJxv+YPvD2G+XPq8XGHDooDc8BQg8Z9RzRlf1mkj0PZN7vU2lC+ZibB6cdmL2KGqSdrcSPVhGg== X-Received: by 2002:a63:d504:0:b0:3c6:ab6b:fd2b with SMTP id c4-20020a63d504000000b003c6ab6bfd2bmr2043291pgg.437.1652407837737; Thu, 12 May 2022 19:10:37 -0700 (PDT) Received: from gmail.com ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id a12-20020a170902900c00b0015e8d4eb1ddsm590247plp.39.2022.05.12.19.10.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 May 2022 19:10:37 -0700 (PDT) Date: Fri, 13 May 2022 10:10:33 +0800 From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Message-ID: <20220513021033.GA19590@gmail.com> Mail-Followup-To: ffmpeg-devel@ffmpeg.org References: <1652280498-10408-1-git-send-email-lance.lmwang@gmail.com> <1652280498-10408-2-git-send-email-lance.lmwang@gmail.com> <20220511233840.GA15884@gmail.com> <20220512151713.GA8500@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 2/4] avcodec/ccaption_dec: check the length of packet and return used length 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 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 Thu, May 12, 2022 at 06:29:51PM +0200, Andreas Rheinhardt wrote: > Andreas Rheinhardt: > > lance.lmwang@gmail.com: > >> On Thu, May 12, 2022 at 08:25:29AM +0200, Paul B Mahol wrote: > >>> On Thu, May 12, 2022 at 1:39 AM wrote: > >>> > >>>> On Wed, May 11, 2022 at 09:47:52PM +0200, Paul B Mahol wrote: > >>>>> why? > >>>> > >>>> assuming the len is 1, the following code will access the next 3 > >>>> array anymore, I think it's better to check the i with len -2. > >>>> > >>>> for (i = 0; i < len; i += 3) { > >>>> to > >>>> for (i = 0; i < len - 2; i += 3) { > >>>> > >>>> for the return, I think it's correct to return the used length, > >>>> if it's error, have return already. right? > >>> > >>> > >>> I doubt so. > >> > >> maybe I'm misunderstand it, but from the comments, the API claims that: > >> libavcodec/codec_internal.h > >> 175 * @return amount of bytes read from the packet on success, > >> 176 * negative error code on failure > >> 177 */ > >> 178 int (*decode)(struct AVCodecContext *avctx, struct AVFrame *frame, > >> 179 int *got_frame_ptr, struct AVPacket *avpkt); > >> 180 /** > >> 181 * Decode subtitle data to an AVSubtitle. > >> 182 * cb is in this state if cb_type is FF_CODEC_CB_TYPE_DECODE_SUB. > >> 183 * > >> 184 * Apart from that this is like the decode callback. > >> 185 */ > >> 186 int (*decode_sub)(struct AVCodecContext *avctx, struct AVSubtitle *sub, > >> 187 int *got_frame_ptr, const struct AVPacket *avpkt); > >> > > > > This is correct. It is not only the internal API which claims that, but > > the public API, too. And this just not honoured, in particular not in > > case of subtitle recoding. See > > https://github.com/mkver/FFmpeg/commit/ba1564c532654888015d67b70bf73d117c2d9f75 > > > > It seems like there really are people who call this in a loop until all > the input is exhausted (as the documentation leads you to believe (The > internal uses of avcodec_decode_subtitle2 don't do this.)): > https://github.com/HandBrake/HandBrake/blob/a40fb6bce6755209461166140f131f26a2857eb9/libhb/decavsub.c#L335 > I wonder if they ever got something meaningful the second time they > called it with the same packet (presuming there was a second time). At first, I thought it was an unintentional return as all other subtitle decode return packet size always. If the code don't support for that as claims by document, then I prefer to fix the document. If not, we need to fix the code. > > - Andreas > _______________________________________________ > 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". -- Thanks, Limin Wang _______________________________________________ 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".