On Fri, Feb 16, 2018 at 12:02 PM, Luca Barbato <[email protected]> wrote:
> In preparation of using it in the encoders.
> ---
> libavcodec/avcodec.h | 3 ++-
> libavcodec/utils.c | 5 +++++
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 7eaa0c9277..f86ae0b8d6 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2638,7 +2638,8 @@ typedef struct AVCodecContext {
> * bitstream, the decoder may export it here. { 0, 1} when
> * unknown.
> * - encoding: May be used to signal the framerate of CFR content to
> an
> - * encoder.
> + * encoder or the target average framerate for
> rate-control
> + * tuning.
> */
> AVRational framerate;
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index ba3457664a..887c5618e2 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -539,6 +539,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
> goto free_and_end;
> }
>
> + if (avctx->framerate.num <= 0) {
> + avctx->framerate.num = avctx->time_base.den;
> + avctx->framerate.den = avctx->time_base.num;
> + }
>
Would be nice to have a comment that this is a fallback for when framerate
is not set.
Probably it would make sense to check for time_base.num too, in order to
avoid 0 as denominator.
+
> if (avctx->codec->sample_fmts) {
> for (i = 0; avctx->codec->sample_fmts[i] !=
> AV_SAMPLE_FMT_NONE; i++) {
> if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
> --
>
--
Vittorio
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel