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
83 lines
2.1 KiB
C++
83 lines
2.1 KiB
C++
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
/** \file
|
|
* \ingroup bke
|
|
*/
|
|
|
|
#ifdef WITH_FFMPEG
|
|
|
|
enum {
|
|
FFMPEG_MPEG1 = 0,
|
|
FFMPEG_MPEG2 = 1,
|
|
FFMPEG_MPEG4 = 2,
|
|
FFMPEG_AVI = 3,
|
|
FFMPEG_MOV = 4,
|
|
FFMPEG_DV = 5,
|
|
FFMPEG_H264 = 6,
|
|
FFMPEG_XVID = 7,
|
|
FFMPEG_FLV = 8,
|
|
FFMPEG_MKV = 9,
|
|
FFMPEG_OGG = 10,
|
|
FFMPEG_INVALID = 11,
|
|
FFMPEG_WEBM = 12,
|
|
FFMPEG_AV1 = 13,
|
|
};
|
|
|
|
enum {
|
|
FFMPEG_PRESET_NONE = 0,
|
|
FFMPEG_PRESET_DVD = 1,
|
|
FFMPEG_PRESET_SVCD = 2,
|
|
FFMPEG_PRESET_VCD = 3,
|
|
FFMPEG_PRESET_DV = 4,
|
|
FFMPEG_PRESET_H264 = 5,
|
|
FFMPEG_PRESET_THEORA = 6,
|
|
FFMPEG_PRESET_XVID = 7,
|
|
FFMPEG_PRESET_AV1 = 8,
|
|
};
|
|
|
|
struct AVFrame;
|
|
struct RenderData;
|
|
struct ReportList;
|
|
struct Scene;
|
|
struct SwsContext;
|
|
|
|
int BKE_ffmpeg_start(void *context_v,
|
|
const Scene *scene,
|
|
RenderData *rd,
|
|
int rectx,
|
|
int recty,
|
|
ReportList *reports,
|
|
bool preview,
|
|
const char *suffix);
|
|
void BKE_ffmpeg_end(void *context_v);
|
|
int BKE_ffmpeg_append(void *context_v,
|
|
RenderData *rd,
|
|
int start_frame,
|
|
int frame,
|
|
int *pixels,
|
|
int rectx,
|
|
int recty,
|
|
const char *suffix,
|
|
ReportList *reports);
|
|
void BKE_ffmpeg_filepath_get(char filepath[/*FILE_MAX*/ 1024],
|
|
const RenderData *rd,
|
|
bool preview,
|
|
const char *suffix);
|
|
|
|
void BKE_ffmpeg_preset_set(RenderData *rd, int preset);
|
|
void BKE_ffmpeg_image_type_verify(RenderData *rd, const ImageFormatData *imf);
|
|
bool BKE_ffmpeg_alpha_channel_is_supported(const RenderData *rd);
|
|
|
|
void *BKE_ffmpeg_context_create(void);
|
|
void BKE_ffmpeg_context_free(void *context_v);
|
|
|
|
SwsContext *BKE_ffmpeg_sws_get_context(
|
|
int width, int height, int av_src_format, int av_dst_format, int sws_flags);
|
|
void BKE_ffmpeg_sws_scale_frame(SwsContext *ctx, AVFrame *dst, const AVFrame *src);
|
|
|
|
#endif
|