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

libavcodec/mpegvideo_enc.c:1118:1: start of procedure estimate_best_b_count()
1116. }
1117. 
1118. static int estimate_best_b_count(MpegEncContext *s)
      ^
1119. {
1120.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);

libavcodec/mpegvideo_enc.c:1120:5: 
1118. static int estimate_best_b_count(MpegEncContext *s)
1119. {
1120.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
          ^
1121.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1122.     const int scale = s->avctx->brd_scale;

libavcodec/utils.c:1813:1: start of procedure avcodec_find_encoder()
  1811. }
  1812. 
  1813. AVCodec *avcodec_find_encoder(enum AVCodecID id)
        ^
  1814. {
  1815.     return find_encdec(id, 1);

libavcodec/utils.c:1815:5: Skipping find_encdec(): empty list of specs
  1813. AVCodec *avcodec_find_encoder(enum AVCodecID id)
  1814. {
  1815.     return find_encdec(id, 1);
            ^
  1816. }
  1817. 

libavcodec/utils.c:1816:1: return from a call to avcodec_find_encoder
  1814. {
  1815.     return find_encdec(id, 1);
  1816. }
        ^
  1817. 
  1818. AVCodec *avcodec_find_encoder_by_name(const char *name)

libavcodec/mpegvideo_enc.c:1121:5: 
1119. {
1120.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
1121.     AVCodecContext *c = avcodec_alloc_context3(NULL);
          ^
1122.     const int scale = s->avctx->brd_scale;
1123.     int i, j, out_size, p_lambda, b_lambda, lambda2;

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)

libavutil/mem.c:62:1: start of procedure av_malloc()
    60.  * linker will do it automatically. */
    61. 
    62. void *av_malloc(size_t size)
        ^
    63. {
    64.     void *ptr = NULL;

libavutil/mem.c:64:5: 
    62. void *av_malloc(size_t size)
    63. {
    64.     void *ptr = NULL;
            ^
    65. #if CONFIG_MEMALIGN_HACK
    66.     long diff;

libavutil/mem.c:70:9: Taking false branch
    68. 
    69.     /* let's disallow possibly ambiguous cases */
    70.     if (size > (INT_MAX - 32) || !size)
                ^
    71.         return NULL;
    72. 

libavutil/mem.c:70:35: Taking false branch
    68. 
    69.     /* let's disallow possibly ambiguous cases */
    70.     if (size > (INT_MAX - 32) || !size)
                                          ^
    71.         return NULL;
    72. 

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

libavutil/mem.c:114:5: 
    112.     ptr = malloc(size);
    113. #endif
    114.     return ptr;
             ^
    115. }
    116. 

libavutil/mem.c:115:1: return from a call to av_malloc
    113. #endif
    114.     return ptr;
    115. }
         ^
    116. 
    117. void *av_realloc(void *ptr, size_t size)

libavcodec/options.c:130:10: Taking true branch
  128.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
  129. 
  130.     if (!avctx)
                ^
  131.         return NULL;
  132. 

libavcodec/options.c:131:9: 
  129. 
  130.     if (!avctx)
  131.         return NULL;
               ^
  132. 
  133.     if(avcodec_get_context_defaults3(avctx, codec) < 0){

libavcodec/options.c:139:1: return from a call to avcodec_alloc_context3
  137. 
  138.     return avctx;
  139. }
       ^
  140. 
  141. void avcodec_free_context(AVCodecContext **pavctx)

libavcodec/mpegvideo_enc.c:1122:5: 
1120.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
1121.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1122.     const int scale = s->avctx->brd_scale;
          ^
1123.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1124.     int64_t best_rd  = INT64_MAX;

libavcodec/mpegvideo_enc.c:1124:5: 
1122.     const int scale = s->avctx->brd_scale;
1123.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1124.     int64_t best_rd  = INT64_MAX;
          ^
1125.     int best_b_count = -1;
1126. 

libavcodec/mpegvideo_enc.c:1125:5: 
1123.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1124.     int64_t best_rd  = INT64_MAX;
1125.     int best_b_count = -1;
          ^
1126. 
1127.     assert(scale >= 0 && scale <= 3);

libavcodec/mpegvideo_enc.c:1127:5: 
1125.     int best_b_count = -1;
1126. 
1127.     assert(scale >= 0 && scale <= 3);
          ^
1128. 
1129.     //emms_c();

libavcodec/mpegvideo_enc.c:1131:5: 
1129.     //emms_c();
1130.     //s->next_picture_ptr->quality;
1131.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
          ^
1132.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1133.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];

libavcodec/mpegvideo_enc.c:1133:5: 
1131.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
1132.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1133.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];
          ^
1134.     if (!b_lambda) // FIXME we should do this somewhere else
1135.         b_lambda = p_lambda;

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

libavcodec/mpegvideo_enc.c:1136:5: 
1134.     if (!b_lambda) // FIXME we should do this somewhere else
1135.         b_lambda = p_lambda;
1136.     lambda2  = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >>
          ^
1137.                FF_LAMBDA_SHIFT;
1138. 

libavcodec/mpegvideo_enc.c:1139:5: 
1137.                FF_LAMBDA_SHIFT;
1138. 
1139.     c->width        = s->width  >> scale;
          ^
1140.     c->height       = s->height >> scale;
1141.     c->flags        = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR;
