diff mbox series

[FFmpeg-devel,2/2] avformat: add a deprecated attribute to AVStream.attached_pic

Message ID 20210321170900.2045-2-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] avformat/utils: add an internal getter function to access AVStream.attached_pic | expand

Checks

Context Check Description
andriy/x86_make_warn warning New warnings during build
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer March 21, 2021, 5:09 p.m. UTC
And mention how the field is not being removed but changed, with instructions
for library users to migrate their code.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/avformat.h | 8 ++++++++
 libavformat/utils.c    | 4 ++++
 2 files changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 822aa4c631..9fa8049149 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -953,8 +953,16 @@  typedef struct AVStream {
      *
      * decoding: set by libavformat, must not be modified by the caller.
      * encoding: unused
+     *
+     * @deprecated This field will not be removed but become a pointer to an AVPacket
+     *             owned by libavformat instead.
+     *             Callers that want to be forward compatible with future libavformat
+     *             versions should wrap access to this field with a
+     *             LIBAVFORMAT_VERSION_MAJOR preoprocessor check and start treating it
+     *             as a pointer from version 60 onwards.
      */
 #if FF_API_INIT_PACKET
+    attribute_deprecated
     AVPacket attached_pic;
 #else
     AVPacket *attached_pic;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3db12af1b6..f7a3b96dab 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4384,8 +4384,10 @@  static void free_stream(AVStream **pst)
         av_parser_close(st->parser);
 
 #if FF_API_INIT_PACKET
+FF_DISABLE_DEPRECATION_WARNINGS
     if (st->attached_pic.data)
         av_packet_unref(&st->attached_pic);
+FF_ENABLE_DEPRECATION_WARNINGS
 #else
     av_packet_free(st->attached_pic);
 #endif
@@ -5864,7 +5866,9 @@  FF_ENABLE_DEPRECATION_WARNINGS
 AVPacket *ff_stream_get_attached_pic(AVStream *st)
 {
 #if FF_API_INIT_PACKET
+FF_DISABLE_DEPRECATION_WARNINGS
     return &st->attached_pic;
+FF_ENABLE_DEPRECATION_WARNINGS
 #else
     return st->attached_pic;
 #endif