Re: [libav-devel] [PATCH 1/7] avcodec: Always fill the encoder target framerate

2018-02-21 Thread Luca Barbato

On 21/02/2018 22:20, Mark Thompson wrote:

Perhaps there should be a flag somewhere (AVCodecContext.flags2, I
guess) which would distinguish between the two cases?


I can add a flag for it indeed. Which encoders would be able to use it ?

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/7] avcodec: Always fill the encoder target framerate

2018-02-21 Thread Mark Thompson
On 16/02/18 17:02, Luca Barbato 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;
> +}
> +
>  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])
> 

How should an encoder detect that its input is actually variable framerate 
after this change and the following one?  Currently it can check for 
!(framerate.{num,den} > 0), but after this change it can't distinguish that 
from the given constrant framerate until it gets some frames (possibly 
arbitrarily many).

Perhaps there should be a flag somewhere (AVCodecContext.flags2, I guess) which 
would distinguish between the two cases?

- Mark
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/7] avcodec: Always fill the encoder target framerate

2018-02-17 Thread Luca Barbato

On 17/02/2018 04:52, Vittorio Giovara wrote:

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.


time_base is checked just above. Do you have a wording in mind for the 
comment?

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/7] avcodec: Always fill the encoder target framerate

2018-02-16 Thread Vittorio Giovara
On Fri, Feb 16, 2018 at 12:02 PM, Luca Barbato  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
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 1/7] avcodec: Always fill the encoder target framerate

2018-02-16 Thread Luca Barbato
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;
+}
+
 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])
-- 
2.12.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel