diff --git a/Output/x64/acinerella.dll b/Output/x64/acinerella.dll index c57d9661..06abee8d 100644 Binary files a/Output/x64/acinerella.dll and b/Output/x64/acinerella.dll differ diff --git a/Output/x64/avcodec-54.dll b/Output/x64/avcodec-54.dll index 3906d3bf..b677a13a 100644 Binary files a/Output/x64/avcodec-54.dll and b/Output/x64/avcodec-54.dll differ diff --git a/Output/x64/avformat-54.dll b/Output/x64/avformat-54.dll index 9b9f360f..115949e2 100644 Binary files a/Output/x64/avformat-54.dll and b/Output/x64/avformat-54.dll differ diff --git a/Output/x64/avutil-52.dll b/Output/x64/avutil-52.dll index 025a4bf1..d8aa1179 100644 Binary files a/Output/x64/avutil-52.dll and b/Output/x64/avutil-52.dll differ diff --git a/Output/x64/swresample-0.dll b/Output/x64/swresample-0.dll index 026fe92d..ad600fdb 100644 Binary files a/Output/x64/swresample-0.dll and b/Output/x64/swresample-0.dll differ diff --git a/Output/x64/swscale-2.dll b/Output/x64/swscale-2.dll index 2b915705..58cf9119 100644 Binary files a/Output/x64/swscale-2.dll and b/Output/x64/swscale-2.dll differ diff --git a/Output/x86/acinerella.dll b/Output/x86/acinerella.dll index e4dc5ce2..e83b3f64 100644 Binary files a/Output/x86/acinerella.dll and b/Output/x86/acinerella.dll differ diff --git a/Output/x86/avcodec-54.dll b/Output/x86/avcodec-54.dll index d6e72cb7..62616e37 100644 Binary files a/Output/x86/avcodec-54.dll and b/Output/x86/avcodec-54.dll differ diff --git a/Output/x86/avformat-54.dll b/Output/x86/avformat-54.dll index d1233b57..68d8c5d4 100644 Binary files a/Output/x86/avformat-54.dll and b/Output/x86/avformat-54.dll differ diff --git a/Output/x86/avutil-52.dll b/Output/x86/avutil-52.dll index 98791159..12ab8847 100644 Binary files a/Output/x86/avutil-52.dll and b/Output/x86/avutil-52.dll differ diff --git a/Output/x86/swresample-0.dll b/Output/x86/swresample-0.dll index e546c3c7..2b52c0f4 100644 Binary files a/Output/x86/swresample-0.dll and b/Output/x86/swresample-0.dll differ diff --git a/Output/x86/swscale-2.dll b/Output/x86/swscale-2.dll index 200ebf30..e7b7dd3d 100644 Binary files a/Output/x86/swscale-2.dll and b/Output/x86/swscale-2.dll differ diff --git a/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs b/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs index 6afcafe2..d6830b94 100644 --- a/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs +++ b/Vocaluxe/Lib/Sound/Decoder/CAudioDecoderFFmpeg.cs @@ -27,8 +27,8 @@ namespace Vocaluxe.Lib.Sound.Decoder public override void Init() { - _rc = new TAc_read_callback(read_proc); - _sc = new TAc_seek_callback(seek_proc); + //_rc = new TAc_read_callback(read_proc); + //_sc = new TAc_seek_callback(seek_proc); _FileOpened = false; @@ -41,63 +41,51 @@ namespace Vocaluxe.Lib.Sound.Decoder return; _FileName = FileName; - _fs = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); + //_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) + int ret = 0; + //CAcinerella.ac_open(_instance, IntPtr.Zero, null, _rc, _sc, null, IntPtr.Zero); + if ((ret = CAcinerella.ac_open2(_instance, _FileName)) < 0) { - //Free(); + CLog.LogError("Error opening sound file (Errorcode: " + ret.ToString() + "): " + _FileName); return; } - int AudioStreamIndex = -1; + _Instance = (TAc_instance)Marshal.PtrToStructure(_instance, typeof(TAc_instance)); - TAc_stream_info Info = new TAc_stream_info(); - for (int i = 0; i < _Instance.stream_count; i++) + if (!_Instance.opened || _Instance.info.duration == 0) { - 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 (!_Instance.opened) + CLog.LogError("Can't open sound file: " + _FileName); + else + CLog.LogError("Can't open sound file (length = 0?): " + _FileName); + return; } - if (AudioStreamIndex < 0) + try { - //Free(); + _audiodecoder = CAcinerella.ac_create_audio_decoder(_instance); + } + catch (Exception e) + { + CLog.LogError("Can't create audio decoder for file: " + _FileName + "; " + e.Message); + return; + } + + if (_audiodecoder == IntPtr.Zero) + { + CLog.LogError("Can't create audio decoder for file: " + _FileName); 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; } @@ -136,7 +124,7 @@ namespace Vocaluxe.Lib.Sound.Decoder if (!_Initialized && !_FileOpened) return 0f; - return (float)_Instance.info.duration / 1000f; ; + return (float)_Instance.info.duration / 1000f; } public override void SetPosition(float Time) diff --git a/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs b/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs index 0b3fbc90..54d90fe3 100644 --- a/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs +++ b/Vocaluxe/Lib/Video/Acinerella/CAcinerella.cs @@ -253,6 +253,17 @@ namespace Vocaluxe.Lib.Video.Acinerella return _ac_open(PAc_instance, sender, open_proc, read_proc, seek_proc, close_proc, proberesult); } } + + [DllImport(AcDll, EntryPoint = "ac_open2", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] + private static extern Int32 _ac_open2(IntPtr PAc_instance, [MarshalAs(UnmanagedType.LPStr)]string Filename); + + public static Int32 ac_open2(IntPtr PAc_instance, string Filename) + { + lock (_lock) + { + return _ac_open2(PAc_instance, Filename); + } + } // Closes an opened media file. //procedure ac_close(inst: PAc_instance);cdecl; external ac_dll; @@ -316,6 +327,28 @@ namespace Vocaluxe.Lib.Video.Acinerella return _ac_create_decoder(PAc_instance, nb); } } + + [DllImport(AcDll, EntryPoint = "ac_create_audio_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] + private static extern IntPtr _ac_create_audio_decoder(IntPtr PAc_instance); + + public static IntPtr ac_create_audio_decoder(IntPtr PAc_instance) + { + lock (_lock) + { + return _ac_create_audio_decoder(PAc_instance); + } + } + + [DllImport(AcDll, EntryPoint = "ac_create_video_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)] + private static extern IntPtr _ac_create_video_decoder(IntPtr PAc_instance); + + public static IntPtr ac_create_video_decoder(IntPtr PAc_instance) + { + lock (_lock) + { + return _ac_create_video_decoder(PAc_instance); + } + } // Frees an created decoder. //procedure ac_free_decoder(pDecoder: PAc_decoder); cdecl; external ac_dll; diff --git a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs index 9b0f7828..ed759756 100644 --- a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs +++ b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs @@ -267,8 +267,8 @@ namespace Vocaluxe.Lib.Video public Decoder() { - _rc = new TAc_read_callback(read_proc); - _sc = new TAc_seek_callback(seek_proc); + //_rc = new TAc_read_callback(read_proc); + //_sc = new TAc_seek_callback(seek_proc); _thread = new Thread(Execute); } @@ -485,56 +485,45 @@ namespace Vocaluxe.Lib.Video private void DoOpen() { - bool ok = false; TAc_instance Instance = new TAc_instance(); + + _instance = CAcinerella.ac_init(); + int ret = -1; + if ((ret = CAcinerella.ac_open2(_instance, _FileName)) < 0) + { + CLog.LogError("Error opening video file (Errorcode: " + ret.ToString() + "): " + _FileName); + return; + } + + Instance = (TAc_instance)Marshal.PtrToStructure(_instance, typeof(TAc_instance)); + + if (!Instance.opened || Instance.info.duration == 0) + { + if (!Instance.opened) + CLog.LogError("Can't open video file: " + _FileName); + else + CLog.LogError("Can't open video file (length = 0?): " + _FileName); + return; + } + 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; + _videodecoder = CAcinerella.ac_create_video_decoder(_instance); } - catch (Exception) + catch (Exception e) { - CLog.LogError("Error opening video file: " + _FileName); - ok = false; + CLog.LogError("Can't create video decoder for file: " + _FileName + "; " + e.Message); + return; } - - if (!Instance.opened || !ok) + if (_videodecoder == IntPtr.Zero) { - //Free(); + CLog.LogError("Can't create video decoder for file: " + _FileName); 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;