History

avcodec/packet: deprecate av_init_packet()

Once removed, sizeof(AVPacket) will stop being a part of the public ABI.

James Almer committed 5 years ago

Commit f7db77b1 parent a1cd4195 files · +46 −13Browse files

Unified · Split

5 files
  1. doc/APIchanges +5 −0
  2. libavcodec/avpacket.c +15 −8
  3. libavcodec/packet.h +18 −4
  4. libavcodec/version.h +4 −1
  5. libavformat/avformat.h +4 −0
doc/APIchanges+5−0
@@ -15,6 +15,11 @@ libavutil: 2017-10-21 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182021-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
182021-03-xx - xxxxxxxxxx - lavc 58.132.100 - codec.h232021-03-xx - xxxxxxxxxx - lavc 58.132.100 - codec.h
19 Add AV_CODEC_CAP_OTHER_THREADS as a new name for24 Add AV_CODEC_CAP_OTHER_THREADS as a new name for
20 AV_CODEC_CAP_AUTO_THREADS. AV_CODEC_CAP_AUTO_THREADS25 AV_CODEC_CAP_AUTO_THREADS. AV_CODEC_CAP_AUTO_THREADS
libavcodec/avpacket.c+15−8
@@ -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
35void av_init_packet(AVPacket *pkt)36void 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
55static 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
53AVPacket *av_packet_alloc(void)64AVPacket *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
619int av_packet_ref(AVPacket *dst, const AVPacket *src)628int av_packet_ref(AVPacket *dst, const AVPacket *src)
@@ -668,9 +677,7 @@ AVPacket *av_packet_clone(const AVPacket *src) · 48 unmodified lines
668void av_packet_move_ref(AVPacket *dst, AVPacket *src)677void 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
676int av_packet_make_refcounted(AVPacket *pkt)683int av_packet_make_refcounted(AVPacket *pkt)
libavcodec/packet.h+18−4
@@ -323,10 +323,6 @@ typedef struct AVPacketSideData { · 322 unmodified lines
323 * packets, with no compressed data, containing only side data323 * 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 is327 * If it is set, the packet data is dynamically allocated and is
332 * valid indefinitely until a call to av_packet_unref() reduces the328 * 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 by334 * 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_ref343 * @see av_packet_ref
342 * @see av_packet_unref344 * @see av_packet_unref
343 */345 */
@@ -397,10 +399,13 @@ typedef struct AVPacket { · 53 unmodified lines
397#endif399#endif
398} AVPacket;400} AVPacket;
399 401
402#if FF_API_INIT_PACKET
403attribute_deprecated
400typedef struct AVPacketList {404typedef 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 keyframe410#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
406#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted411#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 */
465void av_packet_free(AVPacket **pkt);470void 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 packet479 * @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 */
487attribute_deprecated
475void av_init_packet(AVPacket *pkt);488void av_init_packet(AVPacket *pkt);
489#endif
476 490
477/**491/**
478 * Allocate the payload of a packet and initialize its fields with492 * Allocate the payload of a packet and initialize its fields with
libavcodec/version.h+4−1
@@ -28,7 +28,7 @@ · 27 unmodified lines
28#include "libavutil/version.h"28#include "libavutil/version.h"
29 29
30#define LIBAVCODEC_VERSION_MAJOR 5830#define LIBAVCODEC_VERSION_MAJOR 58
31#define LIBAVCODEC_VERSION_MINOR 13231#define LIBAVCODEC_VERSION_MINOR 133
32#define LIBAVCODEC_VERSION_MICRO 10032#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_THREADS165#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#endif167#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 */
libavformat/avformat.h+4−0
@@ -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: unused955 * 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. the964 * An array of side data that applies to the whole stream (i.e. the

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t