On 05/09/2012 03:13 AM, Anton Khirnov wrote:
> ---
>  libavcodec/utils.c |   17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 5eda596..077768b 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -910,6 +910,7 @@ int attribute_align_arg 
> avcodec_encode_audio2(AVCodecContext *avctx,
>                                                const AVFrame *frame,
>                                                int *got_packet_ptr)
>  {
> +    AVFrame tmp;
>      AVFrame *padded_frame = NULL;
>      int ret;
>      int user_packet = !!avpkt->data;
> @@ -922,6 +923,22 @@ int attribute_align_arg 
> avcodec_encode_audio2(AVCodecContext *avctx,
>          return 0;
>      }
>  
> +    /* ensure that extended_data is properly set */
> +    if (frame && !frame->extended_data) {
> +        if (av_sample_fmt_is_planar(avctx->sample_fmt) &&
> +            avctx->channels > AV_NUM_DATA_POINTERS) {
> +            av_log(avctx, AV_LOG_ERROR, "Encoding to a planar sample format, 
> "
> +                   "with more than %d channels, but extended_data is not 
> set.\n",
> +                   AV_NUM_DATA_POINTERS);
> +            return AVERROR(EINVAL);
> +        }
> +        av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n");
> +
> +        tmp = *frame;
> +        tmp.extended_data = tmp.data;
> +        frame = &tmp;
> +    }
> +
>      /* check for valid frame size */
>      if (frame) {
>          if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {

LGTM

-Justin

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

Reply via email to