Exemplo n.º 1
0
        unsafe int getSubstreamHeaderLen(byte[] substream_buf, int substream_off, int substream_len)
        {
            if (substream_len <= 4)
                return(0);

            fixed(byte *p = &substream_buf[substream_off])
            {
                var fr  = new FrameReader(p, substream_len);
                var hdr = new SUB_HEADER(fr);

                switch (hdr.stream_id)
                {
                case DVDA.PCM_STREAM_ID:
                case DVDA.MLP_STREAM_ID:
                    return(SUB_HEADER.SIZE + hdr.extra_len);

                default:
                    return(0);
                }
            }
        }
Exemplo n.º 2
0
        unsafe void getPS1Params(byte[] ps1_header, int ps1_len)
        {
            ch_assignment = -1;
            gr1_frequency = 0;
            gr1_bits      = 0;
            gr2_frequency = 0;
            gr2_bits      = 0;
            vbr           = false;
            peak_bitrate  = 0;
            substreams    = 0;
            cci           = 0;
            if (ps1_len == 0)
                return;

            fixed(byte *p_ps1_header = &ps1_header[0])
            {
                var fr = new FrameReader(p_ps1_header, ps1_len);

                sh = new SUB_HEADER(fr);
                switch (sh.stream_id)
                {
                case DVDA.PCM_STREAM_ID:
                {
                    if (sh.extra_len < PCM_EXTRAHEADER.SIZE)
                    {
                        break;
                    }
                    PCM_EXTRAHEADER pcm_ehdr = new PCM_EXTRAHEADER(fr);
                    cci           = pcm_ehdr.cci;
                    ch_assignment = pcm_ehdr.channel_assignment;
                    decode_grp1_bits(pcm_ehdr.group1_bits);
                    decode_grp2_bits(pcm_ehdr.group2_bits);
                    decode_grp1_freq(pcm_ehdr.group1_freq);
                    decode_grp2_freq(pcm_ehdr.group2_freq);
                    vbr          = false;
                    peak_bitrate = gr1_channels * gr1_frequency * gr1_bits + gr2_channels * gr2_frequency * gr2_bits;
                    substreams   = 1;
                    break;
                }

                case DVDA.MLP_STREAM_ID:
                {
                    if (sh.extra_len < MLP_EXTRAHEADER.SIZE)
                    {
                        break;
                    }
                    MLP_EXTRAHEADER mlp_ehdr = new MLP_EXTRAHEADER(fr);
                    fr.skip(sh.extra_len - MLP_EXTRAHEADER.SIZE);
                    while (fr.Length > MLP_LINK.SIZE + MLP_SIGNATURE.SIZE)
                    {
                        FrameReader fr1 = new FrameReader(fr, MLP_LINK.SIZE + MLP_SIGNATURE.SIZE);
                        fr1.skip(MLP_LINK.SIZE);
                        MLP_SIGNATURE mlp_sign = new MLP_SIGNATURE(fr1);
                        if (mlp_sign.signature1 != 0xF8726FBB /*|| p_mlp_sign->signature2 != 0xB752*/)
                        {
                            fr.skip(1);
                            continue;
                        }
                        cci = mlp_ehdr.cci;
                        fr.skip(MLP_LINK.SIZE);
                        ch_assignment = mlp_sign.channel_assignment;
                        decode_grp1_bits(mlp_sign.group1_bits);
                        decode_grp2_bits(mlp_sign.group2_bits);
                        decode_grp1_freq(mlp_sign.group1_freq);
                        decode_grp2_freq(mlp_sign.group2_freq);
                        vbr          = (mlp_sign.bitrate & 0x8000) != 0;
                        peak_bitrate = ((mlp_sign.bitrate & ~0x8000) * gr1_frequency + 8) >> 4;
                        substreams   = mlp_sign.substreams;
                        break;
                    }
                    break;
                }
                }
            }
        }