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
1414
1515 API changes, most recent first:
1616
17+2021-08-02 - xxxxxxxxxx - lavc 59.4.100 - packet.h
18+ Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base.
19+
1720 2021-07-23 - xxxxxxxxxx - lavu 57.3.100 - common.h macros.h
1821 Move several macros (AV_NE, FFDIFFSIGN, FFMAX, FFMAX3, FFMIN, FFMIN3,
1922 FFSWAP, FF_ARRAY_ELEMS, MKTAG, MKBETAG) from common.h to macros.h.
libavcodec/avpacket.c+15−2
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include "libavutil/internal.h"
2727 #include "libavutil/mathematics.h"
2828 #include "libavutil/mem.h"
29+#include "libavutil/rational.h"
2930
3031 #include "bytestream.h"
3132 #include "internal.h"
@@ -44,6 +45,9 @@ void av_init_packet(AVPacket *pkt) · 12 unmodified lines
4445 pkt->buf = NULL;
4546 pkt->side_data = NULL;
4647 pkt->side_data_elems = 0;
48+ pkt->opaque = NULL;
49+ pkt->opaque_ref = NULL;
50+ pkt->time_base = av_make_q(0, 0);
4751 }
4852 #endif
4953
@@ -374,7 +378,7 @@ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, · 324 unmodified lines
374378
375379 int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
376380 {
377− int i;
381+ int i, ret;
378382
379383 dst->pts = src->pts;
380384 dst->dts = src->dts;
@@ -382,9 +386,16 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src) · 1 unmodified line
382386 dst->duration = src->duration;
383387 dst->flags = src->flags;
384388 dst->stream_index = src->stream_index;
385−
389+ dst->opaque = src->opaque;
390+ dst->time_base = src->time_base;
391+ dst->opaque_ref = NULL;
386392 dst->side_data = NULL;
387393 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+
388399 for (i = 0; i < src->side_data_elems; i++) {
389400 enum AVPacketSideDataType type = src->side_data[i].type;
390401 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
392403 uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
393404
394405 if (!dst_data) {
406+ av_buffer_unref(&dst->opaque_ref);
395407 av_packet_free_side_data(dst);
396408 return AVERROR(ENOMEM);
397409 }
@@ -404,6 +416,7 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src) · 6 unmodified lines
404416 void av_packet_unref(AVPacket *pkt)
405417 {
406418 av_packet_free_side_data(pkt);
419+ av_buffer_unref(&pkt->opaque_ref);
407420 av_buffer_unref(&pkt->buf);
408421 get_packet_defaults(pkt);
409422 }
libavcodec/packet.h+21−0
@@ -391,6 +391,27 @@ typedef struct AVPacket { · 390 unmodified lines
391391 int64_t duration;
392392
393393 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;
394415 } AVPacket;
395416
396417 #if FF_API_INIT_PACKET
libavcodec/version.h+2−2
@@ -28,8 +28,8 @@ · 27 unmodified lines
2828 #include "libavutil/version.h"
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 59
31−#define LIBAVCODEC_VERSION_MINOR 3
32−#define LIBAVCODEC_VERSION_MICRO 102
31+#define LIBAVCODEC_VERSION_MINOR 4
32+#define LIBAVCODEC_VERSION_MICRO 100
3333
3434 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3535 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