ac3enc: drop a global variable
authorAnton Khirnov <anton@khirnov.net>
Wed, 29 Jan 2020 15:34:48 +0000 (16:34 +0100)
committerJames Almer <jamrial@gmail.com>
Fri, 7 Feb 2020 16:36:57 +0000 (13:36 -0300)
Log the warning message once per encoder instance instead.

Reviewed-by: Kieran Kunhya <kierank@obe.tv>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/ac3enc.c
libavcodec/ac3enc.h

index 25318f8..7ce17db 100644 (file)
@@ -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;
index a2442d0..1e4a740 100644 (file)
@@ -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);