Commit 28f60eea authored by James Almer's avatar James Almer

avcodec/avpacket: allow only one element per type in packet side data

It was never meant to do otherwise, as av_packet_get_side_data() returns the first
entry it finds of a given type.

Based on code from libavformat's av_stream_add_side_data().
Reviewed-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 3d55e488
...@@ -296,7 +296,18 @@ int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, ...@@ -296,7 +296,18 @@ int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
uint8_t *data, size_t size) uint8_t *data, size_t size)
{ {
AVPacketSideData *tmp; 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 > AV_PKT_DATA_NB) if ((unsigned)elems + 1 > AV_PKT_DATA_NB)
return AVERROR(ERANGE); return AVERROR(ERANGE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment