On Sun, Feb 09, 2014 at 07:28:16PM +0100, Luca Barbato wrote:
> --- a/libavcodec/ffv1dec.c
> +++ b/libavcodec/ffv1dec.c
> @@ -353,6 +354,43 @@ static int decode_slice(AVCodecContext *c, void *arg)
> +            memcpy(pdst, psrc, sizeof(*pdst));
> +            pdst->state = NULL;
> +            pdst->vlc_state = NULL;

nit: align

> +            if (fssrc->ac) {
> +                pdst->state = av_malloc(CONTEXT_SIZE * psrc->context_count);
> +                memcpy(pdst->state, psrc->state,
> +                       CONTEXT_SIZE * psrc->context_count);
> +            } else {
> +                pdst->vlc_state = av_malloc(sizeof(*pdst->vlc_state) *
> +                                            psrc->context_count);
> +                memcpy(pdst->vlc_state, psrc->vlc_state,
> +                       sizeof(*pdst->vlc_state) * psrc->context_count);
> +            }

unchecked av_malloc

> @@ -905,44 +977,135 @@ static int ffv1_decode_frame(AVCodecContext *avctx, 
> void *data,
>  
> -    av_frame_free(&s->last_picture);
> +    f->picture.f      = NULL;
> +    f->last_picture.f = NULL;
> +    f->sample_buffer  = NULL;
> +    f->slice_count = 0;

align

> +    f->picture.f      = av_frame_alloc();
> +    f->last_picture.f = av_frame_alloc();

unchecked allocations

> +static void copy_fields(FFV1Context *fsdst, FFV1Context *fssrc, FFV1Context 
> *fsrc)
> +{
> +    fsdst->version             = fsrc->version;
> +    fsdst->minor_version       = fsrc->minor_version;
> +    fsdst->chroma_planes       = fsrc->chroma_planes;
> +    fsdst->chroma_h_shift      = fsrc->chroma_h_shift;
> +    fsdst->chroma_v_shift      = fsrc->chroma_v_shift;
> +    fsdst->transparency        = fsrc->transparency;
> +    fsdst->plane_count         = fsrc->plane_count;
> +    fsdst->ac                  = fsrc->ac;
> +    fsdst->colorspace          = fsrc->colorspace;
> +
> +    fsdst->ec                  = fsrc->ec;
> +    fsdst->slice_damaged       = fssrc->slice_damaged;
> +    fsdst->key_frame_ok        = fsrc->key_frame_ok;
> +
> +    fsdst->bits_per_raw_sample = fsrc->bits_per_raw_sample;
> +    fsdst->packed_at_lsb       = fsrc->packed_at_lsb;
> +    fsdst->slice_count         = fsrc->slice_count;
> +    if (fsrc->version<3){

spacing

> +static int update_thread_context(AVCodecContext *dst, const AVCodecContext 
> *src)
> +{
> +    FFV1Context *fsrc = src->priv_data;
> +    FFV1Context *fdst = dst->priv_data;
> +    int i, ret;
> +
> +    if (dst == src)
> +        return 0;
> +
> +    {
> +        FFV1Context bak = *fdst;
> +        memcpy(fdst, fsrc, sizeof(*fdst));
> +        memcpy(fdst->initial_states, bak.initial_states, 
> sizeof(fdst->initial_states));
> +        memcpy(fdst->slice_context,  bak.slice_context , 
> sizeof(fdst->slice_context));

odd comma spacing

> +        fdst->picture      = bak.picture;
> +        fdst->last_picture = bak.last_picture;
> +        for (i = 0; i<fdst->num_h_slices * fdst->num_v_slices; i++) {

spacing

> +            FFV1Context *fssrc = fsrc->slice_context[i];
> +            FFV1Context *fsdst = fdst->slice_context[i];
> +            copy_fields(fsdst, fssrc, fsrc);
> +        }
> +    }

This extra block seems unnecessary, just move the variable declaration.

Diego
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to