History

Merge commit 'a9a60106370f862e191dea58e748626da6a8fe97'

* commit 'a9a60106370f862e191dea58e748626da6a8fe97': avpacket: Provide an alloc and a free function for the struct

Hendrik Leppkes committed 11 years ago

Commit 3ec049b2 parents 87a6f53 a9a60103 files · +69 −0Browse files

Unified · Split

3 files
  1. doc/APIchanges +2 −0
  2. libavcodec/avcodec.h +34 −0
  3. libavcodec/avpacket.c +33 −0
doc/APIchanges+2−0
@@ -20,6 +20,8 @@ API changes, most recent first: · 19 unmodified lines
20 it resets the packet in a more consistent way.20 it resets the packet in a more consistent way.
21 xxxxxx - Deprecate av_dup_packet(), it is a no-op for most cases.21 xxxxxx - Deprecate av_dup_packet(), it is a no-op for most cases.
22 Use av_packet_ref() to make a non-refcounted AVPacket refcounted.22 Use av_packet_ref() to make a non-refcounted AVPacket refcounted.
23 xxxxxx - Add av_packet_alloc(), av_packet_clone(), av_packet_free().
24 They match the AVFrame functions with the same name.
23 25
242015-10-27 - xxxxxxx - lavu 55.5.100 - cpu.h262015-10-27 - xxxxxxx - lavu 55.5.100 - cpu.h
25 Add AV_CPU_FLAG_AESNI.27 Add AV_CPU_FLAG_AESNI.
libavcodec/avcodec.h+34−0
@@ -3847,6 +3847,40 @@ void avsubtitle_free(AVSubtitle *sub); · 3846 unmodified lines
3847 * @{3847 * @{
3848 */3848 */
3849 3849
3850/**
3851 * Allocate an AVPacket and set its fields to default values. The resulting
3852 * struct must be freed using av_packet_free().
3853 *
3854 * @return An AVPacket filled with default values or NULL on failure.
3855 *
3856 * @note this only allocates the AVPacket itself, not the data buffers. Those
3857 * must be allocated through other means such as av_new_packet.
3858 *
3859 * @see av_new_packet
3860 */
3861AVPacket *av_packet_alloc(void);
3862
3863/**
3864 * Create a new packet that references the same data as src.
3865 *
3866 * This is a shortcut for av_packet_alloc()+av_packet_ref().
3867 *
3868 * @return newly created AVPacket on success, NULL on error.
3869 *
3870 * @see av_packet_alloc
3871 * @see av_packet_ref
3872 */
3873AVPacket *av_packet_clone(AVPacket *src);
3874
3875/**
3876 * Free the packet, if the packet is reference counted, it will be
3877 * unreferenced first.
3878 *
3879 * @param packet packet to be freed. The pointer will be set to NULL.
3880 * @note passing NULL is a no-op.
3881 */
3882void av_packet_free(AVPacket **pkt);
3883
3850/**3884/**
3851 * Initialize optional fields of a packet with default values.3885 * Initialize optional fields of a packet with default values.
3852 *3886 *
libavcodec/avpacket.c+33−0
@@ -48,6 +48,26 @@ FF_ENABLE_DEPRECATION_WARNINGS · 47 unmodified lines
48 pkt->side_data_elems = 0;48 pkt->side_data_elems = 0;
49}49}
50 50
51AVPacket *av_packet_alloc(void)
52{
53 AVPacket *pkt = av_mallocz(sizeof(AVPacket));
54 if (!pkt)
55 return pkt;
56
57 av_packet_unref(pkt);
58
59 return pkt;
60}
61
62void av_packet_free(AVPacket **pkt)
63{
64 if (!pkt || !*pkt)
65 return;
66
67 av_packet_unref(*pkt);
68 av_freep(pkt);
69}
70
51static int packet_alloc(AVBufferRef **buf, int size)71static int packet_alloc(AVBufferRef **buf, int size)
52{72{
53 int ret;73 int ret;
@@ -542,6 +562,19 @@ fail: · 488 unmodified lines
542 return ret;562 return ret;
543}563}
544 564
565AVPacket *av_packet_clone(AVPacket *src)
566{
567 AVPacket *ret = av_packet_alloc();
568
569 if (!ret)
570 return ret;
571
572 if (av_packet_ref(ret, src))
573 av_packet_free(&ret);
574
575 return ret;
576}
577
545void av_packet_move_ref(AVPacket *dst, AVPacket *src)578void av_packet_move_ref(AVPacket *dst, AVPacket *src)
546{579{
547 *dst = *src;580 *dst = *src;

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