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

libavcodec/mpegvideo_enc.c:1060:1: start of procedure estimate_best_b_count()
1058. }
1059. 
1060. static int estimate_best_b_count(MpegEncContext *s)
      ^
1061. {
1062.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);

libavcodec/mpegvideo_enc.c:1062:5: 
1060. static int estimate_best_b_count(MpegEncContext *s)
1061. {
1062.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
          ^
1063.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1064.     const int scale = s->avctx->brd_scale;

libavcodec/utils.c:1649:1: start of procedure avcodec_find_encoder()
  1647. }
  1648. 
  1649. AVCodec *avcodec_find_encoder(enum AVCodecID id)
        ^
  1650. {
  1651.     return find_encdec(id, 1);

libavcodec/utils.c:1651:5: Skipping find_encdec(): empty list of specs
  1649. AVCodec *avcodec_find_encoder(enum AVCodecID id)
  1650. {
  1651.     return find_encdec(id, 1);
            ^
  1652. }
  1653. 

libavcodec/utils.c:1652:1: return from a call to avcodec_find_encoder
  1650. {
  1651.     return find_encdec(id, 1);
  1652. }
        ^
  1653. 
  1654. AVCodec *avcodec_find_encoder_by_name(const char *name)

libavcodec/mpegvideo_enc.c:1063:5: 
1061. {
1062.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
1063.     AVCodecContext *c = avcodec_alloc_context3(NULL);
          ^
1064.     const int scale = s->avctx->brd_scale;
1065.     int i, j, out_size, p_lambda, b_lambda, lambda2;

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

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

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:128:8: Taking true branch
  126.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
  127. 
  128.     if(avctx==NULL) return NULL;
              ^
  129. 
  130.     if(avcodec_get_context_defaults3(avctx, codec) < 0){

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

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

libavcodec/mpegvideo_enc.c:1064:5: 
1062.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
1063.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1064.     const int scale = s->avctx->brd_scale;
          ^
1065.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1066.     int64_t best_rd  = INT64_MAX;

libavcodec/mpegvideo_enc.c:1066:5: 
1064.     const int scale = s->avctx->brd_scale;
1065.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1066.     int64_t best_rd  = INT64_MAX;
          ^
1067.     int best_b_count = -1;
1068. 

libavcodec/mpegvideo_enc.c:1067:5: 
1065.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1066.     int64_t best_rd  = INT64_MAX;
1067.     int best_b_count = -1;
          ^
1068. 
1069.     assert(scale >= 0 && scale <= 3);

libavcodec/mpegvideo_enc.c:1069:5: 
1067.     int best_b_count = -1;
1068. 
1069.     assert(scale >= 0 && scale <= 3);
          ^
1070. 
1071.     //emms_c();

libavcodec/mpegvideo_enc.c:1073:5: 
1071.     //emms_c();
1072.     //s->next_picture_ptr->quality;
1073.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
          ^
1074.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1075.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];

libavcodec/mpegvideo_enc.c:1075:5: 
1073.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
1074.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1075.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];
          ^
1076.     if (!b_lambda) // FIXME we should do this somewhere else
1077.         b_lambda = p_lambda;

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

libavcodec/mpegvideo_enc.c:1078:5: 
1076.     if (!b_lambda) // FIXME we should do this somewhere else
1077.         b_lambda = p_lambda;
1078.     lambda2  = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >>
          ^
1079.                FF_LAMBDA_SHIFT;
1080. 

libavcodec/mpegvideo_enc.c:1081:5: 
1079.                FF_LAMBDA_SHIFT;
1080. 
1081.     c->width        = s->width  >> scale;
          ^
1082.     c->height       = s->height >> scale;
1083.     c->flags        = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR |
