libavcodec/mpegvideo_enc.c:1315: error: Integer Overflow L2
  ([1, 2147483616] + 32):signed32 by call to `ff_alloc_picture`.

libavcodec/mpegvideo_enc.c:1315:17: Call
1313. 
1314.             pic->reference = s->reordered_input_picture[0]->reference;
1315.             if (ff_alloc_picture(s, pic, 0) < 0) {
                      ^
1316.                 return -1;
1317.             }

libavcodec/mpegvideo.c:587:1: Parameter `pic->f.nb_samples`
  585.  * The pixels are allocated/set by calling get_buffer() if shared = 0
  586.  */
  587. int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)
       ^
  588. {
  589.     int i, ret;

libavcodec/mpegvideo.c:597:13: Call
  595.         assert(!pic->f.buf[0]);
  596. 
  597.         if (alloc_frame_buffer(s, pic) < 0)
                   ^
  598.             return -1;
  599. 

libavcodec/mpegvideo.c:424:1: Parameter `pic->f.nb_samples`
    422.  * Allocate a frame buffer
    423.  */
    424. static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
         ^
    425. {
    426.     int edges_needed = av_codec_is_encoder(s->avctx->codec);

libavcodec/mpegvideo.c:444:13: Call
    442.         pic->f.height = s->avctx->height;
    443.         pic->f.format = s->avctx->pix_fmt;
    444.         r = avcodec_default_get_buffer2(s->avctx, &pic->f, 0);
                     ^
    445.     }
    446. 

libavcodec/utils.c:524:1: Parameter `frame->nb_samples`
      522. }
      523. 
      524. int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags)
           ^
      525. {
      526.     int ret;

libavcodec/utils.c:528:16: Call
      526.     int ret;
      527. 
      528.     if ((ret = update_frame_pool(avctx, frame)) < 0)
                          ^
      529.         return ret;
      530. 

libavcodec/utils.c:327:1: Parameter `frame->nb_samples`
        325. }
        326. 
        327. static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
             ^
        328. {
        329.     FramePool *pool = avctx->internal->pool;

libavcodec/utils.c:399:15: Call
        397. 
        398.         av_buffer_pool_uninit(&pool->pools[0]);
        399.         ret = av_samples_get_buffer_size(&pool->linesize[0], ch,
                           ^
        400.                                          frame->nb_samples, frame->format, 0);
        401.         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 `ff_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;
}
['static int select_input_picture(MpegEncContext *s)\n{\n    int i, ret;\n    for (i = 1; i < MAX_PICTURE_COUNT; i++)\n        s->reordered_input_picture[i - 1] = s->reordered_input_picture[i];\n    s->reordered_input_picture[MAX_PICTURE_COUNT - 1] = NULL;\n    if (s->reordered_input_picture[0] == NULL && s->input_picture[0]) {\n        if (\n            s->next_picture_ptr == NULL || s->intra_only) {\n            s->reordered_input_picture[0] = s->input_picture[0];\n            s->reordered_input_picture[0]->f.pict_type = AV_PICTURE_TYPE_I;\n            s->reordered_input_picture[0]->f.coded_picture_number =\n                s->coded_picture_number++;\n        } else {\n            int b_frames;\n            if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) {\n                if (s->picture_in_gop_number < s->gop_size &&\n                    skip_check(s, s->input_picture[0], s->next_picture_ptr)) {\n                    av_frame_unref(&s->input_picture[0]->f);\n                    emms_c();\n                    ff_vbv_update(s, 0);\n                    goto no_output_pic;\n                }\n            }\n            if (s->flags & CODEC_FLAG_PASS2) {\n                for (i = 0; i < s->max_b_frames + 1; i++) {\n                    int pict_num = s->input_picture[0]->f.display_picture_number + i;\n                    if (pict_num >= s->rc_context.num_entries)\n                        break;\n                    if (!s->input_picture[i]) {\n                        s->rc_context.entry[pict_num - 1].new_pict_type = AV_PICTURE_TYPE_P;\n                        break;\n                    }\n                    s->input_picture[i]->f.pict_type =\n                        s->rc_context.entry[pict_num].new_pict_type;\n                }\n            }\n            if (s->avctx->b_frame_strategy == 0) {\n                b_frames = s->max_b_frames;\n                while (b_frames && !s->input_picture[b_frames])\n                    b_frames--;\n            } else if (s->avctx->b_frame_strategy == 1) {\n                for (i = 1; i < s->max_b_frames + 1; i++) {\n                    if (s->input_picture[i] &&\n                        s->input_picture[i]->b_frame_score == 0) {\n                        s->input_picture[i]->b_frame_score =\n                            get_intra_count(s,\n                                            s->input_picture[i    ]->f.data[0],\n                                            s->input_picture[i - 1]->f.data[0],\n                                            s->linesize) + 1;\n                    }\n                }\n                for (i = 0; i < s->max_b_frames + 1; i++) {\n                    if (s->input_picture[i] == NULL ||\n                        s->input_picture[i]->b_frame_score - 1 >\n                            s->mb_num / s->avctx->b_sensitivity)\n                        break;\n                }\n                b_frames = FFMAX(0, i - 1);\n                for (i = 0; i < b_frames + 1; i++) {\n                    s->input_picture[i]->b_frame_score = 0;\n                }\n            } else if (s->avctx->b_frame_strategy == 2) {\n                b_frames = estimate_best_b_count(s);\n            } else {\n                av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\\n");\n                b_frames = 0;\n            }\n            emms_c();\n            for (i = b_frames - 1; i >= 0; i--) {\n                int type = s->input_picture[i]->f.pict_type;\n                if (type && type != AV_PICTURE_TYPE_B)\n                    b_frames = i;\n            }\n            if (s->input_picture[b_frames]->f.pict_type == AV_PICTURE_TYPE_B &&\n                b_frames == s->max_b_frames) {\n                av_log(s->avctx, AV_LOG_ERROR,\n                       "warning, too many b frames in a row\\n");\n            }\n            if (s->picture_in_gop_number + b_frames >= s->gop_size) {\n                if ((s->mpv_flags & FF_MPV_FLAG_STRICT_GOP) &&\n                    s->gop_size > s->picture_in_gop_number) {\n                    b_frames = s->gop_size - s->picture_in_gop_number - 1;\n                } else {\n                    if (s->flags & CODEC_FLAG_CLOSED_GOP)\n                        b_frames = 0;\n                    s->input_picture[b_frames]->f.pict_type = AV_PICTURE_TYPE_I;\n                }\n            }\n            if ((s->flags & CODEC_FLAG_CLOSED_GOP) && b_frames &&\n                s->input_picture[b_frames]->f.pict_type == AV_PICTURE_TYPE_I)\n                b_frames--;\n            s->reordered_input_picture[0] = s->input_picture[b_frames];\n            if (s->reordered_input_picture[0]->f.pict_type != AV_PICTURE_TYPE_I)\n                s->reordered_input_picture[0]->f.pict_type = AV_PICTURE_TYPE_P;\n            s->reordered_input_picture[0]->f.coded_picture_number =\n                s->coded_picture_number++;\n            for (i = 0; i < b_frames; i++) {\n                s->reordered_input_picture[i + 1] = s->input_picture[i];\n                s->reordered_input_picture[i + 1]->f.pict_type =\n                    AV_PICTURE_TYPE_B;\n                s->reordered_input_picture[i + 1]->f.coded_picture_number =\n                    s->coded_picture_number++;\n            }\n        }\n    }\nno_output_pic:\n    if (s->reordered_input_picture[0]) {\n        s->reordered_input_picture[0]->reference =\n           s->reordered_input_picture[0]->f.pict_type !=\n               AV_PICTURE_TYPE_B ? 3 : 0;\n        ff_mpeg_unref_picture(s, &s->new_picture);\n        if ((ret = ff_mpeg_ref_picture(s, &s->new_picture, s->reordered_input_picture[0])))\n            return ret;\n        if (s->reordered_input_picture[0]->shared || s->avctx->rc_buffer_size) {\n            Picture *pic;\n            int i = ff_find_unused_picture(s, 0);\n            if (i < 0)\n                return i;\n            pic = &s->picture[i];\n            pic->reference = s->reordered_input_picture[0]->reference;\n            if (ff_alloc_picture(s, pic, 0) < 0) {\n                return -1;\n            }\n            ret = av_frame_copy_props(&pic->f, &s->reordered_input_picture[0]->f);\n            if (ret < 0)\n                return ret;\n            av_frame_unref(&s->reordered_input_picture[0]->f);\n            s->reordered_input_picture[0]->shared = 0;\n            s->current_picture_ptr = pic;\n        } else {\n            s->current_picture_ptr = s->reordered_input_picture[0];\n            for (i = 0; i < 4; i++) {\n                s->new_picture.f.data[i] += INPLACE_OFFSET;\n            }\n        }\n        ff_mpeg_unref_picture(s, &s->current_picture);\n        if ((ret = ff_mpeg_ref_picture(s, &s->current_picture,\n                                       s->current_picture_ptr)) < 0)\n            return ret;\n        s->picture_number = s->new_picture.f.display_picture_number;\n    } else {\n        ff_mpeg_unref_picture(s, &s->new_picture);\n    }\n    return 0;\n}', 'int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)\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(s, pic) < 0)\n            return -1;\n        s->linesize   = pic->f.linesize[0];\n        s->uvlinesize = pic->f.linesize[1];\n    }\n    if (!pic->qscale_table_buf)\n        ret = alloc_picture_tables(s, pic);\n    else\n        ret = make_tables_writable(pic);\n    if (ret < 0)\n        goto fail;\n    if (s->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 * s->mb_stride + 1;\n    pic->mb_type      = (uint32_t*)pic->mb_type_buf->data + 2 * s->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(s->avctx, AV_LOG_ERROR, "Error allocating a picture.\\n");\n    ff_mpeg_unref_picture(s, pic);\n    ff_free_picture_tables(pic);\n    return AVERROR(ENOMEM);\n}', 'static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)\n{\n    int edges_needed = av_codec_is_encoder(s->avctx->codec);\n    int r, ret;\n    pic->tf.f = &pic->f;\n    if (s->codec_id != AV_CODEC_ID_WMV3IMAGE &&\n        s->codec_id != AV_CODEC_ID_VC1IMAGE  &&\n        s->codec_id != AV_CODEC_ID_MSS2) {\n        if (edges_needed) {\n            pic->f.width  = s->avctx->width  + 2 * EDGE_WIDTH;\n            pic->f.height = s->avctx->height + 2 * EDGE_WIDTH;\n        }\n        r = ff_thread_get_buffer(s->avctx, &pic->tf,\n                                 pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);\n    } else {\n        pic->f.width  = s->avctx->width;\n        pic->f.height = s->avctx->height;\n        pic->f.format = s->avctx->pix_fmt;\n        r = avcodec_default_get_buffer2(s->avctx, &pic->f, 0);\n    }\n    if (r < 0 || !pic->f.buf[0]) {\n        av_log(s->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 ? s->chroma_y_shift : 0)) *\n                         pic->f.linesize[i] +\n                         (EDGE_WIDTH >> (i ? s->chroma_x_shift : 0));\n            pic->f.data[i] += offset;\n        }\n        pic->f.width  = s->avctx->width;\n        pic->f.height = s->avctx->height;\n    }\n    if (s->avctx->hwaccel) {\n        assert(!pic->hwaccel_picture_private);\n        if (s->avctx->hwaccel->priv_data_size) {\n            pic->hwaccel_priv_buf = av_buffer_allocz(s->avctx->hwaccel->priv_data_size);\n            if (!pic->hwaccel_priv_buf) {\n                av_log(s->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 (s->linesize && (s->linesize   != pic->f.linesize[0] ||\n                        s->uvlinesize != pic->f.linesize[1])) {\n        av_log(s->avctx, AV_LOG_ERROR,\n               "get_buffer() failed (stride changed)\\n");\n        ff_mpeg_unref_picture(s, pic);\n        return -1;\n    }\n    if (pic->f.linesize[1] != pic->f.linesize[2]) {\n        av_log(s->avctx, AV_LOG_ERROR,\n               "get_buffer() failed (uv stride mismatch)\\n");\n        ff_mpeg_unref_picture(s, pic);\n        return -1;\n    }\n    if (!s->edge_emu_buffer &&\n        (ret = frame_size_alloc(s, pic->f.linesize[0])) < 0) {\n        av_log(s->avctx, AV_LOG_ERROR,\n               "get_buffer() failed to allocate context scratch buffers.\\n");\n        ff_mpeg_unref_picture(s, 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        if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) {\n            w += EDGE_WIDTH * 2;\n            h += EDGE_WIDTH * 2;\n        }\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}']