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

libavcodec/mpegvideo_enc.c:1072:1: start of procedure estimate_best_b_count()
1070. }
1071. 
1072. static int estimate_best_b_count(MpegEncContext *s)
      ^
1073. {
1074.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);

libavcodec/mpegvideo_enc.c:1074:5: Skipping avcodec_find_encoder(): empty list of specs
1072. static int estimate_best_b_count(MpegEncContext *s)
1073. {
1074.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
          ^
1075.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1076.     AVFrame input[FF_MAX_B_FRAMES + 2];

libavcodec/mpegvideo_enc.c:1075:5: 
1073. {
1074.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
1075.     AVCodecContext *c = avcodec_alloc_context3(NULL);
          ^
1076.     AVFrame input[FF_MAX_B_FRAMES + 2];
1077.     const int scale = s->avctx->brd_scale;

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

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

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

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

libavutil/mem.c:71:5: 
    69. #endif
    70. 
    71.     assert(size);
            ^
    72. 
    73.     /* let's disallow possible ambiguous cases */

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

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

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

libavcodec/mpegvideo_enc.c:1077:5: 
1075.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1076.     AVFrame input[FF_MAX_B_FRAMES + 2];
1077.     const int scale = s->avctx->brd_scale;
          ^
1078.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1079.     int outbuf_size  = s->width * s->height; // FIXME

libavcodec/mpegvideo_enc.c:1079:5: 
1077.     const int scale = s->avctx->brd_scale;
1078.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1079.     int outbuf_size  = s->width * s->height; // FIXME
          ^
1080.     uint8_t *outbuf  = av_malloc(outbuf_size);
1081.     int64_t best_rd  = INT64_MAX;

libavcodec/mpegvideo_enc.c:1080:5: 
1078.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1079.     int outbuf_size  = s->width * s->height; // FIXME
1080.     uint8_t *outbuf  = av_malloc(outbuf_size);
          ^
1081.     int64_t best_rd  = INT64_MAX;
1082.     int best_b_count = -1;

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

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

libavutil/mem.c:71:5: 
  69. #endif
  70. 
  71.     assert(size);
          ^
  72. 
  73.     /* let's disallow possible ambiguous cases */

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:33: 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/mpegvideo_enc.c:1081:5: 
1079.     int outbuf_size  = s->width * s->height; // FIXME
1080.     uint8_t *outbuf  = av_malloc(outbuf_size);
1081.     int64_t best_rd  = INT64_MAX;
          ^
1082.     int best_b_count = -1;
1083. 

libavcodec/mpegvideo_enc.c:1082:5: 
1080.     uint8_t *outbuf  = av_malloc(outbuf_size);
1081.     int64_t best_rd  = INT64_MAX;
1082.     int best_b_count = -1;
          ^
1083. 
1084.     assert(scale >= 0 && scale <= 3);

libavcodec/mpegvideo_enc.c:1084:5: 
1082.     int best_b_count = -1;
1083. 
1084.     assert(scale >= 0 && scale <= 3);
          ^
1085. 
1086.     //emms_c();

libavcodec/mpegvideo_enc.c:1088:5: 
1086.     //emms_c();
1087.     //s->next_picture_ptr->quality;
1088.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
          ^
1089.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1090.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];

libavcodec/mpegvideo_enc.c:1090:5: 
1088.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
1089.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1090.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];
          ^
1091.     if (!b_lambda) // FIXME we should do this somewhere else
1092.         b_lambda = p_lambda;

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

libavcodec/mpegvideo_enc.c:1093:5: 
1091.     if (!b_lambda) // FIXME we should do this somewhere else
1092.         b_lambda = p_lambda;
1093.     lambda2  = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >>
          ^
1094.                FF_LAMBDA_SHIFT;
1095. 

libavcodec/mpegvideo_enc.c:1096:5: 
1094.                FF_LAMBDA_SHIFT;
1095. 
1096.     c->width        = s->width  >> scale;
          ^
1097.     c->height       = s->height >> scale;
1098.     c->flags        = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR |
