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,206 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""The significance of the audio and video frame channels."""
|
|
4
|
+
|
|
5
|
+
import numbers
|
|
6
|
+
import re
|
|
7
|
+
import subprocess
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
from cutcutcodec.core.opti.cache.singleton import MetaSingleton
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AllLayouts(metaclass=MetaSingleton):
|
|
14
|
+
"""Parse the ``ffmpeg -layouts`` command line.
|
|
15
|
+
|
|
16
|
+
Attributes
|
|
17
|
+
----------
|
|
18
|
+
individuals : dict[str, str]
|
|
19
|
+
To each channel canonical name in lower case, associate the description (readonly).
|
|
20
|
+
layouts : dict[str, tuple[str, ...]]
|
|
21
|
+
To each layouts name, associate the names of the channels (readonly).
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(self):
|
|
25
|
+
doc = "\n" + subprocess.run(
|
|
26
|
+
("ffmpeg", "-v", "error", "-layouts"), capture_output=True, check=True
|
|
27
|
+
).stdout.decode()
|
|
28
|
+
|
|
29
|
+
if (match := re.search(r"\n.+:\s+NAME[ \t]+DESCRIPTION", doc)) is None:
|
|
30
|
+
raise RuntimeError(f"impossible to find invidual channels description in {doc}")
|
|
31
|
+
ind = match.span()
|
|
32
|
+
if (match := re.search(r"\n.+:\s+NAME[ \t]+DECOMPOSITION", doc)) is None:
|
|
33
|
+
raise RuntimeError(f"impossible to find standard channel layouts description in {doc}")
|
|
34
|
+
lay = match.span()
|
|
35
|
+
ind, lay = (
|
|
36
|
+
(ind[1], lay[0] if lay[0] > ind[1] else len(doc)),
|
|
37
|
+
(lay[1], ind[0] if ind[0] > lay[1] else len(doc)),
|
|
38
|
+
)
|
|
39
|
+
ind, lay = doc[ind[0]:ind[1]], doc[lay[0]:lay[1]]
|
|
40
|
+
self._individuals = {
|
|
41
|
+
m["name"].lower(): m["desc"]
|
|
42
|
+
for m in re.finditer(r"(?P<name>[a-zA-Z0-9]+)[ \t]+(?P<desc>.+)", ind)
|
|
43
|
+
}
|
|
44
|
+
self._layouts = {
|
|
45
|
+
m["name"].lower(): tuple(c.lower() for c in m["channels"].split("+"))
|
|
46
|
+
for m in re.finditer(r"(?P<name>[\w\.\-\(\)]+)[ \t]+(?P<channels>[a-zA-Z0-9\+]+)", lay)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def individuals(self) -> dict[str, str]:
|
|
51
|
+
"""To each channel canonical name in lower case, associate the description.
|
|
52
|
+
|
|
53
|
+
Examples
|
|
54
|
+
--------
|
|
55
|
+
>>> from pprint import pprint
|
|
56
|
+
>>> from cutcutcodec.core.classes.layout import AllLayouts
|
|
57
|
+
>>> pprint(AllLayouts().individuals)
|
|
58
|
+
{'bc': 'back center',
|
|
59
|
+
'bfc': 'bottom front center',
|
|
60
|
+
'bfl': 'bottom front left',
|
|
61
|
+
'bfr': 'bottom front right',
|
|
62
|
+
'bl': 'back left',
|
|
63
|
+
'br': 'back right',
|
|
64
|
+
'dl': 'downmix left',
|
|
65
|
+
'dr': 'downmix right',
|
|
66
|
+
'fc': 'front center',
|
|
67
|
+
'fl': 'front left',
|
|
68
|
+
'flc': 'front left-of-center',
|
|
69
|
+
'fr': 'front right',
|
|
70
|
+
'frc': 'front right-of-center',
|
|
71
|
+
'lfe': 'low frequency',
|
|
72
|
+
'lfe2': 'low frequency 2',
|
|
73
|
+
'sdl': 'surround direct left',
|
|
74
|
+
'sdr': 'surround direct right',
|
|
75
|
+
'sl': 'side left',
|
|
76
|
+
'sr': 'side right',
|
|
77
|
+
'tbc': 'top back center',
|
|
78
|
+
'tbl': 'top back left',
|
|
79
|
+
'tbr': 'top back right',
|
|
80
|
+
'tc': 'top center',
|
|
81
|
+
'tfc': 'top front center',
|
|
82
|
+
'tfl': 'top front left',
|
|
83
|
+
'tfr': 'top front right',
|
|
84
|
+
'tsl': 'top side left',
|
|
85
|
+
'tsr': 'top side right',
|
|
86
|
+
'wl': 'wide left',
|
|
87
|
+
'wr': 'wide right'}
|
|
88
|
+
>>>
|
|
89
|
+
"""
|
|
90
|
+
return self._individuals.copy()
|
|
91
|
+
|
|
92
|
+
@property
|
|
93
|
+
def layouts(self) -> dict[str, list[str]]:
|
|
94
|
+
"""To each layouts name, associate the names of the channels.
|
|
95
|
+
|
|
96
|
+
Examples
|
|
97
|
+
--------
|
|
98
|
+
>>> from pprint import pprint
|
|
99
|
+
>>> from cutcutcodec.core.classes.layout import AllLayouts
|
|
100
|
+
>>> pprint(AllLayouts().layouts) # doctest: +ELLIPSIS
|
|
101
|
+
{'2.1': ('fl', 'fr', 'lfe'),
|
|
102
|
+
...
|
|
103
|
+
'stereo': ('fl', 'fr')}
|
|
104
|
+
>>>
|
|
105
|
+
"""
|
|
106
|
+
return self._layouts.copy()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class Layout:
|
|
110
|
+
"""An audio profile.
|
|
111
|
+
|
|
112
|
+
Attributes
|
|
113
|
+
----------
|
|
114
|
+
channels : tuple[tuple[str, str], ...]
|
|
115
|
+
Each audio channel (readonly) as an ordered dict with:
|
|
116
|
+
The canonical name of the audio channel and a human description of the audio channel.
|
|
117
|
+
name : str
|
|
118
|
+
The canonical name of the audio profile (readonly).
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
def __init__(self, name: typing.Union[str, numbers.Integral]):
|
|
122
|
+
"""Initialise and create the class.
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
name : str or numbers.Integral
|
|
127
|
+
The canonical name of the audio profile.
|
|
128
|
+
If an integer is provide, a default profile is assigned.
|
|
129
|
+
"""
|
|
130
|
+
if isinstance(name, numbers.Integral):
|
|
131
|
+
if (
|
|
132
|
+
name_ := {
|
|
133
|
+
1: "mono",
|
|
134
|
+
2: "stereo",
|
|
135
|
+
3: "2.1",
|
|
136
|
+
4: "quad",
|
|
137
|
+
5: "4.1",
|
|
138
|
+
6: "5.1",
|
|
139
|
+
7: "6.1",
|
|
140
|
+
8: "7.1",
|
|
141
|
+
10: "5.1.4",
|
|
142
|
+
12: "7.1.4",
|
|
143
|
+
16: "hexadecagonal",
|
|
144
|
+
24: "22.2",
|
|
145
|
+
}.get(name, None)
|
|
146
|
+
) is None:
|
|
147
|
+
raise ValueError(
|
|
148
|
+
f"only 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, or 24 audio channels, not {name}"
|
|
149
|
+
)
|
|
150
|
+
name = name_
|
|
151
|
+
assert isinstance(name, str), name.__class__.__name__
|
|
152
|
+
audio_profile = AllLayouts()
|
|
153
|
+
if (channels := audio_profile.layouts.get(name, None)) is None:
|
|
154
|
+
raise ValueError(
|
|
155
|
+
f"profile audio {name} not in {sorted(AllLayouts().layouts)}"
|
|
156
|
+
)
|
|
157
|
+
self._name = str(name)
|
|
158
|
+
self._channels = tuple((c, audio_profile.individuals[c]) for c in channels)
|
|
159
|
+
|
|
160
|
+
def __hash__(self):
|
|
161
|
+
"""Make this object able to be used in set or as dict key."""
|
|
162
|
+
return hash(self._name)
|
|
163
|
+
|
|
164
|
+
def __eq__(self, other):
|
|
165
|
+
"""Make this object able to be used in set or as dict key."""
|
|
166
|
+
if not isinstance(other, Layout):
|
|
167
|
+
return False
|
|
168
|
+
return other.name == self._name
|
|
169
|
+
|
|
170
|
+
def __repr__(self):
|
|
171
|
+
"""Give a nice representation of the layout."""
|
|
172
|
+
return f"{self.__class__.__name__}({repr(self._name)})"
|
|
173
|
+
|
|
174
|
+
@property
|
|
175
|
+
def channels(self) -> tuple[tuple[str, str], ...]:
|
|
176
|
+
"""Return the description of each channels.
|
|
177
|
+
|
|
178
|
+
Examples
|
|
179
|
+
--------
|
|
180
|
+
>>> from pprint import pprint
|
|
181
|
+
>>> from cutcutcodec.core.classes.layout import Layout
|
|
182
|
+
>>> Layout("stereo").channels
|
|
183
|
+
(('fl', 'front left'), ('fr', 'front right'))
|
|
184
|
+
>>> pprint(Layout("5.1").channels)
|
|
185
|
+
(('fl', 'front left'),
|
|
186
|
+
('fr', 'front right'),
|
|
187
|
+
('fc', 'front center'),
|
|
188
|
+
('lfe', 'low frequency'),
|
|
189
|
+
('bl', 'back left'),
|
|
190
|
+
('br', 'back right'))
|
|
191
|
+
>>>
|
|
192
|
+
"""
|
|
193
|
+
return self._channels
|
|
194
|
+
|
|
195
|
+
@property
|
|
196
|
+
def name(self) -> str:
|
|
197
|
+
"""Return the canonical name of the audio profile.
|
|
198
|
+
|
|
199
|
+
Examples
|
|
200
|
+
--------
|
|
201
|
+
>>> from cutcutcodec.core.classes.layout import Layout
|
|
202
|
+
>>> Layout(2).name
|
|
203
|
+
'stereo'
|
|
204
|
+
>>>
|
|
205
|
+
"""
|
|
206
|
+
return self._name
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""It's an effect that combine several effects."""
|
|
4
|
+
|
|
5
|
+
import abc
|
|
6
|
+
import typing
|
|
7
|
+
|
|
8
|
+
from cutcutcodec.core.classes.filter import Filter
|
|
9
|
+
from cutcutcodec.core.classes.node import Node
|
|
10
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MetaFilter(Filter):
|
|
14
|
+
"""A filter that combine several filters, a sub-graph."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, in_streams: typing.Iterable[Stream]):
|
|
17
|
+
super().__init__(in_streams, in_streams)
|
|
18
|
+
if not self.in_streams:
|
|
19
|
+
self.subgraph = self
|
|
20
|
+
else:
|
|
21
|
+
self.subgraph = self._compile(self.in_streams)
|
|
22
|
+
assert isinstance(self.subgraph, Node), self.subgraph.__class__.__name__
|
|
23
|
+
super().__init__(self.in_streams, self.subgraph.out_streams)
|
|
24
|
+
for out_stream in self.out_streams:
|
|
25
|
+
out_stream.node_main = self
|
|
26
|
+
|
|
27
|
+
@abc.abstractmethod
|
|
28
|
+
def _compile(self, in_streams: tuple[Stream]) -> Node:
|
|
29
|
+
"""Create and returns the sub graph.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
in_streams : typing.Iterable[Stream]
|
|
34
|
+
The none empty list of the ordered input streams.
|
|
35
|
+
|
|
36
|
+
Return
|
|
37
|
+
------
|
|
38
|
+
node : cutcutcodec.core.classes.node.Node
|
|
39
|
+
The final node used as itself.
|
|
40
|
+
"""
|
|
41
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""The multimedia formats."""
|
|
4
|
+
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
7
|
+
import av
|
|
8
|
+
|
|
9
|
+
from cutcutcodec.core.opti.cache.singleton import MetaSingleton
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AllMuxers(metaclass=MetaSingleton):
|
|
13
|
+
"""Equivalent to parse ``ffmpeg -muxers`` but use av insted.
|
|
14
|
+
|
|
15
|
+
Some muxers are remove if they are strange or not allow writting.
|
|
16
|
+
|
|
17
|
+
Attributes
|
|
18
|
+
----------
|
|
19
|
+
set : frozenset[str]
|
|
20
|
+
All the available muxers (readonly).
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self):
|
|
24
|
+
self._muxers = av.format.formats_available
|
|
25
|
+
self._muxers -= {
|
|
26
|
+
"alsa",
|
|
27
|
+
"audiotoolbox",
|
|
28
|
+
# "caca",
|
|
29
|
+
"chromaprint",
|
|
30
|
+
# "decklink",
|
|
31
|
+
"dash",
|
|
32
|
+
"dshow",
|
|
33
|
+
"fbdev",
|
|
34
|
+
"ffmetadata",
|
|
35
|
+
"fifo_test",
|
|
36
|
+
# "image2pipe",
|
|
37
|
+
# "null",
|
|
38
|
+
"opengl",
|
|
39
|
+
# "oss",
|
|
40
|
+
"pulse",
|
|
41
|
+
# "roq",
|
|
42
|
+
# "rtp",
|
|
43
|
+
"sdl", # stream in live windows
|
|
44
|
+
"sdl,sdl2", # alias to sdl
|
|
45
|
+
"sdl2", # alias to sdl
|
|
46
|
+
"smoothstreaming",
|
|
47
|
+
"xv",
|
|
48
|
+
}
|
|
49
|
+
for muxer in self._muxers.copy():
|
|
50
|
+
try:
|
|
51
|
+
av.format.ContainerFormat(muxer, "w")
|
|
52
|
+
except ValueError:
|
|
53
|
+
self._muxers.remove(muxer)
|
|
54
|
+
self._muxers = frozenset(self._muxers)
|
|
55
|
+
|
|
56
|
+
def from_suffix(self, suffix: str) -> list[str]:
|
|
57
|
+
"""Find the muxers from the file suffix.
|
|
58
|
+
|
|
59
|
+
Parameters
|
|
60
|
+
----------
|
|
61
|
+
suffix : str
|
|
62
|
+
The filename extension, including the ".".
|
|
63
|
+
|
|
64
|
+
Returns
|
|
65
|
+
-------
|
|
66
|
+
muxers : list[str]
|
|
67
|
+
The sorted available muxer names,
|
|
68
|
+
from the most pertinant (index 0) to the less pertinant.
|
|
69
|
+
|
|
70
|
+
Raises
|
|
71
|
+
------
|
|
72
|
+
KeyError
|
|
73
|
+
If the extension is not associate to any muxer.
|
|
74
|
+
|
|
75
|
+
Examples
|
|
76
|
+
--------
|
|
77
|
+
>>> from cutcutcodec.core.classes.muxer import AllMuxers
|
|
78
|
+
>>> AllMuxers().from_suffix(".mkv")
|
|
79
|
+
['matroska']
|
|
80
|
+
>>>
|
|
81
|
+
"""
|
|
82
|
+
assert isinstance(suffix, str), suffix.__class__.__name__
|
|
83
|
+
assert suffix.startswith("."), suffix
|
|
84
|
+
suffix = suffix.lower()[1:]
|
|
85
|
+
|
|
86
|
+
# get all avalaible extensions
|
|
87
|
+
all_suffix = {}
|
|
88
|
+
for muxer in self._muxers:
|
|
89
|
+
for suf in av.format.ContainerFormat(muxer, "w").extensions:
|
|
90
|
+
all_suffix[suf] = all_suffix.get(suf, set())
|
|
91
|
+
all_suffix[suf].add(muxer)
|
|
92
|
+
|
|
93
|
+
# simple case
|
|
94
|
+
if suffix not in all_suffix:
|
|
95
|
+
raise KeyError(f"{suffix} not in {sorted(all_suffix)}")
|
|
96
|
+
muxers = all_suffix[suffix]
|
|
97
|
+
if len(muxers) == 1:
|
|
98
|
+
return list(muxers)
|
|
99
|
+
|
|
100
|
+
criteria = []
|
|
101
|
+
|
|
102
|
+
# 1 choice, if one of the muxer supports only this extension
|
|
103
|
+
criteria.append(lambda muxer: av.format.ContainerFormat(muxer).extensions == {suffix})
|
|
104
|
+
|
|
105
|
+
# 2 choice, alphabetic order.
|
|
106
|
+
criteria.append(lambda muxer: muxer)
|
|
107
|
+
|
|
108
|
+
# sorted with the criteria
|
|
109
|
+
cost = {m: tuple(c(m) for c in criteria) for m in muxers}
|
|
110
|
+
return sorted(muxers, key=lambda muxer: cost[muxer])
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def set(self) -> frozenset[str]:
|
|
114
|
+
"""Return the set of all the available muxer."""
|
|
115
|
+
return self._muxers
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class Muxer(av.format.ContainerFormat):
|
|
119
|
+
"""A specific muxer.
|
|
120
|
+
|
|
121
|
+
Attributes
|
|
122
|
+
----------
|
|
123
|
+
doc : str
|
|
124
|
+
The documentation of the muxer (readonly).
|
|
125
|
+
extensions : frozenset[str]
|
|
126
|
+
All the available extensions for this muxer (readonly).
|
|
127
|
+
"""
|
|
128
|
+
|
|
129
|
+
def __new__(cls, name: str):
|
|
130
|
+
"""Initialise and create the class.
|
|
131
|
+
|
|
132
|
+
Parameters
|
|
133
|
+
----------
|
|
134
|
+
name : str
|
|
135
|
+
The canonical name or the extension with the suffix ".".
|
|
136
|
+
"""
|
|
137
|
+
assert isinstance(name, str), name.__class__.__name__
|
|
138
|
+
name = name.lower()
|
|
139
|
+
if name.startswith("."):
|
|
140
|
+
try:
|
|
141
|
+
name = AllMuxers().from_suffix(name).pop(0)
|
|
142
|
+
except KeyError as err:
|
|
143
|
+
raise ValueError(f"failed to init muxer with extension {name}") from err
|
|
144
|
+
if name not in AllMuxers().set:
|
|
145
|
+
raise ValueError(f"muxer {name} not in {sorted(AllMuxers().set)}")
|
|
146
|
+
muxer = super().__new__(cls, name, "w")
|
|
147
|
+
return muxer
|
|
148
|
+
|
|
149
|
+
@property
|
|
150
|
+
def doc(self) -> str:
|
|
151
|
+
"""Return the documentation of the muxer.
|
|
152
|
+
|
|
153
|
+
Based on ffmpeg, it parse ``ffmpeg -h muxer=...``.
|
|
154
|
+
|
|
155
|
+
Examples
|
|
156
|
+
--------
|
|
157
|
+
>>> from cutcutcodec.core.classes.muxer import Muxer
|
|
158
|
+
>>> print(Muxer("null").doc)
|
|
159
|
+
Muxer null [raw null video]:
|
|
160
|
+
Default video codec: wrapped_avframe.
|
|
161
|
+
Default audio codec: pcm_s16le.
|
|
162
|
+
<BLANKLINE>
|
|
163
|
+
>>>
|
|
164
|
+
"""
|
|
165
|
+
doc = subprocess.run(
|
|
166
|
+
["ffmpeg", "-v", "error", "-h", f"muxer={self.name}"],
|
|
167
|
+
capture_output=True, check=True,
|
|
168
|
+
).stdout.decode()
|
|
169
|
+
return doc
|
|
170
|
+
|
|
171
|
+
@property
|
|
172
|
+
def extensions(self) -> frozenset[str]:
|
|
173
|
+
"""All the available extensions for this muxer.
|
|
174
|
+
|
|
175
|
+
Examples
|
|
176
|
+
--------
|
|
177
|
+
>>> from cutcutcodec.core.classes.muxer import Muxer
|
|
178
|
+
>>> sorted(Muxer("matroska").extensions)
|
|
179
|
+
['.mkv']
|
|
180
|
+
>>> sorted(Muxer("mpeg").extensions)
|
|
181
|
+
['.mpeg', '.mpg']
|
|
182
|
+
>>>
|
|
183
|
+
"""
|
|
184
|
+
return frozenset(f".{e}" for e in super().extensions)
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""General node of the assembly graph."""
|
|
4
|
+
|
|
5
|
+
import abc
|
|
6
|
+
import typing
|
|
7
|
+
|
|
8
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Node(abc.ABC):
|
|
12
|
+
"""General node of the assembly graph.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
copy : boolean, default=True
|
|
17
|
+
If False, try to avoid realocation as much as possible.
|
|
18
|
+
By default, the modifications are not inplace (readonly).
|
|
19
|
+
in_streams : tuple[Stream, ...]
|
|
20
|
+
The streams arriving on the node (readonly).
|
|
21
|
+
out_streams : tuple[Stream, ...]
|
|
22
|
+
The streams coming back on the node (readonly).
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
in_streams: typing.Union[list[Stream], tuple[Stream]],
|
|
28
|
+
out_streams: typing.Union[list[Stream], tuple[Stream]],
|
|
29
|
+
):
|
|
30
|
+
assert isinstance(in_streams, (list, tuple)), in_streams.__class__.__name__
|
|
31
|
+
in_streams = tuple(in_streams)
|
|
32
|
+
assert all(isinstance(stream, Stream) for stream in in_streams), \
|
|
33
|
+
[stream.__class__.__name__ for stream in in_streams]
|
|
34
|
+
assert isinstance(out_streams, (list, tuple)), out_streams.__class__.__name__
|
|
35
|
+
out_streams = tuple(out_streams)
|
|
36
|
+
assert all(isinstance(stream, Stream) for stream in out_streams), \
|
|
37
|
+
[stream.__class__.__name__ for stream in out_streams]
|
|
38
|
+
self._in_streams = in_streams
|
|
39
|
+
self._out_streams = out_streams
|
|
40
|
+
self._copy = getattr(self, "_copy", True)
|
|
41
|
+
|
|
42
|
+
def __eq__(self, other) -> bool:
|
|
43
|
+
"""Check that 2 nodes are equivalent."""
|
|
44
|
+
if self.__class__ != other.__class__:
|
|
45
|
+
return False
|
|
46
|
+
if self.getstate() != other.getstate():
|
|
47
|
+
return False
|
|
48
|
+
if self.in_streams != other.in_streams:
|
|
49
|
+
return False # not compare out_streams to avoide infinite loop
|
|
50
|
+
return True
|
|
51
|
+
|
|
52
|
+
def __getstate__(self) -> tuple[typing.Iterable[Stream], dict]:
|
|
53
|
+
"""Allow ``pickle`` to serialize efficiently."""
|
|
54
|
+
return self.in_streams, self.getstate()
|
|
55
|
+
|
|
56
|
+
def __setstate__(self, streams_state) -> None:
|
|
57
|
+
"""Allow ``pickle`` to recreate the object identically.
|
|
58
|
+
|
|
59
|
+
Parameters
|
|
60
|
+
----------
|
|
61
|
+
streams_state : tuple[typing.Iterable[cutcutcodec.core.classes.stream.Stream], dict]
|
|
62
|
+
These are the input streams and the other arguments.
|
|
63
|
+
"""
|
|
64
|
+
assert isinstance(streams_state, tuple), streams_state.__class__.__name__
|
|
65
|
+
assert len(streams_state) == 2, streams_state
|
|
66
|
+
in_streams, state = streams_state
|
|
67
|
+
self.setstate(in_streams, state)
|
|
68
|
+
|
|
69
|
+
@abc.abstractmethod
|
|
70
|
+
def _getstate(self) -> dict:
|
|
71
|
+
"""Help for ``cutcutcodec.core.classes.node.Node.getstate``."""
|
|
72
|
+
raise NotImplementedError
|
|
73
|
+
|
|
74
|
+
@abc.abstractmethod
|
|
75
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
76
|
+
"""Help for ``cutcutcodec.core.classes.node.Node.setstate``."""
|
|
77
|
+
raise NotImplementedError
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def copy(self) -> bool:
|
|
81
|
+
"""Try to avoid realocation as much as possible if False."""
|
|
82
|
+
return self._copy
|
|
83
|
+
|
|
84
|
+
@classmethod
|
|
85
|
+
@abc.abstractmethod
|
|
86
|
+
def default(cls):
|
|
87
|
+
"""Provide an example of an instance of this node.
|
|
88
|
+
|
|
89
|
+
Returns
|
|
90
|
+
-------
|
|
91
|
+
example : Node
|
|
92
|
+
An example of an instance of this class.
|
|
93
|
+
|
|
94
|
+
Notes
|
|
95
|
+
-----
|
|
96
|
+
It is a ``classmethod`` rather than a ``staticmethod`` in order to simplify inheritance.
|
|
97
|
+
"""
|
|
98
|
+
raise NotImplementedError
|
|
99
|
+
|
|
100
|
+
def getstate(self) -> dict:
|
|
101
|
+
"""Retrieve the internal state of the object.
|
|
102
|
+
|
|
103
|
+
Returns
|
|
104
|
+
-------
|
|
105
|
+
state : dict
|
|
106
|
+
An explicit dictionary containing the different attributes of the object.
|
|
107
|
+
Even if this is not optimal in terms of memory and speed,
|
|
108
|
+
the objects must be explicit so that they can be easily manipulated
|
|
109
|
+
when the assembly graph is optimized.
|
|
110
|
+
The keys must be of type str and the dictionary must to be jsonisable.
|
|
111
|
+
"""
|
|
112
|
+
state = self._getstate()
|
|
113
|
+
if self._copy is False:
|
|
114
|
+
state.update({"copy": False})
|
|
115
|
+
return state
|
|
116
|
+
|
|
117
|
+
def in_index(self, stream: Stream) -> int:
|
|
118
|
+
"""Return the input index of the stream comming on this node."""
|
|
119
|
+
indexs = [index for index, stream_ in enumerate(self._in_streams) if stream_ is stream]
|
|
120
|
+
if len(indexs) != 1:
|
|
121
|
+
raise AttributeError(f"the stream {stream} doesn't comme into the node {self}")
|
|
122
|
+
return indexs.pop()
|
|
123
|
+
|
|
124
|
+
def in_select(self, type_: str) -> tuple[Stream, ...]:
|
|
125
|
+
"""Select the incoming streams of a specific type."""
|
|
126
|
+
assert isinstance(type_, str), type_.__class__.__name__
|
|
127
|
+
return tuple(s for s in self._in_streams if s.type == type_)
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def in_streams(self) -> tuple[Stream, ...]:
|
|
131
|
+
"""Return the incoming streams on the node."""
|
|
132
|
+
return self._in_streams
|
|
133
|
+
|
|
134
|
+
def out_index(self, stream: Stream) -> int:
|
|
135
|
+
"""Return the output index of the stream escaping this node."""
|
|
136
|
+
indexs = [index for index, stream_ in enumerate(self._out_streams) if stream_ is stream]
|
|
137
|
+
if len(indexs) != 1:
|
|
138
|
+
raise AttributeError(f"the stream {stream} doesn't leave from the node {self}")
|
|
139
|
+
return indexs.pop()
|
|
140
|
+
|
|
141
|
+
def out_select(self, type_: str) -> tuple[Stream, ...]:
|
|
142
|
+
"""Select the outgoing streams of a specific type."""
|
|
143
|
+
assert isinstance(type_, str), type_.__class__.__name__
|
|
144
|
+
return tuple(s for s in self._out_streams if s.type == type_)
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def out_streams(self) -> tuple[Stream, ...]:
|
|
148
|
+
"""Return the outgoing streams on the node."""
|
|
149
|
+
return self._out_streams
|
|
150
|
+
|
|
151
|
+
def setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
152
|
+
"""Allow to completely change the internal state of the node.
|
|
153
|
+
|
|
154
|
+
Parameters
|
|
155
|
+
----------
|
|
156
|
+
in_streams
|
|
157
|
+
Same as ``cutcutcodec.core.classes.stream.Stream.in_streams``.
|
|
158
|
+
state : dict
|
|
159
|
+
The internal state returned by the ``getstate`` method of the same class.
|
|
160
|
+
"""
|
|
161
|
+
state = state.copy()
|
|
162
|
+
if (copy := state.pop("copy", None)) is not None:
|
|
163
|
+
self._copy = copy
|
|
164
|
+
self._setstate(in_streams, state)
|