Fix some stuff from Coverity Scan

Mostly just bugs in unreachable code and stylistic things, but there's a
few incorrect reachable things that were working by coincidence and
gratuitous dynamic_casts.
This commit is contained in:
Thomas Goyne 2012-10-14 21:37:14 -07:00
parent ccafd0be17
commit 53433426bb
36 changed files with 149 additions and 217 deletions

View file

@ -78,7 +78,7 @@ uint64_t freespace(std::string const& path, PathType type) {
acs::CheckDirRead(check);
if ((statvfs(check.c_str(), &fs)) == 0) {
return fs.f_bsize * fs.f_bavail;
return (uint64_t)fs.f_bsize * fs.f_bavail;
} else {
/// @todo We need a collective set of exceptions for ENOTDIR, EIO etc.
throw("Failed getting free space");

View file

@ -290,7 +290,7 @@ void AssDialogue::StripTag (wxString tagName) {
continue;
}
AssDialogueBlockOverride *over = dynamic_cast<AssDialogueBlockOverride*>(*cur);
AssDialogueBlockOverride *over = static_cast<AssDialogueBlockOverride*>(*cur);
wxString temp;
for (size_t i = 0; i < over->Tags.size(); ++i) {
if (over->Tags[i]->Name != tagName)

View file

@ -206,6 +206,10 @@ void AssKaraoke::AddSplit(size_t syl_idx, size_t pos) {
if (new_syl.text.empty())
new_syl.duration = 0;
else if (syl.text.empty()) {
new_syl.duration = syl.duration;
syl.duration = 0;
}
else {
new_syl.duration = syl.duration * new_syl.text.size() / (syl.text.size() + new_syl.text.size());
syl.duration -= new_syl.duration;

View file

@ -183,7 +183,7 @@ class SecondsMarkerProvider : public AudioMarkerProvider {
Pen *style;
int position;
Marker(Pen *style) : style(style) { }
Marker(Pen *style) : style(style), position(0) { }
int GetPosition() const { return position; }
FeetStyle GetFeet() const { return Feet_None; }
bool CanSnap() const { return false; }

View file

@ -148,6 +148,7 @@ struct PlaybackState {
start_position = 0;
end_position = 0;
last_position = 0;
memset(&last_position_time, 0, sizeof last_position_time);
provider = 0;
}
};
@ -275,7 +276,7 @@ do_setup:
}
// Fill buffer
long tmp_pcm_avail = snd_pcm_avail(pcm);
snd_pcm_sframes_t tmp_pcm_avail = snd_pcm_avail(pcm);
if (tmp_pcm_avail == -EPIPE)
{
if (snd_pcm_recover(pcm, -EPIPE, 1) < 0)
@ -288,8 +289,8 @@ do_setup:
avail = std::min(tmp_pcm_avail, (snd_pcm_sframes_t)(ps.end_position-position));
if (avail < 0)
{
printf("\n--------- avail was less than 0: %" PRId64 "\n", avail);
printf("snd_pcm_avail(pcm): %" PRId64 "\n", tmp_pcm_avail);
printf("\n--------- avail was less than 0: %ld\n", (long)avail);
printf("snd_pcm_avail(pcm): %ld\n", (long)tmp_pcm_avail);
printf("original position: %" PRId64 "\n", orig_position);
printf("current position: %" PRId64 "\n", position);
printf("original ps.end_position: %" PRId64 "\n", orig_ps_end_position);

View file

@ -60,8 +60,11 @@
#include "utils.h"
PCMAudioProvider::PCMAudioProvider(const wxString &filename)
: current_mapping(0)
, mapping_start(0)
, mapping_length(0)
#ifdef _WIN32
: file_handle(0, CloseHandle)
, file_handle(0, CloseHandle)
, file_mapping(0, CloseHandle)
{
file_handle = CreateFile(
@ -91,11 +94,8 @@ PCMAudioProvider::PCMAudioProvider(const wxString &filename)
if (file_mapping == 0)
throw agi::AudioProviderOpenError("Failed creating file mapping", 0);
current_mapping = 0;
#else
: file_handle(open(filename.mb_str(*wxConvFileName), O_RDONLY), close)
, file_handle(open(filename.mb_str(*wxConvFileName), O_RDONLY), close)
{
if (file_handle == -1)
throw agi::FileNotFoundError(STD_STR(filename));
@ -107,8 +107,6 @@ PCMAudioProvider::PCMAudioProvider(const wxString &filename)
throw agi::AudioProviderOpenError("Could not stat file to get size", 0);
}
file_size = filestats.st_size;
current_mapping = 0;
#endif
float_samples = false;
}

View file

@ -56,19 +56,19 @@
///
/// DOCME
class PCMAudioProvider : public AudioProvider {
#ifdef _WIN32
agi::scoped_holder<HANDLE, BOOL (__stdcall *)(HANDLE)> file_handle;
agi::scoped_holder<HANDLE, BOOL (__stdcall *)(HANDLE)> file_mapping;
mutable void *current_mapping;
#ifdef _WIN32
mutable int64_t mapping_start;
mutable size_t mapping_length;
agi::scoped_holder<HANDLE, BOOL (__stdcall *)(HANDLE)> file_handle;
agi::scoped_holder<HANDLE, BOOL (__stdcall *)(HANDLE)> file_mapping;
#else
agi::scoped_holder<int, int(*)(int)> file_handle;
mutable void *current_mapping;
mutable off_t mapping_start;
mutable size_t mapping_length;
agi::scoped_holder<int, int(*)(int)> file_handle;
#endif
protected:

View file

@ -62,7 +62,13 @@ public:
{
}
KaraokeMarker(int position) : position(position) { }
KaraokeMarker(int position)
: position(position)
, pen(0)
, style(Feet_None)
{
}
operator int() const { return position; }
};

View file

@ -760,6 +760,7 @@ namespace Automation4 {
// LuaFeature
LuaFeature::LuaFeature(lua_State *L)
: L(L)
, myid(0)
{
}

View file

@ -716,7 +716,7 @@ namespace Automation4 {
, last_entry_id(1)
{
// prepare userdata object
*static_cast<LuaAssFile**>(lua_newuserdata(L, sizeof(LuaAssFile**))) = this;
*static_cast<LuaAssFile**>(lua_newuserdata(L, sizeof(LuaAssFile*))) = this;
// make the metatable
lua_newtable(L);

View file

@ -177,6 +177,7 @@ namespace Automation4 {
Edit(lua_State *L)
: LuaDialogControl(L)
, text(get_field(L, "value"))
, cw(0)
{
// Undocumented behaviour, 'value' is also accepted as key for text,
// mostly so a text control can stand in for other things.
@ -290,6 +291,7 @@ namespace Automation4 {
IntEdit(lua_State *L)
: Edit(L)
, cw(0)
, value(get_field(L, "value", 0))
, min(get_field(L, "min", INT_MIN))
, max(get_field(L, "max", INT_MAX))
@ -415,6 +417,7 @@ namespace Automation4 {
Dropdown(lua_State *L)
: LuaDialogControl(L)
, value(get_field(L, "value"))
, cw(0)
{
lua_getfield(L, -1, "items");
read_string_array(L, items);
@ -455,6 +458,7 @@ namespace Automation4 {
: LuaDialogControl(L)
, label(get_field(L, "label"))
, value(get_field(L, "value", false))
, cw(0)
{
}
@ -491,6 +495,7 @@ namespace Automation4 {
LuaDialog::LuaDialog(lua_State *L, bool include_buttons)
: use_buttons(include_buttons)
, button_pushed(0)
, window(0)
{
LOG_D("automation/lua/dialog") << "creating LuaDialoug, addr: " << this;

View file

@ -42,6 +42,8 @@
#include <algorithm>
#include <wx/clipbrd.h>
#include <wx/fontdlg.h>
#include <wx/tokenzr.h>
#endif
#include "command.h"

View file

@ -70,14 +70,8 @@ enum {
/// DOCME
struct ResolutionShortcut {
/// DOCME
const char *name;
/// DOCME
int width;
/// DOCME
int height;
};
@ -95,13 +89,6 @@ static ResolutionShortcut resolutions[] = {
{0, 0, 0}
};
/// @brief DOCME
/// @param parent
/// @param out_filename
/// @return
///
bool DialogDummyVideo::CreateDummyVideo(wxWindow *parent, wxString &out_filename)
{
DialogDummyVideo dlg(parent);
@ -156,9 +143,6 @@ bool DialogDummyVideo::CreateDummyVideo(wxWindow *parent, wxString &out_filename
}
}
/// @brief DOCME
/// @param parent
///
DialogDummyVideo::DialogDummyVideo(wxWindow *parent)
: wxDialog(parent, -1, _("Dummy video options"),wxDefaultPosition,wxDefaultSize)
{
@ -204,9 +188,6 @@ DialogDummyVideo::DialogDummyVideo(wxWindow *parent)
main_sizer->Add(new wxStaticLine(this,wxHORIZONTAL),0,wxALL|wxEXPAND,5);
main_sizer->Add(btnSizer,0,wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND,5);
// main_sizer->Add(CreateSeparatedButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
// ok_button = static_cast<wxButton*>(FindWindow(wxID_OK));
// cancel_button = static_cast<wxButton*>(FindWindow(wxID_CANCEL));
// Initialise controls
int lastwidth, lastheight, lastres = 0;
@ -219,11 +200,6 @@ DialogDummyVideo::DialogDummyVideo(wxWindow *parent)
lastres++;
}
pattern->SetValue(OPT_GET("Video/Dummy/Pattern")->GetBool());
/*fps->Append("23.976");
fps->Append("29.97");
fps->Append("24");
fps->Append("25");
fps->Append("30");*/
width->ChangeValue(AegiIntegerToString(OPT_GET("Video/Dummy/Last/Width")->GetInt()));
height->ChangeValue(AegiIntegerToString(OPT_GET("Video/Dummy/Last/Height")->GetInt()));
length->SetRange(0, 0x10000000);
@ -235,10 +211,6 @@ DialogDummyVideo::DialogDummyVideo(wxWindow *parent)
CenterOnParent();
}
/// @brief DOCME
///
DialogDummyVideo::~DialogDummyVideo()
{
}
@ -251,11 +223,6 @@ BEGIN_EVENT_TABLE(DialogDummyVideo,wxDialog)
EVT_TEXT(Dummy_Video_Length, DialogDummyVideo::OnLengthChange)
END_EVENT_TABLE()
/// @brief DOCME
/// @param evt
///
void DialogDummyVideo::OnResolutionShortcut(wxCommandEvent &)
{
int rs = resolution_shortcuts->GetSelection();
@ -263,40 +230,21 @@ void DialogDummyVideo::OnResolutionShortcut(wxCommandEvent &)
height->ChangeValue(wxString::Format("%d", resolutions[rs].height));
}
/// @brief DOCME
/// @param evt
///
void DialogDummyVideo::OnFpsChange(wxCommandEvent &)
{
UpdateLengthDisplay();
}
/// @brief DOCME
/// @param evt
///
void DialogDummyVideo::OnLengthSpin(wxSpinEvent &)
{
UpdateLengthDisplay();
}
/// @brief DOCME
/// @param evt
///
void DialogDummyVideo::OnLengthChange(wxCommandEvent &)
{
UpdateLengthDisplay();
}
/// @brief DOCME
///
void DialogDummyVideo::UpdateLengthDisplay()
{
double fpsval;
@ -323,5 +271,3 @@ void DialogDummyVideo::UpdateLengthDisplay()
ok_button->Disable();
}
}

View file

@ -55,36 +55,16 @@ class DialogDummyVideo : public wxDialog {
DialogDummyVideo(wxWindow *parent);
~DialogDummyVideo();
/// DOCME
wxComboBox *resolution_shortcuts;
/// DOCME
wxTextCtrl *width;
/// DOCME
wxTextCtrl *height;
/// DOCME
ColourButton *colour;
/// DOCME
wxCheckBox *pattern;
/// DOCME
wxTextCtrl *fps;
/// DOCME
wxSpinCtrl *length;
/// DOCME
wxStaticText *length_display;
/// DOCME
wxButton *ok_button;
/// DOCME
wxButton *cancel_button;
void OnResolutionShortcut(wxCommandEvent &evt);
void OnFpsChange(wxCommandEvent &evt);
void OnLengthSpin(wxSpinEvent &evt);

View file

@ -218,9 +218,23 @@ void DialogSearchReplace::UpdateDropDowns() {
}
}
/// @brief Constructor SearchReplaceEngine ///////////////////////
SearchReplaceEngine::SearchReplaceEngine () {
CanContinue = false;
SearchReplaceEngine::SearchReplaceEngine()
: curLine(0)
, pos(0)
, matchLen(0)
, replaceLen(0)
, Modified(0)
, LastWasFind(true)
, hasReplace(false)
, isReg(false)
, matchCase(false)
, updateVideo(false)
, CanContinue(false)
, hasFocus(false)
, field(0)
, affect(0)
, context(0)
{
}
void SearchReplaceEngine::FindNext() {
@ -228,7 +242,6 @@ void SearchReplaceEngine::FindNext() {
}
/// @brief Find & Replace next instance
void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
if (!CanContinue) {
OpenDialog(DoReplace);

View file

@ -45,66 +45,27 @@
namespace agi { struct Context; }
/// DOCME
/// @class SearchReplaceEngine
/// @brief DOCME
///
/// DOCME
class SearchReplaceEngine {
/// DOCME
int curLine;
/// DOCME
size_t pos;
/// DOCME
size_t matchLen;
/// DOCME
size_t replaceLen;
/// DOCME
bool Modified;
/// DOCME
bool LastWasFind;
/// DOCME
bool hasReplace;
/// DOCME
bool isReg;
/// DOCME
bool matchCase;
/// DOCME
bool updateVideo;
/// DOCME
bool CanContinue;
/// DOCME
bool hasFocus;
/// DOCME
int field;
/// DOCME
int affect;
/// DOCME
wxString LookFor;
/// DOCME
wxString ReplaceWith;
wxString *GetText(AssDialogue *cur, int field);
public:
/// DOCME
agi::Context *context;
void FindNext();
@ -123,37 +84,17 @@ public:
// Instance
extern SearchReplaceEngine Search;
/// DOCME
/// @class DialogSearchReplace
/// @brief DOCME
///
/// DOCME
class DialogSearchReplace : public wxDialog {
friend class SearchReplaceEngine;
/// DOCME
bool hasReplace;
/// DOCME
wxComboBox *FindEdit;
/// DOCME
wxComboBox *ReplaceEdit;
/// DOCME
wxCheckBox *CheckMatchCase;
/// DOCME
wxCheckBox *CheckRegExp;
/// DOCME
wxCheckBox *CheckUpdateVideo;
/// DOCME
wxRadioBox *Affect;
/// DOCME
wxRadioBox *Field;
void UpdateDropDowns();

View file

@ -59,6 +59,11 @@
AssTransformFramerateFilter::AssTransformFramerateFilter()
: AssExportFilter(_("Transform Framerate"), _("Transform subtitle times, including those in override tags, from an input framerate to an output framerate.\n\nThis is useful for converting regular time subtitles to VFRaC time subtitles for hardsubbing.\nIt can also be used to convert subtitles to a different speed video, such as NTSC to PAL speedup."), 1000)
, c(0)
, line(0)
, newStart(0)
, newEnd(0)
, newK(0)
, oldK(0)
, Input(0)
, Output(0)
{

View file

@ -41,6 +41,8 @@ using namespace std::tr1::placeholders;
FontCollector::FontCollector(FontCollectorStatusCallback status_callback, FontFileLister &lister)
: status_callback(status_callback)
, lister(lister)
, missing(0)
, missing_glyphs(0)
{
}

View file

@ -377,6 +377,11 @@ void OpenGLTextGlyph::Draw(float x, float y) const {
/// @brief DOCME
OpenGLTextGlyph::OpenGLTextGlyph(int value, wxFont const& font)
: str(wxChar(value))
, tex(0)
, x1(0)
, x2(0)
, y1(0)
, y2(0)
, font(font)
{
wxCoord desc,lead;

View file

@ -334,7 +334,9 @@ longlong StdIoGetFileSize(InputStream *_st) {
return epos;
}
MkvStdIO::MkvStdIO(wxString filename) {
MkvStdIO::MkvStdIO(wxString filename)
: error(0)
{
read = StdIoRead;
scan = StdIoScan;
getcachesize = StdIoGetCacheSize;

View file

@ -343,7 +343,10 @@ class HotkeyRenderer : public wxDataViewCustomRenderer {
wxTextCtrl *ctrl;
public:
HotkeyRenderer() : wxDataViewCustomRenderer("string", wxDATAVIEW_CELL_EDITABLE) { }
HotkeyRenderer()
: wxDataViewCustomRenderer("string", wxDATAVIEW_CELL_EDITABLE)
, ctrl(0)
{ }
wxWindow *CreateEditorCtrl(wxWindow *parent, wxRect label_rect, wxVariant const& var) {
ctrl = new wxTextCtrl(parent, -1, var.GetString(), label_rect.GetPosition(), label_rect.GetSize(), wxTE_PROCESS_ENTER);

View file

@ -869,7 +869,7 @@ void SubsTextEditCtrl::SplitLine(bool estimateTimes) {
n1->Text = orig.Left(from).Trim(true); // Trim off trailing whitespace
n2->Text = orig.Mid(from).Trim(false); // Trim off leading whitespace
if (estimateTimes) {
if (estimateTimes && orig.size()) {
double splitPos = double(from) / orig.size();
n2->Start = n1->End = (int)((n1->End - n1->Start) * splitPos) + n1->Start;
}

View file

@ -75,20 +75,16 @@ static void expand_times(AssDialogue *src, AssDialogue *dst) {
/// @brief Recombine
void SubtitlesGrid::RecombineLines() {
using namespace std;
Selection selectedSet = GetSelectedSet();
if (selectedSet.size() < 2) return;
AssDialogue *activeLine = GetActiveLine();
vector<AssDialogue*> sel;
sel.reserve(selectedSet.size());
copy(selectedSet.begin(), selectedSet.end(), back_inserter(sel));
std::vector<AssDialogue*> sel(selectedSet.begin(), selectedSet.end());
for_each(sel.begin(), sel.end(), trim_text);
sort(sel.begin(), sel.end(), &AssFile::CompStart);
typedef vector<AssDialogue*>::iterator diag_iter;
typedef std::vector<AssDialogue*>::iterator diag_iter;
diag_iter end = sel.end() - 1;
for (diag_iter cur = sel.begin(); cur != end; ++cur) {
AssDialogue *d1 = *cur;
@ -97,21 +93,21 @@ void SubtitlesGrid::RecombineLines() {
// 1, 1+2 (or 2+1), 2 gets turned into 1, 2, 2 so kill the duplicate
if (d1->Text == (*d2)->Text) {
expand_times(d1, *d2);
delete d1;
context->ass->Line.remove(d1);
delete d1;
continue;
}
// 1, 1+2, 1 turns into 1, 2, [empty]
if (d1->Text.empty()) {
delete d1;
context->ass->Line.remove(d1);
delete d1;
continue;
}
// If d2 is the last line in the selection it'll never hit the above test
if (d2 == end && (*d2)->Text.empty()) {
delete *d2;
context->ass->Line.remove(*d2);
delete *d2;
continue;
}

View file

@ -243,7 +243,7 @@ void SubtitleFormat::RecombineOverlaps(LineList &lines) {
//Is there an A part before the overlap?
if (curdlg->Start > prevdlg->Start) {
// Produce new entry with correct values
AssDialogue *newdlg = dynamic_cast<AssDialogue*>(prevdlg->Clone());
AssDialogue *newdlg = static_cast<AssDialogue*>(prevdlg->Clone());
newdlg->Start = prevdlg->Start;
newdlg->End = curdlg->Start;
newdlg->Text = prevdlg->Text;
@ -253,7 +253,7 @@ void SubtitleFormat::RecombineOverlaps(LineList &lines) {
// Overlapping A+B part
{
AssDialogue *newdlg = dynamic_cast<AssDialogue*>(prevdlg->Clone());
AssDialogue *newdlg = static_cast<AssDialogue*>(prevdlg->Clone());
newdlg->Start = curdlg->Start;
newdlg->End = (prevdlg->End < curdlg->End) ? prevdlg->End : curdlg->End;
// Put an ASS format hard linewrap between lines
@ -265,7 +265,7 @@ void SubtitleFormat::RecombineOverlaps(LineList &lines) {
// Is there an A part after the overlap?
if (prevdlg->End > curdlg->End) {
// Produce new entry with correct values
AssDialogue *newdlg = dynamic_cast<AssDialogue*>(prevdlg->Clone());
AssDialogue *newdlg = static_cast<AssDialogue*>(prevdlg->Clone());
newdlg->Start = curdlg->End;
newdlg->End = prevdlg->End;
newdlg->Text = prevdlg->Text;
@ -276,7 +276,7 @@ void SubtitleFormat::RecombineOverlaps(LineList &lines) {
// Is there a B part after the overlap?
if (curdlg->End > prevdlg->End) {
// Produce new entry with correct values
AssDialogue *newdlg = dynamic_cast<AssDialogue*>(prevdlg->Clone());
AssDialogue *newdlg = static_cast<AssDialogue*>(prevdlg->Clone());
newdlg->Start = prevdlg->End;
newdlg->End = curdlg->End;
newdlg->Text = curdlg->Text;

View file

@ -112,11 +112,11 @@ namespace
typedef std::vector<EbuFormattedText> EbuTextRow;
/// Formatting character constants
const char EBU_FORMAT_ITALIC[] = "\x81\x80";
const char EBU_FORMAT_UNDERLINE[] = "\x83\x82";
const char EBU_FORMAT_BOXING[] = "\x85\x84";
const char EBU_FORMAT_LINEBREAK = '\x8a';
const char EBU_FORMAT_UNUSED_SPACE = '\x8f';
const unsigned char EBU_FORMAT_ITALIC[] = "\x81\x80";
const unsigned char EBU_FORMAT_UNDERLINE[] = "\x83\x82";
const unsigned char EBU_FORMAT_BOXING[] = "\x85\x84";
const unsigned char EBU_FORMAT_LINEBREAK = '\x8a';
const unsigned char EBU_FORMAT_UNUSED_SPACE = '\x8f';
/// intermediate format
class EbuSubtitle

View file

@ -187,7 +187,9 @@ ThreadedFrameSource::ThreadedFrameSource(wxString videoFileName, wxEvtHandler *p
, provider(get_subs_provider(parent))
, videoProvider(VideoProviderFactory::GetProvider(videoFileName))
, parent(parent)
, nextFrame(-1)
, nextTime(-1.)
, singleFrame(-1)
, jobReady(jobMutex)
, run(true)
{

View file

@ -93,9 +93,9 @@ wxString PrettySize(int bytes) {
const char *suffix[] = { "", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
// Set size
int i = 0;
size_t i = 0;
double size = bytes;
while (size > 1024 && i < 9) {
while (size > 1024 && i + 1 < sizeof(suffix) / sizeof(suffix[0])) {
size /= 1024.0;
i++;
}

View file

@ -44,12 +44,13 @@
#include "validators.h"
NumValidator::NumValidator(wxString val, bool isfloat, bool issigned)
: isFloat(isfloat)
: fValue(0)
, iValue(0)
, isFloat(isfloat)
, isSigned(issigned)
{
if (isFloat) {
if (!val.ToDouble(&fValue))
fValue = 0;
val.ToDouble(&fValue);
}
else {
long tLong = 0;
@ -59,14 +60,16 @@ NumValidator::NumValidator(wxString val, bool isfloat, bool issigned)
}
NumValidator::NumValidator(int val, bool issigned)
: iValue(val)
: fValue(0)
, iValue(val)
, isFloat(false)
, isSigned(issigned)
{
}
NumValidator::NumValidator(int64_t val, bool issigned)
: iValue((int)val)
: fValue(0)
, iValue((int)val)
, isFloat(false)
, isSigned(issigned)
{
@ -74,6 +77,7 @@ NumValidator::NumValidator(int64_t val, bool issigned)
NumValidator::NumValidator(double val, bool issigned)
: fValue(val)
, iValue(0)
, isFloat(true)
, isSigned(issigned)
{

View file

@ -94,18 +94,19 @@ static bool TestTexture(int width, int height, GLint format) {
}
VideoOutGL::VideoOutGL()
: maxTextureSize(0),
supportsRectangularTextures(false),
internalFormat(0),
frameWidth(0),
frameHeight(0),
frameFormat(0),
frameFlipped(false),
textureIdList(),
textureList(),
textureCount(0),
textureRows(0),
textureCols(0)
: maxTextureSize(0)
, supportsRectangularTextures(false)
, internalFormat(0)
, frameWidth(0)
, frameHeight(0)
, frameFormat(0)
, frameFlipped(false)
, textureIdList()
, textureList()
, dl(0)
, textureCount(0)
, textureRows(0)
, textureCols(0)
{ }
/// @brief Runtime detection of required OpenGL capabilities

View file

@ -81,7 +81,7 @@ YUV4MPEGVideoProvider::YUV4MPEGVideoProvider(wxString fname)
CheckFileFormat();
ParseFileHeader(ReadHeader(0, false));
ParseFileHeader(ReadHeader(0));
if (w <= 0 || h <= 0)
throw VideoOpenError("Invalid resolution");
@ -145,8 +145,7 @@ void YUV4MPEGVideoProvider::CheckFileFormat() {
/// @param startpos The byte offset at where to start reading
/// @param reset_pos If true, the function will reset the file position to what it was before the function call before returning
/// @return A list of parameters
std::vector<wxString> YUV4MPEGVideoProvider::ReadHeader(int64_t startpos, bool reset_pos) {
int64_t oldpos = ftello(sf);
std::vector<wxString> YUV4MPEGVideoProvider::ReadHeader(int64_t startpos) {
std::vector<wxString> tags;
wxString curtag;
int bytesread = 0;
@ -159,12 +158,8 @@ std::vector<wxString> YUV4MPEGVideoProvider::ReadHeader(int64_t startpos, bool r
while ((buf = fgetc(sf)) != 0x0A) {
if (ferror(sf))
throw VideoOpenError("ReadHeader: Failed to read from file");
if (feof(sf)) {
// you know, this is one of the places where it would be really nice
// to be able to throw an exception object that tells the caller that EOF was reached
LOG_D("provider/video/yuv4mpeg") << "ReadHeader: Reached EOF, returning";
break;
}
if (feof(sf))
throw VideoOpenError("ReadHeader: Reached eof while reading header");
// some basic low-effort sanity checking
if (buf == 0x00)
@ -187,9 +182,6 @@ std::vector<wxString> YUV4MPEGVideoProvider::ReadHeader(int64_t startpos, bool r
curtag.Clear();
}
if (reset_pos)
fseeko(sf, oldpos, SEEK_SET);
return tags;
}
@ -313,9 +305,14 @@ int YUV4MPEGVideoProvider::IndexFile() {
// the file header for us and set the seek position correctly
while (true) {
int64_t curpos = ftello(sf); // update position
if (curpos < 0)
throw VideoOpenError("IndexFile: ftello failed");
// continue reading headers until no more are found
std::vector<wxString> tags = ReadHeader(curpos, false);
std::vector<wxString> tags = ReadHeader(curpos);
curpos = ftello(sf);
if (curpos < 0)
throw VideoOpenError("IndexFile: ftello failed");
if (tags.empty())
break; // no more headers

View file

@ -134,7 +134,7 @@ class YUV4MPEGVideoProvider : public VideoProvider {
void CheckFileFormat();
void ParseFileHeader(const std::vector<wxString>& tags);
Y4M_FrameFlags ParseFrameHeader(const std::vector<wxString>& tags);
std::vector<wxString> ReadHeader(int64_t startpos, bool reset_pos=false);
std::vector<wxString> ReadHeader(int64_t startpos);
int IndexFile();
public:

View file

@ -169,14 +169,17 @@ void VisualToolDrag::OnSelectedSetChanged(const SubtitleSelection &added, const
c->selectionController->GetSelectedSet(selection);
bool any_changed = false;
for (feature_iterator it = features.begin(); it != features.end(); ++it) {
for (feature_iterator it = features.begin(); it != features.end(); ) {
if (removed.count(it->line)) {
sel_features.erase(it);
sel_features.erase(it++);
any_changed = true;
}
else if (added.count(it->line) && it->type == DRAG_START && line_not_present(sel_features, it)) {
sel_features.insert(it);
any_changed = true;
else {
if (added.count(it->line) && it->type == DRAG_START && line_not_present(sel_features, it)) {
sel_features.insert(it);
any_changed = true;
}
++it;
}
}

View file

@ -30,6 +30,11 @@
VisualToolRotateXY::VisualToolRotateXY(VideoDisplay *parent, agi::Context *context)
: VisualTool<VisualDraggableFeature>(parent, context)
, angle_x(0)
, angle_y(0)
, angle_z(0)
, orig_x(0)
, orig_y(0)
{
features.resize(1);
org = &features.back();

View file

@ -35,6 +35,10 @@ static const float rad2deg = 180.f / 3.1415926536f;
VisualToolRotateZ::VisualToolRotateZ(VideoDisplay *parent, agi::Context *context)
: VisualTool<VisualDraggableFeature>(parent, context)
, angle(0)
, orig_angle(0)
, rotation_x(0)
, rotation_y(0)
{
features.resize(1);
org = &features.back();

View file

@ -32,6 +32,9 @@
VisualToolScale::VisualToolScale(VideoDisplay *parent, agi::Context *context)
: VisualTool<VisualDraggableFeature>(parent, context)
, rx(0)
, ry(0)
, rz(0)
{
}

View file

@ -51,6 +51,9 @@ enum {
VisualToolVectorClip::VisualToolVectorClip(VideoDisplay *parent, agi::Context *context)
: VisualTool<VisualToolVectorClipDraggableFeature>(parent, context)
, spline(*this)
, toolBar(0)
, mode(0)
, inverse(false)
{
}