updated some casts and warnings

This commit is contained in:
itsmattkc
2019-01-12 13:29:10 +11:00
parent a8e37ac76a
commit 6c31e458f7
5 changed files with 44 additions and 37 deletions
+14 -4
View File
@@ -142,7 +142,6 @@ void TextEffect::redraw(double timecode) {
switch (halign_field->get_combo_data(timecode).toInt()) {
case Qt::AlignLeft: text_x = 0; break;
case Qt::AlignHCenter: text_x = (width/2) - (fm.width(lines.at(i))/2); break;
case Qt::AlignRight: text_x = width - fm.width(lines.at(i)); break;
case Qt::AlignJustify:
// add spaces until the string is too big
@@ -167,12 +166,23 @@ void TextEffect::redraw(double timecode) {
}
}
break;
case Qt::AlignHCenter:
default:
text_x = (width/2) - (fm.width(lines.at(i))/2);
break;
}
switch (valign_field->get_combo_data(timecode).toInt()) {
case Qt::AlignTop: text_y = (fm.height()*i)+fm.ascent(); break;
case Qt::AlignVCenter: text_y = ((height/2) - (text_height/2) - fm.descent()) + (fm.height()*(i+1)); break;
case Qt::AlignBottom: text_y = (height - text_height - fm.descent()) + (fm.height()*(i+1)); break;
case Qt::AlignTop:
text_y = (fm.height()*i)+fm.ascent();
break;
case Qt::AlignBottom:
text_y = (height - text_height - fm.descent()) + (fm.height()*(i+1));
break;
case Qt::AlignVCenter:
default:
text_y = ((height/2) - (text_height/2) - fm.descent()) + (fm.height()*(i+1));
break;
}
path.addText(text_x, text_y, font, lines.at(i));
+7 -11
View File
@@ -31,26 +31,22 @@ void ToneEffect::process_audio(double timecode_start, double timecode_end, quint
for (int i=0;i<nb_bytes;i+=4) {
double timecode = timecode_start+(interval*i);
qint16 left_tone_sample = qSin((2*M_PI*sinX*freq_val->get_double_value(timecode, true))/parent_clip->sequence->audio_frequency)*log_volume(amount_val->get_double_value(timecode, true)*0.01)*INT16_MAX;
qint16 left_tone_sample = qint16(qRound(qSin((2*M_PI*sinX*freq_val->get_double_value(timecode, true))/parent_clip->sequence->audio_frequency)*log_volume(amount_val->get_double_value(timecode, true)*0.01)*INT16_MAX));
qint16 right_tone_sample = left_tone_sample;
// mix with source audio
if (mix_val->get_bool_value(timecode, true)) {
qint16 left_sample = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
qint16 right_sample = (qint16) (((samples[i+3] & 0xFF) << 8) | (samples[i+2] & 0xFF));
qint16 left_sample = qint16(((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
qint16 right_sample = qint16(((samples[i+3] & 0xFF) << 8) | (samples[i+2] & 0xFF));
left_tone_sample = mix_audio_sample(left_tone_sample, left_sample);
right_tone_sample = mix_audio_sample(right_tone_sample, right_sample);
}
samples[i+3] = (quint8) (right_tone_sample >> 8);
samples[i+2] = (quint8) right_tone_sample;
samples[i+1] = (quint8) (left_tone_sample >> 8);
samples[i] = (quint8) left_tone_sample;
samples[i+3] = quint8(right_tone_sample >> 8);
samples[i+2] = quint8(right_tone_sample);
samples[i+1] = quint8(left_tone_sample >> 8);
samples[i] = quint8(left_tone_sample);
int presin = sinX;
sinX++;
if (sinX < presin) {
qWarning() << "Tone effect overflowed";
}
}
}
+8 -11
View File
@@ -40,7 +40,7 @@
#include <QStatusBar>
long refactor_frame_number(long framenumber, double source_frame_rate, double target_frame_rate) {
return qRound(((double)framenumber/source_frame_rate)*target_frame_rate);
return qRound((double(framenumber)/source_frame_rate)*target_frame_rate);
}
Timeline::Timeline(QWidget *parent) :
@@ -78,7 +78,7 @@ Timeline::Timeline(QWidget *parent) :
setup_ui();
default_track_height = (QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96) * TRACK_DEFAULT_HEIGHT;
default_track_height = qRound((QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96) * TRACK_DEFAULT_HEIGHT);
headers->viewer = panel_sequence_viewer;
@@ -150,7 +150,7 @@ void Timeline::toggle_show_all() {
showing_all = !showing_all;
if (showing_all) {
old_zoom = zoom;
set_zoom_value((double) (timeline_area->width() - 200) / (double) sequence->getEndFrame());
set_zoom_value(double(timeline_area->width() - 200) / double(sequence->getEndFrame()));
} else {
set_zoom_value(old_zoom);
}
@@ -166,7 +166,6 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
Media* medium = media_list.at(i);
Footage* m = nullptr;
Sequence* s = nullptr;
void* media = nullptr;
long sequence_length = 0;
long default_clip_in = 0;
long default_clip_out = 0;
@@ -174,7 +173,6 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
switch (medium->get_type()) {
case MEDIA_TYPE_FOOTAGE:
m = medium->to_footage();
media = m;
can_import = m->ready;
if (m->using_inout) {
double source_fr = 30;
@@ -187,7 +185,6 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
s = medium->to_sequence();
sequence_length = s->getEndFrame();
if (seq != nullptr) sequence_length = refactor_frame_number(sequence_length, s->frame_rate, seq->frame_rate);
media = s;
can_import = (s != seq && sequence_length != 0);
if (s->using_workarea) {
default_clip_in = refactor_frame_number(s->workarea_in, s->frame_rate, seq->frame_rate);
@@ -671,7 +668,7 @@ Clip* Timeline::split_clip(ComboAction* ca, int p, long frame, long post_in) {
}
if (pre->get_closing_transition() != nullptr) {
ca->append(new DeleteTransitionCommand(pre->sequence, pre->closing_transition));
if (pre->get_closing_transition()->secondary_clip == nullptr) post->get_closing_transition()->set_length(qMin((long) post->get_closing_transition()->get_true_length(), post->getLength()));
if (pre->get_closing_transition()->secondary_clip == nullptr) post->get_closing_transition()->set_length(qMin(long(post->get_closing_transition()->get_true_length()), post->getLength()));
}
return post;
@@ -1458,7 +1455,7 @@ void Timeline::deselect() {
}
long getFrameFromScreenPoint(double zoom, int x) {
long f = qCeil((float) x / zoom);
long f = qCeil(double(x) / zoom);
if (f < 0) {
return 0;
}
@@ -1466,7 +1463,7 @@ long getFrameFromScreenPoint(double zoom, int x) {
}
int getScreenPointFromFrame(double zoom, long frame) {
return (int) qFloor(frame*zoom);
return qFloor(double(frame)*zoom);
}
long Timeline::getTimelineFrameFromScreenPoint(int x) {
@@ -1824,13 +1821,13 @@ void move_clip(ComboAction* ca, Clip *c, long iin, long iout, long iclip_in, int
if (verify_transitions) {
if (c->get_opening_transition() != nullptr && c->get_opening_transition()->secondary_clip != nullptr && c->get_opening_transition()->secondary_clip->timeline_out != iin) {
// separate transition
ca->append(new SetPointer((void**) &c->get_opening_transition()->secondary_clip, nullptr));
ca->append(new SetPointer(reinterpret_cast<void**>(&c->get_opening_transition()->secondary_clip), nullptr));
ca->append(new AddTransitionCommand(c->get_opening_transition()->secondary_clip, nullptr, c->get_opening_transition(), nullptr, TA_CLOSING_TRANSITION, 0));
}
if (c->get_closing_transition() != nullptr && c->get_closing_transition()->secondary_clip != nullptr && c->get_closing_transition()->parent_clip->timeline_in != iout) {
// separate transition
ca->append(new SetPointer((void**) &c->get_closing_transition()->secondary_clip, nullptr));
ca->append(new SetPointer(reinterpret_cast<void**>(&c->get_closing_transition()->secondary_clip), nullptr));
ca->append(new AddTransitionCommand(c, nullptr, c->get_closing_transition(), nullptr, TA_CLOSING_TRANSITION, 0));
}
}
+13 -10
View File
@@ -268,9 +268,9 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
enable_image(false),
glslProgram(nullptr),
texture(nullptr),
enable_always_update(false),
isOpen(false),
bound(false),
enable_always_update(false)
bound(false)
{
// set up base UI
container = new CollapsibleWidget();
@@ -366,11 +366,11 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
} else if (attr.name() == "b") {
color.setBlue(attr.value().toInt());
} else if (attr.name() == "rf") {
color.setRedF(attr.value().toFloat());
color.setRedF(attr.value().toDouble());
} else if (attr.name() == "gf") {
color.setGreenF(attr.value().toFloat());
color.setGreenF(attr.value().toDouble());
} else if (attr.name() == "bf") {
color.setBlueF(attr.value().toFloat());
color.setBlueF(attr.value().toDouble());
} else if (attr.name() == "hex") {
color.setNamedColor(attr.value().toString());
}
@@ -655,7 +655,6 @@ void Effect::load(QXmlStreamReader& stream) {
if (stream.name() == "field" && stream.isStartElement()) {
if (field_count < row->fieldCount()) {
// match field using ID
bool found_field_by_id = false;
int field_number = field_count;
for (int k=0;k<stream.attributes().size();k++) {
const QXmlStreamAttribute& attr = stream.attributes().at(k);
@@ -663,7 +662,6 @@ void Effect::load(QXmlStreamReader& stream) {
for (int l=0;l<row->fieldCount();l++) {
if (row->field(l)->id == attr.value()) {
field_number = l;
found_field_by_id = true;
qInfo() << "Found field by ID";
break;
}
@@ -874,7 +872,7 @@ Effect* Effect::copy(Clip* c) {
void Effect::process_shader(double timecode, GLTextureCoords&) {
glslProgram->setUniformValue("resolution", parent_clip->getWidth(), parent_clip->getHeight());
glslProgram->setUniformValue("time", (GLfloat) timecode);
glslProgram->setUniformValue("time", GLfloat(timecode));
for (int i=0;i<rows.size();i++) {
EffectRow* row = rows.at(i);
@@ -883,10 +881,15 @@ void Effect::process_shader(double timecode, GLTextureCoords&) {
if (!field->id.isEmpty()) {
switch (field->type) {
case EFFECT_FIELD_DOUBLE:
glslProgram->setUniformValue(field->id.toUtf8().constData(), (GLfloat) field->get_double_value(timecode));
glslProgram->setUniformValue(field->id.toUtf8().constData(), GLfloat(field->get_double_value(timecode)));
break;
case EFFECT_FIELD_COLOR:
glslProgram->setUniformValue(field->id.toUtf8().constData(), field->get_color_value(timecode).redF(), field->get_color_value(timecode).greenF(), field->get_color_value(timecode).blueF());
glslProgram->setUniformValue(
field->id.toUtf8().constData(),
GLfloat(field->get_color_value(timecode).redF()),
GLfloat(field->get_color_value(timecode).greenF()),
GLfloat(field->get_color_value(timecode).blueF())
);
break;
case EFFECT_FIELD_STRING: break; // can you even send a string to a uniform value?
case EFFECT_FIELD_BOOL:
+2 -1
View File
@@ -221,7 +221,8 @@ void GraphView::paintEvent(QPaintEvent *) {
// sort keyframes by time
QVector<int> sorted_keys = sort_keys_from_field(field);
int last_key_x, last_key_y;
int last_key_x = 0;
int last_key_y = 0;
// draw lines
for (int j=0;j<sorted_keys.size();j++) {