Message ID | 20170306182314.50131-1-ffmpeg@tmm1.net |
---|---|
State | Superseded |
Headers | show |
On Mon, Mar 06, 2017 at 10:23:14AM -0800, Aman Gupta wrote: > From: Aman Gupta <aman@tmm1.net> > > --- > libavcodec/mpeg12dec.c | 38 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c > index 27db14c..8cafdb0 100644 > --- a/libavcodec/mpeg12dec.c > +++ b/libavcodec/mpeg12dec.c > @@ -2260,6 +2260,44 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, > avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; > } > return 1; > + } else if (buf_size >= 2 && > + p[0] == 0x03 && (p[1]&0x7f) == 0x01) { > + /* extract SCTE-20 CC data */ > + GetBitContext gb; > + int cc_count = 0; > + int i; > + > + init_get_bits(&gb, p + 2, buf_size - 2); > + cc_count = get_bits(&gb, 5); > + if (cc_count > 0) { > + 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) { a53_caption_size should be reset to 0 if allocation fails to keep the fields consistent [...]
On Sat, Mar 11, 2017 at 7:05 AM, Michael Niedermayer <michael@niedermayer.cc > wrote: > On Mon, Mar 06, 2017 at 10:23:14AM -0800, Aman Gupta wrote: > > From: Aman Gupta <aman@tmm1.net> > > > > --- > > libavcodec/mpeg12dec.c | 38 ++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 38 insertions(+) > > > > diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c > > index 27db14c..8cafdb0 100644 > > --- a/libavcodec/mpeg12dec.c > > +++ b/libavcodec/mpeg12dec.c > > @@ -2260,6 +2260,44 @@ static int mpeg_decode_a53_cc(AVCodecContext > *avctx, > > avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; > > } > > return 1; > > + } else if (buf_size >= 2 && > > + p[0] == 0x03 && (p[1]&0x7f) == 0x01) { > > + /* extract SCTE-20 CC data */ > > + GetBitContext gb; > > + int cc_count = 0; > > + int i; > > + > > + init_get_bits(&gb, p + 2, buf_size - 2); > > + cc_count = get_bits(&gb, 5); > > + if (cc_count > 0) { > > + 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) { > > a53_caption_size should be reset to 0 if allocation fails to keep the > fields consistent > The other branches in this function all follow the same pattern, and will not reset a53_caption_size on malloc failure. Would you like me to fix all of them? > > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > In fact, the RIAA has been known to suggest that students drop out > of college or go to community college in order to be able to afford > settlements. -- The RIAA > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >
On Wed, Mar 15, 2017 at 12:10:35PM -0700, Aman Gupta wrote: > On Sat, Mar 11, 2017 at 7:05 AM, Michael Niedermayer <michael@niedermayer.cc > > wrote: > > > On Mon, Mar 06, 2017 at 10:23:14AM -0800, Aman Gupta wrote: > > > From: Aman Gupta <aman@tmm1.net> > > > > > > --- > > > libavcodec/mpeg12dec.c | 38 ++++++++++++++++++++++++++++++++++++++ > > > 1 file changed, 38 insertions(+) > > > > > > diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c > > > index 27db14c..8cafdb0 100644 > > > --- a/libavcodec/mpeg12dec.c > > > +++ b/libavcodec/mpeg12dec.c > > > @@ -2260,6 +2260,44 @@ static int mpeg_decode_a53_cc(AVCodecContext > > *avctx, > > > avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; > > > } > > > return 1; > > > + } else if (buf_size >= 2 && > > > + p[0] == 0x03 && (p[1]&0x7f) == 0x01) { > > > + /* extract SCTE-20 CC data */ > > > + GetBitContext gb; > > > + int cc_count = 0; > > > + int i; > > > + > > > + init_get_bits(&gb, p + 2, buf_size - 2); > > > + cc_count = get_bits(&gb, 5); > > > + if (cc_count > 0) { > > > + 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) { > > > > a53_caption_size should be reset to 0 if allocation fails to keep the > > fields consistent > > > > The other branches in this function all follow the same pattern, and will > not reset a53_caption_size on malloc failure. > > Would you like me to fix all of them? i think it would be more robust to reset it, yes, in a seperate patch thanks [...]
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 27db14c..8cafdb0 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2260,6 +2260,44 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; } return 1; + } else if (buf_size >= 2 && + p[0] == 0x03 && (p[1]&0x7f) == 0x01) { + /* extract SCTE-20 CC data */ + GetBitContext gb; + int cc_count = 0; + int i; + + init_get_bits(&gb, p + 2, buf_size - 2); + cc_count = get_bits(&gb, 5); + if (cc_count > 0) { + 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) { + uint8_t field, cc1, cc2; + uint8_t *cap = s1->a53_caption; + for (i = 0; i < cc_count; i++) { + skip_bits(&gb, 2); // priority + field = get_bits(&gb, 2); + skip_bits(&gb, 5); // line_offset + cc1 = get_bits(&gb, 8); + cc2 = get_bits(&gb, 8); + skip_bits(&gb, 1); // marker + + if (!field) { // forbidden + cap[0] = cap[1] = cap[2] = 0x00; + } else { + field = (field == 2 ? 1 : 0); + if (!s1->mpeg_enc_ctx.top_field_first) field = !field; + cap[0] = 0x04 | field; + cap[1] = ff_reverse[cc1]; + cap[2] = ff_reverse[cc2]; + } + cap += 3; + } + } + } + return 1; } else if (buf_size >= 11 && p[0] == 'C' && p[1] == 'C' && p[2] == 0x01 && p[3] == 0xf8) { /* extract DVD CC data
From: Aman Gupta <aman@tmm1.net> --- libavcodec/mpeg12dec.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)