On 2013-03-12 12:48:35 +0100, Anton Khirnov wrote:
> Needed e.g. for h264 cropping to work properly.
> ---
>  libavcodec/utils.c |   23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index b4c294e..bec0b3f 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -549,14 +549,19 @@ static void compat_release_buffer(void *opaque, uint8_t 
> *data)
>  
>  int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
>  {
> +    int orig_width = 0, orig_height = 0;
>      int ret;
>  
>      switch (avctx->codec_type) {
>      case AVMEDIA_TYPE_VIDEO:
>          if (!frame->width)
> -            frame->width               = avctx->width;
> +            frame->width               = FFMAX(avctx->width, 
> avctx->coded_width);
> +        else
> +            orig_width = frame->width;
>          if (!frame->height)
> -            frame->height              = avctx->height;
> +            frame->height              = FFMAX(avctx->height, 
> avctx->coded_height);
> +        else
> +            orig_height = frame->height;

under which conditions would frame->{height,width} be set? reusing a
frame? Why are we trusting those values for allocation? Especially
since a zeroed frame gets height and not MAX(height, coded_height). If
that frame is reused later we would allocate buffers not large enough
for the coded dimensions if those are larger.

>          if (frame->format < 0)
>              frame->format              = avctx->pix_fmt;
>          if (!frame->sample_aspect_ratio.num)
> @@ -696,6 +701,11 @@ do {                                                     
>                \
>  
>          av_buffer_unref(&dummy_buf);
>  
> +        if (!orig_width)
> +            frame->width  = avctx->width;
> +        if (!orig_height)
> +            frame->height = avctx->height;
> +

see above, also what happens for audio? do we trust that avctx->width
and height are zero for audio codecs?

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

Reply via email to