update of ffmpeg (04.01.) acinerella opens the files now itself

This commit is contained in:
Alexander Eckart committed 2013-01-06 15:03:30 +01:00
1 parent b861c4dbdb
commit 88573e6c45
15 files changed
+88 -78

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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)
@@ -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;
+28 -39
View File
@@ -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;