Merge remote-tracking branch 'upstream/develop' into 6-player
This commit is contained in:
commit
6ad006b3bd
20 files changed
+252
-187
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.
@@ -156,6 +156,9 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static void Play()
|
public static void Play()
|
||||||
{
|
{
|
||||||
|
if (_Playing)
|
||||||
|
return;
|
||||||
|
|
||||||
if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
|
if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
|
||||||
{
|
{
|
||||||
if (_AllFileNames.Count > 0)
|
if (_AllFileNames.Count > 0)
|
||||||
@@ -181,6 +184,9 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static void Stop()
|
public static void Stop()
|
||||||
{
|
{
|
||||||
|
if (!_Playing)
|
||||||
|
return;
|
||||||
|
|
||||||
if (_VideoEnabled && _Video != -1)
|
if (_VideoEnabled && _Video != -1)
|
||||||
{
|
{
|
||||||
CVideo.VdClose(_Video);
|
CVideo.VdClose(_Video);
|
||||||
@@ -195,6 +201,9 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static void Pause()
|
public static void Pause()
|
||||||
{
|
{
|
||||||
|
if (!_Playing)
|
||||||
|
return;
|
||||||
|
|
||||||
if (_VideoEnabled && _Video != -1)
|
if (_VideoEnabled && _Video != -1)
|
||||||
{
|
{
|
||||||
CVideo.VdPause(_Video);
|
CVideo.VdPause(_Video);
|
||||||
|
|||||||
@@ -797,10 +797,16 @@ namespace Vocaluxe.Base
|
|||||||
data.id = Sqlite3.sqlite3_column_int(Stmt, 0);
|
data.id = Sqlite3.sqlite3_column_int(Stmt, 0);
|
||||||
|
|
||||||
byte[] bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 1);
|
byte[] bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 1);
|
||||||
data.str1 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes));
|
if (bytes != null)
|
||||||
|
data.str1 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes));
|
||||||
|
else
|
||||||
|
data.str1 = "Someone";
|
||||||
|
|
||||||
bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 2);
|
bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 2);
|
||||||
data.str2 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes));
|
if (bytes != null)
|
||||||
|
data.str2 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes));
|
||||||
|
else
|
||||||
|
data.str2 = "Someone";
|
||||||
|
|
||||||
songs.Add(data);
|
songs.Add(data);
|
||||||
}
|
}
|
||||||
@@ -832,7 +838,10 @@ namespace Vocaluxe.Base
|
|||||||
data.id = Sqlite3.sqlite3_column_int(Stmt, 0);
|
data.id = Sqlite3.sqlite3_column_int(Stmt, 0);
|
||||||
|
|
||||||
byte[] bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 1);
|
byte[] bytes = Sqlite3.sqlite3_column_rawbytes(Stmt, 1);
|
||||||
data.str1 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes));
|
if (bytes != null)
|
||||||
|
data.str1 = UTF8.GetString(Encoding.Convert(CP1252, UTF8, bytes));
|
||||||
|
else
|
||||||
|
data.str1 = "Someone";
|
||||||
|
|
||||||
if (dateExists)
|
if (dateExists)
|
||||||
data.ticks = UnixTimeToTicks(Sqlite3.sqlite3_column_int(Stmt, 2));
|
data.ticks = UnixTimeToTicks(Sqlite3.sqlite3_column_int(Stmt, 2));
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace Vocaluxe.Base
|
|||||||
public const int iVersionSub = 0; // patches
|
public const int iVersionSub = 0; // patches
|
||||||
public const ERevision VersionRevision = ERevision.Alpha;
|
public const ERevision VersionRevision = ERevision.Alpha;
|
||||||
|
|
||||||
public const int iBuild = 63; // Increase on every published version! Never Reset!
|
public const int iBuild = 65; // Increase on every published version! Never Reset!
|
||||||
|
|
||||||
public const int iDatabaseHighscoreVersion = 1;
|
public const int iDatabaseHighscoreVersion = 1;
|
||||||
public const int iDatabaseCoverVersion = 1;
|
public const int iDatabaseCoverVersion = 1;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
using Vocaluxe.Lib.Draw;
|
using Vocaluxe.Lib.Draw;
|
||||||
@@ -95,4 +97,100 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
#endregion VideoDecoder
|
#endregion VideoDecoder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class VideoPlayer
|
||||||
|
{
|
||||||
|
private STexture _VideoTexture;
|
||||||
|
private int _VideoStream;
|
||||||
|
private Stopwatch _VideoTimer;
|
||||||
|
private bool _Finished;
|
||||||
|
private bool _Loaded;
|
||||||
|
|
||||||
|
public bool IsFinished
|
||||||
|
{
|
||||||
|
get { return _Finished || !_Loaded; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Loop
|
||||||
|
{
|
||||||
|
set { CVideo.VdSetLoop(_VideoStream, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public VideoPlayer()
|
||||||
|
{
|
||||||
|
_VideoTimer = new Stopwatch();
|
||||||
|
_VideoTexture = new STexture(-1);
|
||||||
|
_Finished = false;
|
||||||
|
_Loaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Load(string VideoName)
|
||||||
|
{
|
||||||
|
_VideoStream = CVideo.VdLoad(CTheme.GetVideoFilePath(VideoName));
|
||||||
|
_Loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
_VideoTimer.Reset();
|
||||||
|
_Finished = false;
|
||||||
|
//CVideo.VdSkip(_VideoStream, 0f, 0f);
|
||||||
|
_VideoTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Pause()
|
||||||
|
{
|
||||||
|
_VideoTimer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Resume()
|
||||||
|
{
|
||||||
|
_VideoTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Draw()
|
||||||
|
{
|
||||||
|
if (!_Finished)
|
||||||
|
{
|
||||||
|
|
||||||
|
float VideoTime = _VideoTimer.ElapsedMilliseconds / 1000f;
|
||||||
|
_Finished = CVideo.VdFinished(_VideoStream);
|
||||||
|
|
||||||
|
STexture tex = new STexture(-1);
|
||||||
|
tex.height = 0f;
|
||||||
|
CVideo.VdGetFrame(_VideoStream, ref tex, VideoTime, ref VideoTime);
|
||||||
|
|
||||||
|
if (tex.height > 0)
|
||||||
|
{
|
||||||
|
CDraw.RemoveTexture(ref _VideoTexture);
|
||||||
|
_VideoTexture = tex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RectangleF bounds = new RectangleF(0f, 0f, CSettings.iRenderW, CSettings.iRenderH);
|
||||||
|
RectangleF rect = new RectangleF(0f, 0f, _VideoTexture.width, _VideoTexture.height);
|
||||||
|
CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop);
|
||||||
|
|
||||||
|
CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.zFar / 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PreLoad()
|
||||||
|
{
|
||||||
|
float VideoTime = 0f;
|
||||||
|
while (_VideoTexture.index == -1 && VideoTime < 1f)
|
||||||
|
{
|
||||||
|
float dummy = 0f;
|
||||||
|
CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, ref dummy);
|
||||||
|
VideoTime += 0.05f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
CVideo.VdClose(_VideoStream);
|
||||||
|
CDraw.RemoveTexture(ref _VideoTexture);
|
||||||
|
_Loaded = false;
|
||||||
|
_Finished = false;
|
||||||
|
_VideoTimer.Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -389,9 +389,9 @@ namespace Vocaluxe.Lib.Song
|
|||||||
TempC = (char)sr.Read();
|
TempC = (char)sr.Read();
|
||||||
} while ((TempC.CompareTo(':') != 0) && (TempC.CompareTo('F') != 0) && (TempC.CompareTo('*') != 0) && (TempC.CompareTo('P') != 0));
|
} while ((TempC.CompareTo(':') != 0) && (TempC.CompareTo('F') != 0) && (TempC.CompareTo('*') != 0) && (TempC.CompareTo('P') != 0));
|
||||||
|
|
||||||
FileLineNo++;
|
|
||||||
while (!sr.EndOfStream && (TempC.CompareTo('E') != 0))
|
while (!sr.EndOfStream && (TempC.CompareTo('E') != 0))
|
||||||
{
|
{
|
||||||
|
FileLineNo++;
|
||||||
if (TempC.CompareTo('P') == 0)
|
if (TempC.CompareTo('P') == 0)
|
||||||
{
|
{
|
||||||
char chr = (char)sr.Read();
|
char chr = (char)sr.Read();
|
||||||
@@ -466,7 +466,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
{
|
{
|
||||||
c = sr.Read();
|
c = sr.Read();
|
||||||
TempC = (char)c;
|
TempC = (char)c;
|
||||||
} while ((TempC.CompareTo('E') != 0) && !sr.EndOfStream && (c == 19 || c == 16 || c == 13));
|
} while ((TempC.CompareTo('E') != 0) && !sr.EndOfStream && (c == 19 || c == 16 || c == 13 || c==10));
|
||||||
}
|
}
|
||||||
foreach(CLines lines in this.Notes.Lines)
|
foreach(CLines lines in this.Notes.Lines)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -422,10 +422,10 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
|
|
||||||
private Thread _DecoderThread;
|
private Thread _DecoderThread;
|
||||||
|
|
||||||
AutoResetEvent EventDecode = new AutoResetEvent(false);
|
private AutoResetEvent EventDecode = new AutoResetEvent(false);
|
||||||
|
|
||||||
Object MutexData = new Object();
|
private Object _LockData = new Object();
|
||||||
Object MutexSyncSignals = new Object();
|
private Object _LockSyncSignals = new Object();
|
||||||
|
|
||||||
public PortAudioStream()
|
public PortAudioStream()
|
||||||
{
|
{
|
||||||
@@ -456,7 +456,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
lock (MutexData)
|
lock (_LockData)
|
||||||
{
|
{
|
||||||
return _NoMoreData && _data.BytesNotRead == 0L;
|
return _NoMoreData && _data.BytesNotRead == 0L;
|
||||||
}
|
}
|
||||||
@@ -468,7 +468,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
get { return _Volume * 100f; }
|
get { return _Volume * 100f; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
lock (MutexData)
|
lock (_LockData)
|
||||||
{
|
{
|
||||||
_Volume = value / 100f;
|
_Volume = value / 100f;
|
||||||
if (_Volume < 0f)
|
if (_Volume < 0f)
|
||||||
@@ -484,7 +484,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
lock (MutexData)
|
lock (_LockData)
|
||||||
{
|
{
|
||||||
if (Finished)
|
if (Finished)
|
||||||
_SyncTimer.Pause();
|
_SyncTimer.Pause();
|
||||||
@@ -500,7 +500,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_Paused = value;
|
_Paused = value;
|
||||||
lock (MutexSyncSignals)
|
lock (_LockData)
|
||||||
{
|
{
|
||||||
if (_Paused)
|
if (_Paused)
|
||||||
_SyncTimer.Pause();
|
_SyncTimer.Pause();
|
||||||
@@ -615,12 +615,13 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
outputParams.sampleFormat = PortAudio.PaSampleFormat.paInt16;
|
outputParams.sampleFormat = PortAudio.PaSampleFormat.paInt16;
|
||||||
outputParams.suggestedLatency = _outputDeviceInfo.defaultLowOutputLatency;
|
outputParams.suggestedLatency = _outputDeviceInfo.defaultLowOutputLatency;
|
||||||
|
|
||||||
|
uint bufsize = (uint)CConfig.AudioBufferSize;
|
||||||
errorCheck("OpenDefaultStream", PortAudio.Pa_OpenStream(
|
errorCheck("OpenDefaultStream", PortAudio.Pa_OpenStream(
|
||||||
out _Ptr,
|
out _Ptr,
|
||||||
IntPtr.Zero,
|
IntPtr.Zero,
|
||||||
ref outputParams,
|
ref outputParams,
|
||||||
format.SamplesPerSecond,
|
format.SamplesPerSecond,
|
||||||
(uint)CConfig.AudioBufferSize,
|
bufsize,
|
||||||
PortAudio.PaStreamFlags.paNoFlag,
|
PortAudio.PaStreamFlags.paNoFlag,
|
||||||
_paStreamCallback,
|
_paStreamCallback,
|
||||||
data));
|
data));
|
||||||
@@ -645,7 +646,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
|
|
||||||
public bool Skip(float Time)
|
public bool Skip(float Time)
|
||||||
{
|
{
|
||||||
lock (MutexSyncSignals)
|
lock (_LockSyncSignals)
|
||||||
{
|
{
|
||||||
_SetStart = Time;
|
_SetStart = Time;
|
||||||
_SetSkip = true;
|
_SetSkip = true;
|
||||||
@@ -658,7 +659,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
#region Threading
|
#region Threading
|
||||||
private void DoSkip()
|
private void DoSkip()
|
||||||
{
|
{
|
||||||
lock (MutexData)
|
lock (_LockData)
|
||||||
{
|
{
|
||||||
_Decoder.SetPosition(_Start);
|
_Decoder.SetPosition(_Start);
|
||||||
_CurrentTime = _Start;
|
_CurrentTime = _Start;
|
||||||
@@ -677,7 +678,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
{
|
{
|
||||||
if (EventDecode.WaitOne(10))
|
if (EventDecode.WaitOne(10))
|
||||||
{
|
{
|
||||||
lock (MutexSyncSignals)
|
lock (_LockSyncSignals)
|
||||||
{
|
{
|
||||||
if (_SetSkip)
|
if (_SetSkip)
|
||||||
{
|
{
|
||||||
@@ -724,7 +725,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
byte[] Buffer;
|
byte[] Buffer;
|
||||||
|
|
||||||
bool DoIt = false;
|
bool DoIt = false;
|
||||||
lock (MutexData)
|
lock (_LockData)
|
||||||
{
|
{
|
||||||
if (!_skip && BUFSIZE - 10000L > _data.BytesNotRead)
|
if (!_skip && BUFSIZE - 10000L > _data.BytesNotRead)
|
||||||
DoIt = true;
|
DoIt = true;
|
||||||
@@ -739,7 +740,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
{
|
{
|
||||||
if (_Loop)
|
if (_Loop)
|
||||||
{
|
{
|
||||||
lock (MutexSyncSignals)
|
lock (_LockSyncSignals)
|
||||||
{
|
{
|
||||||
_CurrentTime = 0f;
|
_CurrentTime = 0f;
|
||||||
_Start = 0f;
|
_Start = 0f;
|
||||||
@@ -754,7 +755,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (MutexData)
|
lock (_LockData)
|
||||||
{
|
{
|
||||||
_data.Write(Buffer);
|
_data.Write(Buffer);
|
||||||
_TimeCode = Timecode;
|
_TimeCode = Timecode;
|
||||||
@@ -804,7 +805,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
return PortAudio.PaStreamCallbackResult.paContinue;
|
return PortAudio.PaStreamCallbackResult.paContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (MutexData)
|
lock (_LockData)
|
||||||
{
|
{
|
||||||
if (_NoMoreData || _data.BytesNotRead >= buf.Length)
|
if (_NoMoreData || _data.BytesNotRead >= buf.Length)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -167,21 +167,6 @@ static int64_t io_seek(void *opaque, int64_t pos, int whence)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//uint64_t global_video_pkt_pts = AV_NOPTS_VALUE;
|
|
||||||
|
|
||||||
int ac_get_buffer(struct AVCodecContext *c, AVFrame *pic) {
|
|
||||||
int ret = avcodec_default_get_buffer(c, pic);
|
|
||||||
uint64_t *pts = av_malloc(sizeof(uint64_t));
|
|
||||||
*pts = AV_NOPTS_VALUE;
|
|
||||||
pic->opaque = pts;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ac_release_buffer(struct AVCodecContext *c, AVFrame *pic){
|
|
||||||
if (pic) av_freep(&pic->opaque);
|
|
||||||
avcodec_default_release_buffer(c, pic);
|
|
||||||
}
|
|
||||||
|
|
||||||
lp_ac_proberesult CALL_CONVT ac_probe_input_buffer(
|
lp_ac_proberesult CALL_CONVT ac_probe_input_buffer(
|
||||||
void* buf,
|
void* buf,
|
||||||
int bufsize,
|
int bufsize,
|
||||||
@@ -534,6 +519,9 @@ void* ac_create_video_decoder(lp_ac_instance pacInstance, lp_ac_stream_info info
|
|||||||
return NULL; //Codec could not have been found
|
return NULL; //Codec could not have been found
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pDecoder->pCodecCtx->thread_count = 1; //this is for HT CPUs, it should be
|
||||||
|
// tested if there is a better solution
|
||||||
|
|
||||||
//Open codec
|
//Open codec
|
||||||
if (avcodec_open2(pDecoder->pCodecCtx, pDecoder->pCodec, NULL) < 0) {
|
if (avcodec_open2(pDecoder->pCodecCtx, pDecoder->pCodec, NULL) < 0) {
|
||||||
return NULL; //Codec could not have been opened
|
return NULL; //Codec could not have been opened
|
||||||
@@ -635,36 +623,34 @@ double ac_sync_video(lp_ac_package pPackage, lp_ac_decoder pDec, AVFrame *src_fr
|
|||||||
return pts;
|
return pts;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ac_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder, lp_ac_decoder pDec) {
|
int ac_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder, lp_ac_decoder pDec)
|
||||||
if (((lp_ac_package_data)pPackage)->ffpackage.size <= 0)
|
{
|
||||||
return 0;
|
|
||||||
|
|
||||||
int finished = 0;
|
int finished = 0;
|
||||||
double pts = 0;
|
double pts = 0;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
AVPacket pkt_tmp = ((lp_ac_package_data)pPackage)->ffpackage;
|
||||||
|
|
||||||
|
while (pkt_tmp.size > 0) {
|
||||||
|
len = avcodec_decode_video2(
|
||||||
|
pDecoder->pCodecCtx, pDecoder->pFrame,
|
||||||
|
&finished, &pkt_tmp);
|
||||||
|
|
||||||
|
if (len < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pkt_tmp.size -= len;
|
||||||
|
pkt_tmp.data += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
avcodec_decode_video2(
|
avcodec_decode_video2(
|
||||||
pDecoder->pCodecCtx, pDecoder->pFrame, &finished,
|
pDecoder->pCodecCtx, pDecoder->pFrame, &finished,
|
||||||
&(((lp_ac_package_data)pPackage)->ffpackage));
|
&(((lp_ac_package_data)pPackage)->ffpackage));
|
||||||
|
*/
|
||||||
|
|
||||||
if (finished) {
|
if (finished != 0) {
|
||||||
if(((lp_ac_package_data)pPackage)->ffpackage.dts == AV_NOPTS_VALUE &&
|
|
||||||
*(uint64_t*)pDecoder->pFrame->opaque != AV_NOPTS_VALUE ){
|
|
||||||
pts = *(uint64_t*)pDecoder->pFrame->opaque;
|
|
||||||
} else if(((lp_ac_package_data)pPackage)->ffpackage.dts != AV_NOPTS_VALUE){
|
|
||||||
pts = ((lp_ac_package_data)pPackage)->ffpackage.dts;
|
|
||||||
} else {
|
|
||||||
pts = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->start_time != AV_NOPTS_VALUE){
|
|
||||||
pts -= ((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->start_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
pts *= av_q2d(((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->time_base);
|
|
||||||
|
|
||||||
pts = ac_sync_video(pPackage, pDec, pDecoder->pFrame, pts);
|
|
||||||
pDec->timecode = pts;
|
|
||||||
|
|
||||||
pDecoder->pSwsCtx = sws_getCachedContext(pDecoder->pSwsCtx,
|
pDecoder->pSwsCtx = sws_getCachedContext(pDecoder->pSwsCtx,
|
||||||
pDecoder->pCodecCtx->width, pDecoder->pCodecCtx->height, pDecoder->pCodecCtx->pix_fmt,
|
pDecoder->pCodecCtx->width, pDecoder->pCodecCtx->height, pDecoder->pCodecCtx->pix_fmt,
|
||||||
pDecoder->pCodecCtx->width, pDecoder->pCodecCtx->height, convert_pix_format(pDecoder->decoder.pacInstance->output_format),
|
pDecoder->pCodecCtx->width, pDecoder->pCodecCtx->height, convert_pix_format(pDecoder->decoder.pacInstance->output_format),
|
||||||
@@ -678,6 +664,24 @@ int ac_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder
|
|||||||
pDecoder->pCodecCtx->height,
|
pDecoder->pCodecCtx->height,
|
||||||
pDecoder->pFrameRGB->data,
|
pDecoder->pFrameRGB->data,
|
||||||
pDecoder->pFrameRGB->linesize);
|
pDecoder->pFrameRGB->linesize);
|
||||||
|
|
||||||
|
|
||||||
|
if(pkt_tmp.dts == AV_NOPTS_VALUE &&
|
||||||
|
*(uint64_t*)pDecoder->pFrame->opaque != AV_NOPTS_VALUE ){
|
||||||
|
pts = *(uint64_t*)pDecoder->pFrame->opaque;
|
||||||
|
} else if(pkt_tmp.dts != AV_NOPTS_VALUE){
|
||||||
|
pts = pkt_tmp.dts;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->start_time != AV_NOPTS_VALUE){
|
||||||
|
pts -= ((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->start_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
pts *= av_q2d(((lp_ac_data)pDec->pacInstance)->pFormatCtx->streams[pPackage->stream_index]->time_base);
|
||||||
|
|
||||||
|
pts = ac_sync_video(pPackage, pDec, pDecoder->pFrame, pts);
|
||||||
|
pDec->timecode = pts;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -795,10 +799,22 @@ int CALL_CONVT ac_drop_decode_package(lp_ac_package pPackage, lp_ac_decoder pDec
|
|||||||
int ac_drop_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder, lp_ac_decoder pDec) {
|
int ac_drop_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder, lp_ac_decoder pDec) {
|
||||||
int finished;
|
int finished;
|
||||||
double pts;
|
double pts;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
avcodec_decode_video2(
|
AVPacket pkt_tmp = ((lp_ac_package_data)pPackage)->ffpackage;
|
||||||
pDecoder->pCodecCtx, pDecoder->pFrame, &finished,
|
|
||||||
&(((lp_ac_package_data)pPackage)->ffpackage));
|
while (pkt_tmp.size > 0) {
|
||||||
|
len = avcodec_decode_video2(
|
||||||
|
pDecoder->pCodecCtx, pDecoder->pFrame,
|
||||||
|
&finished, &pkt_tmp);
|
||||||
|
|
||||||
|
if (len < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pkt_tmp.size -= len;
|
||||||
|
pkt_tmp.data += len;
|
||||||
|
}
|
||||||
|
|
||||||
if (finished) {
|
if (finished) {
|
||||||
pts=0;
|
pts=0;
|
||||||
@@ -860,11 +876,12 @@ int CALL_CONVT ac_get_frame(lp_ac_instance pacInstance, lp_ac_decoder pDecoder)
|
|||||||
|
|
||||||
lp_ac_package pPackage = ac_read_package(pacInstance);
|
lp_ac_package pPackage = ac_read_package(pacInstance);
|
||||||
int done = 0;
|
int done = 0;
|
||||||
|
int pcount = 0;
|
||||||
while(done == 0 && pPackage != NULL){
|
while(done == 0 && pPackage != NULL){
|
||||||
if (((lp_ac_package_data)pPackage)->package.stream_index == pDecoder->stream_index){
|
if (((lp_ac_package_data)pPackage)->package.stream_index == pDecoder->stream_index){
|
||||||
done = ac_decode_package(pPackage, pDecoder);
|
done = ac_decode_package(pPackage, pDecoder);
|
||||||
ac_free_package(pPackage);
|
ac_free_package(pPackage);
|
||||||
|
pcount++;
|
||||||
if (done == 0)
|
if (done == 0)
|
||||||
pPackage = ac_read_package(pacInstance);
|
pPackage = ac_read_package(pacInstance);
|
||||||
} else {
|
} else {
|
||||||
@@ -876,7 +893,7 @@ int CALL_CONVT ac_get_frame(lp_ac_instance pacInstance, lp_ac_decoder pDecoder)
|
|||||||
if (done == 0)
|
if (done == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return pcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CALL_CONVT ac_skip_frames(lp_ac_instance pacInstance, lp_ac_decoder pDecoder, int num) {
|
int CALL_CONVT ac_skip_frames(lp_ac_instance pacInstance, lp_ac_decoder pDecoder, int num) {
|
||||||
|
|||||||
@@ -258,8 +258,9 @@ namespace Vocaluxe.Lib.Video
|
|||||||
private bool _terminated = false;
|
private bool _terminated = false;
|
||||||
|
|
||||||
private Thread _thread;
|
private Thread _thread;
|
||||||
AutoResetEvent EventDecode = new AutoResetEvent(false);
|
//AutoResetEvent EventDecode = new AutoResetEvent(false);
|
||||||
SFrameBuffer[] _FrameBuffer = new SFrameBuffer[5];
|
SFrameBuffer[] _FrameBuffer = new SFrameBuffer[5];
|
||||||
|
private bool _NewFrame = false;
|
||||||
Object MutexFramebuffer = new Object();
|
Object MutexFramebuffer = new Object();
|
||||||
Object MutexSyncSignals = new Object();
|
Object MutexSyncSignals = new Object();
|
||||||
|
|
||||||
@@ -359,7 +360,7 @@ namespace Vocaluxe.Lib.Video
|
|||||||
|
|
||||||
|
|
||||||
UploadNewFrame(ref frame);
|
UploadNewFrame(ref frame);
|
||||||
EventDecode.Set();
|
//EventDecode.Set();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,10 +369,10 @@ namespace Vocaluxe.Lib.Video
|
|||||||
lock (MutexSyncSignals)
|
lock (MutexSyncSignals)
|
||||||
{
|
{
|
||||||
_SetTime = Time;
|
_SetTime = Time;
|
||||||
VideoTime = _CurrentVideoTime;
|
|
||||||
}
|
}
|
||||||
UploadNewFrame(ref frame);
|
UploadNewFrame(ref frame);
|
||||||
EventDecode.Set();
|
VideoTime = _CurrentVideoTime;
|
||||||
|
//EventDecode.Set();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -387,7 +388,7 @@ namespace Vocaluxe.Lib.Video
|
|||||||
_NoMoreFrames = false;
|
_NoMoreFrames = false;
|
||||||
_Finished = false;
|
_Finished = false;
|
||||||
}
|
}
|
||||||
EventDecode.Set();
|
//EventDecode.Set();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -441,17 +442,18 @@ namespace Vocaluxe.Lib.Video
|
|||||||
|
|
||||||
_BufferFull = false;
|
_BufferFull = false;
|
||||||
_skip = false;
|
_skip = false;
|
||||||
EventDecode.Set();
|
_NewFrame = false;
|
||||||
|
//EventDecode.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Execute()
|
private void Execute()
|
||||||
{
|
{
|
||||||
DoOpen();
|
DoOpen();
|
||||||
EventDecode.Set();
|
//EventDecode.Set();
|
||||||
|
|
||||||
while (!_terminated)
|
while (!_terminated)
|
||||||
{
|
{
|
||||||
if (EventDecode.WaitOne(10))
|
//if (EventDecode.WaitOne(10))
|
||||||
{
|
{
|
||||||
lock (MutexSyncSignals)
|
lock (MutexSyncSignals)
|
||||||
{
|
{
|
||||||
@@ -468,11 +470,12 @@ namespace Vocaluxe.Lib.Video
|
|||||||
if (_skip)
|
if (_skip)
|
||||||
DoSkip();
|
DoSkip();
|
||||||
|
|
||||||
if (!_BufferFull)
|
if (!_NewFrame)
|
||||||
DoDecode();
|
DoDecode();
|
||||||
|
|
||||||
if (_BufferFull)
|
if (_NewFrame)
|
||||||
Copy();
|
Copy();
|
||||||
|
Thread.Sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,7 +558,7 @@ namespace Vocaluxe.Lib.Video
|
|||||||
{
|
{
|
||||||
const int FRAMEDROPCOUNT = 4;
|
const int FRAMEDROPCOUNT = 4;
|
||||||
|
|
||||||
if (!_FileOpened)
|
if (!_FileOpened || _NewFrame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_Paused || _NoMoreFrames || _BufferFull)
|
if (_Paused || _NoMoreFrames || _BufferFull)
|
||||||
@@ -641,12 +644,18 @@ namespace Vocaluxe.Lib.Video
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
Copy();
|
{
|
||||||
|
_NewFrame = true;
|
||||||
|
Copy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Copy()
|
private void Copy()
|
||||||
{
|
{
|
||||||
|
if (!_NewFrame)
|
||||||
|
return;
|
||||||
|
|
||||||
int num = -1;
|
int num = -1;
|
||||||
|
|
||||||
lock (MutexFramebuffer)
|
lock (MutexFramebuffer)
|
||||||
@@ -687,11 +696,13 @@ namespace Vocaluxe.Lib.Video
|
|||||||
|
|
||||||
if (numfull < _FrameBuffer.Length)
|
if (numfull < _FrameBuffer.Length)
|
||||||
_BufferFull = false;
|
_BufferFull = false;
|
||||||
|
|
||||||
|
_NewFrame = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_BufferFull)
|
//if (!_BufferFull)
|
||||||
EventDecode.Set();
|
// EventDecode.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UploadNewFrame(ref STexture frame)
|
private void UploadNewFrame(ref STexture frame)
|
||||||
@@ -720,7 +731,7 @@ namespace Vocaluxe.Lib.Video
|
|||||||
_CurrentVideoTime = _FrameBuffer[num].time;
|
_CurrentVideoTime = _FrameBuffer[num].time;
|
||||||
}
|
}
|
||||||
_Finished = false;
|
_Finished = false;
|
||||||
EventDecode.Set();
|
//EventDecode.Set();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -739,7 +750,7 @@ namespace Vocaluxe.Lib.Video
|
|||||||
{
|
{
|
||||||
float td = _SetTime + _VideoSkipTime - _FrameBuffer[i].time;
|
float td = _SetTime + _VideoSkipTime - _FrameBuffer[i].time;
|
||||||
|
|
||||||
if (td > _VideoTimeBase * 2)
|
if (td > _VideoTimeBase * 2f)
|
||||||
{
|
{
|
||||||
_FrameBuffer[i].displayed = true;
|
_FrameBuffer[i].displayed = true;
|
||||||
}
|
}
|
||||||
@@ -754,6 +765,7 @@ namespace Vocaluxe.Lib.Video
|
|||||||
if (Result != -1)
|
if (Result != -1)
|
||||||
{
|
{
|
||||||
_FrameBuffer[Result].displayed = true;
|
_FrameBuffer[Result].displayed = true;
|
||||||
|
_BufferFull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
|
|||||||
+20
-104
@@ -31,6 +31,8 @@ namespace Vocaluxe.Screens
|
|||||||
private bool _IntroOutPlayed;
|
private bool _IntroOutPlayed;
|
||||||
private VideoPlayer[] _Intros;
|
private VideoPlayer[] _Intros;
|
||||||
|
|
||||||
|
private bool _BGMusicStartet;
|
||||||
|
|
||||||
|
|
||||||
public CScreenLoad()
|
public CScreenLoad()
|
||||||
{
|
{
|
||||||
@@ -121,8 +123,7 @@ namespace Vocaluxe.Screens
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CBackgroundMusic.Playing)
|
_BGMusicStartet = false;
|
||||||
CBackgroundMusic.Next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnShowFinish()
|
public override void OnShowFinish()
|
||||||
@@ -142,8 +143,18 @@ namespace Vocaluxe.Screens
|
|||||||
_SongLoaderThread.Start();
|
_SongLoaderThread.Start();
|
||||||
_timer.Start();
|
_timer.Start();
|
||||||
|
|
||||||
if (!CBackgroundMusic.Playing)
|
if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON &&
|
||||||
CBackgroundMusic.Next();
|
CConfig.BackgroundMusicSource == EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC && !_BGMusicStartet)
|
||||||
|
{
|
||||||
|
CBackgroundMusic.AddOwnMusic();
|
||||||
|
|
||||||
|
if (!CBackgroundMusic.Playing)
|
||||||
|
CBackgroundMusic.Next();
|
||||||
|
|
||||||
|
_BGMusicStartet = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CBackgroundMusic.CanSing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool UpdateGame()
|
public override bool UpdateGame()
|
||||||
@@ -172,14 +183,15 @@ namespace Vocaluxe.Screens
|
|||||||
CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")";
|
CLanguage.Translate("TR_SCREENLOAD_LOADED") + ")";
|
||||||
|
|
||||||
if (CSongs.SongsLoaded && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON &&
|
if (CSongs.SongsLoaded && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON &&
|
||||||
CConfig.BackgroundMusicSource != EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC)
|
CConfig.BackgroundMusicSource != EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC && !_BGMusicStartet)
|
||||||
{
|
{
|
||||||
CBackgroundMusic.AddOwnMusic();
|
CBackgroundMusic.AddOwnMusic();
|
||||||
|
|
||||||
//if (!CBackgroundMusic.Playing)
|
if (!CBackgroundMusic.Playing)
|
||||||
// CBackgroundMusic.Next();
|
CBackgroundMusic.Next();
|
||||||
|
|
||||||
|
_BGMusicStartet = true;
|
||||||
}
|
}
|
||||||
CBackgroundMusic.CanSing = false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -248,100 +260,4 @@ namespace Vocaluxe.Screens
|
|||||||
_IntroOutPlayed = true;
|
_IntroOutPlayed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VideoPlayer
|
|
||||||
{
|
|
||||||
private STexture _VideoTexture;
|
|
||||||
private int _VideoStream;
|
|
||||||
private Stopwatch _VideoTimer;
|
|
||||||
private bool _Finished;
|
|
||||||
private bool _Loaded;
|
|
||||||
|
|
||||||
public bool IsFinished
|
|
||||||
{
|
|
||||||
get { return _Finished || !_Loaded; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Loop
|
|
||||||
{
|
|
||||||
set { CVideo.VdSetLoop(_VideoStream, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public VideoPlayer()
|
|
||||||
{
|
|
||||||
_VideoTimer = new Stopwatch();
|
|
||||||
_VideoTexture = new STexture(-1);
|
|
||||||
_Finished = false;
|
|
||||||
_Loaded = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Load(string VideoName)
|
|
||||||
{
|
|
||||||
_VideoStream = CVideo.VdLoad(CTheme.GetVideoFilePath(VideoName));
|
|
||||||
_Loaded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
_VideoTimer.Reset();
|
|
||||||
_Finished = false;
|
|
||||||
//CVideo.VdSkip(_VideoStream, 0f, 0f);
|
|
||||||
_VideoTimer.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Pause()
|
|
||||||
{
|
|
||||||
_VideoTimer.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Resume()
|
|
||||||
{
|
|
||||||
_VideoTimer.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Draw()
|
|
||||||
{
|
|
||||||
if (!_Finished)
|
|
||||||
{
|
|
||||||
|
|
||||||
float VideoTime = _VideoTimer.ElapsedMilliseconds / 1000f;
|
|
||||||
_Finished = CVideo.VdFinished(_VideoStream);
|
|
||||||
|
|
||||||
STexture tex = new STexture(-1);
|
|
||||||
tex.height = 0f;
|
|
||||||
CVideo.VdGetFrame(_VideoStream, ref tex, VideoTime, ref VideoTime);
|
|
||||||
|
|
||||||
if (tex.height > 0)
|
|
||||||
{
|
|
||||||
CDraw.RemoveTexture(ref _VideoTexture);
|
|
||||||
_VideoTexture = tex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RectangleF bounds = new RectangleF(0f, 0f, CSettings.iRenderW, CSettings.iRenderH);
|
|
||||||
RectangleF rect = new RectangleF(0f, 0f, _VideoTexture.width, _VideoTexture.height);
|
|
||||||
CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop);
|
|
||||||
|
|
||||||
CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.zFar / 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PreLoad()
|
|
||||||
{
|
|
||||||
float VideoTime = 0f;
|
|
||||||
while (_VideoTexture.index == -1 && VideoTime < 1f)
|
|
||||||
{
|
|
||||||
float dummy = 0f;
|
|
||||||
CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, ref dummy);
|
|
||||||
VideoTime += 0.05f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
CVideo.VdClose(_VideoStream);
|
|
||||||
CDraw.RemoveTexture(ref _VideoTexture);
|
|
||||||
_Loaded = false;
|
|
||||||
_Finished = false;
|
|
||||||
_VideoTimer.Reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -183,16 +183,19 @@ namespace Vocaluxe.Screens
|
|||||||
SongMenus[htSongMenus(SongMenu)].Update();
|
SongMenus[htSongMenus(SongMenu)].Update();
|
||||||
Texts[htTexts(TextCategory)].Text = CSongs.GetActualCategoryName();
|
Texts[htTexts(TextCategory)].Text = CSongs.GetActualCategoryName();
|
||||||
|
|
||||||
|
if (CSongs.Category > -1 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF)
|
||||||
|
CBackgroundMusic.Disabled = true;
|
||||||
|
else
|
||||||
|
CBackgroundMusic.Disabled = false;
|
||||||
|
|
||||||
int song = SongMenus[htSongMenus(SongMenu)].GetActualSelection();
|
int song = SongMenus[htSongMenus(SongMenu)].GetActualSelection();
|
||||||
if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Length)
|
if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Length)
|
||||||
{
|
{
|
||||||
Texts[htTexts(TextSelection)].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title;
|
Texts[htTexts(TextSelection)].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title;
|
||||||
CBackgroundMusic.Disabled = true;
|
|
||||||
}
|
}
|
||||||
else if (CSongs.Category == -1 && song >= 0 && song < CSongs.Categories.Length)
|
else if (CSongs.Category == -1 && song >= 0 && song < CSongs.Categories.Length)
|
||||||
{
|
{
|
||||||
Texts[htTexts(TextSelection)].Text = CSongs.Categories[song].Name;
|
Texts[htTexts(TextSelection)].Text = CSongs.Categories[song].Name;
|
||||||
CBackgroundMusic.Disabled = false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Texts[htTexts(TextSelection)].Text = String.Empty;
|
Texts[htTexts(TextSelection)].Text = String.Empty;
|
||||||
|
|||||||
Reference in new issue
Block a user