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

libavcodec/mpegvideo_enc.c:954:1: start of procedure estimate_best_b_count()
952. }
953. 
954. static int estimate_best_b_count(MpegEncContext *s){
     ^
955.     AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id);
956.     AVCodecContext *c= avcodec_alloc_context();

libavcodec/mpegvideo_enc.c:955:5: Skipping avcodec_find_encoder(): empty list of specs
953. 
954. static int estimate_best_b_count(MpegEncContext *s){
955.     AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id);
         ^
956.     AVCodecContext *c= avcodec_alloc_context();
957.     AVFrame input[FF_MAX_B_FRAMES+2];

libavcodec/mpegvideo_enc.c:956:5: 
954. static int estimate_best_b_count(MpegEncContext *s){
955.     AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id);
956.     AVCodecContext *c= avcodec_alloc_context();
         ^
957.     AVFrame input[FF_MAX_B_FRAMES+2];
958.     const int scale= s->avctx->brd_scale;

libavcodec/options.c:515:1: start of procedure avcodec_alloc_context()
  513. }
  514. 
  515. AVCodecContext *avcodec_alloc_context(void){
       ^
  516.     return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN);
  517. }

libavcodec/options.c:516:5: 
  514. 
  515. AVCodecContext *avcodec_alloc_context(void){
  516.     return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN);
           ^
  517. }
  518. 

libavcodec/options.c:501:1: start of procedure avcodec_alloc_context2()
    499. }
    500. 
    501. AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){
         ^
    502.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
    503. 

libavcodec/options.c:502:5: 
    500. 
    501. AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){
    502.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
             ^
    503. 
    504.     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(FF_INTERNAL_MEM_TYPE size)
          ^
      65. {
      66.     void *ptr = NULL;

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

libavutil/mem.c:72:8: Taking false branch
      70. 
      71.     /* let's disallow possible ambiguous cases */
      72.     if(size > (INT_MAX-16) )
                 ^
      73.         return NULL;
      74. 

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

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

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

libavcodec/options.c:504:8: Taking true branch
    502.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
    503. 
    504.     if(avctx==NULL) return NULL;
                ^
    505. 
    506.     avcodec_get_context_defaults2(avctx, codec_type);

libavcodec/options.c:504:21: 
    502.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
    503. 
    504.     if(avctx==NULL) return NULL;
                             ^
    505. 
    506.     avcodec_get_context_defaults2(avctx, codec_type);

libavcodec/options.c:509:1: return from a call to avcodec_alloc_context2
    507. 
    508.     return avctx;
    509. }
         ^
    510. 
    511. void avcodec_get_context_defaults(AVCodecContext *s){

libavcodec/options.c:517:1: return from a call to avcodec_alloc_context
  515. AVCodecContext *avcodec_alloc_context(void){
  516.     return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN);
  517. }
       ^
  518. 
  519. int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)

libavcodec/mpegvideo_enc.c:958:5: 
956.     AVCodecContext *c= avcodec_alloc_context();
957.     AVFrame input[FF_MAX_B_FRAMES+2];
958.     const int scale= s->avctx->brd_scale;
         ^
959.     int i, j, out_size, p_lambda, b_lambda, lambda2;
960.     int outbuf_size= s->width * s->height; //FIXME

libavcodec/mpegvideo_enc.c:960:5: 
958.     const int scale= s->avctx->brd_scale;
959.     int i, j, out_size, p_lambda, b_lambda, lambda2;
960.     int outbuf_size= s->width * s->height; //FIXME
         ^
961.     uint8_t *outbuf= av_malloc(outbuf_size);
962.     int64_t best_rd= INT64_MAX;

libavcodec/mpegvideo_enc.c:961:5: 
959.     int i, j, out_size, p_lambda, b_lambda, lambda2;
960.     int outbuf_size= s->width * s->height; //FIXME
961.     uint8_t *outbuf= av_malloc(outbuf_size);
         ^
962.     int64_t best_rd= INT64_MAX;
963.     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(FF_INTERNAL_MEM_TYPE size)
      ^
  65. {
  66.     void *ptr = NULL;

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

libavutil/mem.c:72:8: Taking false branch
  70. 
  71.     /* let's disallow possible ambiguous cases */
  72.     if(size > (INT_MAX-16) )
             ^
  73.         return NULL;
  74. 

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

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

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

libavcodec/mpegvideo_enc.c:962:5: 
960.     int outbuf_size= s->width * s->height; //FIXME
961.     uint8_t *outbuf= av_malloc(outbuf_size);
962.     int64_t best_rd= INT64_MAX;
         ^
963.     int best_b_count= -1;
964. 

libavcodec/mpegvideo_enc.c:963:5: 
961.     uint8_t *outbuf= av_malloc(outbuf_size);
962.     int64_t best_rd= INT64_MAX;
963.     int best_b_count= -1;
         ^
964. 
965.     assert(scale>=0 && scale <=3);

libavcodec/mpegvideo_enc.c:965:5: 
963.     int best_b_count= -1;
964. 
965.     assert(scale>=0 && scale <=3);
         ^
966. 
967. //    emms_c();

libavcodec/mpegvideo_enc.c:968:5: 
966. 
967. //    emms_c();
968.     p_lambda= s->last_lambda_for[FF_P_TYPE]; //s->next_picture_ptr->quality;
         ^
969.     b_lambda= s->last_lambda_for[FF_B_TYPE]; //p_lambda *FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
970.     if(!b_lambda) b_lambda= p_lambda; //FIXME we should do this somewhere else

libavcodec/mpegvideo_enc.c:969:5: 
967. //    emms_c();
968.     p_lambda= s->last_lambda_for[FF_P_TYPE]; //s->next_picture_ptr->quality;
969.     b_lambda= s->last_lambda_for[FF_B_TYPE]; //p_lambda *FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
         ^
970.     if(!b_lambda) b_lambda= p_lambda; //FIXME we should do this somewhere else
971.     lambda2= (b_lambda*b_lambda + (1<<FF_LAMBDA_SHIFT)/2 ) >> FF_LAMBDA_SHIFT;

libavcodec/mpegvideo_enc.c:970:9: Taking false branch
968.     p_lambda= s->last_lambda_for[FF_P_TYPE]; //s->next_picture_ptr->quality;
969.     b_lambda= s->last_lambda_for[FF_B_TYPE]; //p_lambda *FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
970.     if(!b_lambda) b_lambda= p_lambda; //FIXME we should do this somewhere else
             ^
971.     lambda2= (b_lambda*b_lambda + (1<<FF_LAMBDA_SHIFT)/2 ) >> FF_LAMBDA_SHIFT;
972. 

libavcodec/mpegvideo_enc.c:971:5: 
969.     b_lambda= s->last_lambda_for[FF_B_TYPE]; //p_lambda *FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
970.     if(!b_lambda) b_lambda= p_lambda; //FIXME we should do this somewhere else
971.     lambda2= (b_lambda*b_lambda + (1<<FF_LAMBDA_SHIFT)/2 ) >> FF_LAMBDA_SHIFT;
         ^
972. 
973.     c->width = s->width >> scale;

libavcodec/mpegvideo_enc.c:973:5: 
971.     lambda2= (b_lambda*b_lambda + (1<<FF_LAMBDA_SHIFT)/2 ) >> FF_LAMBDA_SHIFT;
972. 
973.     c->width = s->width >> scale;
         ^
974.     c->height= s->height>> scale;
975.     c->flags= CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR | CODEC_FLAG_INPUT_PRESERVED /*| CODEC_FLAG_EMU_EDGE*/;
