Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_proxy.c
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ | * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup spseq | * \ingroup spseq | ||||
| */ | */ | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_ghash.h" | #include "BLI_ghash.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_video_edit_types.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "SEQ_iterator.h" | #include "SEQ_iterator.h" | ||||
| #include "SEQ_proxy.h" | #include "SEQ_proxy.h" | ||||
| Show All 12 Lines | |||||
| #include "sequencer_intern.h" | #include "sequencer_intern.h" | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Rebuild Proxy and Timecode Indices Operator | /** \name Rebuild Proxy and Timecode Indices Operator | ||||
| * \{ */ | * \{ */ | ||||
| static void seq_proxy_build_job(const bContext *C, ReportList *reports) | static void seq_proxy_build_job(const bContext *C, ReportList *reports) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_get(scene); | |||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| if (ed == NULL) { | if (video_edit == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| wmJob *wm_job = ED_seq_proxy_wm_job_get(C); | wmJob *wm_job = ED_seq_proxy_wm_job_get(C); | ||||
| ProxyJob *pj = ED_seq_proxy_job_get(C, wm_job); | ProxyJob *pj = ED_seq_proxy_job_get(C, wm_job); | ||||
| GSet *file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list"); | GSet *file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list"); | ||||
| bool selected = false; /* Check for no selected strips */ | bool selected = false; /* Check for no selected strips */ | ||||
| LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) { | LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(video_edit)) { | ||||
| if (!ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE) || (seq->flag & SELECT) == 0) { | if (!ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE) || (seq->flag & SELECT) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| selected = true; | selected = true; | ||||
| if (!(seq->flag & SEQ_USE_PROXY)) { | if (!(seq->flag & SEQ_USE_PROXY)) { | ||||
| BKE_reportf(reports, RPT_WARNING, "Proxy is not enabled for %s, skipping", seq->name); | BKE_reportf(reports, RPT_WARNING, "Proxy is not enabled for %s, skipping", seq->name); | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (seq->strip->proxy->build_size_flags == 0) { | if (seq->strip->proxy->build_size_flags == 0) { | ||||
| BKE_reportf(reports, RPT_WARNING, "Resolution is not selected for %s, skipping", seq->name); | BKE_reportf(reports, RPT_WARNING, "Resolution is not selected for %s, skipping", seq->name); | ||||
| continue; | continue; | ||||
| } | } | ||||
| bool success = SEQ_proxy_rebuild_context( | bool success = SEQ_proxy_rebuild_context( | ||||
| pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue, false); | pj->main, pj->depsgraph, pj->video_edit, seq, file_list, &pj->queue, false); | ||||
| if (!success && (seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) != 0) { | if (!success && (seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) != 0) { | ||||
| BKE_reportf(reports, RPT_WARNING, "Overwrite is not checked for %s, skipping", seq->name); | BKE_reportf(reports, RPT_WARNING, "Overwrite is not checked for %s, skipping", seq->name); | ||||
| } | } | ||||
| } | } | ||||
| BLI_gset_free(file_list, MEM_freeN); | BLI_gset_free(file_list, MEM_freeN); | ||||
| Show All 18 Lines | static int sequencer_rebuild_proxy_invoke(bContext *C, | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) | static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_get(scene); | |||||
| GSet *file_list; | GSet *file_list; | ||||
| if (ed == NULL) { | if (video_edit == NULL) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list"); | file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list"); | ||||
| LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) { | LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(video_edit)) { | ||||
| if (seq->flag & SELECT) { | if (seq->flag & SELECT) { | ||||
| ListBase queue = {NULL, NULL}; | ListBase queue = {NULL, NULL}; | ||||
| LinkData *link; | LinkData *link; | ||||
| short stop = 0, do_update; | short stop = 0, do_update; | ||||
| float progress; | float progress; | ||||
| SEQ_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue, false); | SEQ_proxy_rebuild_context(bmain, depsgraph, video_edit, seq, file_list, &queue, false); | ||||
| for (link = queue.first; link; link = link->next) { | for (link = queue.first; link; link = link->next) { | ||||
| struct SeqIndexBuildContext *context = link->data; | struct SeqIndexBuildContext *context = link->data; | ||||
| SEQ_proxy_rebuild(context, &stop, &do_update, &progress); | SEQ_proxy_rebuild(context, &stop, &do_update, &progress); | ||||
| SEQ_proxy_rebuild_finish(context, 0); | SEQ_proxy_rebuild_finish(context, 0); | ||||
| } | } | ||||
| SEQ_relations_free_imbuf(scene, &ed->seqbase, false); | SEQ_relations_free_imbuf(video_edit, &video_edit->seqbase, false); | ||||
| } | } | ||||
| } | } | ||||
| BLI_gset_free(file_list, MEM_freeN); | BLI_gset_free(file_list, MEM_freeN); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| Show All 22 Lines | static int sequencer_enable_proxies_invoke(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const wmEvent *UNUSED(event)) | const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| return WM_operator_props_dialog_popup(C, op, 200); | return WM_operator_props_dialog_popup(C, op, 200); | ||||
| } | } | ||||
| static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op) | static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_get(scene); | |||||
| bool proxy_25 = RNA_boolean_get(op->ptr, "proxy_25"); | bool proxy_25 = RNA_boolean_get(op->ptr, "proxy_25"); | ||||
| bool proxy_50 = RNA_boolean_get(op->ptr, "proxy_50"); | bool proxy_50 = RNA_boolean_get(op->ptr, "proxy_50"); | ||||
| bool proxy_75 = RNA_boolean_get(op->ptr, "proxy_75"); | bool proxy_75 = RNA_boolean_get(op->ptr, "proxy_75"); | ||||
| bool proxy_100 = RNA_boolean_get(op->ptr, "proxy_100"); | bool proxy_100 = RNA_boolean_get(op->ptr, "proxy_100"); | ||||
| bool overwrite = RNA_boolean_get(op->ptr, "overwrite"); | bool overwrite = RNA_boolean_get(op->ptr, "overwrite"); | ||||
| bool turnon = true; | bool turnon = true; | ||||
| if (ed == NULL || !(proxy_25 || proxy_50 || proxy_75 || proxy_100)) { | if (video_edit == NULL || !(proxy_25 || proxy_50 || proxy_75 || proxy_100)) { | ||||
| turnon = false; | turnon = false; | ||||
| } | } | ||||
| LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) { | LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(video_edit)) { | ||||
| if (seq->flag & SELECT) { | if (seq->flag & SELECT) { | ||||
| if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) { | if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) { | ||||
| SEQ_proxy_set(seq, turnon); | SEQ_proxy_set(seq, turnon); | ||||
| if (seq->strip->proxy == NULL) { | if (seq->strip->proxy == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (proxy_25) { | if (proxy_25) { | ||||
| Show All 29 Lines | if (seq->flag & SELECT) { | ||||
| } | } | ||||
| else { | else { | ||||
| seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING; | seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SEQUENCER_OT_enable_proxies(wmOperatorType *ot) | void SEQUENCER_OT_enable_proxies(wmOperatorType *ot) | ||||
| { | { | ||||
| /* Identifiers. */ | /* Identifiers. */ | ||||
| ot->name = "Set Selected Strip Proxies"; | ot->name = "Set Selected Strip Proxies"; | ||||
| Show All 18 Lines | |||||