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

libavcodec/mpegvideo_enc.c:1101:1: start of procedure estimate_best_b_count()
1099. }
1100. 
1101. static int estimate_best_b_count(MpegEncContext *s)
      ^
1102. {
1103.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);

libavcodec/mpegvideo_enc.c:1103:5: 
1101. static int estimate_best_b_count(MpegEncContext *s)
1102. {
1103.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
          ^
1104.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1105.     const int scale = s->avctx->brd_scale;

libavcodec/utils.c:1752:1: start of procedure avcodec_find_encoder()
  1750. }
  1751. 
  1752. AVCodec *avcodec_find_encoder(enum AVCodecID id)
        ^
  1753. {
  1754.     return find_encdec(id, 1);

libavcodec/utils.c:1754:5: Skipping find_encdec(): empty list of specs
  1752. AVCodec *avcodec_find_encoder(enum AVCodecID id)
  1753. {
  1754.     return find_encdec(id, 1);
            ^
  1755. }
  1756. 

libavcodec/utils.c:1755:1: return from a call to avcodec_find_encoder
  1753. {
  1754.     return find_encdec(id, 1);
  1755. }
        ^
  1756. 
  1757. AVCodec *avcodec_find_encoder_by_name(const char *name)

libavcodec/mpegvideo_enc.c:1104:5: 
1102. {
1103.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
1104.     AVCodecContext *c = avcodec_alloc_context3(NULL);
          ^
1105.     const int scale = s->avctx->brd_scale;
1106.     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)

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:10: Taking true branch
  126.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
  127. 
  128.     if (!avctx)
                ^
  129.         return NULL;
  130. 

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

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

libavcodec/mpegvideo_enc.c:1105:5: 
1103.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
1104.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1105.     const int scale = s->avctx->brd_scale;
          ^
1106.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1107.     int64_t best_rd  = INT64_MAX;

libavcodec/mpegvideo_enc.c:1107:5: 
1105.     const int scale = s->avctx->brd_scale;
1106.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1107.     int64_t best_rd  = INT64_MAX;
          ^
1108.     int best_b_count = -1;
1109. 

libavcodec/mpegvideo_enc.c:1108:5: 
1106.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1107.     int64_t best_rd  = INT64_MAX;
1108.     int best_b_count = -1;
          ^
1109. 
1110.     assert(scale >= 0 && scale <= 3);

libavcodec/mpegvideo_enc.c:1110:5: 
1108.     int best_b_count = -1;
1109. 
1110.     assert(scale >= 0 && scale <= 3);
          ^
1111. 
1112.     //emms_c();

libavcodec/mpegvideo_enc.c:1114:5: 
1112.     //emms_c();
1113.     //s->next_picture_ptr->quality;
1114.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
          ^
1115.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1116.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];

libavcodec/mpegvideo_enc.c:1116:5: 
1114.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
1115.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1116.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];
          ^
1117.     if (!b_lambda) // FIXME we should do this somewhere else
1118.         b_lambda = p_lambda;

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

libavcodec/mpegvideo_enc.c:1119:5: 
1117.     if (!b_lambda) // FIXME we should do this somewhere else
1118.         b_lambda = p_lambda;
1119.     lambda2  = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >>
          ^
1120.                FF_LAMBDA_SHIFT;
1121. 

libavcodec/mpegvideo_enc.c:1122:5: 
1120.                FF_LAMBDA_SHIFT;
1121. 
1122.     c->width        = s->width  >> scale;
          ^
1123.     c->height       = s->height >> scale;
1124.     c->flags        = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR;
