diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-05-14 10:50:01 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-05-14 10:50:01 +0200 |
commit | e9dd029f5d00590e1a53e63b0ab805110a10b54c (patch) | |
tree | 1126ca5dda925a62be3dc12c99c90e953d08afcf /media/ffvpx/libavcodec/avpacket.c | |
parent | 9d6a7ae25d7f5da855a8f8df884de483b4e2a538 (diff) | |
parent | 36b8fd734f590eb726ca2e50f8d1ff9cc968b8e1 (diff) | |
download | UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.gz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.lz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.xz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.zip |
Merge branch 'master' into Basilisk-release
Diffstat (limited to 'media/ffvpx/libavcodec/avpacket.c')
-rw-r--r-- | media/ffvpx/libavcodec/avpacket.c | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/media/ffvpx/libavcodec/avpacket.c b/media/ffvpx/libavcodec/avpacket.c index e5a8bdbe4..d1f4ea9eb 100644 --- a/media/ffvpx/libavcodec/avpacket.c +++ b/media/ffvpx/libavcodec/avpacket.c @@ -247,8 +247,6 @@ failed_alloc: av_packet_unref(pkt); return AVERROR(ENOMEM); } -FF_ENABLE_DEPRECATION_WARNINGS -#endif int av_dup_packet(AVPacket *pkt) { @@ -266,6 +264,8 @@ int av_copy_packet(AVPacket *dst, const AVPacket *src) *dst = *src; return copy_packet_data(dst, src, 0); } +FF_ENABLE_DEPRECATION_WARNINGS +#endif void av_packet_free_side_data(AVPacket *pkt) { @@ -296,9 +296,20 @@ 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; + int i, elems = pkt->side_data_elems; + + for (i = 0; i < elems; i++) { + AVPacketSideData *sd = &pkt->side_data[i]; + + if (sd->type == type) { + av_free(sd->data); + sd->data = data; + sd->size = size; + return 0; + } + } - if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data)) + if ((unsigned)elems + 1 > AV_PKT_DATA_NB) return AVERROR(ERANGE); tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp)); @@ -336,7 +347,7 @@ uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, return data; } -uint8_t *av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, +uint8_t *av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size) { int i; @@ -348,6 +359,8 @@ uint8_t *av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, return pkt->side_data[i].data; } } + if (size) + *size = 0; return NULL; } @@ -372,10 +385,15 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type) case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update"; case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID"; case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata"; + case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: return "Content light level metadata"; + case AV_PKT_DATA_SPHERICAL: return "Spherical Mapping"; + case AV_PKT_DATA_A53_CC: return "A53 Closed Captions"; } return NULL; } +#if FF_API_MERGE_SD_API + #define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL int av_packet_merge_side_data(AVPacket *pkt){ @@ -431,6 +449,9 @@ int av_packet_split_side_data(AVPacket *pkt){ p-= size+5; } + if (i > AV_PKT_DATA_NB) + return AVERROR(ERANGE); + pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data)); if (!pkt->side_data) return AVERROR(ENOMEM); @@ -456,6 +477,35 @@ int av_packet_split_side_data(AVPacket *pkt){ } return 0; } +#endif + +#if FF_API_MERGE_SD +int ff_packet_split_and_drop_side_data(AVPacket *pkt){ + if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){ + int i; + unsigned int size; + uint8_t *p; + + p = pkt->data + pkt->size - 8 - 5; + for (i=1; ; i++){ + size = AV_RB32(p); + if (size>INT_MAX - 5 || p - pkt->data < size) + return 0; + if (p[4]&128) + break; + if (p - pkt->data < size + 5) + return 0; + p-= size+5; + if (i > AV_PKT_DATA_NB) + return 0; + } + pkt->size = p - pkt->data - size; + av_assert0(pkt->size >= 0); + return 1; + } + return 0; +} +#endif uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size) { @@ -505,7 +555,7 @@ int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **di const uint8_t *key = data; const uint8_t *val = data + strlen(key) + 1; - if (val >= end) + if (val >= end || !*key) return AVERROR_INVALIDDATA; ret = av_dict_set(dict, key, val, 0); @@ -607,7 +657,7 @@ fail: return ret; } -AVPacket *av_packet_clone(AVPacket *src) +AVPacket *av_packet_clone(const AVPacket *src) { AVPacket *ret = av_packet_alloc(); |