Message ID | 20170726001042.5984-1-jamrial@gmail.com |
---|---|
State | New |
Headers | show |
On 7/25/2017 9:10 PM, James Almer wrote: > Same rationale as with packet side data, it was never meant to do otherwise > as av_frame_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> > --- > libavutil/frame.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/libavutil/frame.c b/libavutil/frame.c > index 24d5d5f184..c41d4be8cc 100644 > --- a/libavutil/frame.c > +++ b/libavutil/frame.c > @@ -638,10 +638,24 @@ static AVFrameSideData *frame_new_side_data(AVFrame *frame, > AVBufferRef *buf) > { > AVFrameSideData *ret, **tmp; > + int i; > > if (!buf) > return NULL; > > + for (i = 0; i < frame->nb_side_data; i++) { > + AVFrameSideData *sd = frame->side_data[i]; > + > + if (sd->type == type) { > + av_buffer_unref(&sd->buf); > + av_dict_free(&sd->metadata); > + sd->buf = buf; > + sd->data = sd->buf->data; > + sd->size = buf->size; > + return sd; > + } > + } > + > if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1) > goto fail; Ping.
On 7/29/2017 1:12 AM, James Almer wrote: > On 7/25/2017 9:10 PM, James Almer wrote: >> Same rationale as with packet side data, it was never meant to do otherwise >> as av_frame_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> >> --- >> libavutil/frame.c | 14 ++++++++++++++ >> 1 file changed, 14 insertions(+) >> >> diff --git a/libavutil/frame.c b/libavutil/frame.c >> index 24d5d5f184..c41d4be8cc 100644 >> --- a/libavutil/frame.c >> +++ b/libavutil/frame.c >> @@ -638,10 +638,24 @@ static AVFrameSideData *frame_new_side_data(AVFrame *frame, >> AVBufferRef *buf) >> { >> AVFrameSideData *ret, **tmp; >> + int i; >> >> if (!buf) >> return NULL; >> >> + for (i = 0; i < frame->nb_side_data; i++) { >> + AVFrameSideData *sd = frame->side_data[i]; >> + >> + if (sd->type == type) { >> + av_buffer_unref(&sd->buf); >> + av_dict_free(&sd->metadata); >> + sd->buf = buf; >> + sd->data = sd->buf->data; >> + sd->size = buf->size; >> + return sd; >> + } >> + } >> + >> if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1) >> goto fail; > > Ping. > I'll apply this soon unless someone objects.
diff --git a/libavutil/frame.c b/libavutil/frame.c index 24d5d5f184..c41d4be8cc 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -638,10 +638,24 @@ static AVFrameSideData *frame_new_side_data(AVFrame *frame, AVBufferRef *buf) { AVFrameSideData *ret, **tmp; + int i; if (!buf) return NULL; + for (i = 0; i < frame->nb_side_data; i++) { + AVFrameSideData *sd = frame->side_data[i]; + + if (sd->type == type) { + av_buffer_unref(&sd->buf); + av_dict_free(&sd->metadata); + sd->buf = buf; + sd->data = sd->buf->data; + sd->size = buf->size; + return sd; + } + } + if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1) goto fail;
Same rationale as with packet side data, it was never meant to do otherwise as av_frame_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> --- libavutil/frame.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)