libavcodec/mpegvideo_enc.c:1114: error: Null Dereference
  pointer `c` last assigned on line 1095 could be null and is dereferenced at line 1114, column 5.

libavcodec/mpegvideo_enc.c:1092:1: start of procedure estimate_best_b_count()
1090. }
1091. 
1092. static int estimate_best_b_count(MpegEncContext *s)
      ^
1093. {
1094.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);

libavcodec/mpegvideo_enc.c:1094:5: 
1092. static int estimate_best_b_count(MpegEncContext *s)
1093. {
1094.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
          ^
1095.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1096.     AVFrame input[FF_MAX_B_FRAMES + 2];

libavcodec/utils.c:1530:1: start of procedure avcodec_find_encoder()
  1528. }
  1529. 
  1530. AVCodec *avcodec_find_encoder(enum AVCodecID id)
        ^
  1531. {
  1532.     return find_encdec(id, 1);

libavcodec/utils.c:1532:5: Skipping find_encdec(): empty list of specs
  1530. AVCodec *avcodec_find_encoder(enum AVCodecID id)
  1531. {
  1532.     return find_encdec(id, 1);
            ^
  1533. }
  1534. 

libavcodec/utils.c:1533:1: return from a call to avcodec_find_encoder
  1531. {
  1532.     return find_encdec(id, 1);
  1533. }
        ^
  1534. 
  1535. AVCodec *avcodec_find_encoder_by_name(const char *name)

libavcodec/mpegvideo_enc.c:1095:5: 
1093. {
1094.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
1095.     AVCodecContext *c = avcodec_alloc_context3(NULL);
          ^
1096.     AVFrame input[FF_MAX_B_FRAMES + 2];
1097.     const int scale = s->avctx->brd_scale;

libavcodec/options.c:126:1: start of procedure avcodec_alloc_context3()
  124. }
  125. 
  126. AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
       ^
  127. {
  128.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));

libavcodec/options.c:128:5: 
  126. AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
  127. {
  128.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
           ^
  129. 
  130.     if(avctx==NULL) return NULL;

libavutil/mem.c:66:1: start of procedure av_malloc()
    64.  * linker will do it automatically. */
    65. 
    66. void *av_malloc(size_t size)
        ^
    67. {
    68.     void *ptr = NULL;

libavutil/mem.c:68:5: 
    66. void *av_malloc(size_t size)
    67. {
    68.     void *ptr = NULL;
            ^
    69. #if CONFIG_MEMALIGN_HACK
    70.     long diff;

libavutil/mem.c:74:9: Taking false branch
    72. 
    73.     /* let's disallow possible ambiguous cases */
    74.     if (size > (INT_MAX - 32) || !size)
                ^
    75.         return NULL;
    76. 

libavutil/mem.c:74:35: Taking false branch
    72. 
    73.     /* let's disallow possible ambiguous cases */
    74.     if (size > (INT_MAX - 32) || !size)
                                          ^
    75.         return NULL;
    76. 

libavutil/mem.c:85:9: Taking false branch
    83.     ((char *)ptr)[-1] = diff;
    84. #elif HAVE_POSIX_MEMALIGN
    85.     if (posix_memalign(&ptr, 32, size))
                ^
    86.         ptr = NULL;
    87. #elif HAVE_ALIGNED_MALLOC

libavutil/mem.c:118:5: 
    116.     ptr = malloc(size);
    117. #endif
    118.     return ptr;
             ^
    119. }
    120. 

libavutil/mem.c:119:1: return from a call to av_malloc
    117. #endif
    118.     return ptr;
    119. }
         ^
    120. 
    121. void *av_realloc(void *ptr, size_t size)

libavcodec/options.c:130:8: Taking true branch
  128.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
  129. 
  130.     if(avctx==NULL) return NULL;
              ^
  131. 
  132.     if(avcodec_get_context_defaults3(avctx, codec) < 0){

libavcodec/options.c:130:21: 
  128.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
  129. 
  130.     if(avctx==NULL) return NULL;
                           ^
  131. 
  132.     if(avcodec_get_context_defaults3(avctx, codec) < 0){

libavcodec/options.c:138:1: return from a call to avcodec_alloc_context3
  136. 
  137.     return avctx;
  138. }
       ^
  139. 
  140. int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)

libavcodec/mpegvideo_enc.c:1097:5: 
1095.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1096.     AVFrame input[FF_MAX_B_FRAMES + 2];
1097.     const int scale = s->avctx->brd_scale;
          ^
1098.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1099.     int64_t best_rd  = INT64_MAX;

libavcodec/mpegvideo_enc.c:1099:5: 
1097.     const int scale = s->avctx->brd_scale;
1098.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1099.     int64_t best_rd  = INT64_MAX;
          ^
1100.     int best_b_count = -1;
1101. 

libavcodec/mpegvideo_enc.c:1100:5: 
1098.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1099.     int64_t best_rd  = INT64_MAX;
1100.     int best_b_count = -1;
          ^
1101. 
1102.     assert(scale >= 0 && scale <= 3);

libavcodec/mpegvideo_enc.c:1102:5: 
1100.     int best_b_count = -1;
1101. 
1102.     assert(scale >= 0 && scale <= 3);
          ^
1103. 
1104.     //emms_c();

libavcodec/mpegvideo_enc.c:1106:5: 
1104.     //emms_c();
1105.     //s->next_picture_ptr->quality;
1106.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
          ^
1107.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1108.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];

libavcodec/mpegvideo_enc.c:1108:5: 
1106.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
1107.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1108.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];
          ^
1109.     if (!b_lambda) // FIXME we should do this somewhere else
1110.         b_lambda = p_lambda;

libavcodec/mpegvideo_enc.c:1109:10: Taking false branch
1107.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1108.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];
1109.     if (!b_lambda) // FIXME we should do this somewhere else
               ^
1110.         b_lambda = p_lambda;
1111.     lambda2  = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >>

libavcodec/mpegvideo_enc.c:1111:5: 
1109.     if (!b_lambda) // FIXME we should do this somewhere else
1110.         b_lambda = p_lambda;
1111.     lambda2  = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >>
          ^
1112.                FF_LAMBDA_SHIFT;
1113. 

libavcodec/mpegvideo_enc.c:1114:5: 
1112.                FF_LAMBDA_SHIFT;
1113. 
1114.     c->width        = s->width  >> scale;
          ^
1115.     c->height       = s->height >> scale;
1116.     c->flags        = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR |
