[FFmpeg-devel] [FFmpeg-cvslog] avcodec/mpeg12dec: do not discard older a53 captions
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Sun Jun 21 01:53:30 EEST 2020
On Sat, Jun 20, 2020 at 01:44:28PM -0300, James Almer wrote:
> > ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com <https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog>> | Sat Jun 20 15:02:48 2020 +0200| [29ea4e1b3c511de0a406722bcfffa11604745451] | committer: Paul B Mahol
> >
> > avcodec/mpeg12dec: do not discard older a53 captions
> >
> > Fixes #6105.
> >
> > >/http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=29ea4e1b3c511de0a406722bcfffa11604745451
> > /---
> >
> > libavcodec/mpeg12dec.c | 22 +++++++++++++++++-----
> > 1 file changed, 17 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> > index a12857d358..1253bde66e 100644
> > --- a/libavcodec/mpeg12dec.c
> > +++ b/libavcodec/mpeg12dec.c
> > @@ -2242,13 +2242,25 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
> > /* extract A53 Part 4 CC data */
> > int cc_count = p[5] & 0x1f;
> > if (cc_count > 0 && buf_size >= 7 + cc_count * 3) {
> > - av_freep(&s1->a53_caption);
> > - s1->a53_caption_size = cc_count * 3;
> > - s1->a53_caption = av_malloc(s1->a53_caption_size);
> > + if (s1->a53_caption && s1->a53_caption_size > 0) {
> > + uint8_t *old_a53_caption = s1->a53_caption;
> > + int old_a53_caption_size = s1->a53_caption_size;
> > +
> > + s1->a53_caption_size = old_a53_caption_size + cc_count * 3;
> > + s1->a53_caption = av_malloc(s1->a53_caption_size);
> > + if (s1->a53_caption) {
> > + memcpy(s1->a53_caption, old_a53_caption, old_a53_caption_size);
> > + memcpy(s1->a53_caption + old_a53_caption_size, p + 7, cc_count * 3);
> > + }
> > + av_freep(&old_a53_caption);
> > + } else {
> > + s1->a53_caption_size = cc_count * 3;
> > + s1->a53_caption = av_malloc(s1->a53_caption_size);
> > + if (s1->a53_caption)
> > + memcpy(s1->a53_caption, p + 7, s1->a53_caption_size);
> > + }
> > if (!s1->a53_caption) {
> > s1->a53_caption_size = 0;
> > - } else {
> > - memcpy(s1->a53_caption, p + 7, s1->a53_caption_size);
> > }
> > avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
> > }
>
> You should have used av_realloc() instead (And you should have sent a
> patch to the mailing list as well).
> See h264_sei.c and hevc_sei.c
I think I have submitted a patch for that last year:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20191222132705.15271-1-lance.lmwang@gmail.com/
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
--
Thanks,
Limin Wang
More information about the ffmpeg-devel
mailing list