diff options
author | trav90 <travawine@openmailbox.org> | 2018-02-04 13:19:22 -0600 |
---|---|---|
committer | trav90 <travawine@openmailbox.org> | 2018-02-04 13:19:22 -0600 |
commit | 30bfbb3f97bd64b7838bcb55c98fa698b1bcc9d2 (patch) | |
tree | a6031d45b30f0b5b66e2b1774d75b0f953a2aedc /media/ffvpx/libavcodec/avpacket.c | |
parent | fc7d9fade54dfbe275c4808dabe30a19415082e0 (diff) | |
download | UXP-30bfbb3f97bd64b7838bcb55c98fa698b1bcc9d2.tar UXP-30bfbb3f97bd64b7838bcb55c98fa698b1bcc9d2.tar.gz UXP-30bfbb3f97bd64b7838bcb55c98fa698b1bcc9d2.tar.lz UXP-30bfbb3f97bd64b7838bcb55c98fa698b1bcc9d2.tar.xz UXP-30bfbb3f97bd64b7838bcb55c98fa698b1bcc9d2.zip |
Update FFmpeg code to n3.2-65-gee56777
Diffstat (limited to 'media/ffvpx/libavcodec/avpacket.c')
-rw-r--r-- | media/ffvpx/libavcodec/avpacket.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/media/ffvpx/libavcodec/avpacket.c b/media/ffvpx/libavcodec/avpacket.c index 921868923..e5a8bdbe4 100644 --- a/media/ffvpx/libavcodec/avpacket.c +++ b/media/ffvpx/libavcodec/avpacket.c @@ -139,7 +139,8 @@ int av_grow_packet(AVPacket *pkt, int grow_by) pkt->buf = av_buffer_alloc(new_size); if (!pkt->buf) return AVERROR(ENOMEM); - memcpy(pkt->buf->data, pkt->data, pkt->size); + if (pkt->size > 0) + memcpy(pkt->buf->data, pkt->data, pkt->size); pkt->data = pkt->buf->data; } pkt->size += grow_by; @@ -198,6 +199,7 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup) { pkt->data = NULL; pkt->side_data = NULL; + pkt->side_data_elems = 0; if (pkt->buf) { AVBufferRef *ref = av_buffer_ref(src->buf); if (!ref) @@ -207,9 +209,11 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup) } else { DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF); } - if (pkt->side_data_elems && dup) + if (src->side_data_elems && dup) { pkt->side_data = src->side_data; - if (pkt->side_data_elems && !dup) { + pkt->side_data_elems = src->side_data_elems; + } + if (src->side_data_elems && !dup) { return av_copy_packet_side_data(pkt, src); } return 0; @@ -291,16 +295,17 @@ FF_ENABLE_DEPRECATION_WARNINGS int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size) { + AVPacketSideData *tmp; int elems = pkt->side_data_elems; if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data)) return AVERROR(ERANGE); - pkt->side_data = av_realloc(pkt->side_data, - (elems + 1) * sizeof(*pkt->side_data)); - if (!pkt->side_data) + tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp)); + if (!tmp) return AVERROR(ENOMEM); + pkt->side_data = tmp; pkt->side_data[elems].data = data; pkt->side_data[elems].size = size; pkt->side_data[elems].type = type; @@ -581,7 +586,8 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src) ret = packet_alloc(&dst->buf, src->size); if (ret < 0) goto fail; - memcpy(dst->buf->data, src->data, src->size); + if (src->size) + memcpy(dst->buf->data, src->data, src->size); dst->data = dst->buf->data; } else { |