[FFmpeg-soc] [soc]: r5057 - als/ffmpeg-patches/addALSreadconfig.patch

thilo.borgmann subversion at mplayerhq.hu
Thu Aug 13 02:08:02 CEST 2009


Author: thilo.borgmann
Date: Thu Aug 13 02:08:01 2009
New Revision: 5057

Log:
Changed ffmpeg integration patch.
Added functionality to parse the ALSSpecificConfig struct within
AudioSpecificConfig and set the correct number of channels accordingly.

Modified:
   als/ffmpeg-patches/addALSreadconfig.patch

Modified: als/ffmpeg-patches/addALSreadconfig.patch
==============================================================================
--- als/ffmpeg-patches/addALSreadconfig.patch	Wed Aug 12 23:25:46 2009	(r5056)
+++ als/ffmpeg-patches/addALSreadconfig.patch	Thu Aug 13 02:08:01 2009	(r5057)
@@ -1,65 +1,84 @@
 Index: libavcodec/mpeg4audio.c
 ===================================================================
---- libavcodec/mpeg4audio.c	(Revision 19089)
-+++ libavcodec/mpeg4audio.c	(Arbeitskopie)
-@@ -57,6 +57,8 @@
-     c->object_type = get_object_type(&gb);
-     c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
-     c->chan_config = get_bits(&gb, 4);
-+    c->absolute_channels = 0;
-+    c->bits_per_sample   = 0;
-     c->sbr = -1;
-     if (c->object_type == 5) {
-         c->ext_object_type = c->object_type;
-@@ -84,6 +86,12 @@
-                 get_bits1(&gb); // skip 1 bit
-         }
+--- libavcodec/mpeg4audio.c	(revision 19634)
++++ libavcodec/mpeg4audio.c	(working copy)
+@@ -24,6 +24,29 @@
+ #include "put_bits.h"
+ #include "mpeg4audio.h"
+
++/**
++ * Parse MPEG-4 audio configuration for ALS object type.
++ * @param[in] gb       Bit reader context.
++ * @param[in] c        MPEG4AudioConfig structure to fill.
++ * @return On error -1 is returned, on success 0 is returned.
++ */
++static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c, int buf_size)
++{
++    buf_size -= get_bits_count(gb) >> 3;
++
++    if (buf_size < 14)
++        return -1;
++
++    if (show_bits_long(gb, 24) != 0x414C53)
++        return -1;
++
++    // skip als_id, sample_rate, number of samples
++    skip_bits_long(gb, 96);
++    c->channels = get_bits(gb, 16) + 1;
++
++    return 0;
++}
++
+ const int ff_mpeg4audio_sample_rates[16] = {
+     96000, 88200, 64000, 48000, 44100, 32000,
+     24000, 22050, 16000, 12000, 11025, 8000, 7350
+@@ -71,8 +94,18 @@
      }
+     specific_config_bitindex = get_bits_count(&gb);
+
 +    if (c->object_type == AOT_ALS) {
-+        c->absolute_channels = 1;
-+        c->sample_rate       = AV_RB32(buf + 10);
-+        c->chan_config       = AV_RB16(buf + 18) + 1;
-+        c->bits_per_sample   = (((buf[20] >> 2) & 0x07) + 1) << 3;
++        skip_bits(&gb, 5);
++        if (show_bits_long(&gb, 24) != 0x414C53) {
++            skip_bits_long(&gb, 24);
++        }
++        specific_config_bitindex = get_bits_count(&gb);
++        if (!c->chan_config && parse_config_ALS(&gb, c, buf_size))
++            return -1;
 +    }
-     return specific_config_bitindex;
- }
- 
++
+     if (c->ext_object_type != AOT_SBR) {
+-        int bits_left = buf_size*8 - specific_config_bitindex;
++        int bits_left = buf_size*8 - get_bits_count(&gb);
+         for (; bits_left > 15; bits_left--) {
+             if (show_bits(&gb, 11) == 0x2b7) { // sync extension
+                 get_bits(&gb, 11);
 Index: libavcodec/mpeg4audio.h
 ===================================================================
---- libavcodec/mpeg4audio.h	(Revision 19089)
-+++ libavcodec/mpeg4audio.h	(Arbeitskopie)
-@@ -36,6 +36,8 @@
+--- libavcodec/mpeg4audio.h	(revision 19634)
++++ libavcodec/mpeg4audio.h	(working copy)
+@@ -36,6 +36,7 @@
      int ext_sampling_index;
      int ext_sample_rate;
      int ext_chan_config;
-+    int bits_per_sample;
-+    int absolute_channels;
++    int channels;
  } MPEG4AudioConfig;
- 
+
  extern const int ff_mpeg4audio_sample_rates[16];
 Index: libavformat/mov.c
 ===================================================================
---- libavformat/mov.c	(Revision 19089)
-+++ libavformat/mov.c	(Arbeitskopie)
-@@ -425,13 +425,18 @@
+--- libavformat/mov.c	(revision 19634)
++++ libavformat/mov.c	(working copy)
+@@ -434,9 +434,13 @@
                  MPEG4AudioConfig cfg;
                  ff_mpeg4audio_get_config(&cfg, st->codec->extradata,
                                           st->codec->extradata_size);
--                if (cfg.chan_config > 7)
--                    return -1;
--                st->codec->channels = ff_mpeg4audio_channels[cfg.chan_config];
-+                if (!cfg.absolute_channels) {
-+                    if (cfg.chan_config > 7)
-+                        return -1;
-+                    st->codec->channels = ff_mpeg4audio_channels[cfg.chan_config];
-+                } else st->codec->channels = cfg.chan_config;
-+
++                if (cfg.chan_config) {
+                 if (cfg.chan_config > 7)
+                     return -1;
+                 st->codec->channels = ff_mpeg4audio_channels[cfg.chan_config];
++                } else {
++                    st->codec->channels = cfg.channels;
++                }
                  if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4
                      st->codec->sample_rate = ff_mpa_freq_tab[cfg.sampling_index];
                  else
-                     st->codec->sample_rate = cfg.sample_rate; // ext sample rate ?
-+                if (cfg.bits_per_sample)
-+                    st->codec->bits_per_coded_sample = cfg.bits_per_sample;
-                 dprintf(c->fc, "mp4a config channels %d obj %d ext obj %d "
-                         "sample rate %d ext sample rate %d\n", st->codec->channels,
-                         cfg.object_type, cfg.ext_object_type,


More information about the FFmpeg-soc mailing list