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

libavcodec/mpegvideo_enc.c:906:1: start of procedure estimate_best_b_count()
904. }
905. 
906. static int estimate_best_b_count(MpegEncContext *s){
     ^
907.     AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id);
908.     AVCodecContext *c= avcodec_alloc_context();

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

libavcodec/mpegvideo_enc.c:908:5: 
906. static int estimate_best_b_count(MpegEncContext *s){
907.     AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id);
908.     AVCodecContext *c= avcodec_alloc_context();
         ^
909.     AVFrame input[FF_MAX_B_FRAMES+2];
910.     const int scale= s->avctx->brd_scale;

libavcodec/utils.c:800:1: start of procedure avcodec_alloc_context()
  798. }
  799. 
  800. AVCodecContext *avcodec_alloc_context(void){
       ^
  801.     return avcodec_alloc_context2(CODEC_TYPE_UNKNOWN);
  802. }

libavcodec/utils.c:801:5: 
  799. 
  800. AVCodecContext *avcodec_alloc_context(void){
  801.     return avcodec_alloc_context2(CODEC_TYPE_UNKNOWN);
           ^
  802. }
  803. 

libavcodec/utils.c:786:1: start of procedure avcodec_alloc_context2()
    784. }
    785. 
    786. AVCodecContext *avcodec_alloc_context2(enum CodecType codec_type){
         ^
    787.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
    788. 

libavcodec/utils.c:787:5: 
    785. 
    786. AVCodecContext *avcodec_alloc_context2(enum CodecType codec_type){
    787.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
             ^
    788. 
    789.     if(avctx==NULL) return NULL;

libavutil/mem.c:42:1: start of procedure av_malloc()
      40.    linker will do it automatically */
      41. 
      42. void *av_malloc(unsigned int size)
          ^
      43. {
      44.     void *ptr;

libavutil/mem.c:50:8: Taking false branch
      48. 
      49.     /* let's disallow possible ambiguous cases */
      50.     if(size > (INT_MAX-16) )
                 ^
      51.         return NULL;
      52. 

libavutil/mem.c:61:5: Skipping memalign(): method has no implementation
      59.     ((char*)ptr)[-1]= diff;
      60. #elif defined (HAVE_MEMALIGN)
      61.     ptr = memalign(16,size);
              ^
      62.     /* Why 64?
      63.        Indeed, we should align it:

libavutil/mem.c:91:5: 
      89.     ptr = malloc(size);
      90. #endif
      91.     return ptr;
              ^
      92. }
      93. 

libavutil/mem.c:92:1: return from a call to av_malloc
      90. #endif
      91.     return ptr;
      92. }
          ^
      93. 
      94. void *av_realloc(void *ptr, unsigned int size)

libavcodec/utils.c:789:8: Taking true branch
    787.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
    788. 
    789.     if(avctx==NULL) return NULL;
                ^
    790. 
    791.     avcodec_get_context_defaults2(avctx, codec_type);

libavcodec/utils.c:789:21: 
    787.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
    788. 
    789.     if(avctx==NULL) return NULL;
                             ^
    790. 
    791.     avcodec_get_context_defaults2(avctx, codec_type);

libavcodec/utils.c:794:1: return from a call to avcodec_alloc_context2
    792. 
    793.     return avctx;
    794. }
         ^
    795. 
    796. void avcodec_get_context_defaults(AVCodecContext *s){

libavcodec/utils.c:802:1: return from a call to avcodec_alloc_context
  800. AVCodecContext *avcodec_alloc_context(void){
  801.     return avcodec_alloc_context2(CODEC_TYPE_UNKNOWN);
  802. }
       ^
  803. 
  804. void avcodec_get_frame_defaults(AVFrame *pic){

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

libavcodec/mpegvideo_enc.c:912:5: 
910.     const int scale= s->avctx->brd_scale;
911.     int i, j, out_size, p_lambda, b_lambda, lambda2;
912.     int outbuf_size= s->width * s->height; //FIXME
         ^
913.     uint8_t *outbuf= av_malloc(outbuf_size);
914.     int64_t best_rd= INT64_MAX;

libavcodec/mpegvideo_enc.c:913:5: 
911.     int i, j, out_size, p_lambda, b_lambda, lambda2;
912.     int outbuf_size= s->width * s->height; //FIXME
913.     uint8_t *outbuf= av_malloc(outbuf_size);
         ^
914.     int64_t best_rd= INT64_MAX;
915.     int best_b_count= -1;

libavutil/mem.c:42:1: start of procedure av_malloc()
  40.    linker will do it automatically */
  41. 
  42. void *av_malloc(unsigned int size)
      ^
  43. {
  44.     void *ptr;

libavutil/mem.c:50:8: Taking false branch
  48. 
  49.     /* let's disallow possible ambiguous cases */
  50.     if(size > (INT_MAX-16) )
             ^
  51.         return NULL;
  52. 

libavutil/mem.c:61:5: Skipping memalign(): method has no implementation
  59.     ((char*)ptr)[-1]= diff;
  60. #elif defined (HAVE_MEMALIGN)
  61.     ptr = memalign(16,size);
          ^
  62.     /* Why 64?
  63.        Indeed, we should align it:

libavutil/mem.c:91:5: 
  89.     ptr = malloc(size);
  90. #endif
  91.     return ptr;
          ^
  92. }
  93. 

libavutil/mem.c:92:1: return from a call to av_malloc
  90. #endif
  91.     return ptr;
  92. }
      ^
  93. 
  94. void *av_realloc(void *ptr, unsigned int size)

libavcodec/mpegvideo_enc.c:914:5: 
912.     int outbuf_size= s->width * s->height; //FIXME
913.     uint8_t *outbuf= av_malloc(outbuf_size);
914.     int64_t best_rd= INT64_MAX;
         ^
915.     int best_b_count= -1;
916. 

libavcodec/mpegvideo_enc.c:915:5: 
913.     uint8_t *outbuf= av_malloc(outbuf_size);
914.     int64_t best_rd= INT64_MAX;
915.     int best_b_count= -1;
         ^
916. 
917.     assert(scale>=0 && scale <=3);

libavcodec/mpegvideo_enc.c:917:5: 
915.     int best_b_count= -1;
916. 
917.     assert(scale>=0 && scale <=3);
         ^
918. 
919. //    emms_c();

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

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

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

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

libavcodec/mpegvideo_enc.c:925:5: 
923.     lambda2= (b_lambda*b_lambda + (1<<FF_LAMBDA_SHIFT)/2 ) >> FF_LAMBDA_SHIFT;
924. 
925.     c->width = s->width >> scale;
         ^
926.     c->height= s->height>> scale;
927.     c->flags= CODEC_FLAG_QSCALE | CODEC_FLAG_PSNR | CODEC_FLAG_INPUT_PRESERVED /*| CODEC_FLAG_EMU_EDGE*/;
