Re: [FFmpeg-devel] [PATCH 2/5] lavc/libopenh264enc: use framerate if available
On Wed, Aug 5, 2020 at 4:26 PM Martin Storsjö wrote: > > On Wed, 5 Aug 2020, myp...@gmail.com wrote: > > > On Sun, Jul 26, 2020 at 8:26 PM Jun Zhao wrote: > >> > >> From: Jun Zhao > >> > >> Respecting the framerate in the libopenh264enc codec context. > >> > >> Both the libx264 and libx264 encoders already contain similar logic > >> to first check the framerate before falling back to the timebase. > >> > >> Signed-off-by: Jun Zhao > >> --- > >> libavcodec/libopenh264enc.c | 11 ++- > >> 1 file changed, 10 insertions(+), 1 deletion(-) > >> > >> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c > >> index f63aa52..cf48566 100644 > >> --- a/libavcodec/libopenh264enc.c > >> +++ b/libavcodec/libopenh264enc.c > >> @@ -156,7 +156,16 @@ static av_cold int svc_encode_init(AVCodecContext > >> *avctx) > >> > >> (*s->encoder)->GetDefaultParams(s->encoder, ); > >> > >> -param.fMaxFrameRate = 1/av_q2d(avctx->time_base); > >> +if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { > >> +param.fMaxFrameRate = av_q2d(avctx->framerate); > >> +} else { > >> +if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) { > >> +av_log(avctx, AV_LOG_ERROR, > >> + "Could not set framerate for libopenh264enc: integer > >> overflow\n"); > >> +return AVERROR(EINVAL); > >> +} > >> +param.fMaxFrameRate = 1.0 / av_q2d(avctx->time_base) / > >> FFMAX(avctx->ticks_per_frame, 1); > >> +} > >> param.iPicWidth = avctx->width; > >> param.iPicHeight = avctx->height; > >> param.iTargetBitrate = avctx->bit_rate > 0 ? > >> avctx->bit_rate : TARGET_BITRATE_DEFAULT; > >> -- > >> 2.7.4 > > ping ? > > LGTM > > // Martin Applied and fixed typo in commit message (Both the libx264 and libx264 => Both the libx264 and libx265), thx ___ 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 2/5] lavc/libopenh264enc: use framerate if available
On Wed, 5 Aug 2020, myp...@gmail.com wrote: On Sun, Jul 26, 2020 at 8:26 PM Jun Zhao wrote: From: Jun Zhao Respecting the framerate in the libopenh264enc codec context. Both the libx264 and libx264 encoders already contain similar logic to first check the framerate before falling back to the timebase. Signed-off-by: Jun Zhao --- libavcodec/libopenh264enc.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index f63aa52..cf48566 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -156,7 +156,16 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) (*s->encoder)->GetDefaultParams(s->encoder, ); -param.fMaxFrameRate = 1/av_q2d(avctx->time_base); +if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { +param.fMaxFrameRate = av_q2d(avctx->framerate); +} else { +if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) { +av_log(avctx, AV_LOG_ERROR, + "Could not set framerate for libopenh264enc: integer overflow\n"); +return AVERROR(EINVAL); +} +param.fMaxFrameRate = 1.0 / av_q2d(avctx->time_base) / FFMAX(avctx->ticks_per_frame, 1); +} param.iPicWidth = avctx->width; param.iPicHeight = avctx->height; param.iTargetBitrate = avctx->bit_rate > 0 ? avctx->bit_rate : TARGET_BITRATE_DEFAULT; -- 2.7.4 ping ? LGTM // Martin ___ 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 2/5] lavc/libopenh264enc: use framerate if available
On Sun, Jul 26, 2020 at 8:26 PM Jun Zhao wrote: > > From: Jun Zhao > > Respecting the framerate in the libopenh264enc codec context. > > Both the libx264 and libx264 encoders already contain similar logic > to first check the framerate before falling back to the timebase. > > Signed-off-by: Jun Zhao > --- > libavcodec/libopenh264enc.c | 11 ++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c > index f63aa52..cf48566 100644 > --- a/libavcodec/libopenh264enc.c > +++ b/libavcodec/libopenh264enc.c > @@ -156,7 +156,16 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) > > (*s->encoder)->GetDefaultParams(s->encoder, ); > > -param.fMaxFrameRate = 1/av_q2d(avctx->time_base); > +if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { > +param.fMaxFrameRate = av_q2d(avctx->framerate); > +} else { > +if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) { > +av_log(avctx, AV_LOG_ERROR, > + "Could not set framerate for libopenh264enc: integer > overflow\n"); > +return AVERROR(EINVAL); > +} > +param.fMaxFrameRate = 1.0 / av_q2d(avctx->time_base) / > FFMAX(avctx->ticks_per_frame, 1); > +} > param.iPicWidth = avctx->width; > param.iPicHeight = avctx->height; > param.iTargetBitrate = avctx->bit_rate > 0 ? avctx->bit_rate > : TARGET_BITRATE_DEFAULT; > -- > 2.7.4 ping ? ___ 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 2/5] lavc/libopenh264enc: use framerate if available
From: Jun Zhao Respecting the framerate in the libopenh264enc codec context. Both the libx264 and libx264 encoders already contain similar logic to first check the framerate before falling back to the timebase. Signed-off-by: Jun Zhao --- libavcodec/libopenh264enc.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index f63aa52..cf48566 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -156,7 +156,16 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) (*s->encoder)->GetDefaultParams(s->encoder, ); -param.fMaxFrameRate = 1/av_q2d(avctx->time_base); +if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { +param.fMaxFrameRate = av_q2d(avctx->framerate); +} else { +if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) { +av_log(avctx, AV_LOG_ERROR, + "Could not set framerate for libopenh264enc: integer overflow\n"); +return AVERROR(EINVAL); +} +param.fMaxFrameRate = 1.0 / av_q2d(avctx->time_base) / FFMAX(avctx->ticks_per_frame, 1); +} param.iPicWidth = avctx->width; param.iPicHeight = avctx->height; param.iTargetBitrate = avctx->bit_rate > 0 ? avctx->bit_rate : TARGET_BITRATE_DEFAULT; -- 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".
[FFmpeg-devel] [PATCH 2/5] lavc/libopenh264enc: use framerate if available
From: Jun Zhao Respecting the framerate in the libopenh264enc codec context. Both the libx264 and libx264 encoders already contain similar logic to first check the framerate before falling back to the timebase. Signed-off-by: Jun Zhao --- libavcodec/libopenh264enc.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index f63aa52..cf48566 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -156,7 +156,16 @@ static av_cold int svc_encode_init(AVCodecContext *avctx) (*s->encoder)->GetDefaultParams(s->encoder, ); -param.fMaxFrameRate = 1/av_q2d(avctx->time_base); +if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { +param.fMaxFrameRate = av_q2d(avctx->framerate); +} else { +if (avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) { +av_log(avctx, AV_LOG_ERROR, + "Could not set framerate for libopenh264enc: integer overflow\n"); +return AVERROR(EINVAL); +} +param.fMaxFrameRate = 1.0 / av_q2d(avctx->time_base) / FFMAX(avctx->ticks_per_frame, 1); +} param.iPicWidth = avctx->width; param.iPicHeight = avctx->height; param.iTargetBitrate = avctx->bit_rate > 0 ? avctx->bit_rate : TARGET_BITRATE_DEFAULT; -- 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".