static void dca_exss_parse_header(DCAContext *s)
{
    int asset_size[8];
    int ss_index;
    int blownup;
    int num_audiop = 1;
    int num_assets = 1;
    int active_ss_mask[8];
    int i, j;
    int start_posn;
    int hdrsize;
    uint32_t mkr;
    if (get_bits_left(&s->gb) < 52)
        return;
    start_posn = get_bits_count(&s->gb) - 32;
    skip_bits(&s->gb, 8); // user data
    ss_index = get_bits(&s->gb, 2);
    blownup = get_bits1(&s->gb);
    hdrsize = get_bits(&s->gb,  8 + 4 * blownup) + 1; // header_size
    skip_bits(&s->gb, 16 + 4 * blownup); // hd_size
    s->static_fields = get_bits1(&s->gb);
    if (s->static_fields) {
        skip_bits(&s->gb, 2); // reference clock code
        skip_bits(&s->gb, 3); // frame duration code
        if (get_bits1(&s->gb))
            skip_bits_long(&s->gb, 36); // timestamp
        /* a single stream can contain multiple audio assets that can be
         * combined to form multiple audio presentations */
        num_audiop = get_bits(&s->gb, 3) + 1;
        if (num_audiop > 1) {
            avpriv_request_sample(s->avctx,
                                  "Multiple DTS-HD audio presentations");
            /* ignore such streams for now */
            return;
        }
        num_assets = get_bits(&s->gb, 3) + 1;
        if (num_assets > 1) {
            avpriv_request_sample(s->avctx, "Multiple DTS-HD audio assets");
            /* ignore such streams for now */
            return;
        }
        for (i = 0; i < num_audiop; i++)
            active_ss_mask[i] = get_bits(&s->gb, ss_index + 1);
        for (i = 0; i < num_audiop; i++)
            for (j = 0; j <= ss_index; j++)
                if (active_ss_mask[i] & (1 << j))
                    skip_bits(&s->gb, 8); // active asset mask
        s->mix_metadata = get_bits1(&s->gb);
        if (s->mix_metadata) {
            int mix_out_mask_size;
            skip_bits(&s->gb, 2); // adjustment level
            mix_out_mask_size  = (get_bits(&s->gb, 2) + 1) << 2;
            s->num_mix_configs =  get_bits(&s->gb, 2) + 1;
            for (i = 0; i < s->num_mix_configs; i++) {
                int mix_out_mask        = get_bits(&s->gb, mix_out_mask_size);
                s->mix_config_num_ch[i] = dca_exss_mask2count(mix_out_mask);
            }
        }
    }
    for (i = 0; i < num_assets; i++)
        asset_size[i] = get_bits_long(&s->gb, 16 + 4 * blownup);
    for (i = 0; i < num_assets; i++) {
        if (dca_exss_parse_asset_header(s))
            return;
    }
    /* not parsed further, we were only interested in the extensions mask
     * from the asset header */
        j = get_bits_count(&s->gb);
        if (start_posn + hdrsize * 8 > j)
            skip_bits_long(&s->gb, start_posn + hdrsize * 8 - j);
        for (i = 0; i < num_assets; i++) {
            start_posn = get_bits_count(&s->gb);
            mkr        = get_bits_long(&s->gb, 32);
            /* parse extensions that we know about */
            if (mkr == 0x655e315e) {
                dca_xbr_parse_frame(s);
            } else if (mkr == 0x47004a03) {
                dca_xxch_decode_frame(s);
                s->core_ext_mask |= DCA_EXT_XXCH; /* xxx use for chan reordering */
            } else {
                av_log(s->avctx, AV_LOG_DEBUG,
                       "DTS-ExSS: unknown marker = 0x%08x\n", mkr);
            }
            /* skip to end of block */
            j = get_bits_count(&s->gb);
            if (start_posn + asset_size[i] * 8 > j)
                skip_bits_long(&s->gb, start_posn + asset_size[i] * 8 - j);
        }
}
static void dca_exss_parse_header(DCAContext *s)
{
    int asset_size[8];
    int ss_index;
    int blownup;
    int num_audiop = 1;
    int num_assets = 1;
    int active_ss_mask[8];
    int i, j;
    int start_posn;
    int hdrsize;
    uint32_t mkr;
    if (get_bits_left(&s->gb) < 52)
        return;
    start_posn = get_bits_count(&s->gb) - 32;
    skip_bits(&s->gb, 8); 
    ss_index = get_bits(&s->gb, 2);
    blownup = get_bits1(&s->gb);
    hdrsize = get_bits(&s->gb,  8 + 4 * blownup) + 1; 
    skip_bits(&s->gb, 16 + 4 * blownup); 
    s->static_fields = get_bits1(&s->gb);
    if (s->static_fields) {
        skip_bits(&s->gb, 2); 
        skip_bits(&s->gb, 3); 
        if (get_bits1(&s->gb))
            skip_bits_long(&s->gb, 36); 
        

        num_audiop = get_bits(&s->gb, 3) + 1;
        if (num_audiop > 1) {
            avpriv_request_sample(s->avctx,
                                  "Multiple DTS-HD audio presentations");
            
            return;
        }
        num_assets = get_bits(&s->gb, 3) + 1;
        if (num_assets > 1) {
            avpriv_request_sample(s->avctx, "Multiple DTS-HD audio assets");
            
            return;
        }
        for (i = 0; i < num_audiop; i++)
            active_ss_mask[i] = get_bits(&s->gb, ss_index + 1);
        for (i = 0; i < num_audiop; i++)
            for (j = 0; j <= ss_index; j++)
                if (active_ss_mask[i] & (1 << j))
                    skip_bits(&s->gb, 8); 
        s->mix_metadata = get_bits1(&s->gb);
        if (s->mix_metadata) {
            int mix_out_mask_size;
            skip_bits(&s->gb, 2); 
            mix_out_mask_size  = (get_bits(&s->gb, 2) + 1) << 2;
            s->num_mix_configs =  get_bits(&s->gb, 2) + 1;
            for (i = 0; i < s->num_mix_configs; i++) {
                int mix_out_mask        = get_bits(&s->gb, mix_out_mask_size);
                s->mix_config_num_ch[i] = dca_exss_mask2count(mix_out_mask);
            }
        }
    }
    for (i = 0; i < num_assets; i++)
        asset_size[i] = get_bits_long(&s->gb, 16 + 4 * blownup);
    for (i = 0; i < num_assets; i++) {
        if (dca_exss_parse_asset_header(s))
            return;
    }
    

        j = get_bits_count(&s->gb);
        if (start_posn + hdrsize * 8 > j)
            skip_bits_long(&s->gb, start_posn + hdrsize * 8 - j);
        for (i = 0; i < num_assets; i++) {
            start_posn = get_bits_count(&s->gb);
            mkr        = get_bits_long(&s->gb, 32);
            
            if (mkr == 0x655e315e) {
                dca_xbr_parse_frame(s);
            } else if (mkr == 0x47004a03) {
                dca_xxch_decode_frame(s);
                s->core_ext_mask |= DCA_EXT_XXCH; 
            } else {
                av_log(s->avctx, AV_LOG_DEBUG,
                       "DTS-ExSS: unknown marker = 0x%08x\n", mkr);
            }
            
            j = get_bits_count(&s->gb);
            if (start_posn + asset_size[i] * 8 > j)
                skip_bits_long(&s->gb, start_posn + asset_size[i] * 8 - j);
        }
}
static void FUNC_0(DCAContext *VAR_0)
{
    int VAR_1[8];
    int VAR_2;
    int VAR_3;
    int VAR_4 = 1;
    int VAR_5 = 1;
    int VAR_6[8];
    int VAR_7, VAR_8;
    int VAR_9;
    int VAR_10;
    uint32_t mkr;
    if (get_bits_left(&VAR_0->gb) < 52)
        return;
    VAR_9 = get_bits_count(&VAR_0->gb) - 32;
    skip_bits(&VAR_0->gb, 8); 
    VAR_2 = get_bits(&VAR_0->gb, 2);
    VAR_3 = get_bits1(&VAR_0->gb);
    VAR_10 = get_bits(&VAR_0->gb,  8 + 4 * VAR_3) + 1; 
    skip_bits(&VAR_0->gb, 16 + 4 * VAR_3); 
    VAR_0->static_fields = get_bits1(&VAR_0->gb);
    if (VAR_0->static_fields) {
        skip_bits(&VAR_0->gb, 2); 
        skip_bits(&VAR_0->gb, 3); 
        if (get_bits1(&VAR_0->gb))
            skip_bits_long(&VAR_0->gb, 36); 
        

        VAR_4 = get_bits(&VAR_0->gb, 3) + 1;
        if (VAR_4 > 1) {
            avpriv_request_sample(VAR_0->avctx,
                                  "Multiple DTS-HD audio presentations");
            
            return;
        }
        VAR_5 = get_bits(&VAR_0->gb, 3) + 1;
        if (VAR_5 > 1) {
            avpriv_request_sample(VAR_0->avctx, "Multiple DTS-HD audio assets");
            
            return;
        }
        for (VAR_7 = 0; VAR_7 < VAR_4; VAR_7++)
            VAR_6[VAR_7] = get_bits(&VAR_0->gb, VAR_2 + 1);
        for (VAR_7 = 0; VAR_7 < VAR_4; VAR_7++)
            for (VAR_8 = 0; VAR_8 <= VAR_2; VAR_8++)
                if (VAR_6[VAR_7] & (1 << VAR_8))
                    skip_bits(&VAR_0->gb, 8); 
        VAR_0->mix_metadata = get_bits1(&VAR_0->gb);
        if (VAR_0->mix_metadata) {
            int VAR_11;
            skip_bits(&VAR_0->gb, 2); 
            VAR_11  = (get_bits(&VAR_0->gb, 2) + 1) << 2;
            VAR_0->num_mix_configs =  get_bits(&VAR_0->gb, 2) + 1;
            for (VAR_7 = 0; VAR_7 < VAR_0->num_mix_configs; VAR_7++) {
                int mix_out_mask        = get_bits(&VAR_0->gb, VAR_11);
                VAR_0->mix_config_num_ch[VAR_7] = dca_exss_mask2count(mix_out_mask);
            }
        }
    }
    for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++)
        VAR_1[VAR_7] = get_bits_long(&VAR_0->gb, 16 + 4 * VAR_3);
    for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {
        if (dca_exss_parse_asset_header(VAR_0))
            return;
    }
    

        VAR_8 = get_bits_count(&VAR_0->gb);
        if (VAR_9 + VAR_10 * 8 > VAR_8)
            skip_bits_long(&VAR_0->gb, VAR_9 + VAR_10 * 8 - VAR_8);
        for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {
            VAR_9 = get_bits_count(&VAR_0->gb);
            mkr        = get_bits_long(&VAR_0->gb, 32);
            
            if (mkr == 0x655e315e) {
                dca_xbr_parse_frame(VAR_0);
            } else if (mkr == 0x47004a03) {
                dca_xxch_decode_frame(VAR_0);
                VAR_0->core_ext_mask |= DCA_EXT_XXCH; 
            } else {
                av_log(VAR_0->avctx, AV_LOG_DEBUG,
                       "DTS-ExSS: unknown marker = 0x%08x\n", mkr);
            }
            
            VAR_8 = get_bits_count(&VAR_0->gb);
            if (VAR_9 + VAR_1[VAR_7] * 8 > VAR_8)
                skip_bits_long(&VAR_0->gb, VAR_9 + VAR_1[VAR_7] * 8 - VAR_8);
        }
}
static void FUNC_0(DCAContext *VAR_0)
{ int VAR_1[8]; int VAR_2; int VAR_3; int VAR_4 = 1; int VAR_5 = 1; int VAR_6[8]; int VAR_7, VAR_8; int VAR_9; int VAR_10; uint32_t mkr; if (get_bits_left(&VAR_0->gb) < 52)
return; VAR_9 = get_bits_count(&VAR_0->gb) - 32; skip_bits(&VAR_0->gb, 8); VAR_2 = get_bits(&VAR_0->gb, 2); VAR_3 = get_bits1(&VAR_0->gb); VAR_10 = get_bits(&VAR_0->gb,  8 + 4 * VAR_3) + 1; skip_bits(&VAR_0->gb, 16 + 4 * VAR_3); VAR_0->static_fields = get_bits1(&VAR_0->gb); if (VAR_0->static_fields) { skip_bits(&VAR_0->gb, 2); skip_bits(&VAR_0->gb, 3); if (get_bits1(&VAR_0->gb))
skip_bits_long(&VAR_0->gb, 36); VAR_4 = get_bits(&VAR_0->gb, 3) + 1; if (VAR_4 > 1) { avpriv_request_sample(VAR_0->avctx,
"Multiple DTS-HD audio presentations"); return; } VAR_5 = get_bits(&VAR_0->gb, 3) + 1; if (VAR_5 > 1) { avpriv_request_sample(VAR_0->avctx, "Multiple DTS-HD audio assets"); return; } for (VAR_7 = 0; VAR_7 < VAR_4; VAR_7++) VAR_6[VAR_7] = get_bits(&VAR_0->gb, VAR_2 + 1); for (VAR_7 = 0; VAR_7 < VAR_4; VAR_7++) for (VAR_8 = 0; VAR_8 <= VAR_2; VAR_8++) if (VAR_6[VAR_7] & (1 << VAR_8))
skip_bits(&VAR_0->gb, 8); VAR_0->mix_metadata = get_bits1(&VAR_0->gb); if (VAR_0->mix_metadata) { int VAR_11; skip_bits(&VAR_0->gb, 2); VAR_11  = (get_bits(&VAR_0->gb, 2) + 1) << 2; VAR_0->num_mix_configs =  get_bits(&VAR_0->gb, 2) + 1; for (VAR_7 = 0; VAR_7 < VAR_0->num_mix_configs; VAR_7++) { int mix_out_mask        = get_bits(&VAR_0->gb, VAR_11); VAR_0->mix_config_num_ch[VAR_7] = dca_exss_mask2count(mix_out_mask); } } } for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) VAR_1[VAR_7] = get_bits_long(&VAR_0->gb, 16 + 4 * VAR_3); for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) { if (dca_exss_parse_asset_header(VAR_0))
return; } VAR_8 = get_bits_count(&VAR_0->gb); if (VAR_9 + VAR_10 * 8 > VAR_8)
skip_bits_long(&VAR_0->gb, VAR_9 + VAR_10 * 8 - VAR_8); for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) { VAR_9 = get_bits_count(&VAR_0->gb); mkr        = get_bits_long(&VAR_0->gb, 32); if (mkr == 0x655e315e) { dca_xbr_parse_frame(VAR_0); } else if (mkr == 0x47004a03) { dca_xxch_decode_frame(VAR_0); VAR_0->core_ext_mask |= DCA_EXT_XXCH; } else { av_log(VAR_0->avctx, AV_LOG_DEBUG,
"DTS-ExSS: unknown marker = 0x%08x\n", mkr); } VAR_8 = get_bits_count(&VAR_0->gb); if (VAR_9 + VAR_1[VAR_7] * 8 > VAR_8)
skip_bits_long(&VAR_0->gb, VAR_9 + VAR_1[VAR_7] * 8 - VAR_8); } }