[libav-devel] [PATCH] mpeg12dec: Extract CC user data into frame side data

Diego Biurrun diego at biurrun.de
Mon Nov 25 06:44:29 CET 2013


On Sun, Nov 24, 2013 at 09:49:47AM -0800, John Stebbins wrote:
> 
> --- a/libavcodec/mpeg12dec.c
> +++ b/libavcodec/mpeg12dec.c
> @@ -1529,6 +1530,15 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
>  
> +        if (s1->caption != NULL) {

!s1->caption

> +            if (sd != NULL) {
> +                memcpy(sd->data, s1->caption, size);
> +            }

same, drop {}

> @@ -2038,6 +2048,57 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
>  
> +    if (buf_size >= 6 &&
> +        p[0] == 'G' && p[1] == 'A' && p[2] == '9' && p[3] == '4' && p[4] == 3) {
> +        /* extract A53 Part 4 CC data */
> +        int cc_count = p[5] & 0x1f;
> +        if (cc_count > 0 && buf_size >= 7 + cc_count * 3) {
> +            s1->caption = av_malloc(sizeof(AVClosedCaption) + cc_count * 3);
> +            if (s1->caption != NULL) {

!s1->caption

> +        for (i = 5; i + 6 <= buf_size && ((p[i] & 0xfe) == 0xfe); i += 6) {
> +            cc_count++;
> +        }

drop {}

> +        // Transform the DVD format into A53 Part 4 format
> +        if (cc_count > 0) {
> +            s1->caption = av_malloc(sizeof(AVClosedCaption) + cc_count * 6);
> +            if (s1->caption != NULL) {

!s1->caption

> @@ -2057,6 +2118,8 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
>                  return;
>              avctx->dtg_active_format = p[0] & 0x0f;
>          }
> +    } else if (mpeg_decode_cc(avctx, p, buf_size)) {
> +        return;
>      }

You return different values above, but no error checking whatsoever is
performed here.  What was your intention?

Diego


More information about the libav-devel mailing list