Message ID | 20170512165827.8848-1-jamrial@gmail.com |
---|---|
State | Accepted |
Commit | 28f60eeabbdc3d0550f45da813ba91a0354524c4 |
Headers | show |
On Fri, May 12, 2017 at 01:58:27PM -0300, James Almer wrote: > 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(). > > Signed-off-by: James Almer <jamrial@gmail.com> > --- > libavcodec/avpacket.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) probably ok thx [...]
On 5/12/2017 6:27 PM, Michael Niedermayer wrote: > On Fri, May 12, 2017 at 01:58:27PM -0300, James Almer wrote: >> 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(). >> >> Signed-off-by: James Almer <jamrial@gmail.com> >> --- >> libavcodec/avpacket.c | 13 ++++++++++++- >> 1 file changed, 12 insertions(+), 1 deletion(-) > > probably ok > > thx Pushed.
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 26d561a00a..a04cdaf530 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -296,7 +296,18 @@ 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 > AV_PKT_DATA_NB) return AVERROR(ERANGE);
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(). Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/avpacket.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)