[MPlayer-dev-eng] [patch] libmpcodecs/ad_ffmpeg.c: aac/sbr warning too nosiy (+fix for typo)

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Oct 9 17:44:38 CEST 2010


On Sat, Oct 09, 2010 at 05:15:41PM +0400, Yuriy Kaminskiy wrote:
> Index: MPlayer-20100929+lavc-mt/libmpcodecs/ad_ffmpeg.c
> ===================================================================
> --- MPlayer-20100929+lavc-mt.orig/libmpcodecs/ad_ffmpeg.c	2010-10-09 16:40:00.000000000 +0400
> +++ MPlayer-20100929+lavc-mt/libmpcodecs/ad_ffmpeg.c	2010-10-09 16:46:58.000000000 +0400
> @@ -46,6 +46,7 @@ LIBAD_EXTERN(ffmpeg)
>  
>  #include "libavcodec/avcodec.h"
>  
> +static int aac_warned;
>  
>  static int preinit(sh_audio_t *sh)
>  {
> @@ -71,8 +72,11 @@ static int setup_format(sh_audio_t *sh_a
>  
>          if (lavc_context->codec_id == CODEC_ID_AAC &&
>              samplerate == 2*sh_audio->wf->nSamplesPerSec) {
> +            if (unlikely(!aac_warned)) {
> +                aac_warned = 1;
>              mp_msg(MSGT_DECAUDIO, MSGL_WARN,
>                     "Ignoring broken container sample rate for ACC with SBR\n");
> +            }
>          } else if (sh_audio->wf->nSamplesPerSec)
>              samplerate=sh_audio->wf->nSamplesPerSec;
>      }
> @@ -158,6 +162,8 @@ static int init(sh_audio_t *sh_audio)
>         sh_audio->ds->ss_mul = 2*sh_audio->wf->nChannels; // 1 byte*ch/packet
>     }
>  
> +   aac_warned = 0;
> +

I do not like static variables, also it might be nice to warn every time
if the stream switches back and forth between SBR and non-SBR since
I don't think that we have really tested that case.
What about below patch?
Index: libmpcodecs/ad_ffmpeg.c
===================================================================
--- libmpcodecs/ad_ffmpeg.c     (revision 32451)
+++ libmpcodecs/ad_ffmpeg.c     (working copy)
@@ -55,6 +55,7 @@
 
 static int setup_format(sh_audio_t *sh_audio, const AVCodecContext *lavc_context)
 {
+    int broken_srate = 0;
     int samplerate    = lavc_context->sample_rate;
     int sample_format = sh_audio->sample_format;
     switch (lavc_context->sample_fmt) {
@@ -71,8 +72,7 @@
 
         if (lavc_context->codec_id == CODEC_ID_AAC &&
             samplerate == 2*sh_audio->wf->nSamplesPerSec) {
-            mp_msg(MSGT_DECAUDIO, MSGL_WARN,
-                   "Ignoring broken container sample rate for ACC with SBR\n");
+            broken_srate = 1;
         } else if (sh_audio->wf->nSamplesPerSec)
             samplerate=sh_audio->wf->nSamplesPerSec;
     }
@@ -83,6 +83,9 @@
         sh_audio->samplerate=samplerate;
         sh_audio->sample_format = sample_format;
         sh_audio->samplesize=af_fmt2bits(sh_audio->sample_format)/ 8;
+        if (broken_srate)
+            mp_msg(MSGT_DECAUDIO, MSGL_WARN,
+                   "Ignoring broken container sample rate for ACC with SBR\n");
         return 1;
     }
     return 0;


More information about the MPlayer-dev-eng mailing list