History

avpacket: ABI bump additions

This commit adds a long-requested by API users opaque fields for AVPacket, as well as a time_base field.

Lynne committed 5 years ago

Commit a1a0fdd1 parent a27853a4 files · +41 −4Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavcodec/avpacket.c +15 −2
  3. libavcodec/packet.h +21 −0
  4. libavcodec/version.h +2 −2
doc/APIchanges+3−0
@@ -14,6 +14,9 @@ libavutil: 2021-04-27 · 13 unmodified lines
14 14
15API changes, most recent first:15API changes, most recent first:
16 16
172021-08-02 - xxxxxxxxxx - lavc 59.4.100 - packet.h
18 Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base.
19
172021-07-23 - xxxxxxxxxx - lavu 57.3.100 - common.h macros.h202021-07-23 - xxxxxxxxxx - lavu 57.3.100 - common.h macros.h
18 Move several macros (AV_NE, FFDIFFSIGN, FFMAX, FFMAX3, FFMIN, FFMIN3,21 Move several macros (AV_NE, FFDIFFSIGN, FFMAX, FFMAX3, FFMIN, FFMIN3,
19 FFSWAP, FF_ARRAY_ELEMS, MKTAG, MKBETAG) from common.h to macros.h.22 FFSWAP, FF_ARRAY_ELEMS, MKTAG, MKBETAG) from common.h to macros.h.
libavcodec/avpacket.c+15−2
@@ -26,6 +26,7 @@ · 25 unmodified lines
26#include "libavutil/internal.h"26#include "libavutil/internal.h"
27#include "libavutil/mathematics.h"27#include "libavutil/mathematics.h"
28#include "libavutil/mem.h"28#include "libavutil/mem.h"
29#include "libavutil/rational.h"
29 30
30#include "bytestream.h"31#include "bytestream.h"
31#include "internal.h"32#include "internal.h"
@@ -44,6 +45,9 @@ void av_init_packet(AVPacket *pkt) · 12 unmodified lines
44 pkt->buf = NULL;45 pkt->buf = NULL;
45 pkt->side_data = NULL;46 pkt->side_data = NULL;
46 pkt->side_data_elems = 0;47 pkt->side_data_elems = 0;
48 pkt->opaque = NULL;
49 pkt->opaque_ref = NULL;
50 pkt->time_base = av_make_q(0, 0);
47}51}
48#endif52#endif
49 53
@@ -374,7 +378,7 @@ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, · 324 unmodified lines
374 378
375int av_packet_copy_props(AVPacket *dst, const AVPacket *src)379int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
376{380{
377 int i;381 int i, ret;
378 382
379 dst->pts = src->pts;383 dst->pts = src->pts;
380 dst->dts = src->dts;384 dst->dts = src->dts;
@@ -382,9 +386,16 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src) · 1 unmodified line
382 dst->duration = src->duration;386 dst->duration = src->duration;
383 dst->flags = src->flags;387 dst->flags = src->flags;
384 dst->stream_index = src->stream_index;388 dst->stream_index = src->stream_index;
385 389 dst->opaque = src->opaque;
390 dst->time_base = src->time_base;
391 dst->opaque_ref = NULL;
386 dst->side_data = NULL;392 dst->side_data = NULL;
387 dst->side_data_elems = 0;393 dst->side_data_elems = 0;
394
395 ret = av_buffer_replace(&dst->opaque_ref, src->opaque_ref);
396 if (ret < 0)
397 return ret;
398
388 for (i = 0; i < src->side_data_elems; i++) {399 for (i = 0; i < src->side_data_elems; i++) {
389 enum AVPacketSideDataType type = src->side_data[i].type;400 enum AVPacketSideDataType type = src->side_data[i].type;
390 size_t size = src->side_data[i].size;401 size_t size = src->side_data[i].size;
@@ -392,6 +403,7 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src) · 1 unmodified line
392 uint8_t *dst_data = av_packet_new_side_data(dst, type, size);403 uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
393 404
394 if (!dst_data) {405 if (!dst_data) {
406 av_buffer_unref(&dst->opaque_ref);
395 av_packet_free_side_data(dst);407 av_packet_free_side_data(dst);
396 return AVERROR(ENOMEM);408 return AVERROR(ENOMEM);
397 }409 }
@@ -404,6 +416,7 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src) · 6 unmodified lines
404void av_packet_unref(AVPacket *pkt)416void av_packet_unref(AVPacket *pkt)
405{417{
406 av_packet_free_side_data(pkt);418 av_packet_free_side_data(pkt);
419 av_buffer_unref(&pkt->opaque_ref);
407 av_buffer_unref(&pkt->buf);420 av_buffer_unref(&pkt->buf);
408 get_packet_defaults(pkt);421 get_packet_defaults(pkt);
409}422}
libavcodec/packet.h+21−0
@@ -391,6 +391,27 @@ typedef struct AVPacket { · 390 unmodified lines
391 int64_t duration;391 int64_t duration;
392 392
393 int64_t pos; ///< byte position in stream, -1 if unknown393 int64_t pos; ///< byte position in stream, -1 if unknown
394
395 /**
396 * for some private data of the user
397 */
398 void *opaque;
399
400 /**
401 * AVBufferRef for free use by the API user. FFmpeg will never check the
402 * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when
403 * the packet is unreferenced. av_packet_copy_props() calls create a new
404 * reference with av_buffer_ref() for the target packet's opaque_ref field.
405 *
406 * This is unrelated to the opaque field, although it serves a similar
407 * purpose.
408 */
409 AVBufferRef *opaque_ref;
410
411 /**
412 * Time base of the packet's timestamps.
413 */
414 AVRational time_base;
394} AVPacket;415} AVPacket;
395 416
396#if FF_API_INIT_PACKET417#if FF_API_INIT_PACKET
libavcodec/version.h+2−2
@@ -28,8 +28,8 @@ · 27 unmodified lines
28#include "libavutil/version.h"28#include "libavutil/version.h"
29 29
30#define LIBAVCODEC_VERSION_MAJOR 5930#define LIBAVCODEC_VERSION_MAJOR 59
31#define LIBAVCODEC_VERSION_MINOR 331#define LIBAVCODEC_VERSION_MINOR 4
32#define LIBAVCODEC_VERSION_MICRO 10232#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, \
35 LIBAVCODEC_VERSION_MINOR, \35 LIBAVCODEC_VERSION_MINOR, \

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