This commit is contained in:
itsmattkc
2018-06-22 18:07:03 -07:00
parent 045015e096
commit 58736bd243
4 changed files with 25 additions and 11 deletions
+5 -2
View File
@@ -37,6 +37,8 @@ void PreviewGenerator::run() {
AVFrame* temp_frame = av_frame_alloc();
AVCodecContext** codec_ctx = new AVCodecContext* [fmt_ctx->nb_streams];
for (unsigned int i=0;i<fmt_ctx->nb_streams;i++) {
codec_ctx[i] = NULL;
if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
AVCodec* codec = avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id);
codec_ctx[i] = avcodec_alloc_context3(codec);
avcodec_parameters_to_context(codec_ctx[i], fmt_ctx->streams[i]->codecpar);
@@ -46,6 +48,7 @@ void PreviewGenerator::run() {
codec_ctx[i]->channel_layout = guess_layout_from_channels(fmt_ctx->streams[i]->codecpar->channels);
}
}
}
AVPacket packet;
bool done = true;
@@ -56,14 +59,14 @@ void PreviewGenerator::run() {
avcodec_send_packet(codec_ctx[packet.stream_index], &packet);
while (!end_of_file) {
while (avcodec_receive_frame(codec_ctx[packet.stream_index], temp_frame) == AVERROR(EAGAIN)) {
while (codec_ctx[packet.stream_index] == NULL || avcodec_receive_frame(codec_ctx[packet.stream_index], temp_frame) == AVERROR(EAGAIN)) {
av_packet_unref(&packet);
int read_ret = av_read_frame(fmt_ctx, &packet);
if (read_ret < 0) {
end_of_file = true;
if (read_ret != AVERROR_EOF) qDebug() << "[ERROR] Failed to read packet for preview generation";
break;
} else {
} else if (codec_ctx[packet.stream_index] != NULL) {
avcodec_send_packet(codec_ctx[packet.stream_index], &packet);
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.6.2, 2018-06-22T11:11:30. -->
<!-- Written by QtCreator 4.6.2, 2018-06-22T16:59:12. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
+2
View File
@@ -33,6 +33,8 @@ void TimelineHeader::mouseMoveEvent(QMouseEvent* event) {
void TimelineHeader::mouseReleaseEvent(QMouseEvent *) {
dragging = false;
panel_timeline->snapped = false;
panel_timeline->repaint_timeline();
}
void TimelineHeader::paintEvent(QPaintEvent*) {
+11 -2
View File
@@ -53,7 +53,6 @@ int TimelineWidget::calculate_track_height(int track) {
while (track_heights.size() < index+1) {
track_heights.append(TRACK_DEFAULT_HEIGHT);
}
qDebug() << track_heights.at(index);
return track_heights.at(index);
}
@@ -175,7 +174,15 @@ void TimelineWidget::dropEvent(QDropEvent* event) {
}
void TimelineWidget::mouseDoubleClickEvent(QMouseEvent *event) {
if (panel_timeline->tool == TIMELINE_TOOL_EDIT) {
int clip_index = getClipIndexFromCoords(panel_timeline->cursor_frame, panel_timeline->cursor_track);
if (clip_index >= 0) {
Clip* clip = sequence->get_clip(clip_index);
if (!(event->modifiers() & Qt::ShiftModifier)) panel_timeline->selections.clear();
panel_timeline->selections.append({clip->timeline_in, clip->timeline_out, clip->track});
panel_timeline->repaint_timeline();
}
}
}
void TimelineWidget::mousePressEvent(QMouseEvent *event) {
@@ -343,6 +350,8 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
pre_clips.clear();
post_clips.clear();
// panel_timeline->repaint_timeline();
// find out how many clips are selected
bool single_select = false;
int selected_clip = 0;