diff options
Diffstat (limited to 'src/libffmpeg/libavcodec/mpegvideo.c')
-rw-r--r-- | src/libffmpeg/libavcodec/mpegvideo.c | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/libffmpeg/libavcodec/mpegvideo.c b/src/libffmpeg/libavcodec/mpegvideo.c index a33485549..87c913efa 100644 --- a/src/libffmpeg/libavcodec/mpegvideo.c +++ b/src/libffmpeg/libavcodec/mpegvideo.c @@ -1103,7 +1103,7 @@ int MPV_encode_init(AVCodecContext *avctx) } if(s->avctx->scenechange_threshold < 1000000000 && (s->flags & CODEC_FLAG_CLOSED_GOP)){ - av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection arent supported yet\n"); + av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection arent supported yet, set threshold to 1000000000\n"); return -1; } @@ -1553,6 +1553,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) /* mark&release old frames */ if (s->pict_type != B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) { + if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){ avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr); /* release forgotten pictures */ @@ -1565,6 +1566,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) } } } + } } alloc: if(!s->encoding){ @@ -1602,7 +1604,6 @@ alloc: copy_picture(&s->current_picture, s->current_picture_ptr); - if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){ if (s->pict_type != B_TYPE) { s->last_picture_ptr= s->next_picture_ptr; if(!s->dropable) @@ -1617,7 +1618,7 @@ alloc: if(s->last_picture_ptr) copy_picture(&s->last_picture, s->last_picture_ptr); if(s->next_picture_ptr) copy_picture(&s->next_picture, s->next_picture_ptr); - if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL)){ + if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && !s->dropable){ av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n"); assert(s->pict_type != B_TYPE); //these should have been dropped if we don't have a reference goto alloc; @@ -1636,7 +1637,6 @@ alloc: s->next_picture.linesize[i] *=2; } } - } s->hurry_up= s->avctx->hurry_up; s->error_resilience= avctx->error_resilience; @@ -2275,15 +2275,6 @@ static int estimate_best_b_count(MpegEncContext *s){ int csize= (c->width/2)*(c->height/2); Picture pre_input, *pre_input_ptr= i ? s->input_picture[i-1] : s->next_picture_ptr; - if(pre_input_ptr) - pre_input= *pre_input_ptr; - - if(pre_input.type != FF_BUFFER_TYPE_SHARED && i){ - pre_input.data[0]+=INPLACE_OFFSET; - pre_input.data[1]+=INPLACE_OFFSET; - pre_input.data[2]+=INPLACE_OFFSET; - } - avcodec_get_frame_defaults(&input[i]); input[i].data[0]= av_malloc(ysize + 2*csize); input[i].data[1]= input[i].data[0] + ysize; @@ -2292,7 +2283,15 @@ static int estimate_best_b_count(MpegEncContext *s){ input[i].linesize[1]= input[i].linesize[2]= c->width/2; - if(!i || s->input_picture[i-1]){ + if(pre_input_ptr && (!i || s->input_picture[i-1])) { + pre_input= *pre_input_ptr; + + if(pre_input.type != FF_BUFFER_TYPE_SHARED && i) { + pre_input.data[0]+=INPLACE_OFFSET; + pre_input.data[1]+=INPLACE_OFFSET; + pre_input.data[2]+=INPLACE_OFFSET; + } + s->dsp.shrink[scale](input[i].data[0], input[i].linesize[0], pre_input.data[0], pre_input.linesize[0], c->width, c->height); s->dsp.shrink[scale](input[i].data[1], input[i].linesize[1], pre_input.data[1], pre_input.linesize[1], c->width>>1, c->height>>1); s->dsp.shrink[scale](input[i].data[2], input[i].linesize[2], pre_input.data[2], pre_input.linesize[2], c->width>>1, c->height>>1); @@ -4651,6 +4650,7 @@ void ff_mpeg_flush(AVCodecContext *avctx){ s->parse_context.index= 0; s->parse_context.last_index= 0; s->bitstream_buffer_size=0; + s->pp_time=0; } #ifdef CONFIG_ENCODERS @@ -5399,7 +5399,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ if(s->avctx->mb_decision == FF_MB_DECISION_BITS) MPV_decode_mb(s, s->block); } else { - int motion_x, motion_y; + int motion_x = 0, motion_y = 0; s->mv_type=MV_TYPE_16X16; // only one MB-Type possible @@ -5425,7 +5425,6 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0]; s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1]; } - motion_x = motion_y = 0; break; case CANDIDATE_MB_TYPE_INTER4V: s->mv_dir = MV_DIR_FORWARD; @@ -5435,7 +5434,6 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0]; s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1]; } - motion_x= motion_y= 0; break; case CANDIDATE_MB_TYPE_DIRECT: s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; @@ -5455,8 +5453,6 @@ static int encode_thread(AVCodecContext *c, void *arg){ case CANDIDATE_MB_TYPE_BIDIR: s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD; s->mb_intra= 0; - motion_x=0; - motion_y=0; s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0]; s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1]; s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0]; @@ -5484,7 +5480,6 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0]; s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1]; } - motion_x=motion_y=0; break; case CANDIDATE_MB_TYPE_BACKWARD_I: s->mv_dir = MV_DIR_BACKWARD; @@ -5495,7 +5490,6 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0]; s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1]; } - motion_x=motion_y=0; break; case CANDIDATE_MB_TYPE_BIDIR_I: s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD; @@ -5508,10 +5502,8 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1]; } } - motion_x=motion_y=0; break; default: - motion_x=motion_y=0; //gcc warning fix av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n"); } @@ -6236,7 +6228,7 @@ static int dct_quantize_refine(MpegEncContext *s, //FIXME breaks denoise? uint8_t * length; uint8_t * last_length; int lambda; - int rle_index, run, q, sum; + int rle_index, run, q = 1, sum; //q is only used when s->mb_intra is true #ifdef REFINE_STATS static int count=0; static int after_last=0; |