[FFmpeg-cvslog] ac3enc: drop a global variable

Anton Khirnov git at videolan.org
Fri Feb 7 18:37:32 EET 2020


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Jan 29 16:34:48 2020 +0100| [af1f1e8665414f37bd64c8f6878b808055abb0be] | committer: James Almer

ac3enc: drop a global variable

Log the warning message once per encoder instance instead.

Reviewed-by: Kieran Kunhya <kierank at obe.tv>
Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=af1f1e8665414f37bd64c8f6878b808055abb0be
---

 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);



More information about the ffmpeg-cvslog mailing list