X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Favcodec%2Fencoder.c;h=94e098bb10391a6b76b0bb6735798a5db2a3c840;hb=f14f66e9882633ac5fb675766d42eeaf208cd51b;hp=c1b3e802b7b498bd2cb62caa3065461598a1d1f1;hpb=015b33bc369f7cf89df349e81790ddf655427316;p=vlc diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c index c1b3e802b7..94e098bb10 100644 --- a/modules/codec/avcodec/encoder.c +++ b/modules/codec/avcodec/encoder.c @@ -500,7 +500,8 @@ int OpenEncoder( vlc_object_t *p_this ) if ( p_sys->i_qmin > 0 && p_sys->i_qmin == p_sys->i_qmax ) p_context->flags |= CODEC_FLAG_QSCALE; /* These codecs cause libavcodec to exit if thread_count is > 1. - See libavcodec/mpegvideo_enc.c:MPV_encode_init + See libavcodec/mpegvideo_enc.c:MPV_encode_init and + libavcodec/svq3.c , WMV2 calls MPV_encode_init also. */ if ( i_codec_id == CODEC_ID_FLV1 || i_codec_id == CODEC_ID_H261 || @@ -512,6 +513,7 @@ int OpenEncoder( vlc_object_t *p_this ) i_codec_id == CODEC_ID_MSMPEG4V2 || i_codec_id == CODEC_ID_MSMPEG4V3 || i_codec_id == CODEC_ID_WMV1 || + i_codec_id == CODEC_ID_WMV2 || i_codec_id == CODEC_ID_RV10 || i_codec_id == CODEC_ID_RV20 || i_codec_id == CODEC_ID_SVQ3 ) @@ -593,6 +595,56 @@ int OpenEncoder( vlc_object_t *p_this ) /* Misc parameters */ p_context->bit_rate = p_enc->fmt_out.i_bitrate; +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 52, 69, 2 ) + /* Set reasonable defaults to VP8, based on + libvpx-720p preset from libvpx ffmpeg-patch */ + if( i_codec_id == CODEC_ID_VP8 ) + { + /* Lets give bitrate tolerance */ + p_context->bit_rate_tolerance = __MAX(2 * p_enc->fmt_out.i_bitrate, p_sys->i_vtolerance ); + /* default to 120 frames between keyframe */ + if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "keyint" ) ) + p_context->gop_size = 120; + /* Don't set rc-values atm, they were from time before + libvpx was officially in ffmpeg */ + //p_context->rc_max_rate = 24 * 1000 * 1000; //24M + //p_context->rc_min_rate = 40 * 1000; // 40k + /* seems that ffmpeg presets have 720p as divider for buffers */ + if( p_enc->fmt_out.video.i_height >= 720 ) + { + /* Check that we don't overrun users qmin/qmax values */ + if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmin" ) ) + { + p_context->mb_qmin = p_context->qmin = 10; + p_context->mb_lmin = p_context->lmin = 10 * FF_QP2LAMBDA; + } + + if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmax" ) ) + { + p_context->mb_qmax = p_context->qmax = 42; + p_context->mb_lmax = p_context->lmax = 42 * FF_QP2LAMBDA; + } + + } else { + if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmin" ) ) + { + p_context->mb_qmin = p_context->qmin = 1; + p_context->mb_lmin = p_context->lmin = FF_QP2LAMBDA; + } + } + + +#if 0 /* enable when/if vp8 encoder is accepted in libavcodec */ + p_context->lag = 16; + p_context->level = 216; + p_context->profile = 0; + p_context->rc_buffer_aggressivity = 0.95; + p_context->token_partitions = 4; + p_context->mb_static_threshold = 0; +#endif + } +#endif + if( i_codec_id == CODEC_ID_RAWVIDEO ) { /* XXX: hack: Force same codec (will be handled by transcode) */ @@ -870,7 +922,9 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) if( !p_sys->p_context->max_b_frames || !p_sys->p_context->delay ) { /* No delay -> output pts == input pts */ - p_block->i_pts = p_block->i_dts = p_pict->date; + if( p_pict ) + p_block->i_dts = p_pict->date; + p_block->i_pts = p_block->i_dts; } else if( p_sys->p_context->coded_frame->pts != (int64_t)AV_NOPTS_VALUE && p_sys->p_context->coded_frame->pts != 0 &&