[FFmpeg-devel] [PATCH 16/28] dvdsub hacks

Michael Niedermayer michaelni
Sun Jul 11 18:45:13 CEST 2010


On Wed, Jun 30, 2010 at 10:09:44AM +0100, Mans Rullgard wrote:
[...]

> @@ -458,12 +492,13 @@ static int dvdsub_decode(AVCodecContext *avctx,
>                           void *data, int *data_size,
>                           AVPacket *avpkt)
>  {
> +    DVDSubContext *ctx = (DVDSubContext*) avctx->priv_data;

unneeded cast


>      const uint8_t *buf = avpkt->data;
>      int buf_size = avpkt->size;
>      AVSubtitle *sub = (void *)data;
>      int is_menu;
>  
> -    is_menu = decode_dvd_subtitles(sub, buf, buf_size);
> +    is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);
>  
>      if (is_menu < 0) {
>      no_subtitle:
> @@ -486,12 +521,54 @@ static int dvdsub_decode(AVCodecContext *avctx,
>      return buf_size;
>  }
>  

> +static int dvdsub_init(AVCodecContext *avctx)
> +{
> +    DVDSubContext *ctx = (DVDSubContext*) avctx->priv_data;
> +    char *data = avctx->extradata;

char can be signed and unsigned IIRC so is likely not good


> +
> +    if (!avctx->extradata || !avctx->extradata_size)
> +        return 1;
> +
> +    data[avctx->extradata_size] = '\0';
> +

> +    for(;;) {
> +        int pos = strcspn(data, "\n\r");
> +        if (pos==0 && *data==0)

the second condition implicates the first

btw, why is this called a hack?


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I hate to see young programmers poisoned by the kind of thinking
Ulrich Drepper puts forward since it is simply too narrow -- Roman Shaposhnik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100711/1a2e6568/attachment.pgp>



More information about the ffmpeg-devel mailing list