libavcodec/mpegvideo.c:1573: error: Integer Overflow L2
  ([1, 2147483616] + 32):signed32 by call to `alloc_picture`.

libavcodec/mpegvideo.c:1573:9: Call
1571.     pic->f->coded_picture_number = s->coded_picture_number++;
1572. 
1573.     if (alloc_picture(s, pic, 0) < 0)
              ^
1574.         return -1;
1575. 

libavcodec/mpegvideo.c:539:1: Parameter `pic->f->nb_samples`
  537. }
  538. 
  539. static int alloc_picture(MpegEncContext *s, Picture *pic, int shared)
       ^
  540. {
  541.     return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, shared, 0,

libavcodec/mpegvideo.c:541:12: Call
  539. static int alloc_picture(MpegEncContext *s, Picture *pic, int shared)
  540. {
  541.     return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, shared, 0,
                  ^
  542.                             s->chroma_x_shift, s->chroma_y_shift, s->out_format,
  543.                             s->mb_stride, s->mb_height, s->b8_stride,

libavcodec/mpegvideo.c:551:1: Parameter `pic->f->nb_samples`
    549.  * The pixels are allocated/set by calling get_buffer() if shared = 0
    550.  */
    551. int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,
         ^
    552.                      ScratchpadContext *sc, int shared, int encoding,
    553.                      int chroma_x_shift, int chroma_y_shift, int out_format,

libavcodec/mpegvideo.c:564:13: Call
    562.     } else {
    563.         assert(!pic->f->buf[0]);
    564.         if (alloc_frame_buffer(avctx, pic, me, sc,
                     ^
    565.                                chroma_x_shift, chroma_y_shift,
    566.                                *linesize, *uvlinesize) < 0)

libavcodec/mpegvideo.c:375:1: Parameter `pic->f->nb_samples`
      373.  * Allocate a frame buffer
      374.  */
      375. static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic,
           ^
      376.                               MotionEstContext *me, ScratchpadContext *sc,
      377.                               int chroma_x_shift, int chroma_y_shift,

libavcodec/mpegvideo.c:398:13: Call
      396.         pic->f->height = avctx->height;
      397.         pic->f->format = avctx->pix_fmt;
      398.         r = avcodec_default_get_buffer2(avctx, pic->f, 0);
                       ^
      399.     }
      400. 

libavcodec/utils.c:510:1: Parameter `frame->nb_samples`
        508. }
        509. 
        510. int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags)
             ^
        511. {
        512.     int ret;

libavcodec/utils.c:514:16: Call
        512.     int ret;
        513. 
        514.     if ((ret = update_frame_pool(avctx, frame)) < 0)
                            ^
        515.         return ret;
        516. 

libavcodec/utils.c:333:1: Parameter `frame->nb_samples`
          331. }
          332. 
          333. static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
               ^
          334. {
          335.     FramePool *pool = avctx->internal->pool;

libavcodec/utils.c:400:15: Call
          398. 
          399.         av_buffer_pool_uninit(&pool->pools[0]);
          400.         ret = av_samples_get_buffer_size(&pool->linesize[0], ch,
                             ^
          401.                                          frame->nb_samples, frame->format, 0);
          402.         if (ret < 0)

libavutil/samplefmt.c:108:1: <LHS trace>
106. }
107. 
108. int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
     ^
109.                                enum AVSampleFormat sample_fmt, int align)
110. {

libavutil/samplefmt.c:108:1: Parameter `nb_samples`
            106. }
            107. 
            108. int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
                 ^
            109.                                enum AVSampleFormat sample_fmt, int align)
            110. {

libavutil/samplefmt.c:124:9: Binary operation: ([1, 2147483616] + 32):signed32 by call to `alloc_picture` 
            122.             return AVERROR(EINVAL);
            123.         align = 1;
            124.         nb_samples = FFALIGN(nb_samples, 32);
                         ^
            125.     }
            126. 

int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
                               enum AVSampleFormat sample_fmt, int align)
{
    int line_size;
    int sample_size = av_get_bytes_per_sample(sample_fmt);
    int planar      = av_sample_fmt_is_planar(sample_fmt);
    if (!sample_size || nb_samples <= 0 || nb_channels <= 0)
        return AVERROR(EINVAL);
    if (!align) {
        if (nb_samples > INT_MAX - 31)
            return AVERROR(EINVAL);
        align = 1;
        nb_samples = FFALIGN(nb_samples, 32);
    }
    if (nb_channels > INT_MAX / align ||
        (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)
        return AVERROR(EINVAL);
    line_size = planar ? FFALIGN(nb_samples * sample_size,               align) :
                         FFALIGN(nb_samples * sample_size * nb_channels, align);
    if (linesize)
        *linesize = line_size;
    return planar ? line_size * nb_channels : line_size;
}
['int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)\n{\n    int i, ret;\n    Picture *pic;\n    s->mb_skipped = 0;\n    if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&\n        s->last_picture_ptr != s->next_picture_ptr &&\n        s->last_picture_ptr->f->buf[0]) {\n        ff_mpeg_unref_picture(s->avctx, s->last_picture_ptr);\n    }\n    for (i = 0; i < MAX_PICTURE_COUNT; i++) {\n        if (&s->picture[i] != s->last_picture_ptr &&\n            &s->picture[i] != s->next_picture_ptr &&\n            s->picture[i].reference && !s->picture[i].needs_realloc) {\n            if (!(avctx->active_thread_type & FF_THREAD_FRAME))\n                av_log(avctx, AV_LOG_ERROR,\n                       "releasing zombie picture\\n");\n            ff_mpeg_unref_picture(s->avctx, &s->picture[i]);\n        }\n    }\n    ff_mpeg_unref_picture(s->avctx, &s->current_picture);\n    release_unused_pictures(s->avctx, s->picture);\n    if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) {\n        pic = s->current_picture_ptr;\n    } else {\n        i   = ff_find_unused_picture(s->avctx, s->picture, 0);\n        if (i < 0) {\n            av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\\n");\n            return i;\n        }\n        pic = &s->picture[i];\n    }\n    pic->reference = 0;\n    if (!s->droppable) {\n        if (s->pict_type != AV_PICTURE_TYPE_B)\n            pic->reference = 3;\n    }\n    pic->f->coded_picture_number = s->coded_picture_number++;\n    if (alloc_picture(s, pic, 0) < 0)\n        return -1;\n    s->current_picture_ptr = pic;\n    s->current_picture_ptr->f->top_field_first = s->top_field_first;\n    if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||\n        s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {\n        if (s->picture_structure != PICT_FRAME)\n            s->current_picture_ptr->f->top_field_first =\n                (s->picture_structure == PICT_TOP_FIELD) == s->first_field;\n    }\n    s->current_picture_ptr->f->interlaced_frame = !s->progressive_frame &&\n                                                 !s->progressive_sequence;\n    s->current_picture_ptr->field_picture      =  s->picture_structure != PICT_FRAME;\n    s->current_picture_ptr->f->pict_type = s->pict_type;\n    s->current_picture_ptr->f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;\n    if ((ret = ff_mpeg_ref_picture(s->avctx, &s->current_picture,\n                                   s->current_picture_ptr)) < 0)\n        return ret;\n    if (s->pict_type != AV_PICTURE_TYPE_B) {\n        s->last_picture_ptr = s->next_picture_ptr;\n        if (!s->droppable)\n            s->next_picture_ptr = s->current_picture_ptr;\n    }\n    ff_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\\n",\n            s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr,\n            s->last_picture_ptr    ? s->last_picture_ptr->f->data[0]    : NULL,\n            s->next_picture_ptr    ? s->next_picture_ptr->f->data[0]    : NULL,\n            s->current_picture_ptr ? s->current_picture_ptr->f->data[0] : NULL,\n            s->pict_type, s->droppable);\n    if ((!s->last_picture_ptr || !s->last_picture_ptr->f->buf[0]) &&\n        (s->pict_type != AV_PICTURE_TYPE_I ||\n         s->picture_structure != PICT_FRAME)) {\n        int h_chroma_shift, v_chroma_shift;\n        av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,\n                                         &h_chroma_shift, &v_chroma_shift);\n        if (s->pict_type != AV_PICTURE_TYPE_I)\n            av_log(avctx, AV_LOG_ERROR,\n                   "warning: first frame is no keyframe\\n");\n        else if (s->picture_structure != PICT_FRAME)\n            av_log(avctx, AV_LOG_INFO,\n                   "allocate dummy last picture for field based first keyframe\\n");\n        i = ff_find_unused_picture(s->avctx, s->picture, 0);\n        if (i < 0) {\n            av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\\n");\n            return i;\n        }\n        s->last_picture_ptr = &s->picture[i];\n        s->last_picture_ptr->reference   = 3;\n        s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;\n        if (alloc_picture(s, s->last_picture_ptr, 0) < 0) {\n            s->last_picture_ptr = NULL;\n            return -1;\n        }\n        memset(s->last_picture_ptr->f->data[0], 0,\n               avctx->height * s->last_picture_ptr->f->linesize[0]);\n        memset(s->last_picture_ptr->f->data[1], 0x80,\n               (avctx->height >> v_chroma_shift) *\n               s->last_picture_ptr->f->linesize[1]);\n        memset(s->last_picture_ptr->f->data[2], 0x80,\n               (avctx->height >> v_chroma_shift) *\n               s->last_picture_ptr->f->linesize[2]);\n        ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0);\n        ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1);\n    }\n    if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) &&\n        s->pict_type == AV_PICTURE_TYPE_B) {\n        i = ff_find_unused_picture(s->avctx, s->picture, 0);\n        if (i < 0) {\n            av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\\n");\n            return i;\n        }\n        s->next_picture_ptr = &s->picture[i];\n        s->next_picture_ptr->reference   = 3;\n        s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;\n        if (alloc_picture(s, s->next_picture_ptr, 0) < 0) {\n            s->next_picture_ptr = NULL;\n            return -1;\n        }\n        ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 0);\n        ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 1);\n    }\n    if (s->last_picture_ptr) {\n        ff_mpeg_unref_picture(s->avctx, &s->last_picture);\n        if (s->last_picture_ptr->f->buf[0] &&\n            (ret = ff_mpeg_ref_picture(s->avctx, &s->last_picture,\n                                       s->last_picture_ptr)) < 0)\n            return ret;\n    }\n    if (s->next_picture_ptr) {\n        ff_mpeg_unref_picture(s->avctx, &s->next_picture);\n        if (s->next_picture_ptr->f->buf[0] &&\n            (ret = ff_mpeg_ref_picture(s->avctx, &s->next_picture,\n                                       s->next_picture_ptr)) < 0)\n            return ret;\n    }\n    if (s->pict_type != AV_PICTURE_TYPE_I &&\n        !(s->last_picture_ptr && s->last_picture_ptr->f->buf[0])) {\n        av_log(s, AV_LOG_ERROR,\n               "Non-reference picture received and no reference available\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    if (s->picture_structure!= PICT_FRAME) {\n        int i;\n        for (i = 0; i < 4; i++) {\n            if (s->picture_structure == PICT_BOTTOM_FIELD) {\n                s->current_picture.f->data[i] +=\n                    s->current_picture.f->linesize[i];\n            }\n            s->current_picture.f->linesize[i] *= 2;\n            s->last_picture.f->linesize[i]    *= 2;\n            s->next_picture.f->linesize[i]    *= 2;\n        }\n    }\n    if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {\n        s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;\n        s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;\n    } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {\n        s->dct_unquantize_intra = s->dct_unquantize_h263_intra;\n        s->dct_unquantize_inter = s->dct_unquantize_h263_inter;\n    } else {\n        s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;\n        s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;\n    }\n#if FF_API_XVMC\nFF_DISABLE_DEPRECATION_WARNINGS\n    if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)\n        return ff_xvmc_field_start(s, avctx);\nFF_ENABLE_DEPRECATION_WARNINGS\n#endif\n    return 0;\n}', 'static int alloc_picture(MpegEncContext *s, Picture *pic, int shared)\n{\n    return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, shared, 0,\n                            s->chroma_x_shift, s->chroma_y_shift, s->out_format,\n                            s->mb_stride, s->mb_height, s->b8_stride,\n                            &s->linesize, &s->uvlinesize);\n}', 'int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,\n                     ScratchpadContext *sc, int shared, int encoding,\n                     int chroma_x_shift, int chroma_y_shift, int out_format,\n                     int mb_stride, int mb_height, int b8_stride,\n                     ptrdiff_t *linesize, ptrdiff_t *uvlinesize)\n{\n    int i, ret;\n    if (shared) {\n        assert(pic->f->data[0]);\n        pic->shared = 1;\n    } else {\n        assert(!pic->f->buf[0]);\n        if (alloc_frame_buffer(avctx, pic, me, sc,\n                               chroma_x_shift, chroma_y_shift,\n                               *linesize, *uvlinesize) < 0)\n            return -1;\n        *linesize   = pic->f->linesize[0];\n        *uvlinesize = pic->f->linesize[1];\n    }\n    if (!pic->qscale_table_buf)\n        ret = alloc_picture_tables(pic, encoding, out_format,\n                                   mb_stride, mb_height, b8_stride);\n    else\n        ret = make_tables_writable(pic);\n    if (ret < 0)\n        goto fail;\n    if (encoding) {\n        pic->mb_var    = (uint16_t*)pic->mb_var_buf->data;\n        pic->mc_mb_var = (uint16_t*)pic->mc_mb_var_buf->data;\n        pic->mb_mean   = pic->mb_mean_buf->data;\n    }\n    pic->mbskip_table = pic->mbskip_table_buf->data;\n    pic->qscale_table = pic->qscale_table_buf->data + 2 * mb_stride + 1;\n    pic->mb_type      = (uint32_t*)pic->mb_type_buf->data + 2 * mb_stride + 1;\n    if (pic->motion_val_buf[0]) {\n        for (i = 0; i < 2; i++) {\n            pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4;\n            pic->ref_index[i]  = pic->ref_index_buf[i]->data;\n        }\n    }\n    return 0;\nfail:\n    av_log(avctx, AV_LOG_ERROR, "Error allocating a picture.\\n");\n    ff_mpeg_unref_picture(avctx, pic);\n    ff_free_picture_tables(pic);\n    return AVERROR(ENOMEM);\n}', 'static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic,\n                              MotionEstContext *me, ScratchpadContext *sc,\n                              int chroma_x_shift, int chroma_y_shift,\n                              int linesize, int uvlinesize)\n{\n    int edges_needed = av_codec_is_encoder(avctx->codec);\n    int r, ret;\n    pic->tf.f = pic->f;\n    if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE &&\n        avctx->codec_id != AV_CODEC_ID_VC1IMAGE  &&\n        avctx->codec_id != AV_CODEC_ID_MSS2) {\n        if (edges_needed) {\n            pic->f->width  = avctx->width  + 2 * EDGE_WIDTH;\n            pic->f->height = avctx->height + 2 * EDGE_WIDTH;\n        }\n        r = ff_thread_get_buffer(avctx, &pic->tf,\n                                 pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);\n    } else {\n        pic->f->width  = avctx->width;\n        pic->f->height = avctx->height;\n        pic->f->format = avctx->pix_fmt;\n        r = avcodec_default_get_buffer2(avctx, pic->f, 0);\n    }\n    if (r < 0 || !pic->f->buf[0]) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\\n",\n               r, pic->f->data[0]);\n        return -1;\n    }\n    if (edges_needed) {\n        int i;\n        for (i = 0; pic->f->data[i]; i++) {\n            int offset = (EDGE_WIDTH >> (i ? chroma_y_shift : 0)) *\n                         pic->f->linesize[i] +\n                         (EDGE_WIDTH >> (i ? chroma_x_shift : 0));\n            pic->f->data[i] += offset;\n        }\n        pic->f->width  = avctx->width;\n        pic->f->height = avctx->height;\n    }\n    if (avctx->hwaccel) {\n        assert(!pic->hwaccel_picture_private);\n        if (avctx->hwaccel->frame_priv_data_size) {\n            pic->hwaccel_priv_buf = av_buffer_allocz(avctx->hwaccel->frame_priv_data_size);\n            if (!pic->hwaccel_priv_buf) {\n                av_log(avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\\n");\n                return -1;\n            }\n            pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;\n        }\n    }\n    if (linesize && (linesize   != pic->f->linesize[0] ||\n                     uvlinesize != pic->f->linesize[1])) {\n        av_log(avctx, AV_LOG_ERROR,\n               "get_buffer() failed (stride changed)\\n");\n        ff_mpeg_unref_picture(avctx, pic);\n        return -1;\n    }\n    if (pic->f->linesize[1] != pic->f->linesize[2]) {\n        av_log(avctx, AV_LOG_ERROR,\n               "get_buffer() failed (uv stride mismatch)\\n");\n        ff_mpeg_unref_picture(avctx, pic);\n        return -1;\n    }\n    if (!sc->edge_emu_buffer &&\n        (ret = ff_mpeg_framesize_alloc(avctx, me, sc,\n                                       pic->f->linesize[0])) < 0) {\n        av_log(avctx, AV_LOG_ERROR,\n               "get_buffer() failed to allocate context scratch buffers.\\n");\n        ff_mpeg_unref_picture(avctx, pic);\n        return ret;\n    }\n    return 0;\n}', 'int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags)\n{\n    int ret;\n    if ((ret = update_frame_pool(avctx, frame)) < 0)\n        return ret;\n#if FF_API_GET_BUFFER\nFF_DISABLE_DEPRECATION_WARNINGS\n    frame->type = FF_BUFFER_TYPE_INTERNAL;\nFF_ENABLE_DEPRECATION_WARNINGS\n#endif\n    switch (avctx->codec_type) {\n    case AVMEDIA_TYPE_VIDEO:\n        return video_get_buffer(avctx, frame);\n    case AVMEDIA_TYPE_AUDIO:\n        return audio_get_buffer(avctx, frame);\n    default:\n        return -1;\n    }\n}', 'static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)\n{\n    FramePool *pool = avctx->internal->pool;\n    int i, ret;\n    switch (avctx->codec_type) {\n    case AVMEDIA_TYPE_VIDEO: {\n        AVPicture picture;\n        int size[4] = { 0 };\n        int w = frame->width;\n        int h = frame->height;\n        int tmpsize, unaligned;\n        if (pool->format == frame->format &&\n            pool->width == frame->width && pool->height == frame->height)\n            return 0;\n        avcodec_align_dimensions2(avctx, &w, &h, pool->stride_align);\n        do {\n            av_image_fill_linesizes(picture.linesize, avctx->pix_fmt, w);\n            w += w & ~(w - 1);\n            unaligned = 0;\n            for (i = 0; i < 4; i++)\n                unaligned |= picture.linesize[i] % pool->stride_align[i];\n        } while (unaligned);\n        tmpsize = av_image_fill_pointers(picture.data, avctx->pix_fmt, h,\n                                         NULL, picture.linesize);\n        if (tmpsize < 0)\n            return -1;\n        for (i = 0; i < 3 && picture.data[i + 1]; i++)\n            size[i] = picture.data[i + 1] - picture.data[i];\n        size[i] = tmpsize - (picture.data[i] - picture.data[0]);\n        for (i = 0; i < 4; i++) {\n            av_buffer_pool_uninit(&pool->pools[i]);\n            pool->linesize[i] = picture.linesize[i];\n            if (size[i]) {\n                pool->pools[i] = av_buffer_pool_init(size[i] + 16, NULL);\n                if (!pool->pools[i]) {\n                    ret = AVERROR(ENOMEM);\n                    goto fail;\n                }\n            }\n        }\n        pool->format = frame->format;\n        pool->width  = frame->width;\n        pool->height = frame->height;\n        break;\n        }\n    case AVMEDIA_TYPE_AUDIO: {\n        int ch     = av_get_channel_layout_nb_channels(frame->channel_layout);\n        int planar = av_sample_fmt_is_planar(frame->format);\n        int planes = planar ? ch : 1;\n        if (pool->format == frame->format && pool->planes == planes &&\n            pool->channels == ch && frame->nb_samples == pool->samples)\n            return 0;\n        av_buffer_pool_uninit(&pool->pools[0]);\n        ret = av_samples_get_buffer_size(&pool->linesize[0], ch,\n                                         frame->nb_samples, frame->format, 0);\n        if (ret < 0)\n            goto fail;\n        pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL);\n        if (!pool->pools[0]) {\n            ret = AVERROR(ENOMEM);\n            goto fail;\n        }\n        pool->format     = frame->format;\n        pool->planes     = planes;\n        pool->channels   = ch;\n        pool->samples = frame->nb_samples;\n        break;\n        }\n    default: av_assert0(0);\n    }\n    return 0;\nfail:\n    for (i = 0; i < 4; i++)\n        av_buffer_pool_uninit(&pool->pools[i]);\n    pool->format = -1;\n    pool->planes = pool->channels = pool->samples = 0;\n    pool->width  = pool->height = 0;\n    return ret;\n}', 'int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,\n                               enum AVSampleFormat sample_fmt, int align)\n{\n    int line_size;\n    int sample_size = av_get_bytes_per_sample(sample_fmt);\n    int planar      = av_sample_fmt_is_planar(sample_fmt);\n    if (!sample_size || nb_samples <= 0 || nb_channels <= 0)\n        return AVERROR(EINVAL);\n    if (!align) {\n        if (nb_samples > INT_MAX - 31)\n            return AVERROR(EINVAL);\n        align = 1;\n        nb_samples = FFALIGN(nb_samples, 32);\n    }\n    if (nb_channels > INT_MAX / align ||\n        (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)\n        return AVERROR(EINVAL);\n    line_size = planar ? FFALIGN(nb_samples * sample_size,               align) :\n                         FFALIGN(nb_samples * sample_size * nb_channels, align);\n    if (linesize)\n        *linesize = line_size;\n    return planar ? line_size * nb_channels : line_size;\n}']