mirror of https://github.com/odrling/Aegisub
Applied perchr's patch for a progress bar while loading keyframes on posix.
Originally committed to SVN as r1646.
This commit is contained in:
parent
4b607e9454
commit
76da71cef4
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
// Headers
|
// Headers
|
||||||
|
#include "dialog_progress.h"
|
||||||
#include "lavc_keyframes.h"
|
#include "lavc_keyframes.h"
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
|
@ -84,14 +85,28 @@ LAVCKeyFrames::~LAVCKeyFrames() {
|
||||||
// Parse file for keyframes
|
// Parse file for keyframes
|
||||||
wxArrayInt LAVCKeyFrames::GetKeyFrames() {
|
wxArrayInt LAVCKeyFrames::GetKeyFrames() {
|
||||||
wxArrayInt keyframes;
|
wxArrayInt keyframes;
|
||||||
|
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
|
int total_frames = stream->duration;
|
||||||
register unsigned int frameN = 0; // Number of parsed frames
|
register unsigned int frameN = 0; // Number of parsed frames
|
||||||
while (av_read_frame(file->fctx, &packet) >= 0) {
|
|
||||||
|
volatile bool canceled = false;
|
||||||
|
DialogProgress *progress = new DialogProgress(NULL,_("Load keyframes"),&canceled,_("Reading keyframes from video"),0,total_frames);
|
||||||
|
progress->Show();
|
||||||
|
progress->SetProgress(0,1);
|
||||||
|
|
||||||
|
while (av_read_frame(file->fctx, &packet) >= 0 && !canceled) {
|
||||||
// Check if packet is part of video stream
|
// Check if packet is part of video stream
|
||||||
if (packet.stream_index == streamN) {
|
if (packet.stream_index == streamN) {
|
||||||
// Increment number of passed frames
|
// Increment number of passed frames
|
||||||
++frameN;
|
++frameN;
|
||||||
|
|
||||||
|
/* Might need some adjustments here, to make it
|
||||||
|
appear as fluid as wanted. Just copied 2points thingy,
|
||||||
|
and reduced it a bit */
|
||||||
|
if ((frameN & (1024 - 1)) == 0)
|
||||||
|
progress->SetProgress(frameN,total_frames);
|
||||||
|
|
||||||
// Decode frame
|
// Decode frame
|
||||||
int frameFinished;
|
int frameFinished;
|
||||||
avcodec_decode_video(codecContext, frame, &frameFinished, packet.data, packet.size);
|
avcodec_decode_video(codecContext, frame, &frameFinished, packet.data, packet.size);
|
||||||
|
@ -107,7 +122,11 @@ wxArrayInt LAVCKeyFrames::GetKeyFrames() {
|
||||||
av_free_packet(&packet);
|
av_free_packet(&packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clean up progress
|
||||||
|
if (!canceled) progress->Destroy();
|
||||||
|
else throw wxString(_T("Keyframe loading cancelled by user"));
|
||||||
|
|
||||||
return keyframes;
|
return keyframes;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue