+ dca_decode_block(s, 0, i);
+ }
+
+ /* record number of core channels incase less than max channels are requested */
+ num_core_channels = s->prim_channels;
+
+ /* extensions start at 32-bit boundaries into bitstream */
+ skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
+
+ while(get_bits_left(&s->gb) >= 32) {
+ uint32_t bits = get_bits_long(&s->gb, 32);
+
+ switch(bits) {
+ case 0x5a5a5a5a: {
+ int ext_amode, xch_fsize;
+
+ s->xch_base_channel = s->prim_channels;
+
+ /* validate sync word using XCHFSIZE field */
+ xch_fsize = show_bits(&s->gb, 10);
+ if((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) &&
+ (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1))
+ continue;
+
+ /* skip length-to-end-of-frame field for the moment */
+ skip_bits(&s->gb, 10);
+
+ /* extension amode should == 1, number of channels in extension */
+ /* AFAIK XCh is not used for more channels */
+ if ((ext_amode = get_bits(&s->gb, 4)) != 1) {
+ av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not"
+ " supported!\n",ext_amode);
+ continue;
+ }
+
+ /* much like core primary audio coding header */
+ dca_parse_audio_coding_header(s, s->xch_base_channel);
+
+ for (i = 0; i < (s->sample_blocks / 8); i++) {
+ dca_decode_block(s, s->xch_base_channel, i);
+ }
+
+ s->xch_present = 1;
+ break;
+ }
+ case 0x1d95f262:
+ av_log(avctx, AV_LOG_DEBUG, "Possible X96 extension found at %d bits\n", get_bits_count(&s->gb));
+ av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", get_bits(&s->gb, 12)+1);
+ av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4));
+ break;
+ }
+
+ skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);