diff -urN mythtv-4068639/mythtv/external/FFmpeg/libavcodec/aacadtsdec.c mythtv-ffmpeg/mythtv/external/FFmpeg/libavcodec/aacadtsdec.c
--- mythtv-4068639/mythtv/external/FFmpeg/libavcodec/aacadtsdec.c	2011-04-12 11:44:15.000000000 +0900
+++ mythtv-ffmpeg/mythtv/external/FFmpeg/libavcodec/aacadtsdec.c	2011-04-16 21:20:01.000000000 +0900
@@ -35,7 +35,8 @@
         return AAC_AC3_PARSE_ERROR_SYNC;
 
     skip_bits1(gbc);             /* id */
-    skip_bits(gbc, 2);           /* layer */
+    if(get_bits(gbc, 2) != 0)    /* layer */
+        return AAC_AC3_PARSE_ERROR_SYNC;
     crc_abs = get_bits1(gbc);    /* protection_absent */
     aot     = get_bits(gbc, 2);  /* profile_objecttype */
     sr      = get_bits(gbc, 4);  /* sample_frequency_index */
diff -urN mythtv-4068639/mythtv/external/FFmpeg/libavcodec/aacdec.c mythtv-ffmpeg/mythtv/external/FFmpeg/libavcodec/aacdec.c
--- mythtv-4068639/mythtv/external/FFmpeg/libavcodec/aacdec.c	2011-04-12 11:44:15.000000000 +0900
+++ mythtv-ffmpeg/mythtv/external/FFmpeg/libavcodec/aacdec.c	2011-04-16 21:30:14.000000000 +0900
@@ -1906,6 +1906,15 @@
 
     size = ff_aac_parse_header(gb, &hdr_info);
     if (size > 0) {
+        if (hdr_info.chan_config != 0 &&
+            ac->avctx->channel_layout !=
+                aac_channel_layout[hdr_info.chan_config - 1]) {
+            av_log(ac->avctx, AV_LOG_INFO,
+                   "Detected channel config change to [%d]ch. hinfo-br:%d\n",
+                   hdr_info.chan_config, hdr_info.bit_rate);
+            // ac->need_reconfig = 1;
+            ac->output_configured = OC_NONE;
+        }
         if (ac->output_configured != OC_LOCKED && hdr_info.chan_config) {
             enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
             memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
@@ -1915,7 +1924,23 @@
             if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME))
                 return -7;
         } else if (ac->output_configured != OC_LOCKED) {
-            ac->output_configured = OC_NONE;
+            /**
+             * hdr_info.chan_config == 0 -> not default channel position &&
+             * outptu_configured == OC_NONE -> no PCE found (yet)
+             *  in this case, set dual mono as default for ISDB-T/S.
+             */
+            if (ac->output_configured == OC_NONE) {
+                enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
+
+                memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
+                new_che_pos[TYPE_SCE][0] = AAC_CHANNEL_FRONT;
+                new_che_pos[TYPE_SCE][1] = AAC_CHANNEL_FRONT;
+                if (output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_FRAME))
+                    return -7;
+            }
+            // ac->output_configured = OC_NONE;
+            ac->m4ac.chan_config = 0;
+            ac->avctx->channel_layout = 0;
         }
         if (ac->output_configured != OC_LOCKED) {
             ac->m4ac.sbr = -1;
@@ -1924,8 +1949,8 @@
         ac->m4ac.sample_rate     = hdr_info.sample_rate;
         ac->m4ac.sampling_index  = hdr_info.sampling_index;
         ac->m4ac.object_type     = hdr_info.object_type;
-        if (!ac->avctx->sample_rate)
-            ac->avctx->sample_rate = hdr_info.sample_rate;
+        ac->avctx->sample_rate = hdr_info.sample_rate;
+        ac->avctx->bit_rate = hdr_info.bit_rate;
         if (hdr_info.num_aac_frames == 1) {
             if (!hdr_info.crc_absent)
                 skip_bits(gb, 16);
@@ -1950,6 +1975,9 @@
     int buf_consumed;
     int samples = 0, multiplier;
     int buf_offset;
+    uint16_t used_id[TYPE_END] = { 0 }; // bitset of used elem_id's of the type
+    int sce_count = 0;
+    float *tmpbuf = NULL;
 
     init_get_bits(&gb, buf, buf_size * 8);
 
@@ -1969,6 +1997,23 @@
     while ((elem_type = get_bits(&gb, 3)) != TYPE_END) {
         elem_id = get_bits(&gb, 4);
 
+        /* work-around for duplicated elem_id */
+        /* ex. some ADTS frames contain SCE.0 CPE.0 CPE.0(!) LFE.0, without PCE */
+        // check elem_id duplication
+        if (elem_type < TYPE_FIL && used_id[elem_type] & (1 << elem_id)) {
+            int i;
+            for (i = 0; i < 16; i++)
+                if (!(used_id[elem_type] & (1 << i)))
+                    break;
+            if (i == 16)
+                i = elem_id;
+            av_log(avctx, AV_LOG_INFO,
+                   "Changed a duplicated elem_id:%d (of type:%d) to %d.\n",
+                   elem_id, elem_type, i);
+            elem_id = i;
+        }
+        used_id[elem_type] |= (1 << elem_id);
+
         if (elem_type < TYPE_DSE) {
             if (!(che=get_che(ac, elem_type, elem_id))) {
                 av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",
@@ -1982,6 +2027,7 @@
 
         case TYPE_SCE:
             err = decode_ics(ac, &che->ch[0], &gb, 0, 0);
+            sce_count++;
             break;
 
         case TYPE_CPE:
@@ -2005,11 +2051,15 @@
             memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
             if ((err = decode_pce(ac, new_che_pos, &gb)))
                 break;
-            if (ac->output_configured > OC_TRIAL_PCE)
-                av_log(avctx, AV_LOG_ERROR,
-                       "Not evaluating a further program_config_element as this construct is dubious at best.\n");
-            else
+            if (avctx->channel_layout == 0 &&
+                memcmp(ac->che_pos, new_che_pos, sizeof(ac->che_pos))) {
+                // ac->need_reconfig = 1;
                 err = output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_PCE);
+
+                av_log(avctx, AV_LOG_INFO,
+                       "Detected channel config change to [%d] ch.\n",
+                       avctx->channels);
+            }
             break;
         }
 
@@ -2044,12 +2094,12 @@
 
     spectral_to_sample(ac);
 
-    multiplier = (ac->m4ac.sbr == 1) ? ac->m4ac.ext_sample_rate > ac->m4ac.sample_rate : 0;
+    multiplier = (ac->m4ac.sbr == 1) ? !ac->m4ac.ext_sample_rate || ac->m4ac.ext_sample_rate > ac->m4ac.sample_rate : 0;
+    if (multiplier)
+        av_log(avctx, AV_LOG_DEBUG, "SBR multiplier:%d\n", multiplier);
     samples <<= multiplier;
-    if (ac->output_configured < OC_LOCKED) {
-        avctx->sample_rate = ac->m4ac.sample_rate << multiplier;
-        avctx->frame_size = samples;
-    }
+    avctx->sample_rate = ac->m4ac.sample_rate << multiplier;
+    avctx->frame_size = samples;
 
     data_size_tmp = samples * avctx->channels * sizeof(int16_t);
     if (*data_size < data_size_tmp) {
@@ -2060,8 +2110,25 @@
     }
     *data_size = data_size_tmp;
 
+    /* for dual-mono audio (SCE + SCE) */
+    if (avctx->channels == 2 && sce_count == 2) {
+        if (avctx->dualmono_mode == 0) {
+            tmpbuf = ac->output_data[1];
+            ac->output_data[1] = ac->output_data[0];
+        } else if (avctx->dualmono_mode == 1) {
+            tmpbuf = ac->output_data[0];
+            ac->output_data[0] = ac->output_data[1];
+        }
+    }
+
     if (samples)
         ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels);
+    if (avctx->channels == 2 && sce_count == 2) {
+        if (avctx->dualmono_mode == 0)
+            ac->output_data[1] = tmpbuf;
+        else if (avctx->dualmono_mode == 1)
+            ac->output_data[0] = tmpbuf;
+    }
 
     if (ac->output_configured)
         ac->output_configured = OC_LOCKED;
diff -urN mythtv-4068639/mythtv/external/FFmpeg/libavcodec/avcodec.h mythtv-ffmpeg/mythtv/external/FFmpeg/libavcodec/avcodec.h
--- mythtv-4068639/mythtv/external/FFmpeg/libavcodec/avcodec.h	2011-04-12 11:44:15.000000000 +0900
+++ mythtv-ffmpeg/mythtv/external/FFmpeg/libavcodec/avcodec.h	2011-04-16 21:30:00.000000000 +0900
@@ -2742,6 +2742,17 @@
      * - decoding: set by decoder
      */
     int xvmc_vld_hwslice;
+
+   /**
+     * Dual mono audio channel selection.
+     * Indicates how to decode a dual mono audio stream.
+     * 0: Main/L
+     * 1: Sub/R
+     * 2: Both/LR
+     * - encoding: unused
+     * - decoding: Set by user
+     */
+     int dualmono_mode;
 } AVCodecContext;
 
 /**
