On 01/20/2012 10:07 AM, Janne Grunau wrote:

> bug noticed by Vladimir, verified and tested by a patch to convert the
> libavformats custom frame header for rv34 to slice_count and
> slice_offset[].
> 
> Janne
> ---8<---
> They are used to signal the number of slices and offsets of each slice
> out of band to the decoder.
> ---
>  libavcodec/pthread.c |   13 ++++++++++++-
>  1 files changed, 12 insertions(+), 1 deletions(-)
> 
> diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
> index 0688d9d..3f653dd 100644
> --- a/libavcodec/pthread.c
> +++ b/libavcodec/pthread.c
> @@ -413,7 +413,6 @@ static int update_context_from_thread(AVCodecContext 
> *dst, AVCodecContext *src,
>  
>          dst->has_b_frames = src->has_b_frames;
>          dst->idct_algo    = src->idct_algo;
> -        dst->slice_count  = src->slice_count;
>  
>          dst->bits_per_coded_sample = src->bits_per_coded_sample;
>          dst->sample_aspect_ratio   = src->sample_aspect_ratio;
> @@ -469,6 +468,17 @@ static void update_context_from_user(AVCodecContext 
> *dst, AVCodecContext *src)
>  
>      dst->frame_number     = src->frame_number;
>      dst->reordered_opaque = src->reordered_opaque;
> +
> +    if (src->slice_count && src->slice_offset) {
> +        if (dst->slice_count < src->slice_count) {
> +            av_free(dst->slice_offset);
> +            dst->slice_offset = av_malloc(src->slice_count *
> +                                          sizeof(*dst->slice_offset));
> +        }
> +        memcpy(dst->slice_offset, src->slice_offset,
> +               src->slice_count * sizeof(*dst->slice_offset));
> +    }
> +    dst->slice_count = src->slice_count;


realloc might be more appropriate here instead of free/malloc. But
either way we need to check for allocation failure before trying to
memcpy into it.

Thanks,
Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to