[FFmpeg-devel] [PATCH 29/31] avcodec: Make avcodec_decode_subtitle2 accept a const AVPacket*

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Jan 27 16:05:58 EET 2023


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 doc/APIchanges            | 3 +++
 fftools/ffmpeg.c          | 4 ++--
 fftools/ffprobe.c         | 2 +-
 libavcodec/avcodec.h      | 3 +--
 libavcodec/decode.c       | 9 ++++-----
 libavcodec/version.h      | 2 +-
 tools/target_dec_fuzzer.c | 4 ++--
 7 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index a11acadecd..d4c37b9040 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil:     2021-04-27
 
 API changes, most recent first:
 
+2023-01-25 - xxxxxxxxxx - lavc 59.58.100 - avcodec.h
+  avcodec_decode_subtitle2() now accepts const AVPacket*.
+
 2023-01-13 - xxxxxxxxxx - lavu 57.44.100 - ambient_viewing_environment.h frame.h
   Adds a new structure for holding H.274 Ambient Viewing Environment metadata,
   AVAmbientViewingEnvironment.
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index bef910a787..a916f9fe3e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2199,8 +2199,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 5cfc2d9f87..db37ec52f4 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 4a9f9957d2..cb4f7a8514 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2504,8 +2504,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 96889f7dea..c37d607e27 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -771,8 +771,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;
@@ -852,8 +852,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;
 
@@ -873,7 +872,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/libavcodec/version.h b/libavcodec/version.h
index dfd3d5d7e5..7ac8d2b2fe 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  57
+#define LIBAVCODEC_VERSION_MINOR  58
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index a20345db5c..8e89b613c0 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);
-- 
2.34.1



More information about the ffmpeg-devel mailing list