Functionally similar to av_packet_add_side_data(). Allows the use of an already allocated buffer as stream side data.
Unified · Split
| @@ -15,6 +15,9 @@ libavutil: 2015-08-28 · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | API changes, most recent first: |
| 17 | 17 | |
| 18 | +2016-11-18 - xxxxxxx - lavf 57.58.100 - avformat.h | |
| 19 | + Add av_stream_add_side_data(). | |
| 20 | + | |
| 18 | 21 | 2016-xx-xx - xxxxxxx - lavu 55.39.100 - hwcontext_vaapi.h |
| 19 | 22 | Add AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE. |
| 20 | 23 | |
| @@ -2048,6 +2048,21 @@ const AVClass *avformat_get_class(void); · 2047 unmodified lines | ||
| 2048 | 2048 | */ |
| 2049 | 2049 | AVStream *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 | + */ | |
| 2063 | +int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, | |
| 2064 | + uint8_t *data, size_t size); | |
| 2065 | + | |
| 2051 | 2066 | /** |
| 2052 | 2067 | * Allocate new information from stream. |
| 2053 | 2068 | * |
| @@ -5104,15 +5104,11 @@ uint8_t *av_stream_get_side_data(const AVStream *st, · 5103 unmodified lines | ||
| 5104 | 5104 | return NULL; |
| 5105 | 5105 | } |
| 5106 | 5106 | |
| 5107 | −uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, | |
| 5108 | − int size) | |
| 5107 | +int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, | |
| 5108 | + uint8_t *data, size_t size) | |
| 5109 | 5109 | { |
| 5110 | 5110 | AVPacketSideData *sd, *tmp; |
| 5111 | 5111 | int i; |
| 5112 | − uint8_t *data = av_malloc(size); | |
| 5113 | − | |
| 5114 | − if (!data) | |
| 5115 | − return NULL; | |
| 5116 | 5112 | |
| 5117 | 5113 | for (i = 0; i < st->nb_side_data; i++) { |
| 5118 | 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 | 5117 | av_freep(&sd->data); |
| 5122 | 5118 | sd->data = data; |
| 5123 | 5119 | sd->size = size; |
| 5124 | − return sd->data; | |
| 5120 | + return 0; | |
| 5125 | 5121 | } |
| 5126 | 5122 | } |
| 5127 | 5123 | |
| 5128 | 5124 | tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp)); |
| 5129 | 5125 | if (!tmp) { |
| 5130 | − av_freep(&data); | |
| 5131 | − return NULL; | |
| 5126 | + return AVERROR(ENOMEM); | |
| 5132 | 5127 | } |
| 5133 | 5128 | |
| 5134 | 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 | 5133 | sd->type = type; |
| 5139 | 5134 | sd->data = data; |
| 5140 | 5135 | sd->size = size; |
| 5136 | + | |
| 5137 | + return 0; | |
| 5138 | +} | |
| 5139 | + | |
| 5140 | +uint8_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 | 5155 | return data; |
| 5142 | 5156 | } |
| 5143 | 5157 | |
| @@ -32,7 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) |
| 33 | 33 | // Also please add any ticket numbers that you believe might be affected here |
| 34 | 34 | #define LIBAVFORMAT_VERSION_MAJOR 57 |
| 35 | −#define LIBAVFORMAT_VERSION_MINOR 57 | |
| 35 | +#define LIBAVFORMAT_VERSION_MINOR 58 | |
| 36 | 36 | #define LIBAVFORMAT_VERSION_MICRO 100 |
| 37 | 37 | |
| 38 | 38 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |