Exemple #1
0
        internal VideoParams265(TrackEntry videoTrack)
        {
            // File.WriteAllBytes( @"C:\Temp\2remove\mkv\videoPrivateData.bin", videoTrack.codecPrivate );

            ReadOnlySpan <byte> codecPrivate = videoTrack.codecPrivate.AsSpan();
            int          cbHeader            = Marshal.SizeOf <NativeStruct>();
            NativeStruct ns = codecPrivate.Slice(0, cbHeader).cast <NativeStruct>()[0];

            codecPrivate = codecPrivate.Slice(cbHeader);
            chromaFormat = (eChromaFormat)ns.chromaFormatIndex;

            arrays = new ConfigArray[ns.numOfArrays];
            for (int i = 0; i < ns.numOfArrays; i++)
            {
                var ca = new ConfigArray(ref codecPrivate);
                arrays[i] = ca;
            }

            parsedVps = blobs(eNaluType.VPS)
                        .Select(arr => new VideoParameterSet(arr.AsSpan()))
                        .ToDictionary(v => v.vps_video_parameter_set_id);

            parsedSps = blobs(eNaluType.SPS)
                        .Select(arr => new SequenceParameterSet(arr.AsSpan(), parsedVps))
                        .ToArray();

            parsedPps = blobs(eNaluType.PPS)
                        .Select(arr => new PictureParameterSet(arr.AsSpan()))
                        .ToArray();

            if (chromaFormat == eChromaFormat.Unknown)
            {
                chromaFormat = parsedSps[0].chromaFormat;
            }
            else if (parsedSps[0].chromaFormat != eChromaFormat.Unknown && parsedSps[0].chromaFormat != chromaFormat)
            {
                throw new ApplicationException("Different parameter sets disagree on the chroma format");
            }
        }
Exemple #2
0
        internal VideoParams264(TrackEntry videoTrack)
        {
            // File.WriteAllBytes( @"C:\Temp\2remove\mkv\videoPrivateData.bin", videoTrack.codecPrivate );
            ReadOnlySpan <byte> codecPrivate = videoTrack.codecPrivate.AsSpan();
            int          cbHeader            = Marshal.SizeOf <NativeStruct>();
            NativeStruct ns = codecPrivate.Slice(0, cbHeader).cast <NativeStruct>()[0];

            profile = ns.profileCode;
            profileCompatibility = ns.profileCompatibility;
            levelCode            = ns.levelCode;

            int offset = cbHeader;

            sps = ContainerUtils.copyBlobs(ns.numOfSequenceParameterSets, codecPrivate, ref offset);

            // File.WriteAllBytes( @"C:\Temp\2remove\mkv\sps.bin", sps[ 0 ] );

            int ppsCount = codecPrivate[offset++];

            pps = ContainerUtils.copyBlobs(ppsCount, codecPrivate, ref offset);

            ReadOnlySpan <byte> spsBlob = sps[0].AsSpan();

            if (MiscUtils.getNaluType(spsBlob[0]) != eNaluType.SPS)
            {
                throw new ApplicationException("The SPS is invalid, wrong NALU type");
            }
            spsBlob = spsBlob.Slice(1);

            BitReader spsReader = new BitReader(spsBlob);

            parsedSps = new SequenceParameterSet(ref spsReader);

            chromaFormat   = parsedSps.chromaFormat;
            bitDepthLuma   = parsedSps.bitDepthLuma;
            bitDepthChroma = parsedSps.bitDepthChroma;
            m_decodedSize  = new sDecodedVideoSize(parsedSps.decodedSize, parsedSps.cropRectangle, chromaFormat);
        }
Exemple #3
0
 public AudioReader(MkvMediaFile file, TrackEntry track) :
     base(file, track)
 {
 }
Exemple #4
0
 public AudioTrack(MkvMediaFile file, TrackEntry track)
 {
     this.file  = file;
     this.track = track;
     info       = new TrackInfo(track);
 }
Exemple #5
0
        public static int find(MkvMediaFile file, TrackEntry track, CSize size)
        {
            int pixels = size.cx * size.cy;

            return(pixels * maxBitsPerPixel / 8);
        }