History

avformat/utils: add av_stream_add_side_data()

Functionally similar to av_packet_add_side_data(). Allows the use of an already allocated buffer as stream side data.

James Almer committed 10 years ago

Commit 2ab50641 parent 4696f764 files · +42 −10Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavformat/avformat.h +15 −0
  3. libavformat/utils.c +23 −9
  4. libavformat/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2015-08-28 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182016-11-18 - xxxxxxx - lavf 57.58.100 - avformat.h
19 Add av_stream_add_side_data().
20
182016-xx-xx - xxxxxxx - lavu 55.39.100 - hwcontext_vaapi.h212016-xx-xx - xxxxxxx - lavu 55.39.100 - hwcontext_vaapi.h
19 Add AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE.22 Add AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE.
20 23
libavformat/avformat.h+15−0
@@ -2048,6 +2048,21 @@ const AVClass *avformat_get_class(void); · 2047 unmodified lines
2048 */2048 */
2049AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c);2049AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c);
2050 2050
2051/**
2052 * Wrap an existing array as stream side data.
2053 *
2054 * @param st stream
2055 * @param type side information type
2056 * @param data the side data array. It must be allocated with the av_malloc()
2057 * family of functions. The ownership of the data is transferred to
2058 * st.
2059 * @param size side information size
2060 * @return zero on success, a negative AVERROR code on failure. On failure,
2061 * the stream is unchanged and the data remains owned by the caller.
2062 */
2063int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
2064 uint8_t *data, size_t size);
2065
2051/**2066/**
2052 * Allocate new information from stream.2067 * Allocate new information from stream.
2053 *2068 *
libavformat/utils.c+23−9
@@ -5104,15 +5104,11 @@ uint8_t *av_stream_get_side_data(const AVStream *st, · 5103 unmodified lines
5104 return NULL;5104 return NULL;
5105}5105}
5106 5106
5107uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,5107int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
5108 int size)5108 uint8_t *data, size_t size)
5109{5109{
5110 AVPacketSideData *sd, *tmp;5110 AVPacketSideData *sd, *tmp;
5111 int i;5111 int i;
5112 uint8_t *data = av_malloc(size);
5113
5114 if (!data)
5115 return NULL;
5116 5112
5117 for (i = 0; i < st->nb_side_data; i++) {5113 for (i = 0; i < st->nb_side_data; i++) {
5118 sd = &st->side_data[i];5114 sd = &st->side_data[i];
@@ -5121,14 +5117,13 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, · 2 unmodified lines
5121 av_freep(&sd->data);5117 av_freep(&sd->data);
5122 sd->data = data;5118 sd->data = data;
5123 sd->size = size;5119 sd->size = size;
5124 return sd->data;5120 return 0;
5125 }5121 }
5126 }5122 }
5127 5123
5128 tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));5124 tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
5129 if (!tmp) {5125 if (!tmp) {
5130 av_freep(&data);5126 return AVERROR(ENOMEM);
5131 return NULL;
5132 }5127 }
5133 5128
5134 st->side_data = tmp;5129 st->side_data = tmp;
@@ -5138,6 +5133,25 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, · 3 unmodified lines
5138 sd->type = type;5133 sd->type = type;
5139 sd->data = data;5134 sd->data = data;
5140 sd->size = size;5135 sd->size = size;
5136
5137 return 0;
5138}
5139
5140uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
5141 int size)
5142{
5143 int ret;
5144 uint8_t *data = av_malloc(size);
5145
5146 if (!data)
5147 return NULL;
5148
5149 ret = av_stream_add_side_data(st, type, data, size);
5150 if (ret < 0) {
5151 av_freep(&data);
5152 return NULL;
5153 }
5154
5141 return data;5155 return data;
5142}5156}
5143 5157
libavformat/version.h+1−1
@@ -32,7 +32,7 @@ · 31 unmodified lines
32// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)32// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
33// Also please add any ticket numbers that you believe might be affected here33// Also please add any ticket numbers that you believe might be affected here
34#define LIBAVFORMAT_VERSION_MAJOR 5734#define LIBAVFORMAT_VERSION_MAJOR 57
35#define LIBAVFORMAT_VERSION_MINOR 5735#define LIBAVFORMAT_VERSION_MINOR 58
36#define LIBAVFORMAT_VERSION_MICRO 10036#define LIBAVFORMAT_VERSION_MICRO 100
37 37
38#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \38#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \

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