|
FFmpeg
|
#include "libavutil/attributes.h"#include "libavutil/avassert.h"#include "libavutil/hdr_dynamic_metadata.h"#include "libavutil/hwcontext.h"#include "libavutil/mastering_display_metadata.h"#include "libavutil/refstruct.h"#include "format.h"#include "csputils.h"#include "ops_internal.h"#include "config_components.h"#include "swscale_internal.h"Go to the source code of this file.
Data Structures | |
| struct | LegacyFormatEntry |
| struct | FmtInfo |
| struct | comp |
Macros | |
| #define | RET(x) |
| #define | BITSTREAM_FMT(SWIZ, FRAC, MODE, ...) |
| #define | SUBPACKED_FMT(SWIZ, ...) |
| #define | PACKED_FMT(SWIZ, N, ...) |
| #define | RGBA SWS_SWIZZLE(0, 1, 2, 3) |
| #define | BGRA SWS_SWIZZLE(2, 1, 0, 3) |
| #define | ARGB SWS_SWIZZLE(3, 0, 1, 2) |
| #define | ABGR SWS_SWIZZLE(3, 2, 1, 0) |
| #define | AVYU SWS_SWIZZLE(3, 2, 0, 1) |
| #define | VYUA SWS_SWIZZLE(2, 0, 1, 3) |
| #define | UYVA SWS_SWIZZLE(1, 0, 2, 3) |
| #define | VUYA BGRA |
| #define | NATIVE_ENDIAN_FLAG 0 |
| #define | LINEAR_OP_DATA(TYPE, ...) |
| #define | Q64(x) |
Functions | |
| int | sws_isSupportedInput (enum AVPixelFormat pix_fmt) |
| Return a positive value if pix_fmt is a supported input format, 0 otherwise. | |
| int | sws_isSupportedOutput (enum AVPixelFormat pix_fmt) |
| Return a positive value if pix_fmt is a supported output format, 0 otherwise. | |
| int | sws_isSupportedEndiannessConversion (enum AVPixelFormat pix_fmt) |
| static void | sanitize_fmt (SwsFormat *fmt, const AVPixFmtDescriptor *desc) |
| SwsFormat | ff_fmt_from_frame (const AVFrame *frame, int field) |
| This function also sanitizes and strips the input data, removing irrelevant fields for certain formats. | |
| void | ff_fmt_from_pixfmt (enum AVPixelFormat pixfmt, SwsFormat *fmt) |
| Subset of ff_fmt_from_frame() that sets default metadata for the format. | |
| static int | infer_prim_ref (SwsColor *csp, const SwsColor *ref) |
| static int | infer_trc_ref (SwsColor *csp, const SwsColor *ref) |
| bool | ff_infer_colors (SwsColor *src, SwsColor *dst) |
| static int | infer_loc_ref (SwsFormat *fmt, const SwsFormat *ref) |
| bool | ff_infer_chroma_loc (SwsFormat *src, SwsFormat *dst) |
| Infers an unspecified chroma location of a subsampled format from the other format. | |
| void | ff_sws_chroma_pos (const SwsFormat *fmt, bool *incomplete, int *out_x_pos, int *out_y_pos) |
| Wrapper around av_chroma_location_enum_to_pos() that accounts for the per-field offset introduced by interlacing. | |
| static int | test_format_ops (enum AVPixelFormat format, int output) |
| static int | test_format_legacy (enum AVPixelFormat format, int output) |
| int | ff_sws_test_pixfmt_backend (const SwsBackend backends, enum AVPixelFormat format, int output) |
| int | sws_test_format (enum AVPixelFormat format, int output) |
| Test if a given (software) pixel format is supported by any backend, excluding unstable backends. | |
| int | sws_test_hw_format (enum AVPixelFormat format) |
| Test if a given hardware pixel format is supported by any backend, excluding unstable backends. | |
| int | sws_test_colorspace (enum AVColorSpace csp, int output) |
| Test if a given color space is supported. | |
| int | sws_test_primaries (enum AVColorPrimaries prim, int output) |
| Test if a given set of color primaries is supported. | |
| int | sws_test_transfer (enum AVColorTransferCharacteristic trc, int output) |
| Test if a given color transfer function is supported. | |
| static int | test_range (enum AVColorRange range) |
| static int | test_loc (enum AVChromaLocation loc) |
| int | ff_test_fmt (const SwsBackend backends, const SwsFormat *fmt, int output) |
| Statically test if a given format is supported by the given set of backends. | |
| int | sws_test_frame (const AVFrame *frame, int output) |
| Helper function to run all sws_test_* against a frame, as well as testing the basic frame properties for sanity. | |
| int | sws_is_noop (const AVFrame *dst, const AVFrame *src) |
| Check if a given conversion is a noop. | |
| void | ff_sws_frame_from_avframe (SwsFrame *dst, const AVFrame *src) |
| Initialize a SwsFrame from an AVFrame. | |
| static const AVPixFmtDescriptor * | fmt_desc_decoded (enum AVPixelFormat fmt) |
| Returns the underlying descriptor for fake formats like PAL8 whose descriptors alone do not fully describe the pixel data. | |
| static SwsPixelType | fmt_pixel_type (const AVPixFmtDescriptor *desc) |
| static int | is_regular_fmt (enum AVPixelFormat fmt) |
| static FmtInfo | fmt_info_irregular (enum AVPixelFormat fmt) |
| static int | cmp_comp (const void *a, const void *b) |
| static int | fmt_analyze_regular (const AVPixFmtDescriptor *desc, SwsReadWriteOp *rw_op, SwsSwizzleOp *swizzle, SwsShiftOp *shift) |
| static int | fmt_analyze (enum AVPixelFormat fmt, SwsReadWriteOp *rw_op, SwsPackOp *pack_op, SwsSwizzleOp *swizzle, SwsShiftOp *shift, SwsPixelType *pixel_type) |
| static void | swizzle_inv (SwsSwizzleOp *swiz) |
| static SwsClearOp | fmt_clear (const SwsFormat *fmt) |
| This initializes all absent components explicitly to zero. | |
| static AVRational64 | intmax_q64 (int bits) |
| static int | decode_pixfmt (SwsOpList *ops, const SwsFormat *fmt) |
| static int | encode_pixfmt (SwsOpList *ops, const SwsFormat *fmt) |
| static AVRational64 | av_neg_q64 (AVRational64 x) |
| static SwsLinearOp | fmt_encode_range (const SwsFormat *fmt, SwsPixelType type, bool *incomplete) |
| static SwsLinearOp | fmt_decode_range (const SwsFormat *fmt, SwsPixelType type, bool *incomplete) |
| static AVRational64 * | generate_bayer_matrix (const int size_log2) |
| static bool | trc_is_hdr (enum AVColorTransferCharacteristic trc) |
| static int | fmt_dither (SwsContext *ctx, SwsOpList *ops, const SwsFormat *src, const SwsFormat *dst) |
| static SwsLinearOp | linear_mat3 (const SwsPixelType type, const AVRational m00, const AVRational m01, const AVRational m02, const AVRational m10, const AVRational m11, const AVRational m12, const AVRational m20, const AVRational m21, const AVRational m22) |
| static int | decode_colors (SwsContext *ctx, SwsPixelType type, SwsOpList *ops, const SwsFormat *fmt, bool *incomplete) |
| static int | encode_colors (SwsContext *ctx, SwsPixelType type, SwsOpList *ops, const SwsFormat *src, const SwsFormat *dst, bool *incomplete) |
| static SwsScaler | get_scaler_fallback (SwsContext *ctx) |
| static int | add_filter (SwsContext *ctx, SwsPixelType type, SwsOpList *ops, SwsOpType filter, int src_size, int dst_size) |
| static int | add_filters (SwsContext *ctx, SwsPixelType type, SwsOpList *ops, const SwsFormat *src, const SwsFormat *dst) |
| static int | apply_lut3d (SwsContext *ctx, SwsPixelType type, SwsOpList *ops, const SwsLut3D *lut3d) |
| static int | fmt_convert (SwsContext *ctx, const SwsFormat *src, const SwsFormat *dst, const SwsLut3D *lut3d, SwsOpList *ops, bool *incomplete) |
| int | ff_sws_op_list_generate (SwsContext *ctx, const SwsFormat *src, const SwsFormat *dst, const SwsLut3D *lut3d, SwsOpList **out_ops, bool *incomplete) |
Generate an SwsOpList defining a conversion from src to dst, with an optional 3DLUT for converting between gamuts. | |
Variables | |
| static const LegacyFormatEntry | legacy_format_entries [] |
| #define RET | ( | x | ) |
Definition at line 34 of file format.c.
Referenced by apply_lut3d(), decode_colors(), decode_pixfmt(), encode_colors(), encode_pixfmt(), and fmt_convert().
| #define BITSTREAM_FMT | ( | SWIZ, | |
| FRAC, | |||
| MODE, | |||
| ... ) |
Definition at line 812 of file format.c.
Referenced by fmt_info_irregular().
| #define SUBPACKED_FMT | ( | SWIZ, | |
| ... ) |
Definition at line 818 of file format.c.
Referenced by fmt_info_irregular().
| #define PACKED_FMT | ( | SWIZ, | |
| N, | |||
| ... ) |
Definition at line 824 of file format.c.
Referenced by fmt_info_irregular().
| #define RGBA SWS_SWIZZLE(0, 1, 2, 3) |
| #define BGRA SWS_SWIZZLE(2, 1, 0, 3) |
Definition at line 831 of file format.c.
Referenced by ff_sws_init_swscale_x86(), findRgbConvFn(), fmt_info_irregular(), and get_unscaled_swscale_neon().
| #define ARGB SWS_SWIZZLE(3, 0, 1, 2) |
Definition at line 832 of file format.c.
Referenced by ff_sws_init_swscale_x86(), findRgbConvFn(), fmt_info_irregular(), and get_unscaled_swscale_neon().
| #define ABGR SWS_SWIZZLE(3, 2, 1, 0) |
Definition at line 833 of file format.c.
Referenced by ff_sws_init_swscale_x86(), findRgbConvFn(), fmt_info_irregular(), and get_unscaled_swscale_neon().
| #define AVYU SWS_SWIZZLE(3, 2, 0, 1) |
Definition at line 834 of file format.c.
Referenced by fmt_info_irregular().
| #define VYUA SWS_SWIZZLE(2, 0, 1, 3) |
Definition at line 835 of file format.c.
Referenced by fmt_info_irregular().
| #define UYVA SWS_SWIZZLE(1, 0, 2, 3) |
Definition at line 836 of file format.c.
Referenced by findRgbConvFn(), and fmt_info_irregular().
| #define VUYA BGRA |
Definition at line 837 of file format.c.
Referenced by findRgbConvFn(), and fmt_info_irregular().
| #define NATIVE_ENDIAN_FLAG 0 |
Definition at line 1086 of file format.c.
Referenced by decode_pixfmt(), and encode_pixfmt().
| #define LINEAR_OP_DATA | ( | TYPE, | |
| ... ) |
Definition at line 1244 of file format.c.
Referenced by apply_lut3d(), fmt_encode_range(), and linear_mat3().
| #define Q64 | ( | x | ) |
Definition at line 1480 of file format.c.
Referenced by linear_mat3().
|
static |
Definition at line 305 of file format.c.
Referenced by ff_fmt_from_frame(), and ff_fmt_from_pixfmt().
This function also sanitizes and strips the input data, removing irrelevant fields for certain formats.
Calculate largest value from histogram to use as fallback for clips with missing MaxSCL information. Note that this may end up picking the "reserved" value at the 5% percentile, which in practice appears to track the brightest pixel in the scene.
Definition at line 345 of file format.c.
Referenced by sws_frame_setup(), sws_is_noop(), and sws_test_frame().
| void ff_fmt_from_pixfmt | ( | enum AVPixelFormat | pixfmt, |
| SwsFormat * | fmt ) |
Subset of ff_fmt_from_frame() that sets default metadata for the format.
Definition at line 483 of file format.c.
Referenced by enum_ops_fmt().
Definition at line 491 of file format.c.
Referenced by ff_infer_colors().
Definition at line 515 of file format.c.
Referenced by ff_infer_colors().
Definition at line 540 of file format.c.
Referenced by enum_ops_fmt(), and generate_3dlut().
Definition at line 557 of file format.c.
Referenced by ff_infer_chroma_loc().
Infers an unspecified chroma location of a subsampled format from the other format.
Returns true if a location was inferred, false otherwise.
Definition at line 568 of file format.c.
Referenced by init_passes(), and sws_is_noop().
| void ff_sws_chroma_pos | ( | const SwsFormat * | fmt, |
| bool * | incomplete, | ||
| int * | out_x_pos, | ||
| int * | out_y_pos ) |
Wrapper around av_chroma_location_enum_to_pos() that accounts for the per-field offset introduced by interlacing.
Definition at line 578 of file format.c.
Referenced by add_legacy_sws_pass().
|
static |
Definition at line 1023 of file format.c.
Referenced by ff_sws_test_pixfmt_backend().
|
static |
Definition at line 621 of file format.c.
Referenced by ff_sws_test_pixfmt_backend().
| int ff_sws_test_pixfmt_backend | ( | const SwsBackend | backends, |
| enum AVPixelFormat | format, | ||
| int | output ) |
Definition at line 626 of file format.c.
Referenced by ff_test_fmt(), sws_test_format(), and test_formats().
|
static |
Definition at line 682 of file format.c.
Referenced by ff_test_fmt().
|
static |
Definition at line 687 of file format.c.
Referenced by ff_test_fmt().
| int ff_test_fmt | ( | SwsBackend | backends, |
| const SwsFormat * | fmt, | ||
| int | output ) |
Statically test if a given format is supported by the given set of backends.
This is a heuristic, which may have false positives if a specific backend does not actually implement all operations that would be required to support the format.
Definition at line 692 of file format.c.
Referenced by sws_frame_setup(), and sws_test_frame().
Initialize a SwsFrame from an AVFrame.
Definition at line 732 of file format.c.
Referenced by get_field(), and pass_alloc_output().
|
inlinestatic |
Returns the underlying descriptor for fake formats like PAL8 whose descriptors alone do not fully describe the pixel data.
Definition at line 749 of file format.c.
Referenced by decode_pixfmt(), encode_pixfmt(), fmt_clear(), fmt_dither(), and fmt_encode_range().
|
static |
Definition at line 760 of file format.c.
Referenced by decode_colors(), encode_colors(), fmt_analyze(), fmt_analyze_regular(), and fmt_clear().
|
static |
Definition at line 782 of file format.c.
Referenced by fmt_analyze().
|
static |
Definition at line 839 of file format.c.
Referenced by fmt_analyze().
|
static |
Definition at line 925 of file format.c.
Referenced by fmt_analyze_regular().
|
static |
Definition at line 933 of file format.c.
Referenced by fmt_analyze().
|
static |
Definition at line 968 of file format.c.
Referenced by decode_pixfmt(), encode_pixfmt(), and test_format_ops().
|
static |
Definition at line 1038 of file format.c.
Referenced by decode_pixfmt().
|
static |
This initializes all absent components explicitly to zero.
There is no need to worry about the correct neutral value as fmt_decode() will implicitly ignore and overwrite absent components in any case. This function is just to ensure that we don't operate on undefined memory. In most cases, it will end up getting pushed towards the output or optimized away entirely by the optimization pass.
Definition at line 1057 of file format.c.
Referenced by decode_pixfmt().
|
inlinestatic |
Definition at line 1089 of file format.c.
Referenced by decode_pixfmt(), encode_colors(), and fmt_encode_range().
Definition at line 1096 of file format.c.
Referenced by fmt_convert().
Definition at line 1176 of file format.c.
Referenced by fmt_convert().
|
inlinestatic |
Definition at line 1239 of file format.c.
Referenced by fmt_decode_range(), and fmt_encode_range().
|
static |
Definition at line 1249 of file format.c.
Referenced by encode_colors(), and fmt_decode_range().
|
static |
Definition at line 1314 of file format.c.
Referenced by decode_colors().
|
static |
To correctly round, we need to evenly distribute the result on [0, 1), giving an average value of 1/2.
After the above construction, we have a matrix with average value: [ 0/N + 1/N + 2/N + ... (N-1)/N ] / N = (N-1)/(2N) where N = size * size is the total number of entries.
To make the average value equal to 1/2 = N/(2N), add a bias of 1/(2N).
Definition at line 1332 of file format.c.
Referenced by fmt_dither().
|
static |
Definition at line 1373 of file format.c.
Referenced by fmt_dither().
|
static |
For high-bit-depth sources without chroma, use same matrix offset for all color channels. This prevents introducing color noise in grayscale images; and also allows optimizing the dither operation. Skipped for low bit depth (<8 bpc) as the loss in PSNR, from the inability to diffuse error among all three channels, can be substantial.
This shifts: { X, Y, Z, W } -> { X, X, X, Y }
Definition at line 1389 of file format.c.
Referenced by encode_colors().
|
inlinestatic |
Definition at line 1483 of file format.c.
Referenced by decode_colors(), and encode_colors().
|
static |
Definition at line 1497 of file format.c.
Referenced by fmt_convert().
|
static |
Definition at line 1583 of file format.c.
Referenced by fmt_convert().
|
static |
Definition at line 1683 of file format.c.
Referenced by add_filter().
|
static |
Definition at line 1710 of file format.c.
Referenced by add_filter(), and add_filters().
|
static |
Always perform horizontal scaling first, since it's much more likely to benefit from small integer optimizations; we should maybe flip the order here if we're downscaling the vertical resolution by a lot, though.
Definition at line 1747 of file format.c.
Referenced by fmt_convert().
|
static |
Definition at line 1763 of file format.c.
Referenced by fmt_convert().
|
static |
Definition at line 1811 of file format.c.
Referenced by ff_sws_op_list_generate().
| int ff_sws_op_list_generate | ( | SwsContext * | ctx, |
| const SwsFormat * | src, | ||
| const SwsFormat * | dst, | ||
| const SwsLut3D * | lut3d, | ||
| SwsOpList ** | out_ops, | ||
| bool * | incomplete ) |
Generate an SwsOpList defining a conversion from src to dst, with an optional 3DLUT for converting between gamuts.
Returns 0 on success, or a negative error code on failure.
Definition at line 1825 of file format.c.
Referenced by add_ops_convert_pass(), and enum_ops_fmt().
|
static |
Definition at line 48 of file format.c.
Referenced by sws_isSupportedEndiannessConversion(), sws_isSupportedInput(), and sws_isSupportedOutput().