Commit Graph

7 Commits

Author SHA1 Message Date
Campbell Barton 76867ad4c2 Cleanup: redundant "void" in function declarations for C++ 2024-03-05 11:25:35 +11:00
Aras Pranckevicius e76b848697 Cleanup: Video: change bMovieHandle function to take ImBuf as input
Towards #118493: make movie writing functionality take ImBuf instead
of int* to pixel data.

While at it, make other bMovieHandle functions use "bool" return type
when it is strictly a success/failure result.

Pull Request: https://projects.blender.org/blender/blender/pulls/118559
2024-02-21 12:57:36 +01:00
Campbell Barton 7582b15c4c Cleanup: spelling in comments 2024-02-16 14:26:46 +11:00
Aras Pranckevicius ffbc90874b ffmpeg: cache swscale contexts instead of re-creating them
ffmpeg's libswscale is used to do RGB<->YUV conversions on movie reading
and writing. The "context" for the scale operation was being created
and destroyed for each movie clip / animation. Now, maintain a cache
of the scale contexts instead.

E.g. in Gold edit, it only ever needs two contexts (one for reading
source movie clips since they are all exactly the same resolution
and format; and one for rendering the resulting movie).

During playback, on some of the "slow" frames (camera cuts) this
saves 10-20ms (Windows, Ryzen 5950X). Rendering whole movie goes
from 390sec to 376sec.

Pull Request: https://projects.blender.org/blender/blender/pulls/118130
2024-02-15 10:35:02 +01:00
Thomas Dinges 34feee3499 Cleanup: Remove unused internal FFMPEG presets
Formats like VCD and SVCD are obsolete, others are done via Python.

Pull Request: https://projects.blender.org/blender/blender/pulls/118069
2024-02-12 09:45:13 +01:00
Aras Pranckevicius 4ef5d9f60f ffmpeg: optimize ffmpeg_postprocess
After doing regular movie frame decoding, there's a "postprocess" step for
each incoming frame, that does deinterlacing if needed, then YUV->RGB
conversion, then vertical image flip and additional interlace filtering if
needed. While this postprocess step is not the "heavy" part of movie
playback, it still takes 2-3ms per each 1080p resolution input frame that
is being played.

This PR does two things:
- Similar to #116008, uses multi-threaded `sws_scale` to do YUV->RGB
  conversion.
- Reintroduces "do vertical flip while converting to RGB", where possible.
  That was removed in 2ed73fc97e due to issues on arm64 platform, and
  theory that negative strides passed to sws_scale is not an officially
  supported usage.

My take on the last point: negative strides to sws_scale is a fine and
supported usage, just ffmpeg had a bug specifically on arm64 where they
were accidentally not respected. They fixed that for ffmpeg 6.0, and
backported it to all versions back to 3.4.13 -- you would not backport
something to 10 releases unless that was an actual bug fix!

I have tested the glitch_480p.mp4 that was originally attached to the
bug report #94237 back then, and it works fine both on x64 (Windows)
and arm64 (Mac).

Timings, ffmpeg_postprocess cost for a single 1920x1080 resolution movie
strip inside VSE:
- Windows/VS2022 Ryzen 5950X: 3.04ms -> 1.18ms
- Mac/clang15 M1 Max: 1.10ms -> 0.71ms

Pull Request: https://projects.blender.org/blender/blender/pulls/116309
2023-12-19 18:28:51 +01:00
Aras Pranckevicius 3f7ab7069e Cleanup: move writeffmpeg to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/115585
2023-11-30 06:03:18 +01:00