Re: [FFmpeg-devel] [PATCH v3 4/4] lavc/libxavs2: replace 'FrameRate' with 'fps'
At 2019-10-14 19:22:38, "Moritz Barsnick" wrote: >On Mon, Oct 14, 2019 at 14:52:44 +0800, hwr...@126.com wrote: >> From: hwren >> +float framerate; >[...] >> +if (avctx->framerate.den > 0 && avctx->framerate.num > 0) { >> +framerate = (float)avctx->framerate.num / >> (float)avctx->framerate.den; >> +} > >It should suffice to cast only .den. See av_q2d(). Actually, since it's >only used in _init() anyway, you could use av_q2d() at the cost of >double versus float. > Indeed, thanks for review. >BTW, what value does framerate have if this if-clause isn't met? >Zero-initialized, right? > Encoder will use its default frame rate value (25 for xavs2). Thanks, Huiwen Ren >Cheers, >Moritz >___ >ffmpeg-devel mailing list >ffmpeg-devel@ffmpeg.org >https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >To unsubscribe, visit link above, or email >ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 4/4] lavc/libxavs2: replace 'FrameRate' with 'fps'
On Mon, Oct 14, 2019 at 14:52:44 +0800, hwr...@126.com wrote: > From: hwren > +float framerate; [...] > +if (avctx->framerate.den > 0 && avctx->framerate.num > 0) { > +framerate = (float)avctx->framerate.num / > (float)avctx->framerate.den; > +} It should suffice to cast only .den. See av_q2d(). Actually, since it's only used in _init() anyway, you could use av_q2d() at the cost of double versus float. BTW, what value does framerate have if this if-clause isn't met? Zero-initialized, right? Cheers, Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 4/4] lavc/libxavs2: replace 'FrameRate' with 'fps'
From: hwren Remove deprecated parameter FrameRate (frame rate code) and use fps (frame rate) instead. Avoid encoder warnings. Signed-off-by: hwren --- libavcodec/libxavs2.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c index 8077607..382f745 100644 --- a/libavcodec/libxavs2.c +++ b/libavcodec/libxavs2.c @@ -61,7 +61,8 @@ typedef struct XAVS2EContext { static av_cold int xavs2_init(AVCodecContext *avctx) { XAVS2EContext *cae = avctx->priv_data; -int bit_depth, code; +int bit_depth; +float framerate; bit_depth = avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 8 : 10; @@ -78,6 +79,10 @@ static av_cold int xavs2_init(AVCodecContext *avctx) return AVERROR(ENOMEM); } +if (avctx->framerate.den > 0 && avctx->framerate.num > 0) { +framerate = (float)avctx->framerate.num / (float)avctx->framerate.den; +} + xavs2_opt_set2("Width", "%d", avctx->width); xavs2_opt_set2("Height","%d", avctx->height); xavs2_opt_set2("BFrames", "%d", avctx->max_b_frames); @@ -85,6 +90,7 @@ static av_cold int xavs2_init(AVCodecContext *avctx) xavs2_opt_set2("Log", "%d", cae->log_level); xavs2_opt_set2("Preset","%d", cae->preset_level); xavs2_opt_set2("OpenGOP", "%d", !(avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)); +xavs2_opt_set2("fps", "%.3f", framerate); xavs2_opt_set2("IntraPeriodMax","%d", avctx->gop_size); xavs2_opt_set2("IntraPeriodMin","%d", avctx->gop_size); @@ -114,10 +120,6 @@ static av_cold int xavs2_init(AVCodecContext *avctx) xavs2_opt_set2("InitialQP", "%d", cae->qp); } -ff_mpeg12_find_best_frame_rate(avctx->framerate, &code, NULL, NULL, 0); - -xavs2_opt_set2("FrameRate", "%d", code); - cae->encoder = cae->api->encoder_create(cae->param); if (!cae->encoder) { -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".