Once removed, sizeof(AVPacket) will stop being a part of the public ABI.
Unified · Split
| @@ -15,6 +15,11 @@ libavutil: 2017-10-21 · 14 unmodified lines | |||
| 15 | 15 | ||
| 16 | API changes, most recent first: | 16 | API changes, most recent first: |
| 17 | 17 | ||
| 18 | 2021-03-xx - xxxxxxxxxx - lavc 58.133.100 - codec.h | ||
| 19 | Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will | ||
| 20 | no longer be a part of the public ABI. | ||
| 21 | Deprecated AVPacketList. | ||
| 22 | |||
| 18 | 2021-03-xx - xxxxxxxxxx - lavc 58.132.100 - codec.h | 23 | 2021-03-xx - xxxxxxxxxx - lavc 58.132.100 - codec.h |
| 19 | Add AV_CODEC_CAP_OTHER_THREADS as a new name for | 24 | Add AV_CODEC_CAP_OTHER_THREADS as a new name for |
| 20 | AV_CODEC_CAP_AUTO_THREADS. AV_CODEC_CAP_AUTO_THREADS | 25 | AV_CODEC_CAP_AUTO_THREADS. AV_CODEC_CAP_AUTO_THREADS |
| @@ -32,6 +32,7 @@ · 31 unmodified lines | |||
| 32 | #include "packet.h" | 32 | #include "packet.h" |
| 33 | #include "packet_internal.h" | 33 | #include "packet_internal.h" |
| 34 | 34 | ||
| 35 | #if FF_API_INIT_PACKET | ||
| 35 | void av_init_packet(AVPacket *pkt) | 36 | void av_init_packet(AVPacket *pkt) |
| 36 | { | 37 | { |
| 37 | pkt->pts = AV_NOPTS_VALUE; | 38 | pkt->pts = AV_NOPTS_VALUE; |
| @@ -49,6 +50,16 @@ FF_ENABLE_DEPRECATION_WARNINGS · 11 unmodified lines | |||
| 49 | pkt->side_data = NULL; | 50 | pkt->side_data = NULL; |
| 50 | pkt->side_data_elems = 0; | 51 | pkt->side_data_elems = 0; |
| 51 | } | 52 | } |
| 53 | #endif | ||
| 54 | |||
| 55 | static void get_packet_defaults(AVPacket *pkt) | ||
| 56 | { | ||
| 57 | memset(pkt, 0, sizeof(*pkt)); | ||
| 58 | |||
| 59 | pkt->pts = AV_NOPTS_VALUE; | ||
| 60 | pkt->dts = AV_NOPTS_VALUE; | ||
| 61 | pkt->pos = -1; | ||
| 62 | } | ||
| 52 | 63 | ||
| 53 | AVPacket *av_packet_alloc(void) | 64 | AVPacket *av_packet_alloc(void) |
| 54 | { | 65 | { |
| @@ -56,7 +67,7 @@ AVPacket *av_packet_alloc(void) · 1 unmodified line | |||
| 56 | if (!pkt) | 67 | if (!pkt) |
| 57 | return pkt; | 68 | return pkt; |
| 58 | 69 | ||
| 59 | av_init_packet(pkt); | 70 | get_packet_defaults(pkt); |
| 60 | 71 | ||
| 61 | return pkt; | 72 | return pkt; |
| 62 | } | 73 | } |
| @@ -92,7 +103,7 @@ int av_new_packet(AVPacket *pkt, int size) · 29 unmodified lines | |||
| 92 | if (ret < 0) | 103 | if (ret < 0) |
| 93 | return ret; | 104 | return ret; |
| 94 | 105 | ||
| 95 | av_init_packet(pkt); | 106 | get_packet_defaults(pkt); |
| 96 | pkt->buf = buf; | 107 | pkt->buf = buf; |
| 97 | pkt->data = buf->data; | 108 | pkt->data = buf->data; |
| 98 | pkt->size = size; | 109 | pkt->size = size; |
| @@ -611,9 +622,7 @@ void av_packet_unref(AVPacket *pkt) · 512 unmodified lines | |||
| 611 | { | 622 | { |
| 612 | av_packet_free_side_data(pkt); | 623 | av_packet_free_side_data(pkt); |
| 613 | av_buffer_unref(&pkt->buf); | 624 | av_buffer_unref(&pkt->buf); |
| 614 | av_init_packet(pkt); | 625 | get_packet_defaults(pkt); |
| 615 | pkt->data = NULL; | ||
| 616 | pkt->size = 0; | ||
| 617 | } | 626 | } |
| 618 | 627 | ||
| 619 | int av_packet_ref(AVPacket *dst, const AVPacket *src) | 628 | int av_packet_ref(AVPacket *dst, const AVPacket *src) |
| @@ -668,9 +677,7 @@ AVPacket *av_packet_clone(const AVPacket *src) · 48 unmodified lines | |||
| 668 | void av_packet_move_ref(AVPacket *dst, AVPacket *src) | 677 | void av_packet_move_ref(AVPacket *dst, AVPacket *src) |
| 669 | { | 678 | { |
| 670 | *dst = *src; | 679 | *dst = *src; |
| 671 | av_init_packet(src); | 680 | get_packet_defaults(src); |
| 672 | src->data = NULL; | ||
| 673 | src->size = 0; | ||
| 674 | } | 681 | } |
| 675 | 682 | ||
| 676 | int av_packet_make_refcounted(AVPacket *pkt) | 683 | int av_packet_make_refcounted(AVPacket *pkt) |
| @@ -323,10 +323,6 @@ typedef struct AVPacketSideData { · 322 unmodified lines | |||
| 323 | * packets, with no compressed data, containing only side data | 323 | * packets, with no compressed data, containing only side data |
| 324 | * (e.g. to update some stream parameters at the end of encoding). | 324 | * (e.g. to update some stream parameters at the end of encoding). |
| 325 | * | 325 | * |
| 326 | * AVPacket is one of the few structs in FFmpeg, whose size is a part of public | ||
| 327 | * ABI. Thus it may be allocated on stack and no new fields can be added to it | ||
| 328 | * without libavcodec and libavformat major bump. | ||
| 329 | * | ||
| 330 | * The semantics of data ownership depends on the buf field. | 326 | * The semantics of data ownership depends on the buf field. |
| 331 | * If it is set, the packet data is dynamically allocated and is | 327 | * If it is set, the packet data is dynamically allocated and is |
| 332 | * valid indefinitely until a call to av_packet_unref() reduces the | 328 | * valid indefinitely until a call to av_packet_unref() reduces the |
| @@ -338,6 +334,12 @@ typedef struct AVPacketSideData { · 5 unmodified lines | |||
| 338 | * The side data is always allocated with av_malloc(), copied by | 334 | * The side data is always allocated with av_malloc(), copied by |
| 339 | * av_packet_ref() and freed by av_packet_unref(). | 335 | * av_packet_ref() and freed by av_packet_unref(). |
| 340 | * | 336 | * |
| 337 | * sizeof(AVPacket) being a part of the public ABI is deprecated. once | ||
| 338 | * av_init_packet() is removed, new packets will only be able to be allocated | ||
| 339 | * with av_packet_alloc(), and new fields may be added to the end of the struct | ||
| 340 | * with a minor bump. | ||
| 341 | * | ||
| 342 | * @see av_packet_alloc | ||
| 341 | * @see av_packet_ref | 343 | * @see av_packet_ref |
| 342 | * @see av_packet_unref | 344 | * @see av_packet_unref |
| 343 | */ | 345 | */ |
| @@ -397,10 +399,13 @@ typedef struct AVPacket { · 53 unmodified lines | |||
| 397 | #endif | 399 | #endif |
| 398 | } AVPacket; | 400 | } AVPacket; |
| 399 | 401 | ||
| 402 | #if FF_API_INIT_PACKET | ||
| 403 | attribute_deprecated | ||
| 400 | typedef struct AVPacketList { | 404 | typedef struct AVPacketList { |
| 401 | AVPacket pkt; | 405 | AVPacket pkt; |
| 402 | struct AVPacketList *next; | 406 | struct AVPacketList *next; |
| 403 | } AVPacketList; | 407 | } AVPacketList; |
| 408 | #endif | ||
| 404 | 409 | ||
| 405 | #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe | 410 | #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe |
| 406 | #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted | 411 | #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted |
| @@ -464,6 +469,7 @@ AVPacket *av_packet_clone(const AVPacket *src); · 57 unmodified lines | |||
| 464 | */ | 469 | */ |
| 465 | void av_packet_free(AVPacket **pkt); | 470 | void av_packet_free(AVPacket **pkt); |
| 466 | 471 | ||
| 472 | #if FF_API_INIT_PACKET | ||
| 467 | /** | 473 | /** |
| 468 | * Initialize optional fields of a packet with default values. | 474 | * Initialize optional fields of a packet with default values. |
| 469 | * | 475 | * |
| @@ -471,8 +477,16 @@ void av_packet_free(AVPacket **pkt); · 1 unmodified line | |||
| 471 | * initialized separately. | 477 | * initialized separately. |
| 472 | * | 478 | * |
| 473 | * @param pkt packet | 479 | * @param pkt packet |
| 480 | * | ||
| 481 | * @see av_packet_alloc | ||
| 482 | * @see av_packet_unref | ||
| 483 | * | ||
| 484 | * @deprecated This function is deprecated. Once it's removed, | ||
| 485 | sizeof(AVPacket) will not be a part of the ABI anymore. | ||
| 474 | */ | 486 | */ |
| 487 | attribute_deprecated | ||
| 475 | void av_init_packet(AVPacket *pkt); | 488 | void av_init_packet(AVPacket *pkt); |
| 489 | #endif | ||
| 476 | 490 | ||
| 477 | /** | 491 | /** |
| 478 | * Allocate the payload of a packet and initialize its fields with | 492 | * Allocate the payload of a packet and initialize its fields with |
| @@ -28,7 +28,7 @@ · 27 unmodified lines | |||
| 28 | #include "libavutil/version.h" | 28 | #include "libavutil/version.h" |
| 29 | 29 | ||
| 30 | #define LIBAVCODEC_VERSION_MAJOR 58 | 30 | #define LIBAVCODEC_VERSION_MAJOR 58 |
| 31 | #define LIBAVCODEC_VERSION_MINOR 132 | 31 | #define LIBAVCODEC_VERSION_MINOR 133 |
| 32 | #define LIBAVCODEC_VERSION_MICRO 100 | 32 | #define LIBAVCODEC_VERSION_MICRO 100 |
| 33 | 33 | ||
| 34 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ | 34 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| @@ -165,5 +165,8 @@ · 130 unmodified lines | |||
| 165 | #ifndef FF_API_AUTO_THREADS | 165 | #ifndef FF_API_AUTO_THREADS |
| 166 | #define FF_API_AUTO_THREADS (LIBAVCODEC_VERSION_MAJOR < 60) | 166 | #define FF_API_AUTO_THREADS (LIBAVCODEC_VERSION_MAJOR < 60) |
| 167 | #endif | 167 | #endif |
| 168 | #ifndef FF_API_INIT_PACKET | ||
| 169 | #define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60) | ||
| 170 | #endif | ||
| 168 | 171 | ||
| 169 | #endif /* AVCODEC_VERSION_H */ | 172 | #endif /* AVCODEC_VERSION_H */ |
| @@ -954,7 +954,11 @@ typedef struct AVStream { · 953 unmodified lines | |||
| 954 | * decoding: set by libavformat, must not be modified by the caller. | 954 | * decoding: set by libavformat, must not be modified by the caller. |
| 955 | * encoding: unused | 955 | * encoding: unused |
| 956 | */ | 956 | */ |
| 957 | #if FF_API_INIT_PACKET | ||
| 957 | AVPacket attached_pic; | 958 | AVPacket attached_pic; |
| 959 | #else | ||
| 960 | AVPacket *attached_pic; | ||
| 961 | #endif | ||
| 958 | 962 | ||
| 959 | /** | 963 | /** |
| 960 | * An array of side data that applies to the whole stream (i.e. the | 964 | * An array of side data that applies to the whole stream (i.e. the |