예제 #1
0
        private void DoOpen()
        {
            bool ok = false;
            TAc_instance Instance = new TAc_instance();
            try
            {
                _fs = new FileStream(_FileName, FileMode.Open, FileAccess.Read, FileShare.Read);


                _instance = CAcinerella.ac_init();
                CAcinerella.ac_open(_instance, IntPtr.Zero, null, _rc, _sc, null, IntPtr.Zero);

                Instance = (TAc_instance)Marshal.PtrToStructure(_instance, typeof(TAc_instance));
                ok = true;
            }
            catch (Exception)
            {
                CLog.LogError("Error opening video file: " + _FileName);
                ok = false;
            }
            

            if (!Instance.opened || !ok)
            {
                //Free();
                return;
            }

            _Duration = (float)Instance.info.duration / 1000f;

            int VideoStreamIndex = -1;

            TAc_stream_info Info = new TAc_stream_info();
            for (int i = 0; i < Instance.stream_count; i++)
            {
                CAcinerella.ac_get_stream_info(_instance, i, out Info);

                if (Info.stream_type == TAc_stream_type.AC_STREAM_TYPE_VIDEO)
                {
                    _videodecoder = CAcinerella.ac_create_decoder(_instance, i);
                    
                    VideoStreamIndex = i;
                    break;
                }
            }

            if (VideoStreamIndex < 0)
            {
                //Free();
                return;
            }

            TAc_decoder Videodecoder = (TAc_decoder)Marshal.PtrToStructure(_videodecoder, typeof(TAc_decoder));

            _Width = Videodecoder.stream_info.video_info.frame_width;
            _Height = Videodecoder.stream_info.video_info.frame_height;

            if (Videodecoder.stream_info.video_info.frames_per_second > 0)
                _VideoTimeBase = 1f / (float)Videodecoder.stream_info.video_info.frames_per_second;

            _VideoDecoderTime = 0f;
            _Time = 0f;

            for (int i = 0; i < _FrameBuffer.Length; i++)
            {
                _FrameBuffer[i].time = -1f;
                _FrameBuffer[i].displayed = true;
                _FrameBuffer[i].data = new byte[_Width * _Height * 4];
            }
            _FileOpened = true;
        }
예제 #2
0
        public override void Open(string FileName, bool Loop)
        {
            if (!_Initialized)
                return;

            _FileName = FileName;
            _fs = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read);

            _instance = CAcinerella.ac_init();
            CAcinerella.ac_open(_instance, IntPtr.Zero, null, _rc, _sc, null, IntPtr.Zero);

            _Instance = (TAc_instance)Marshal.PtrToStructure(_instance, typeof(TAc_instance));

            if (!_Instance.opened)
            {
                //Free();
                return;
            }

            int AudioStreamIndex = -1;

            TAc_stream_info Info = new TAc_stream_info();
            for (int i = 0; i < _Instance.stream_count; i++)
            {
                CAcinerella.ac_get_stream_info(_instance, i, out Info);

                if (Info.stream_type == TAc_stream_type.AC_STREAM_TYPE_AUDIO)
                {
                    try
                    {
                        _audiodecoder = CAcinerella.ac_create_decoder(_instance, i);
                    }
                    catch (Exception)
                    {
                        return;                        
                    }
                    
                    AudioStreamIndex = i;
                    break;
                }
            }

            if (AudioStreamIndex < 0)
            {
                //Free();
                return;
            }

            TAc_decoder Audiodecoder = (TAc_decoder)Marshal.PtrToStructure(_audiodecoder, typeof(TAc_decoder));

            _FormatInfo = new FormatInfo();

            _FormatInfo.SamplesPerSecond = Audiodecoder.stream_info.audio_info.samples_per_second;
            _FormatInfo.BitDepth = Audiodecoder.stream_info.audio_info.bit_depth;
            _FormatInfo.ChannelCount = Audiodecoder.stream_info.audio_info.channel_count;

            _CurrentTime = 0f;

            if (_FormatInfo.BitDepth != 16)
            {
                CLog.LogError("Unsupported BitDepth in file " + FileName);
                return;
            }
            _FileOpened = true;
        }