diff mbox series

[FFmpeg-devel] ac3enc: drop a global variable

Message ID 20200129153448.22207-1-anton@khirnov.net
State Accepted
Headers show
Series [FFmpeg-devel] ac3enc: drop a global variable
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Anton Khirnov Jan. 29, 2020, 3:34 p.m. UTC
Log the warning message once per encoder instance instead.
---
 libavcodec/ac3enc.c | 5 ++---
 libavcodec/ac3enc.h | 2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)

Comments

Kieran Kunhya Jan. 30, 2020, 2:37 a.m. UTC | #1
Sent from my mobile device

On Wed, 29 Jan 2020, 15:35 Anton Khirnov, <anton@khirnov.net> wrote:

> Log the warning message once per encoder instance instead.
> ---
>  libavcodec/ac3enc.c | 5 ++---
>  libavcodec/ac3enc.h | 2 ++
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
> index 25318f8631..7ce17db067 100644
> --- a/libavcodec/ac3enc.c
> +++ b/libavcodec/ac3enc.c
> @@ -1993,12 +1993,11 @@ int ff_ac3_validate_metadata(AC3EncodeContext *s)
>      /* set bitstream id for alternate bitstream syntax */
>      if (!s->eac3 && (opt->extended_bsi_1 || opt->extended_bsi_2)) {
>          if (s->bitstream_id > 8 && s->bitstream_id < 11) {
> -            static int warn_once = 1;
> -            if (warn_once) {
> +            if (!s->warned_alternate_bitstream) {
>                  av_log(avctx, AV_LOG_WARNING, "alternate bitstream syntax
> is "
>                         "not compatible with reduced samplerates. writing
> of "
>                         "extended bitstream information will be
> disabled.\n");
> -                warn_once = 0;
> +                s->warned_alternate_bitstream = 1;
>              }
>          } else {
>              s->bitstream_id = 6;
> diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
> index a2442d0e55..1e4a7405bf 100644
> --- a/libavcodec/ac3enc.h
> +++ b/libavcodec/ac3enc.h
> @@ -255,6 +255,8 @@ typedef struct AC3EncodeContext {
>      uint8_t *ref_bap     [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit
> allocation pointers (bap)
>      int ref_bap_set;                                         ///<
> indicates if ref_bap pointers have been set
>
> +    int warned_alternate_bitstream;
> +
>      /* fixed vs. float function pointers */
>      void (*mdct_end)(struct AC3EncodeContext *s);
>      int  (*mdct_init)(struct AC3EncodeContext *s);
> --
> 2.24.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".


Yes ofc
Michael Niedermayer Jan. 30, 2020, 5:43 p.m. UTC | #2
On Wed, Jan 29, 2020 at 04:34:48PM +0100, Anton Khirnov wrote:
> Log the warning message once per encoder instance instead.
> ---
>  libavcodec/ac3enc.c | 5 ++---
>  libavcodec/ac3enc.h | 2 ++
>  2 files changed, 4 insertions(+), 3 deletions(-)

LGTM

thx

[...]
Paul B Mahol Feb. 7, 2020, 4:31 p.m. UTC | #3
On 1/30/20, Michael Niedermayer <michael@niedermayer.cc> wrote:
> On Wed, Jan 29, 2020 at 04:34:48PM +0100, Anton Khirnov wrote:
>> Log the warning message once per encoder instance instead.
>> ---
>>  libavcodec/ac3enc.c | 5 ++---
>>  libavcodec/ac3enc.h | 2 ++
>>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> LGTM

Gonna apply?

>
> thx
>
> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The bravest are surely those who have the clearest vision
> of what is before them, glory and danger alike, and yet
> notwithstanding go out to meet it. -- Thucydides
>
James Almer Feb. 7, 2020, 4:37 p.m. UTC | #4
On 2/7/2020 1:31 PM, Paul B Mahol wrote:
> On 1/30/20, Michael Niedermayer <michael@niedermayer.cc> wrote:
>> On Wed, Jan 29, 2020 at 04:34:48PM +0100, Anton Khirnov wrote:
>>> Log the warning message once per encoder instance instead.
>>> ---
>>>  libavcodec/ac3enc.c | 5 ++---
>>>  libavcodec/ac3enc.h | 2 ++
>>>  2 files changed, 4 insertions(+), 3 deletions(-)
>>
>> LGTM
> 
> Gonna apply?

Pushed.
diff mbox series

Patch

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 25318f8631..7ce17db067 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1993,12 +1993,11 @@  int ff_ac3_validate_metadata(AC3EncodeContext *s)
     /* set bitstream id for alternate bitstream syntax */
     if (!s->eac3 && (opt->extended_bsi_1 || opt->extended_bsi_2)) {
         if (s->bitstream_id > 8 && s->bitstream_id < 11) {
-            static int warn_once = 1;
-            if (warn_once) {
+            if (!s->warned_alternate_bitstream) {
                 av_log(avctx, AV_LOG_WARNING, "alternate bitstream syntax is "
                        "not compatible with reduced samplerates. writing of "
                        "extended bitstream information will be disabled.\n");
-                warn_once = 0;
+                s->warned_alternate_bitstream = 1;
             }
         } else {
             s->bitstream_id = 6;
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index a2442d0e55..1e4a7405bf 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -255,6 +255,8 @@  typedef struct AC3EncodeContext {
     uint8_t *ref_bap     [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap)
     int ref_bap_set;                                         ///< indicates if ref_bap pointers have been set
 
+    int warned_alternate_bitstream;
+
     /* fixed vs. float function pointers */
     void (*mdct_end)(struct AC3EncodeContext *s);
     int  (*mdct_init)(struct AC3EncodeContext *s);