cutcutcodec 1.0.post3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cutcutcodec might be problematic. Click here for more details.
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/__init__.py +6 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/__main__.py +38 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/c_build.py +33 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/_helper_properties.py +52 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/properties/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/properties/duration.py +83 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/ffprobe.py +637 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/find.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/time_backprop.py +68 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/rate_audio.py +239 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/rate_video.py +97 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/shape.py +107 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/time_backprop.py +183 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/duration.py +162 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/nb_frames.py +159 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/rate.py +102 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/timestamps.py +194 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/container.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/encoder.py +152 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/filter.py +33 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame.py +127 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame_audio.py +205 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame_video.py +322 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/layout.py +206 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/meta_filter.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/muxer.py +184 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/node.py +164 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream.py +182 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream_audio.py +130 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream_video.py +193 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/__init__.py +7 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/ast_to_file.py +125 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/__init__.py +6 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/compatibility.py +734 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/default.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/encodec.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/muxer.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/rate.py +133 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_ast.py +477 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_json.py +104 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_tree.py +190 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/json_to_graph.py +114 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/parse.py +123 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/__init__.py +15 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/dynamic.py +544 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/lambdify.py +612 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/preprocess.py +698 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/printer.py +926 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/tree_to_graph.py +168 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/decision/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/add.py +73 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/remove.py +476 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/exceptions.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/add.py +170 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/cat.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/cut.py +112 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/delay.py +85 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/equation.py +261 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/fir.py +231 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/identity.py +48 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/resample.py +451 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/subclip.py +91 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/cut.py +74 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/audio_cast.py +208 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/video_cast.py +197 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/subclip.py +53 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/add.py +331 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/cat.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/cut.py +113 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/delay.py +84 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/equation.py +265 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/identity.py +48 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/pad.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/subclip.py +91 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/empty.py +73 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/equation.py +56 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/noise.py +243 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/c_fractal.cpython-312-x86_64-linux-gnu.so +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/empty.py +69 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/equation.py +109 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/fractal.c +116 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/geometry.py +100 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/mandelbrot.py +176 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/noise.py +112 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/interfaces/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/interfaces/seedable.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/read_ffmpeg.py +904 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/read_svg.py +145 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/scheduler.py +356 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/write.py +340 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/basic.py +35 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/clean/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/clean/graph.py +80 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/hashes/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/hashes/graph.py +81 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/singleton.py +47 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cuda/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/factor/__init__.py +5 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/factor/proba.py +189 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/generalize/__init__.py +5 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/generalize/delay_to_fir.py +88 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/graph.py +17 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/parallel/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/parallel/buffer.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/utils.py +34 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/audio_5.1_narration.oga +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/intro.webm +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/logo.svg +13 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/project.json +226 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/video.mp4 +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/__main__.py +25 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/actions.py +63 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/app/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/app/app.py +248 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/base.py +50 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/container_input_ffmpeg.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_delay.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_equation.py +45 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_fir.py +58 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_subclip.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_cut.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_delay.py +20 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_subclip.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_delay.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_equation.py +53 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_subclip.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_audio_equation.py +14 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_audio_noise.py +19 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_equation.py +13 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_mandelbrot.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_noise.py +18 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/base.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/default.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/documentation.py +47 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/general.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/interface.py +305 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/loader.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/main.py +62 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edition_tabs.py +34 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/base.py +122 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/filters.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/generators.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry_tabs.py +46 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/_helper.py +54 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/container.py +226 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/doc.py +67 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/encodec.py +289 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/main.py +173 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/edge_properties.py +56 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/main.py +280 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/node.py +44 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/main.py +151 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/menu.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/audio_settings.py +183 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/main.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/video_settings.py +257 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/run.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/main.py +30 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/slider.py +286 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/track.py +97 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/view.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/toolbar.py +29 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/tools.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/audio_player.py +103 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/control.py +96 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/frame_extractor.py +254 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/main.py +115 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/__main__.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/coding_style.py +49 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/generation.py +52 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/install.py +72 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/run.py +58 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/abstract.py +215 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/audio_cast.py +35 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/audio_equation.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/c_memory.py +132 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/compatibility.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/compile.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/encoder.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_cut.py +107 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_delay.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_empty.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/fir.py +143 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/hashes.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/initialisation.py +24 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/muxer.py +22 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/nan_snapshot.py +39 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/read.py +192 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/serialization_equality.py +50 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/snapshot_shape.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/sympy_to_torch.py +135 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/thread_safe.py +77 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/time_range.py +55 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/video_equation.py +77 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/write.py +95 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/utils.py +40 -0
- cutcutcodec-1.0.post3.dist-info/LICENSE +7 -0
- cutcutcodec-1.0.post3.dist-info/METADATA +271 -0
- cutcutcodec-1.0.post3.dist-info/RECORD +233 -0
- cutcutcodec-1.0.post3.dist-info/WHEEL +5 -0
- cutcutcodec-1.0.post3.dist-info/entry_points.txt +6 -0
- cutcutcodec-1.0.post3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Basic linear casts between different audio layouts.
|
|
4
|
+
|
|
5
|
+
For coefficient downmixing, based on https://www.rfc-editor.org/rfc/rfc7845#section-5.1.1.5
|
|
6
|
+
and http://www.atsc.org/wp-content/uploads/2015/03/A52-201212-17.pdf p96
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import numbers
|
|
10
|
+
import typing
|
|
11
|
+
|
|
12
|
+
from sympy.core.basic import Basic
|
|
13
|
+
from sympy.core.symbol import Symbol
|
|
14
|
+
import networkx
|
|
15
|
+
import numpy as np
|
|
16
|
+
import torch
|
|
17
|
+
|
|
18
|
+
from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
19
|
+
from cutcutcodec.core.classes.layout import AllLayouts, Layout
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class LinearAudioConvertor:
|
|
23
|
+
"""Convertion of a specific layout thanks the transition matrix.
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
in_layout : cutcutcodec.core.classes.layout.Layout
|
|
28
|
+
The layout of the input frames (readonly).
|
|
29
|
+
out_layout : cutcutcodec.core.classes.layout.Layout
|
|
30
|
+
The layout of the converted frames (readonly).
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(self, in_layout: Layout, out_layout: Layout, matrix: np.ndarray[np.float64]):
|
|
34
|
+
"""Initialise and create the class.
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
in_layout : cutcutcodec.core.classes.layout.Layout
|
|
39
|
+
The layout of the input frames.
|
|
40
|
+
out_layout : cutcutcodec.core.classes.layout.Layout
|
|
41
|
+
The layout of the converted frames.
|
|
42
|
+
matrix : array
|
|
43
|
+
The linear transformation matrix.
|
|
44
|
+
"""
|
|
45
|
+
assert isinstance(in_layout, Layout), in_layout.__class__.__name__
|
|
46
|
+
assert isinstance(out_layout, Layout), out_layout.__class__.__name__
|
|
47
|
+
assert isinstance(matrix, np.ndarray), matrix.__class__.__name__
|
|
48
|
+
assert matrix.shape == (len(out_layout.channels), len(in_layout.channels))
|
|
49
|
+
self._in_layout = in_layout
|
|
50
|
+
self._out_layout = out_layout
|
|
51
|
+
self._matrix = torch.from_numpy(matrix)
|
|
52
|
+
|
|
53
|
+
def __call__(self, frame: FrameAudio) -> FrameAudio:
|
|
54
|
+
"""Apply the convertion of the audio frame.
|
|
55
|
+
|
|
56
|
+
Parameters
|
|
57
|
+
----------
|
|
58
|
+
frame : cutcutcodec.core.classes.frame_audio.FrameAudio
|
|
59
|
+
The input frame audio with the layout ``in_layout``.
|
|
60
|
+
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
cutcutcodec.core.classes.frame_audio.FrameAudio
|
|
64
|
+
The input ``frame`` converted in the layout ``out_layout``.
|
|
65
|
+
"""
|
|
66
|
+
assert isinstance(frame, FrameAudio), frame.__class__.__name__
|
|
67
|
+
assert frame.layout == self._in_layout, (frame.layout, self._in_layout)
|
|
68
|
+
out_frame = self._matrix.to(device=frame.device, dtype=frame.dtype) @ torch.Tensor(frame)
|
|
69
|
+
out_frame = FrameAudio(frame.time, frame.rate, self._out_layout, out_frame)
|
|
70
|
+
return out_frame
|
|
71
|
+
|
|
72
|
+
@property
|
|
73
|
+
def equations(self) -> dict[Symbol, Basic]:
|
|
74
|
+
"""To each output channel, associate the equation.
|
|
75
|
+
|
|
76
|
+
The symbols are the real cannonocal name of each channels.
|
|
77
|
+
"""
|
|
78
|
+
in_vars = [Symbol(v, real=True) for v, _ in self._in_layout.channels]
|
|
79
|
+
out_vars = [Symbol(v, real=True) for v, _ in self._out_layout.channels]
|
|
80
|
+
eqs = self._matrix.numpy(force=True) @ np.array([in_vars], dtype=object).transpose()
|
|
81
|
+
return dict(zip(out_vars, eqs[:, 0]))
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def in_layout(self) -> Layout:
|
|
85
|
+
"""Return the layout of the input frames."""
|
|
86
|
+
return self._in_layout
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def out_layout(self) -> Layout:
|
|
90
|
+
"""Return the layout of the converted frames."""
|
|
91
|
+
return self._out_layout
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class AudioConvertor(LinearAudioConvertor):
|
|
95
|
+
"""Combine the matrix in order to find the complete transformation chain.
|
|
96
|
+
|
|
97
|
+
Examples
|
|
98
|
+
--------
|
|
99
|
+
>>> import torch
|
|
100
|
+
>>> _ = torch.manual_seed(0)
|
|
101
|
+
>>> from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
102
|
+
>>> from cutcutcodec.core.filters.mix.audio_cast import AudioConvertor
|
|
103
|
+
>>> frame_in = FrameAudio(0, 1, "5.1", torch.randn((6, 1024)))
|
|
104
|
+
>>> (conv := AudioConvertor("5.1", "mono"))
|
|
105
|
+
AudioConvertor('5.1', 'mono')
|
|
106
|
+
>>> torch.round(conv(frame_in), decimals=3)
|
|
107
|
+
FrameAudio(0, 1, 'mono', [[-0.296, 0.279, -0.775, ..., -2.045, -2.013,
|
|
108
|
+
-0.316]])
|
|
109
|
+
>>> torch.round(
|
|
110
|
+
... AudioConvertor("stereo", "mono")(AudioConvertor("5.1", "stereo")(frame_in)), decimals=3
|
|
111
|
+
... )
|
|
112
|
+
FrameAudio(0, 1, 'mono', [[-0.296, 0.279, -0.775, ..., -2.045, -2.013,
|
|
113
|
+
-0.316]])
|
|
114
|
+
>>>
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
def __init__(
|
|
118
|
+
self,
|
|
119
|
+
in_layout: typing.Union[Layout, str, numbers.Integral],
|
|
120
|
+
out_layout: typing.Union[Layout, str, numbers.Integral],
|
|
121
|
+
):
|
|
122
|
+
"""Initialise and create the class.
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
in_layout : cutcutcodec.core.classes.layout.Layout
|
|
127
|
+
Casted and transmitted to
|
|
128
|
+
``cutcutcodec.core.filters.mix.audio_cast.LinearAudioConvert`` initialisator.
|
|
129
|
+
out_layout : cutcutcodec.core.classes.layout.Layout
|
|
130
|
+
Casted and transmitted to
|
|
131
|
+
``cutcutcodec.core.filters.mix.audio_cast.LinearAudioConvert`` initialisator.
|
|
132
|
+
"""
|
|
133
|
+
in_layout, out_layout = Layout(in_layout), Layout(out_layout)
|
|
134
|
+
|
|
135
|
+
# search the path
|
|
136
|
+
graph = networkx.from_edgelist(
|
|
137
|
+
(
|
|
138
|
+
(p_in, p_out, {"matrix": matrix, "weight": 1.0})
|
|
139
|
+
for (p_in, p_out), matrix in self.all_layouts().items()
|
|
140
|
+
),
|
|
141
|
+
create_using=networkx.DiGraph,
|
|
142
|
+
)
|
|
143
|
+
try:
|
|
144
|
+
path = networkx.dijkstra_path(graph, in_layout.name, out_layout.name, weight="weight")
|
|
145
|
+
except ValueError as err:
|
|
146
|
+
raise NotImplementedError(
|
|
147
|
+
f"impossible convertion from {in_layout.name} to {out_layout.name}"
|
|
148
|
+
) from err
|
|
149
|
+
|
|
150
|
+
# compute the matrix
|
|
151
|
+
if len(path) == 1: # case identity
|
|
152
|
+
path = [path[0], path[0]]
|
|
153
|
+
matrix = np.array(graph.get_edge_data(path[0], path[1])["matrix"])
|
|
154
|
+
for p_in, p_out in zip(path[1:-1], path[2:]):
|
|
155
|
+
matrix = np.array(graph.get_edge_data(p_in, p_out)["matrix"]) @ matrix
|
|
156
|
+
|
|
157
|
+
super().__init__(in_layout, out_layout, matrix)
|
|
158
|
+
|
|
159
|
+
def __repr__(self):
|
|
160
|
+
"""Print a better representation of the object for debug."""
|
|
161
|
+
return (
|
|
162
|
+
f"{self.__class__.__name__}"
|
|
163
|
+
f"({repr(self._in_layout.name)}, {repr(self._out_layout.name)})"
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
@staticmethod
|
|
167
|
+
def all_layouts() -> dict[tuple[str, str], list[list[float]]]:
|
|
168
|
+
"""To each layouts, associate the convertion matrix."""
|
|
169
|
+
downmixing = {
|
|
170
|
+
("stereo", "mono"): ( # 'fl', 'fr'
|
|
171
|
+
[[0.500000, 0.500000]] # be carefull of phase inversion
|
|
172
|
+
),
|
|
173
|
+
("3.0", "stereo"): ( # 'fl', 'fr', 'fc'
|
|
174
|
+
[[0.585786, 0.000000, 0.414214],
|
|
175
|
+
[0.000000, 0.585786, 0.414214]]
|
|
176
|
+
),
|
|
177
|
+
("quad", "stereo"): ( # 'fl', 'fr', 'bl', 'br'
|
|
178
|
+
[[0.422650, 0.000000, 0.366025, 0.211325],
|
|
179
|
+
[0.000000, 0.422650, 0.211325, 0.366025]]
|
|
180
|
+
),
|
|
181
|
+
("5.0", "stereo"): ( # 'fl', 'fr', 'fc', 'bl', 'br'
|
|
182
|
+
[[0.650802, 0.000000, 0.460186, 0.563611, 0.325401],
|
|
183
|
+
[0.000000, 0.650802, 0.460186, 0.325401, 0.563611]]
|
|
184
|
+
),
|
|
185
|
+
("5.1", "stereo"): ( # 'fl', 'fr', 'fc', 'lfe', 'bl', 'br'
|
|
186
|
+
[[0.529067, 0.000000, 0.374107, 0.374107, 0.458186, 0.264534],
|
|
187
|
+
[0.000000, 0.529067, 0.374107, 0.374107, 0.264534, 0.458186]]
|
|
188
|
+
),
|
|
189
|
+
("6.1", "stereo"): ( # 'fl', 'fr', 'fc', 'lfe', 'bc', 'sl', 'sr'
|
|
190
|
+
[[0.455310, 0.000000, 0.321953, 0.321953, 0.278819, 0.394310, 0.227655],
|
|
191
|
+
[0.000000, 0.455310, 0.321953, 0.321953, 0.278819, 0.227655, 0.394310]]
|
|
192
|
+
),
|
|
193
|
+
("7.1", "stereo"): ( # 'fl', 'fr', 'fc', 'lfe', 'bl', 'br', 'sl', 'sr'
|
|
194
|
+
[[0.388631, 0.000000, 0.274804, 0.274804, 0.336565, 0.194316, 0.336565, 0.194316],
|
|
195
|
+
[0.000000, 0.388631, 0.274804, 0.274804, 0.194316, 0.336565, 0.194316, 0.336565]]
|
|
196
|
+
),
|
|
197
|
+
}
|
|
198
|
+
upmixing = {
|
|
199
|
+
("mono", "stereo"): ( # 'fc'
|
|
200
|
+
[[1.000000],
|
|
201
|
+
[1.000000]]
|
|
202
|
+
),
|
|
203
|
+
}
|
|
204
|
+
identity = {
|
|
205
|
+
(c, c): [[1.0 if d2 == d1 else 0.0 for d2 in d] for d1 in d]
|
|
206
|
+
for c, d in AllLayouts().layouts.items()
|
|
207
|
+
}
|
|
208
|
+
return downmixing | upmixing | identity
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Basic casts between different video profiles."""
|
|
4
|
+
|
|
5
|
+
import torch
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _get_alpha(frame: torch.Tensor) -> torch.Tensor:
|
|
9
|
+
"""Get the alpha channel."""
|
|
10
|
+
if frame.shape[2] in {2, 4}:
|
|
11
|
+
return torch.unsqueeze(frame[..., frame.shape[2]-1], 2)
|
|
12
|
+
return torch.full(
|
|
13
|
+
(frame.shape[0], frame.shape[1], 1),
|
|
14
|
+
(1.0 if frame.dtype.is_floating_point else 255),
|
|
15
|
+
dtype=frame.dtype,
|
|
16
|
+
layout=frame.layout,
|
|
17
|
+
device=frame.device,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def to_gray(frame: torch.Tensor) -> torch.Tensor:
|
|
22
|
+
"""Convert any video frame into a 1 gray channel frame.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
frame : torch.Tensor
|
|
27
|
+
The input frame of shape (height, width, channels).
|
|
28
|
+
|
|
29
|
+
Returns
|
|
30
|
+
-------
|
|
31
|
+
frame
|
|
32
|
+
The output 1 gray channel frame, the data can by shared.
|
|
33
|
+
Type has to be floating point or uint8.
|
|
34
|
+
|
|
35
|
+
Examples
|
|
36
|
+
--------
|
|
37
|
+
>>> import torch
|
|
38
|
+
>>> from cutcutcodec.core.filters.mix.video_cast import to_gray
|
|
39
|
+
>>> _ = torch.manual_seed(0)
|
|
40
|
+
>>> for dtype in (torch.uint8, torch.float16, torch.float32, torch.float64):
|
|
41
|
+
... for channels in (1, 2, 3, 4):
|
|
42
|
+
... if dtype == torch.uint8:
|
|
43
|
+
... frame = torch.randint(0, 256, (480, 720, channels), dtype=torch.uint8)
|
|
44
|
+
... else:
|
|
45
|
+
... frame = torch.rand((480, 720, channels), dtype=dtype)
|
|
46
|
+
... assert to_gray(frame).shape == (480, 720, 1)
|
|
47
|
+
... assert to_gray(frame).dtype == dtype
|
|
48
|
+
...
|
|
49
|
+
>>>
|
|
50
|
+
"""
|
|
51
|
+
assert isinstance(frame, torch.Tensor), frame.__class__.__name__
|
|
52
|
+
assert len(frame.shape) == 3, frame.shape
|
|
53
|
+
|
|
54
|
+
if frame.shape[2] == 1:
|
|
55
|
+
return frame
|
|
56
|
+
if frame.shape[2] == 2:
|
|
57
|
+
gray = torch.unsqueeze(frame[..., 0], 2)
|
|
58
|
+
# set the totaly transparent pxl in black, inplace ok no danger
|
|
59
|
+
gray[_get_alpha(frame) == 0] = 0 # 46% faster than torch.where
|
|
60
|
+
return gray
|
|
61
|
+
if frame.shape[2] == 3:
|
|
62
|
+
if frame.dtype == torch.uint8:
|
|
63
|
+
frame = to_gray(frame.to(dtype=torch.float32))
|
|
64
|
+
return torch.round(frame, out=frame).to(dtype=torch.uint8)
|
|
65
|
+
return torch.unsqueeze(.114*frame[..., 0] + 0.587*frame[..., 1] + 0.299*frame[..., 2], 2)
|
|
66
|
+
if frame.shape[2] == 4:
|
|
67
|
+
gray = to_gray(frame[..., :3])
|
|
68
|
+
gray[_get_alpha(frame) == 0] = 0
|
|
69
|
+
return gray
|
|
70
|
+
raise ValueError(f"only, 1, 2, 3, or 4 layers, not {frame.shape[2]}")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def to_gray_alpha(frame: torch.Tensor) -> torch.Tensor:
|
|
74
|
+
"""Convert any video frame into a 2 channels (gray, alpha) frame.
|
|
75
|
+
|
|
76
|
+
Parameters
|
|
77
|
+
----------
|
|
78
|
+
frame : torch.Tensor
|
|
79
|
+
The input frame of shape (height, width, channels).
|
|
80
|
+
|
|
81
|
+
Returns
|
|
82
|
+
-------
|
|
83
|
+
frame
|
|
84
|
+
The output 2 gray alpha channels frame, the data can by shared.
|
|
85
|
+
Type has to be floating point or uint8.
|
|
86
|
+
|
|
87
|
+
Examples
|
|
88
|
+
--------
|
|
89
|
+
>>> import torch
|
|
90
|
+
>>> from cutcutcodec.core.filters.mix.video_cast import to_gray_alpha
|
|
91
|
+
>>> _ = torch.manual_seed(0)
|
|
92
|
+
>>> for dtype in (torch.uint8, torch.float16, torch.float32, torch.float64):
|
|
93
|
+
... for channels in (1, 2, 3, 4):
|
|
94
|
+
... if dtype == torch.uint8:
|
|
95
|
+
... frame = torch.randint(0, 256, (480, 720, channels), dtype=torch.uint8)
|
|
96
|
+
... else:
|
|
97
|
+
... frame = torch.rand((480, 720, channels), dtype=dtype)
|
|
98
|
+
... assert to_gray_alpha(frame).shape == (480, 720, 2)
|
|
99
|
+
... assert to_gray_alpha(frame).dtype == dtype
|
|
100
|
+
...
|
|
101
|
+
>>>
|
|
102
|
+
"""
|
|
103
|
+
assert isinstance(frame, torch.Tensor), frame.__class__.__name__
|
|
104
|
+
assert len(frame.shape) == 3, frame.shape
|
|
105
|
+
|
|
106
|
+
if frame.shape[2] == 2:
|
|
107
|
+
return frame
|
|
108
|
+
if frame.shape[2] in {1, 3, 4}:
|
|
109
|
+
return torch.cat([to_gray(frame), _get_alpha(frame)], 2)
|
|
110
|
+
raise ValueError(f"only, 1, 2, 3, or 4 layers, not {frame.shape[2]}")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def to_bgr(frame: torch.Tensor) -> torch.Tensor:
|
|
114
|
+
"""Convert any video frame into a 3 channels (blue, green, red) frame.
|
|
115
|
+
|
|
116
|
+
Parameters
|
|
117
|
+
----------
|
|
118
|
+
frame : torch.Tensor
|
|
119
|
+
The input frame of shape (height, width, channels).
|
|
120
|
+
|
|
121
|
+
Returns
|
|
122
|
+
-------
|
|
123
|
+
frame
|
|
124
|
+
The output 3 blue, green, red channels frame, the data can by shared.
|
|
125
|
+
Type has to be floating point or uint8.
|
|
126
|
+
|
|
127
|
+
Examples
|
|
128
|
+
--------
|
|
129
|
+
>>> import torch
|
|
130
|
+
>>> from cutcutcodec.core.filters.mix.video_cast import to_bgr
|
|
131
|
+
>>> _ = torch.manual_seed(0)
|
|
132
|
+
>>> for dtype in (torch.uint8, torch.float16, torch.float32, torch.float64):
|
|
133
|
+
... for channels in (1, 2, 3, 4):
|
|
134
|
+
... if dtype == torch.uint8:
|
|
135
|
+
... frame = torch.randint(0, 256, (480, 720, channels), dtype=torch.uint8)
|
|
136
|
+
... else:
|
|
137
|
+
... frame = torch.rand((480, 720, channels), dtype=dtype)
|
|
138
|
+
... assert to_bgr(frame).shape == (480, 720, 3)
|
|
139
|
+
... assert to_bgr(frame).dtype == dtype
|
|
140
|
+
...
|
|
141
|
+
>>>
|
|
142
|
+
"""
|
|
143
|
+
assert isinstance(frame, torch.Tensor), frame.__class__.__name__
|
|
144
|
+
assert len(frame.shape) == 3, frame.shape
|
|
145
|
+
|
|
146
|
+
if frame.shape[2] == 1:
|
|
147
|
+
return frame.expand(-1, -1, 3)
|
|
148
|
+
if frame.shape[2] == 2:
|
|
149
|
+
return to_bgr(to_gray(frame)) # call to_gray manage transparent to black pxls
|
|
150
|
+
if frame.shape[2] == 3:
|
|
151
|
+
return frame
|
|
152
|
+
if frame.shape[2] == 4:
|
|
153
|
+
bgr = frame[..., :3]
|
|
154
|
+
# set the totaly transparent pxl in black, inplace ok no danger
|
|
155
|
+
bgr[(_get_alpha(frame) == 0).expand(-1, -1, 3)] = 0 # 46% faster than torch.where
|
|
156
|
+
return bgr
|
|
157
|
+
raise ValueError(f"only, 1, 2, 3, or 4 layers, not {frame.shape[2]}")
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def to_bgr_alpha(frame: torch.Tensor) -> torch.Tensor:
|
|
161
|
+
"""Convert any video frame into a 4 channels (blue, green, red, alpha) frame.
|
|
162
|
+
|
|
163
|
+
Parameters
|
|
164
|
+
----------
|
|
165
|
+
frame : torch.Tensor
|
|
166
|
+
The input frame of shape (height, width, channels).
|
|
167
|
+
|
|
168
|
+
Returns
|
|
169
|
+
-------
|
|
170
|
+
frame
|
|
171
|
+
The output 4 blue, green, red alpha channels frame, the data can by shared.
|
|
172
|
+
Type has to be floating point or uint8.
|
|
173
|
+
|
|
174
|
+
Examples
|
|
175
|
+
--------
|
|
176
|
+
>>> import torch
|
|
177
|
+
>>> from cutcutcodec.core.filters.mix.video_cast import to_bgr_alpha
|
|
178
|
+
>>> _ = torch.manual_seed(0)
|
|
179
|
+
>>> for dtype in (torch.uint8, torch.float16, torch.float32, torch.float64):
|
|
180
|
+
... for channels in (1, 2, 3, 4):
|
|
181
|
+
... if dtype == torch.uint8:
|
|
182
|
+
... frame = torch.randint(0, 256, (480, 720, channels), dtype=torch.uint8)
|
|
183
|
+
... else:
|
|
184
|
+
... frame = torch.rand((480, 720, channels), dtype=dtype)
|
|
185
|
+
... assert to_bgr_alpha(frame).shape == (480, 720, 4)
|
|
186
|
+
... assert to_bgr_alpha(frame).dtype == dtype
|
|
187
|
+
...
|
|
188
|
+
>>>
|
|
189
|
+
"""
|
|
190
|
+
assert isinstance(frame, torch.Tensor), frame.__class__.__name__
|
|
191
|
+
assert len(frame.shape) == 3, frame.shape
|
|
192
|
+
|
|
193
|
+
if frame.shape[2] == 4:
|
|
194
|
+
return frame
|
|
195
|
+
if frame.shape[2] in {1, 2, 3}:
|
|
196
|
+
return torch.cat([to_bgr(frame), _get_alpha(frame)], 2)
|
|
197
|
+
raise ValueError(f"only, 1, 2, 3, or 4 layers, not {frame.shape[2]}")
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""The common part for ``FilterAudioSubclip`` and ``FilterVideoSubclip``."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import math
|
|
7
|
+
import numbers
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class FilterSubclip:
|
|
11
|
+
"""Extract a segment from a stream.
|
|
12
|
+
|
|
13
|
+
Attributes
|
|
14
|
+
----------
|
|
15
|
+
delay : Fraction
|
|
16
|
+
The offset from the parent stream (readonly).
|
|
17
|
+
duration_max : Fraction or inf
|
|
18
|
+
The maximum duration beyond which the flows do not return anything (readonly).
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, delay: numbers.Real = Fraction(0), duration_max: numbers.Real = math.inf):
|
|
22
|
+
"""Initialise and create the class.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
delay: numbers.Real, default=0
|
|
27
|
+
The time lapse from the parent stream.
|
|
28
|
+
0 means that the beginning of the new stream coincides
|
|
29
|
+
with the beginning of the stream that arrives at this node.
|
|
30
|
+
A delay of x >= 0 seconds means that
|
|
31
|
+
the first x seconds of the stream arriving on this filter are discarded.
|
|
32
|
+
duration_max : numbers.Real, default=inf
|
|
33
|
+
The maximal duration of the new audio stream.
|
|
34
|
+
"""
|
|
35
|
+
assert isinstance(delay, numbers.Real), delay.__class__.__name__
|
|
36
|
+
assert math.isfinite(delay) and delay >= 0, delay
|
|
37
|
+
assert isinstance(duration_max, numbers.Real), duration_max.__class__.__name__
|
|
38
|
+
assert duration_max > 0, duration_max
|
|
39
|
+
self._delay = Fraction(delay)
|
|
40
|
+
self._duration_max = Fraction(duration_max) if math.isfinite(duration_max) else duration_max
|
|
41
|
+
|
|
42
|
+
def _getstate(self) -> dict:
|
|
43
|
+
return {"delay": str(self.delay), "duration_max": str(self.duration_max)}
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def delay(self) -> Fraction:
|
|
47
|
+
"""Return the offset from the parent stream."""
|
|
48
|
+
return self._delay
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def duration_max(self) -> Fraction:
|
|
52
|
+
"""Return the maximum duration beyond which the flows do not return anything."""
|
|
53
|
+
return self._duration_max
|