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,205 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Defines the structure an audio frame."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import numbers
|
|
7
|
+
import re
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
import numpy as np
|
|
11
|
+
import torch
|
|
12
|
+
|
|
13
|
+
from cutcutcodec.core.classes.frame import Frame
|
|
14
|
+
from cutcutcodec.core.classes.layout import Layout
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FrameAudio(Frame):
|
|
18
|
+
"""An audio sample packet with time information.
|
|
19
|
+
|
|
20
|
+
Behaves like a torch tensor of shape (nbr_channels, samples).
|
|
21
|
+
The shape is consistent with pyav and torchaudio.
|
|
22
|
+
Values are supposed to be between -1 and 1 but no verification is done.
|
|
23
|
+
|
|
24
|
+
Attributes
|
|
25
|
+
----------
|
|
26
|
+
channels : int
|
|
27
|
+
The numbers of channels (readonly).
|
|
28
|
+
For more informations about each channels, let see ``self.layout``.
|
|
29
|
+
layout : cutcutcodec.core.classes.layout.Layout
|
|
30
|
+
The signification of each channels (readonly).
|
|
31
|
+
rate : int
|
|
32
|
+
The frequency of the samples in Hz (readonly).
|
|
33
|
+
samples : int
|
|
34
|
+
The number of samples per channels (readonly).
|
|
35
|
+
time : Fraction
|
|
36
|
+
The time of the first sample of the frame in second (readonly).
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
def __new__(
|
|
40
|
+
cls,
|
|
41
|
+
time: typing.Union[Fraction, numbers.Real, str],
|
|
42
|
+
rate: numbers.Integral,
|
|
43
|
+
layout: typing.Union[Layout, str, numbers.Integral],
|
|
44
|
+
data: typing.Union[torch.Tensor, np.ndarray, typing.Container],
|
|
45
|
+
**kwargs,
|
|
46
|
+
):
|
|
47
|
+
"""Initialise and create the class.
|
|
48
|
+
|
|
49
|
+
Parameters
|
|
50
|
+
----------
|
|
51
|
+
time : Fraction
|
|
52
|
+
The time of the first sample of the frame in second.
|
|
53
|
+
rate : int
|
|
54
|
+
The frequency of the samples in Hz.
|
|
55
|
+
layout : cutcutcodec.core.classes.layout.Layout or str or numbers.Integral
|
|
56
|
+
The canonical name of the layout,
|
|
57
|
+
let see ``cutcutcodec.core.classes.layout.Layout`` for the available layouts.
|
|
58
|
+
data : arraylike
|
|
59
|
+
Transmitted to ``cutcutcodec.core.classes.frame.Frame`` initialisator.
|
|
60
|
+
**kwargs : dict
|
|
61
|
+
Transmitted to ``cutcutcodec.core.classes.frame.Frame`` initialisator.
|
|
62
|
+
"""
|
|
63
|
+
frame = super().__new__(cls, data, context=[time, rate, layout], **kwargs)
|
|
64
|
+
frame.check_state()
|
|
65
|
+
return frame
|
|
66
|
+
|
|
67
|
+
def __repr__(self) -> str:
|
|
68
|
+
"""Compact and complete display of an evaluable version of the audio frame.
|
|
69
|
+
|
|
70
|
+
Examples
|
|
71
|
+
--------
|
|
72
|
+
>>> import torch
|
|
73
|
+
>>> from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
74
|
+
>>>
|
|
75
|
+
>>> FrameAudio("2/4", 48000, "stereo", torch.zeros(2, 1024))
|
|
76
|
+
FrameAudio('1/2', 48000, 'stereo', [[0., 0., 0., ..., 0., 0., 0.],
|
|
77
|
+
[0., 0., 0., ..., 0., 0., 0.]])
|
|
78
|
+
>>> _.to(dtype=torch.float16)
|
|
79
|
+
FrameAudio('1/2', 48000, 'stereo', [[0., 0., 0., ..., 0., 0., 0.],
|
|
80
|
+
[0., 0., 0., ..., 0., 0., 0.]],
|
|
81
|
+
dtype=torch.float16)
|
|
82
|
+
>>>
|
|
83
|
+
"""
|
|
84
|
+
time_str = f"'{self.time}'" if int(self.time) != self.time else f"{self.time}"
|
|
85
|
+
header = f"{self.__class__.__name__}({time_str}, {self.rate}, {repr(self.layout.name)}, "
|
|
86
|
+
tensor_str = np.array2string(
|
|
87
|
+
self.numpy(force=True), separator=", ", prefix=header, suffix=" "
|
|
88
|
+
)
|
|
89
|
+
if (infos := re.findall(r"\w+=[a-zA-Z0-9_\-.\"']+", repr(torch.Tensor(self)))):
|
|
90
|
+
infos = "\n" + " "*len(header) + (",\n" + " "*len(header)).join(infos)
|
|
91
|
+
return f"{header}{tensor_str},{infos})"
|
|
92
|
+
return f"{header}{tensor_str})"
|
|
93
|
+
|
|
94
|
+
def check_state(self) -> None:
|
|
95
|
+
"""Apply verifications.
|
|
96
|
+
|
|
97
|
+
Raises
|
|
98
|
+
------
|
|
99
|
+
AssertionError
|
|
100
|
+
If something wrong in this frame.
|
|
101
|
+
"""
|
|
102
|
+
assert isinstance(self.context[0], (Fraction, numbers.Real, str)), \
|
|
103
|
+
self.context[0].__class__.__name__ # corresponds to time attribute
|
|
104
|
+
self.context[0] = Fraction(self.context[0])
|
|
105
|
+
assert isinstance(self.context[1], numbers.Integral), \
|
|
106
|
+
self.context[1].__class__.__name__ # corresponds to rate attribute
|
|
107
|
+
self.context[1] = int(self.context[1])
|
|
108
|
+
assert self.context[1] > 0, self.context[1] # corresponds to rate attribute
|
|
109
|
+
assert isinstance(self.context[2], (Layout, str, numbers.Integral)), \
|
|
110
|
+
self.context[2].__class__.__name__ # corresponds to the layout
|
|
111
|
+
if isinstance(self.context[2], (str, numbers.Integral)):
|
|
112
|
+
self.context[2] = Layout(self.context[2])
|
|
113
|
+
assert self.ndim == 2, self.shape
|
|
114
|
+
assert self.shape[0] == len(self.context[2].channels), self.shape # nbr_channels
|
|
115
|
+
assert self.dtype.is_floating_point, self.dtype
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def channels(self) -> int:
|
|
119
|
+
"""Return the number of channels.
|
|
120
|
+
|
|
121
|
+
Examples
|
|
122
|
+
--------
|
|
123
|
+
>>> import torch
|
|
124
|
+
>>> from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
125
|
+
>>> FrameAudio(0, 48000, "stereo", torch.empty(2, 1024)).channels
|
|
126
|
+
2
|
|
127
|
+
>>>
|
|
128
|
+
"""
|
|
129
|
+
return self.shape[0]
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def layout(self) -> Layout:
|
|
133
|
+
"""Return the signification of each channels.
|
|
134
|
+
|
|
135
|
+
Examples
|
|
136
|
+
--------
|
|
137
|
+
>>> import torch
|
|
138
|
+
>>> from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
139
|
+
>>> FrameAudio(0, 48000, "stereo", torch.empty(2, 1024)).layout
|
|
140
|
+
Layout('stereo')
|
|
141
|
+
>>>
|
|
142
|
+
"""
|
|
143
|
+
return self.context[2]
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def rate(self) -> int:
|
|
147
|
+
"""Return the frequency of the samples in Hz.
|
|
148
|
+
|
|
149
|
+
Examples
|
|
150
|
+
--------
|
|
151
|
+
>>> import torch
|
|
152
|
+
>>> from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
153
|
+
>>> FrameAudio(0, 48000, "stereo", torch.empty(2, 1024)).rate
|
|
154
|
+
48000
|
|
155
|
+
>>>
|
|
156
|
+
"""
|
|
157
|
+
return self.context[1]
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def samples(self) -> int:
|
|
161
|
+
"""Return the number of samples per channels.
|
|
162
|
+
|
|
163
|
+
Examples
|
|
164
|
+
--------
|
|
165
|
+
>>> import torch
|
|
166
|
+
>>> from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
167
|
+
>>> FrameAudio(0, 48000, "stereo", torch.empty(2, 1024)).samples
|
|
168
|
+
1024
|
|
169
|
+
>>>
|
|
170
|
+
"""
|
|
171
|
+
return self.shape[1]
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def time(self) -> Fraction:
|
|
175
|
+
"""Return the time of the first sample of the frame in second.
|
|
176
|
+
|
|
177
|
+
Examples
|
|
178
|
+
--------
|
|
179
|
+
>>> import torch
|
|
180
|
+
>>> from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
181
|
+
>>> FrameAudio(0, 48000, "stereo", torch.empty(2, 1024)).time
|
|
182
|
+
Fraction(0, 1)
|
|
183
|
+
>>>
|
|
184
|
+
"""
|
|
185
|
+
return self.context[0]
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def timestamps(self) -> torch.Tensor:
|
|
189
|
+
"""Return the time value of each sample of the frame.
|
|
190
|
+
|
|
191
|
+
The vector is cast on the same type than the samples and in the same device.
|
|
192
|
+
The shape of the timestamps 1d vector is (self.samples,).
|
|
193
|
+
|
|
194
|
+
Examples
|
|
195
|
+
--------
|
|
196
|
+
>>> import torch
|
|
197
|
+
>>> from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
198
|
+
>>> FrameAudio(1, 48000, "stereo", torch.empty(2, 1024)).timestamps
|
|
199
|
+
tensor([1.0000, 1.0000, 1.0000, ..., 1.0213, 1.0213, 1.0213])
|
|
200
|
+
>>>
|
|
201
|
+
"""
|
|
202
|
+
timestamps = torch.arange(self.samples, dtype=self.dtype, device=self.device)
|
|
203
|
+
timestamps /= float(self.rate)
|
|
204
|
+
timestamps += float(self.time)
|
|
205
|
+
return timestamps
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Defines the structure a video frame."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import numbers
|
|
7
|
+
import re
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
import numpy as np
|
|
11
|
+
import torch
|
|
12
|
+
|
|
13
|
+
from cutcutcodec.core.classes.frame import Frame
|
|
14
|
+
from cutcutcodec.core.filters.mix.video_cast import to_gray, to_gray_alpha, to_bgr, to_bgr_alpha
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FrameVideo(Frame):
|
|
18
|
+
"""An image with time information for video context.
|
|
19
|
+
|
|
20
|
+
Behaves like a torch tensor of shape (height, width, nbr_channels).
|
|
21
|
+
The shape is consistent with pyav and cv2.
|
|
22
|
+
The dtype is automaticaly cast into torch.uint8.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
channels : int
|
|
27
|
+
The numbers of layers (readonly):
|
|
28
|
+
|
|
29
|
+
* 1 -> grayscale
|
|
30
|
+
* 2 -> grayscale, alpha
|
|
31
|
+
* 3 -> blue, green, red
|
|
32
|
+
* 4 -> blue, green, red, alpha
|
|
33
|
+
height : int
|
|
34
|
+
The dimension i (vertical) of the image in pxl (readonly).
|
|
35
|
+
time : Fraction
|
|
36
|
+
The time of the frame inside the video stream in second (readonly).
|
|
37
|
+
width : int
|
|
38
|
+
The dimension j (horizontal) of the image in pxl (readonly).
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __new__(
|
|
42
|
+
cls,
|
|
43
|
+
time: typing.Union[Fraction, numbers.Real, str],
|
|
44
|
+
data: typing.Union[torch.Tensor, np.ndarray, typing.Container],
|
|
45
|
+
**kwargs,
|
|
46
|
+
):
|
|
47
|
+
"""Construct a video frame and normalize the type.
|
|
48
|
+
|
|
49
|
+
Parameters
|
|
50
|
+
----------
|
|
51
|
+
time : Fraction
|
|
52
|
+
The time of the frame inside the video stream in second
|
|
53
|
+
data : arraylike
|
|
54
|
+
Transmitted to ``cutcutcodec.core.classes.frame.Frame`` initialisator.
|
|
55
|
+
**kwargs : dict
|
|
56
|
+
Transmitted to ``cutcutcodec.core.classes.frame.Frame`` initialisator.
|
|
57
|
+
"""
|
|
58
|
+
frame = super().__new__(cls, data, context=time, **kwargs)
|
|
59
|
+
if frame.dtype != torch.uint8:
|
|
60
|
+
frame = frame.to(dtype=torch.uint8, copy=False)
|
|
61
|
+
frame.check_state()
|
|
62
|
+
return frame
|
|
63
|
+
|
|
64
|
+
def __repr__(self) -> str:
|
|
65
|
+
"""Compact and complete display of an evaluable version of the video frame.
|
|
66
|
+
|
|
67
|
+
Examples
|
|
68
|
+
--------
|
|
69
|
+
>>> import torch
|
|
70
|
+
>>> from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
71
|
+
>>> FrameVideo("2/4", torch.zeros((480, 720, 3))) # doctest: +ELLIPSIS
|
|
72
|
+
FrameVideo('1/2', [[[0, 0, 0],
|
|
73
|
+
...
|
|
74
|
+
[0, 0, 0]]])
|
|
75
|
+
>>>
|
|
76
|
+
"""
|
|
77
|
+
time_str = f"'{self.time}'" if int(self.time) != self.time else f"{self.time}"
|
|
78
|
+
header = f"{self.__class__.__name__}({time_str}, "
|
|
79
|
+
tensor_str = np.array2string(
|
|
80
|
+
self.numpy(force=True), separator=", ", prefix=header, suffix=" "
|
|
81
|
+
)
|
|
82
|
+
if (infos := re.findall(r"\w+=[a-zA-Z0-9_\-.\"']+", torch.Tensor.__repr__(self))):
|
|
83
|
+
infos = [inf for inf in infos if inf != "dtype=torch.uint8"]
|
|
84
|
+
if infos:
|
|
85
|
+
infos = "\n" + " "*len(header) + (",\n" + " "*len(header)).join(infos)
|
|
86
|
+
return f"{header}{tensor_str},{infos})"
|
|
87
|
+
return f"{header}{tensor_str})"
|
|
88
|
+
|
|
89
|
+
@property
|
|
90
|
+
def channels(self) -> int:
|
|
91
|
+
"""Return the numbers of layers.
|
|
92
|
+
|
|
93
|
+
Examples
|
|
94
|
+
--------
|
|
95
|
+
>>> import torch
|
|
96
|
+
>>> from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
97
|
+
>>> FrameVideo(0, torch.empty(480, 720, 3)).channels
|
|
98
|
+
3
|
|
99
|
+
>>>
|
|
100
|
+
"""
|
|
101
|
+
return self.shape[2]
|
|
102
|
+
|
|
103
|
+
def check_state(self) -> None:
|
|
104
|
+
"""Apply verifications.
|
|
105
|
+
|
|
106
|
+
Raises
|
|
107
|
+
------
|
|
108
|
+
AssertionError
|
|
109
|
+
If something wrong in this frame.
|
|
110
|
+
"""
|
|
111
|
+
context = getattr(self, "context", None)
|
|
112
|
+
assert context is not None
|
|
113
|
+
assert isinstance(context, (Fraction, numbers.Real, str)), context.__class__.__name__
|
|
114
|
+
setattr(self, "context", Fraction(context))
|
|
115
|
+
assert self.ndim == 3, self.shape
|
|
116
|
+
assert self.shape[0] > 0, self.shape
|
|
117
|
+
assert self.shape[1] > 0, self.shape
|
|
118
|
+
assert self.shape[2] in {1, 2, 3, 4}, self.shape
|
|
119
|
+
assert self.dtype == torch.uint8, self.dtype
|
|
120
|
+
|
|
121
|
+
def convert(self, channels: int) -> Frame:
|
|
122
|
+
"""Change the numbers of channels of the frame.
|
|
123
|
+
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
frame : cutcutcodec.core.classes.frame_video.FrameVideo
|
|
127
|
+
The new frame, be carfull, undergroud data can be shared.
|
|
128
|
+
|
|
129
|
+
Examples
|
|
130
|
+
--------
|
|
131
|
+
>>> import torch
|
|
132
|
+
>>> from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
133
|
+
>>> _ = torch.manual_seed(0)
|
|
134
|
+
>>> ref_gray = FrameVideo(0, torch.randint(0, 256, (480, 720, 1), dtype=torch.uint8))
|
|
135
|
+
>>> ref_gray_alpha = FrameVideo(0, torch.randint(0, 256, (480, 720, 2), dtype=torch.uint8))
|
|
136
|
+
>>> ref_bgr = FrameVideo(0, torch.randint(0, 256, (480, 720, 3), dtype=torch.uint8))
|
|
137
|
+
>>> ref_bgr_alpha = FrameVideo(0, torch.randint(0, 256, (480, 720, 4), dtype=torch.uint8))
|
|
138
|
+
>>>
|
|
139
|
+
>>> # case 1 -> 2, 3, 4
|
|
140
|
+
>>> gray_alpha = ref_gray.convert(2)
|
|
141
|
+
>>> gray_alpha.channels
|
|
142
|
+
2
|
|
143
|
+
>>> torch.equal(gray_alpha[..., 0], ref_gray[..., 0])
|
|
144
|
+
True
|
|
145
|
+
>>> torch.eq(gray_alpha[..., 1], 255).all()
|
|
146
|
+
tensor(True)
|
|
147
|
+
>>> bgr = ref_gray.convert(3)
|
|
148
|
+
>>> bgr.channels
|
|
149
|
+
3
|
|
150
|
+
>>> torch.equal(bgr[..., 0], ref_gray[..., 0])
|
|
151
|
+
True
|
|
152
|
+
>>> torch.equal(bgr[..., 1], ref_gray[..., 0])
|
|
153
|
+
True
|
|
154
|
+
>>> torch.equal(bgr[..., 2], ref_gray[..., 0])
|
|
155
|
+
True
|
|
156
|
+
>>> bgr_alpha = ref_gray.convert(4)
|
|
157
|
+
>>> bgr_alpha.channels
|
|
158
|
+
4
|
|
159
|
+
>>> torch.equal(bgr_alpha[..., 0], ref_gray[..., 0])
|
|
160
|
+
True
|
|
161
|
+
>>> torch.equal(bgr_alpha[..., 1], ref_gray[..., 0])
|
|
162
|
+
True
|
|
163
|
+
>>> torch.equal(bgr_alpha[..., 2], ref_gray[..., 0])
|
|
164
|
+
True
|
|
165
|
+
>>> torch.eq(bgr_alpha[..., 3], 255).all()
|
|
166
|
+
tensor(True)
|
|
167
|
+
>>>
|
|
168
|
+
>>> # case 2 -> 1, 3, 4
|
|
169
|
+
>>> gray = ref_gray_alpha.convert(1)
|
|
170
|
+
>>> gray.channels
|
|
171
|
+
1
|
|
172
|
+
>>> torch.equal(gray[..., 0],
|
|
173
|
+
... torch.where(torch.eq(ref_gray_alpha[..., 1], 0), 0, ref_gray_alpha[..., 0]))
|
|
174
|
+
True
|
|
175
|
+
>>> bgr = ref_gray_alpha.convert(3)
|
|
176
|
+
>>> bgr.channels
|
|
177
|
+
3
|
|
178
|
+
>>> torch.equal(bgr[..., 0],
|
|
179
|
+
... torch.where(torch.eq(ref_gray_alpha[..., 1], 0), 0, ref_gray_alpha[..., 0]))
|
|
180
|
+
True
|
|
181
|
+
>>> torch.equal(bgr[..., 1],
|
|
182
|
+
... torch.where(torch.eq(ref_gray_alpha[..., 1], 0), 0, ref_gray_alpha[..., 0]))
|
|
183
|
+
True
|
|
184
|
+
>>> torch.equal(bgr[..., 2],
|
|
185
|
+
... torch.where(torch.eq(ref_gray_alpha[..., 1], 0), 0, ref_gray_alpha[..., 0]))
|
|
186
|
+
True
|
|
187
|
+
>>> bgr_alpha = ref_gray_alpha.convert(4)
|
|
188
|
+
>>> bgr_alpha.channels
|
|
189
|
+
4
|
|
190
|
+
>>> torch.equal(bgr_alpha[..., 0], ref_gray_alpha[..., 0])
|
|
191
|
+
True
|
|
192
|
+
>>> torch.equal(bgr_alpha[..., 1], ref_gray_alpha[..., 0])
|
|
193
|
+
True
|
|
194
|
+
>>> torch.equal(bgr_alpha[..., 2], ref_gray_alpha[..., 0])
|
|
195
|
+
True
|
|
196
|
+
>>> torch.equal(bgr_alpha[..., 3], ref_gray_alpha[..., 1])
|
|
197
|
+
True
|
|
198
|
+
>>>
|
|
199
|
+
>>> # case 3 -> 1, 2, 4
|
|
200
|
+
>>> gray = ref_bgr.convert(1)
|
|
201
|
+
>>> gray.channels
|
|
202
|
+
1
|
|
203
|
+
>>> gray_alpha = ref_bgr.convert(2)
|
|
204
|
+
>>> gray_alpha.channels
|
|
205
|
+
2
|
|
206
|
+
>>> torch.eq(gray_alpha[..., 1], 255).all()
|
|
207
|
+
tensor(True)
|
|
208
|
+
>>> bgr_alpha = ref_bgr.convert(4)
|
|
209
|
+
>>> bgr_alpha.channels
|
|
210
|
+
4
|
|
211
|
+
>>> torch.equal(bgr_alpha[..., 0], ref_bgr[..., 0])
|
|
212
|
+
True
|
|
213
|
+
>>> torch.equal(bgr_alpha[..., 1], ref_bgr[..., 1])
|
|
214
|
+
True
|
|
215
|
+
>>> torch.equal(bgr_alpha[..., 2], ref_bgr[..., 2])
|
|
216
|
+
True
|
|
217
|
+
>>> torch.eq(bgr_alpha[..., 3], 255).all()
|
|
218
|
+
tensor(True)
|
|
219
|
+
>>>
|
|
220
|
+
>>> # case 4 -> 1, 2, 3
|
|
221
|
+
>>> gray = ref_bgr_alpha.convert(1)
|
|
222
|
+
>>> gray.channels
|
|
223
|
+
1
|
|
224
|
+
>>> gray_alpha = ref_bgr_alpha.convert(2)
|
|
225
|
+
>>> gray_alpha.channels
|
|
226
|
+
2
|
|
227
|
+
>>> torch.equal(gray_alpha[..., 1], ref_bgr_alpha[..., 3])
|
|
228
|
+
True
|
|
229
|
+
>>> bgr = ref_bgr_alpha.convert(3)
|
|
230
|
+
>>> bgr.channels
|
|
231
|
+
3
|
|
232
|
+
>>> torch.equal(bgr[..., 0],
|
|
233
|
+
... torch.where(torch.eq(ref_bgr_alpha[..., 3], 0), 0, ref_bgr_alpha[..., 0]))
|
|
234
|
+
True
|
|
235
|
+
>>> torch.equal(bgr[..., 1],
|
|
236
|
+
... torch.where(torch.eq(ref_bgr_alpha[..., 3], 0), 0, ref_bgr_alpha[..., 1]))
|
|
237
|
+
True
|
|
238
|
+
>>> torch.equal(bgr[..., 2],
|
|
239
|
+
... torch.where(torch.eq(ref_bgr_alpha[..., 3], 0), 0, ref_bgr_alpha[..., 2]))
|
|
240
|
+
True
|
|
241
|
+
>>>
|
|
242
|
+
"""
|
|
243
|
+
assert isinstance(channels, int), channels.__class__.__name__
|
|
244
|
+
assert 1 <= channels <= 4, f"channels can only be 1, 2, 3, or 4, not {channels}"
|
|
245
|
+
converter = {
|
|
246
|
+
1: to_gray,
|
|
247
|
+
2: to_gray_alpha,
|
|
248
|
+
3: to_bgr,
|
|
249
|
+
4: to_bgr_alpha,
|
|
250
|
+
}[channels]
|
|
251
|
+
return self.__class__(self.time, converter(self))
|
|
252
|
+
|
|
253
|
+
@property
|
|
254
|
+
def height(self) -> int:
|
|
255
|
+
"""Return the dimension i (vertical) of the image in pxl.
|
|
256
|
+
|
|
257
|
+
Examples
|
|
258
|
+
--------
|
|
259
|
+
>>> import torch
|
|
260
|
+
>>> from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
261
|
+
>>> FrameVideo(0, torch.empty(480, 720, 3)).height
|
|
262
|
+
480
|
|
263
|
+
>>>
|
|
264
|
+
"""
|
|
265
|
+
return self.shape[0]
|
|
266
|
+
|
|
267
|
+
@property
|
|
268
|
+
def time(self) -> Fraction:
|
|
269
|
+
"""Return the time of the frame inside the video stream in second.
|
|
270
|
+
|
|
271
|
+
Examples
|
|
272
|
+
--------
|
|
273
|
+
>>> import torch
|
|
274
|
+
>>> from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
275
|
+
>>> FrameVideo(0, torch.empty(480, 720, 3)).time
|
|
276
|
+
Fraction(0, 1)
|
|
277
|
+
>>>
|
|
278
|
+
"""
|
|
279
|
+
return self.context
|
|
280
|
+
|
|
281
|
+
def to_numpy_bgr(self, contiguous=False) -> np.ndarray[np.uint8]:
|
|
282
|
+
"""Return the 3 channels numpy frame representation.
|
|
283
|
+
|
|
284
|
+
Parameters
|
|
285
|
+
----------
|
|
286
|
+
contiguous : boolean, default=False
|
|
287
|
+
If True, guaranti that the returned numpy array is c-contiguous.
|
|
288
|
+
|
|
289
|
+
Examples
|
|
290
|
+
--------
|
|
291
|
+
>>> import torch
|
|
292
|
+
>>> from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
293
|
+
>>> frame = FrameVideo(0, torch.empty(480, 720, 3)).to_numpy_bgr() # classical bgr
|
|
294
|
+
>>> type(frame), frame.shape, frame.dtype
|
|
295
|
+
(<class 'numpy.ndarray'>, (480, 720, 3), dtype('uint8'))
|
|
296
|
+
>>> frame = FrameVideo(0, torch.empty(480, 720, 3)).to_numpy_bgr() # grayscale
|
|
297
|
+
>>> type(frame), frame.shape, frame.dtype
|
|
298
|
+
(<class 'numpy.ndarray'>, (480, 720, 3), dtype('uint8'))
|
|
299
|
+
>>> frame = FrameVideo(0, torch.empty(480, 720, 3)).to_numpy_bgr() # alpha channel
|
|
300
|
+
>>> type(frame), frame.shape, frame.dtype
|
|
301
|
+
(<class 'numpy.ndarray'>, (480, 720, 3), dtype('uint8'))
|
|
302
|
+
>>>
|
|
303
|
+
"""
|
|
304
|
+
assert isinstance(contiguous, bool), contiguous.__class__.__name__
|
|
305
|
+
frame_np = self.convert(3).numpy(force=True)
|
|
306
|
+
if contiguous:
|
|
307
|
+
return np.ascontiguousarray(frame_np)
|
|
308
|
+
return frame_np
|
|
309
|
+
|
|
310
|
+
@property
|
|
311
|
+
def width(self) -> int:
|
|
312
|
+
"""Return the dimension j (horizontal) of the image in pxl.
|
|
313
|
+
|
|
314
|
+
Examples
|
|
315
|
+
--------
|
|
316
|
+
>>> import torch
|
|
317
|
+
>>> from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
318
|
+
>>> FrameVideo(0, torch.empty(480, 720, 3)).width
|
|
319
|
+
720
|
|
320
|
+
>>>
|
|
321
|
+
"""
|
|
322
|
+
return self.shape[1]
|