libavcodec/imgconvert.c:639: error: Buffer Overrun L3
  Offset: [-1, 63] Size: 89 by call to `avcodec_find_best_pix_fmt2`.

libavcodec/imgconvert.c:637:5: Assignment
635.             list[j++] = i;
636.     }
637.     list[j] = AV_PIX_FMT_NONE;
         ^
638. 
639.     return avcodec_find_best_pix_fmt2(list, src_pix_fmt, has_alpha, loss_ptr);

libavcodec/imgconvert.c:639:12: Call
637.     list[j] = AV_PIX_FMT_NONE;
638. 
639.     return avcodec_find_best_pix_fmt2(list, src_pix_fmt, has_alpha, loss_ptr);
                ^
640. }
641. #endif /* FF_API_FIND_BEST_PIX_FMT */

libavcodec/imgconvert.c:643:1: Parameter `*pix_fmt_list`
  641. #endif /* FF_API_FIND_BEST_PIX_FMT */
  642. 
  643. enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat *pix_fmt_list,
       ^
  644.                                             enum AVPixelFormat src_pix_fmt,
  645.                                             int has_alpha, int *loss_ptr)

libavcodec/imgconvert.c:663:23: Call
  661.     for(;;) {
  662.         loss_mask = loss_mask_order[i++];
  663.         dst_pix_fmt = avcodec_find_best_pix_fmt1(pix_fmt_list, src_pix_fmt,
                             ^
  664.                                                  has_alpha, loss_mask);
  665.         if (dst_pix_fmt >= 0)

libavcodec/imgconvert.c:591:1: Parameter `*pix_fmt_list`
    589. }
    590. 
    591. static enum AVPixelFormat avcodec_find_best_pix_fmt1(enum AVPixelFormat *pix_fmt_list,
         ^
    592.                                       enum AVPixelFormat src_pix_fmt,
    593.                                       int has_alpha,

libavcodec/imgconvert.c:604:9: Assignment
    602.     i = 0;
    603.     while (pix_fmt_list[i] != AV_PIX_FMT_NONE) {
    604.         enum AVPixelFormat pix_fmt = pix_fmt_list[i];
                 ^
    605. 
    606.         if (i > AV_PIX_FMT_NB) {

libavcodec/imgconvert.c:612:16: Call
    610.         }
    611. 
    612.         loss = avcodec_get_pix_fmt_loss(pix_fmt, src_pix_fmt, has_alpha) & loss_mask;
                        ^
    613.         if (loss == 0) {
    614.             dist = avg_bits_per_pixel(pix_fmt);

libavcodec/imgconvert.c:480:1: <Offset trace>
478. }
479. 
480. int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
     ^
481.                              int has_alpha)
482. {

libavcodec/imgconvert.c:480:1: Parameter `dst_pix_fmt`
      478. }
      479. 
      480. int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
           ^
      481.                              int has_alpha)
      482. {

libavcodec/imgconvert.c:71:1: <Length trace>
69. 
70. /* this table gives more information about formats */
71. static const PixFmtInfo pix_fmt_info[AV_PIX_FMT_NB] = {
    ^
72.     /* YUV formats */
73.     [AV_PIX_FMT_YUV420P] = {

libavcodec/imgconvert.c:71:1: Array declaration
      69. 
      70. /* this table gives more information about formats */
      71. static const PixFmtInfo pix_fmt_info[AV_PIX_FMT_NB] = {
          ^
      72.     /* YUV formats */
      73.     [AV_PIX_FMT_YUV420P] = {

libavcodec/imgconvert.c:492:5: Array access: Offset: [-1, 63] Size: 89 by call to `avcodec_find_best_pix_fmt2` 
      490.     /* compute loss */
      491.     loss = 0;
      492.     pf = &pix_fmt_info[dst_pix_fmt];
               ^
      493.     if (pf->depth < ps->depth ||
      494.         ((dst_pix_fmt == AV_PIX_FMT_RGB555BE || dst_pix_fmt == AV_PIX_FMT_RGB555LE ||

int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
                             int has_alpha)
{
    const PixFmtInfo *pf, *ps;
    const AVPixFmtDescriptor *src_desc = &av_pix_fmt_descriptors[src_pix_fmt];
    const AVPixFmtDescriptor *dst_desc = &av_pix_fmt_descriptors[dst_pix_fmt];
    int loss;
    ps = &pix_fmt_info[src_pix_fmt];
    loss = 0;
    pf = &pix_fmt_info[dst_pix_fmt];
    if (pf->depth < ps->depth ||
        ((dst_pix_fmt == AV_PIX_FMT_RGB555BE || dst_pix_fmt == AV_PIX_FMT_RGB555LE ||
          dst_pix_fmt == AV_PIX_FMT_BGR555BE || dst_pix_fmt == AV_PIX_FMT_BGR555LE) &&
         (src_pix_fmt == AV_PIX_FMT_RGB565BE || src_pix_fmt == AV_PIX_FMT_RGB565LE ||
          src_pix_fmt == AV_PIX_FMT_BGR565BE || src_pix_fmt == AV_PIX_FMT_BGR565LE)))
        loss |= FF_LOSS_DEPTH;
    if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w ||
        dst_desc->log2_chroma_h > src_desc->log2_chroma_h)
        loss |= FF_LOSS_RESOLUTION;
    switch(pf->color_type) {
    case FF_COLOR_RGB:
        if (ps->color_type != FF_COLOR_RGB &&
            ps->color_type != FF_COLOR_GRAY)
            loss |= FF_LOSS_COLORSPACE;
        break;
    case FF_COLOR_GRAY:
        if (ps->color_type != FF_COLOR_GRAY)
            loss |= FF_LOSS_COLORSPACE;
        break;
    case FF_COLOR_YUV:
        if (ps->color_type != FF_COLOR_YUV)
            loss |= FF_LOSS_COLORSPACE;
        break;
    case FF_COLOR_YUV_JPEG:
        if (ps->color_type != FF_COLOR_YUV_JPEG &&
            ps->color_type != FF_COLOR_YUV &&
            ps->color_type != FF_COLOR_GRAY)
            loss |= FF_LOSS_COLORSPACE;
        break;
    default:
        if (ps->color_type != pf->color_type)
            loss |= FF_LOSS_COLORSPACE;
        break;
    }
    if (pf->color_type == FF_COLOR_GRAY &&
        ps->color_type != FF_COLOR_GRAY)
        loss |= FF_LOSS_CHROMA;
    if (!pf->is_alpha && (ps->is_alpha && has_alpha))
        loss |= FF_LOSS_ALPHA;
    if (pf->pixel_type == FF_PIXEL_PALETTE &&
        (ps->pixel_type != FF_PIXEL_PALETTE && ps->color_type != FF_COLOR_GRAY))
        loss |= FF_LOSS_COLORQUANT;
    return loss;
}
['enum AVPixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum AVPixelFormat src_pix_fmt,\n                              int has_alpha, int *loss_ptr)\n{\n    enum AVPixelFormat list[64];\n    int i, j = 0;\n    for (i = 0; i < 64; i++) {\n        if (pix_fmt_mask & (1ULL << i))\n            list[j++] = i;\n    }\n    list[j] = AV_PIX_FMT_NONE;\n    return avcodec_find_best_pix_fmt2(list, src_pix_fmt, has_alpha, loss_ptr);\n}', 'enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat *pix_fmt_list,\n                                            enum AVPixelFormat src_pix_fmt,\n                                            int has_alpha, int *loss_ptr)\n{\n    enum AVPixelFormat dst_pix_fmt;\n    int loss_mask, i;\n    static const int loss_mask_order[] = {\n        ~0,\n        ~FF_LOSS_ALPHA,\n        ~FF_LOSS_RESOLUTION,\n        ~(FF_LOSS_COLORSPACE | FF_LOSS_RESOLUTION),\n        ~FF_LOSS_COLORQUANT,\n        ~FF_LOSS_DEPTH,\n        0,\n    };\n    i = 0;\n    for(;;) {\n        loss_mask = loss_mask_order[i++];\n        dst_pix_fmt = avcodec_find_best_pix_fmt1(pix_fmt_list, src_pix_fmt,\n                                                 has_alpha, loss_mask);\n        if (dst_pix_fmt >= 0)\n            goto found;\n        if (loss_mask == 0)\n            break;\n    }\n    return AV_PIX_FMT_NONE;\n found:\n    if (loss_ptr)\n        *loss_ptr = avcodec_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha);\n    return dst_pix_fmt;\n}', 'static enum AVPixelFormat avcodec_find_best_pix_fmt1(enum AVPixelFormat *pix_fmt_list,\n                                      enum AVPixelFormat src_pix_fmt,\n                                      int has_alpha,\n                                      int loss_mask)\n{\n    int dist, i, loss, min_dist;\n    enum AVPixelFormat dst_pix_fmt;\n    dst_pix_fmt = AV_PIX_FMT_NONE;\n    min_dist = 0x7fffffff;\n    i = 0;\n    while (pix_fmt_list[i] != AV_PIX_FMT_NONE) {\n        enum AVPixelFormat pix_fmt = pix_fmt_list[i];\n        if (i > AV_PIX_FMT_NB) {\n            av_log(NULL, AV_LOG_ERROR, "Pixel format list longer than expected, "\n                   "it is either not properly terminated or contains duplicates\\n");\n            return AV_PIX_FMT_NONE;\n        }\n        loss = avcodec_get_pix_fmt_loss(pix_fmt, src_pix_fmt, has_alpha) & loss_mask;\n        if (loss == 0) {\n            dist = avg_bits_per_pixel(pix_fmt);\n            if (dist < min_dist) {\n                min_dist = dist;\n                dst_pix_fmt = pix_fmt;\n            }\n        }\n        i++;\n    }\n    return dst_pix_fmt;\n}', 'int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,\n                             int has_alpha)\n{\n    const PixFmtInfo *pf, *ps;\n    const AVPixFmtDescriptor *src_desc = &av_pix_fmt_descriptors[src_pix_fmt];\n    const AVPixFmtDescriptor *dst_desc = &av_pix_fmt_descriptors[dst_pix_fmt];\n    int loss;\n    ps = &pix_fmt_info[src_pix_fmt];\n    loss = 0;\n    pf = &pix_fmt_info[dst_pix_fmt];\n    if (pf->depth < ps->depth ||\n        ((dst_pix_fmt == AV_PIX_FMT_RGB555BE || dst_pix_fmt == AV_PIX_FMT_RGB555LE ||\n          dst_pix_fmt == AV_PIX_FMT_BGR555BE || dst_pix_fmt == AV_PIX_FMT_BGR555LE) &&\n         (src_pix_fmt == AV_PIX_FMT_RGB565BE || src_pix_fmt == AV_PIX_FMT_RGB565LE ||\n          src_pix_fmt == AV_PIX_FMT_BGR565BE || src_pix_fmt == AV_PIX_FMT_BGR565LE)))\n        loss |= FF_LOSS_DEPTH;\n    if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w ||\n        dst_desc->log2_chroma_h > src_desc->log2_chroma_h)\n        loss |= FF_LOSS_RESOLUTION;\n    switch(pf->color_type) {\n    case FF_COLOR_RGB:\n        if (ps->color_type != FF_COLOR_RGB &&\n            ps->color_type != FF_COLOR_GRAY)\n            loss |= FF_LOSS_COLORSPACE;\n        break;\n    case FF_COLOR_GRAY:\n        if (ps->color_type != FF_COLOR_GRAY)\n            loss |= FF_LOSS_COLORSPACE;\n        break;\n    case FF_COLOR_YUV:\n        if (ps->color_type != FF_COLOR_YUV)\n            loss |= FF_LOSS_COLORSPACE;\n        break;\n    case FF_COLOR_YUV_JPEG:\n        if (ps->color_type != FF_COLOR_YUV_JPEG &&\n            ps->color_type != FF_COLOR_YUV &&\n            ps->color_type != FF_COLOR_GRAY)\n            loss |= FF_LOSS_COLORSPACE;\n        break;\n    default:\n        if (ps->color_type != pf->color_type)\n            loss |= FF_LOSS_COLORSPACE;\n        break;\n    }\n    if (pf->color_type == FF_COLOR_GRAY &&\n        ps->color_type != FF_COLOR_GRAY)\n        loss |= FF_LOSS_CHROMA;\n    if (!pf->is_alpha && (ps->is_alpha && has_alpha))\n        loss |= FF_LOSS_ALPHA;\n    if (pf->pixel_type == FF_PIXEL_PALETTE &&\n        (ps->pixel_type != FF_PIXEL_PALETTE && ps->color_type != FF_COLOR_GRAY))\n        loss |= FF_LOSS_COLORQUANT;\n    return loss;\n}']