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

libavcodec/mpegvideo_enc.c:1028:1: start of procedure estimate_best_b_count()
1026. }
1027. 
1028. static int estimate_best_b_count(MpegEncContext *s)
      ^
1029. {
1030.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);

libavcodec/mpegvideo_enc.c:1030:5: 
1028. static int estimate_best_b_count(MpegEncContext *s)
1029. {
1030.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
          ^
1031.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1032.     AVFrame input[FF_MAX_B_FRAMES + 2];

libavcodec/utils.c:1561:1: start of procedure avcodec_find_encoder()
  1559. }
  1560. 
  1561. AVCodec *avcodec_find_encoder(enum AVCodecID id)
        ^
  1562. {
  1563.     return find_encdec(id, 1);

libavcodec/utils.c:1563:5: Skipping find_encdec(): empty list of specs
  1561. AVCodec *avcodec_find_encoder(enum AVCodecID id)
  1562. {
  1563.     return find_encdec(id, 1);
            ^
  1564. }
  1565. 

libavcodec/utils.c:1564:1: return from a call to avcodec_find_encoder
  1562. {
  1563.     return find_encdec(id, 1);
  1564. }
        ^
  1565. 
  1566. AVCodec *avcodec_find_encoder_by_name(const char *name)

libavcodec/mpegvideo_enc.c:1031:5: 
1029. {
1030.     AVCodec *codec    = avcodec_find_encoder(s->avctx->codec_id);
1031.     AVCodecContext *c = avcodec_alloc_context3(NULL);
          ^
1032.     AVFrame input[FF_MAX_B_FRAMES + 2];
1033.     const int scale = s->avctx->brd_scale;

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:61:1: start of procedure av_malloc()
    59.  * linker will do it automatically. */
    60. 
    61. void *av_malloc(size_t size)
        ^
    62. {
    63.     void *ptr = NULL;

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

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

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

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

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

libavutil/mem.c:114:1: return from a call to av_malloc
    112. #endif
    113.     return ptr;
    114. }
         ^
    115. 
    116. 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:1033:5: 
1031.     AVCodecContext *c = avcodec_alloc_context3(NULL);
1032.     AVFrame input[FF_MAX_B_FRAMES + 2];
1033.     const int scale = s->avctx->brd_scale;
          ^
1034.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1035.     int64_t best_rd  = INT64_MAX;

libavcodec/mpegvideo_enc.c:1035:5: 
1033.     const int scale = s->avctx->brd_scale;
1034.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1035.     int64_t best_rd  = INT64_MAX;
          ^
1036.     int best_b_count = -1;
1037. 

libavcodec/mpegvideo_enc.c:1036:5: 
1034.     int i, j, out_size, p_lambda, b_lambda, lambda2;
1035.     int64_t best_rd  = INT64_MAX;
1036.     int best_b_count = -1;
          ^
1037. 
1038.     assert(scale >= 0 && scale <= 3);

libavcodec/mpegvideo_enc.c:1038:5: 
1036.     int best_b_count = -1;
1037. 
1038.     assert(scale >= 0 && scale <= 3);
          ^
1039. 
1040.     //emms_c();

libavcodec/mpegvideo_enc.c:1042:5: 
1040.     //emms_c();
1041.     //s->next_picture_ptr->quality;
1042.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
          ^
1043.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1044.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];

libavcodec/mpegvideo_enc.c:1044:5: 
1042.     p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P];
1043.     //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
1044.     b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B];
          ^
1045.     if (!b_lambda) // FIXME we should do this somewhere else
1046.         b_lambda = p_lambda;

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

libavcodec/mpegvideo_enc.c:1047:5: 
1045.     if (!b_lambda) // FIXME we should do this somewhere else
1046.         b_lambda = p_lambda;
1047.     lambda2  = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >>
          ^
1048.                FF_LAMBDA_SHIFT;
1049. 

libavcodec/mpegvideo_enc.c:1050:5: 
1048.                FF_LAMBDA_SHIFT;
1049. 
1050.     c->width        = s->width  >> scale;
          ^
1051.     c->height       = s->height >> scale;
1052.     c->flags        = CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR |
