From patchwork Sat Feb 4 10:41:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40264 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp1869872pzk; Sat, 4 Feb 2023 02:46:40 -0800 (PST) X-Google-Smtp-Source: AK7set/k7A0hVoe4z5JUiQsJj+1k5/tuYgwOe+enIW+U9ysBzVsv6JJYfDqAuK8DpUZhErGLwyYE X-Received: by 2002:a17:906:bc88:b0:884:ab29:bd0b with SMTP id lv8-20020a170906bc8800b00884ab29bd0bmr14595831ejb.69.1675507600526; Sat, 04 Feb 2023 02:46:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675507600; cv=none; d=google.com; s=arc-20160816; b=hu0dLgzL1HeRb5IOCkJUZmEUeeK7LB9mOLIYJb1kWPEYvxjAvtkdOIhhjAv7720zHL tiuqYum/6iABG2XPuS9lX7Oq5uD/IeF9gbNiDYRR0uJ6r+De4ZQ3LZ75jfF63dA4lnb9 l7YS1cQgiZw+WYxI+ncGK6EpaVz3U9M4tSBfYNYvBS6KeMbImbFVMhfHAWaP6xr0f1RJ f1nb5nq91Evgfh76cTTvR4I0JQULAkYNfpgfSrzRcV3v1c21ISZSokCqR7kf+rgXKOtg vKTjmM7pUiflH6J5C2FrnIoLPTkNl+hljLm1LSa1C4SKhRhnX1k47zvrHYtm06QZlMCi mpNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=tBJCk3aut3AtP2d0gxHO6ha2YpaNo3rle662ISuA7xk=; b=drSktBhYxdXWRx3xGK3htZyr1Bd4jNZGGlxGe4dNHccGTKjjk4xEl38HlYAe093gxe NcwS01OQWtB9EuZRqCP8b9MNdq5rc+B9P2a1nze3imLc+wCE6fZaM63CJxFL6kBJAwPf 9Df6s0KuZJQmXktykTRJ25z+H85dVDgvl09BJbA4O/LwHZlGq9j01ackGRcJod78e+Ko LU9ZtG0UlkeavWsGls5YkwBhRBVLg60dguwf7rAZLgfRgbaRzr5bgtXA0R4ftujtbNem uGmhn2uZQNj5X9sN1AW/rXH2291m3Z9Nvye8diU1tgYNWNaQQKqcTh7dWpR8maUaYROK zXoQ== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fd2-20020a1709072a0200b008845c668412si5121466ejc.189.2023.02.04.02.46.40; Sat, 04 Feb 2023 02:46:40 -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; 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 4DCE268BE5A; Sat, 4 Feb 2023 12:44:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D4BD168BD40 for ; Sat, 4 Feb 2023 12:44:12 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9FCB42405EC for ; Sat, 4 Feb 2023 11:44:09 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id szTfY0OUACym for ; Sat, 4 Feb 2023 11:44:09 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (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 "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id AB9312404F8 for ; Sat, 4 Feb 2023 11:44:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 20B173A034C for ; Sat, 4 Feb 2023 11:44:05 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 4 Feb 2023 11:41:34 +0100 Message-Id: <20230204104204.20721-4-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230204104204.20721-1-anton@khirnov.net> References: <20230204104204.20721-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 03/33] avcodec: Make avcodec_decode_subtitle2 accept a const AVPacket* 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 8yRDQr20r95a From: Andreas Rheinhardt Signed-off-by: Andreas Rheinhardt Signed-off-by: Anton Khirnov --- doc/APIchanges | 3 +++ fftools/ffmpeg.c | 4 ++-- fftools/ffprobe.c | 2 +- libavcodec/avcodec.h | 3 +-- libavcodec/decode.c | 9 ++++----- tools/target_dec_fuzzer.c | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index bc52a079644..b1181ec60a3 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2023-02-xx - xxxxxxxxxx - lavc 60.0.100 - avcodec.h + avcodec_decode_subtitle2() now accepts const AVPacket*. + 2023-01-29 - xxxxxxxxxx - lavc 59.59.100 - avcodec.h Add AV_CODEC_FLAG_COPY_OPAQUE and AV_CODEC_FLAG_FRAME_DURATION. diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 92fd61f3158..257f319550c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2296,8 +2296,8 @@ fail: return err < 0 ? err : ret; } -static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, - int *decode_failed) +static int transcode_subtitles(InputStream *ist, const AVPacket *pkt, + int *got_output, int *decode_failed) { AVSubtitle subtitle; int free_sub = 1; diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index dfa7ff1b241..5beaece094f 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2733,7 +2733,7 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, static av_always_inline int process_frame(WriterContext *w, InputFile *ifile, - AVFrame *frame, AVPacket *pkt, + AVFrame *frame, const AVPacket *pkt, int *packet_new) { AVFormatContext *fmt_ctx = ifile->fmt_ctx; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 90b437ccbe2..b9bd69a2ec7 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2601,8 +2601,7 @@ enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos); * @param[in] avpkt The input AVPacket containing the input buffer. */ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - AVPacket *avpkt); + int *got_sub_ptr, const AVPacket *avpkt); /** * Supply raw packet data as input to a decoder. diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 0abc88737b2..45c1f085792 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -780,8 +780,8 @@ static void get_subtitle_defaults(AVSubtitle *sub) } #define UTF8_MAX_BYTES 4 /* 5 and 6 bytes sequences should not be used */ -static int recode_subtitle(AVCodecContext *avctx, AVPacket **outpkt, - AVPacket *inpkt, AVPacket *buf_pkt) +static int recode_subtitle(AVCodecContext *avctx, const AVPacket **outpkt, + const AVPacket *inpkt, AVPacket *buf_pkt) { #if CONFIG_ICONV iconv_t cd = (iconv_t)-1; @@ -861,8 +861,7 @@ static int utf8_check(const uint8_t *str) } int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - AVPacket *avpkt) + int *got_sub_ptr, const AVPacket *avpkt) { int ret = 0; @@ -882,7 +881,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size) { AVCodecInternal *avci = avctx->internal; - AVPacket *pkt; + const AVPacket *pkt; ret = recode_subtitle(avctx, &pkt, avpkt, avci->buffer_pkt); if (ret < 0) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index a20345db5c6..8e89b613c07 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -81,8 +81,8 @@ static const FFCodec *AVCodecInitialize(enum AVCodecID codec_id) return ffcodec(res); } -static int subtitle_handler(AVCodecContext *avctx, void *frame, - int *got_sub_ptr, AVPacket *avpkt) +static int subtitle_handler(AVCodecContext *avctx, AVFrame *unused, + int *got_sub_ptr, const AVPacket *avpkt) { AVSubtitle sub; int ret = avcodec_decode_subtitle2(avctx, &sub, got_sub_ptr, avpkt);