Go to the documentation of this file.
87 int w,
int h,
SwsPass **pass,
int slice_align,
100 return (plane == 1 || plane == 2) ?
desc->log2_chroma_h : 0;
107 for (
int i = 0;
i < 4 &&
img.data[
i];
i++)
124 for (
int j = 0; j < lines; j++) {
125 memcpy(
out.data[
i], in.
data[
i], linesize);
137 const int x0 =
c->src0Alpha - 1;
138 const int w4 = 4 * pass->
width;
139 const int src_stride = in->
linesize[0];
140 const int dst_stride =
out->linesize[0];
141 const uint8_t *
src = in->
data[0] + y * src_stride;
142 uint8_t *
dst =
out->data[0] + y * dst_stride;
144 for (
int y = 0; y <
h; y++) {
146 for (
int x = x0; x < w4; x += 4)
188 for (
int i = 0;
i < 4;
i++)
189 memset(
c->dither_error[
i], 0,
sizeof(
c->dither_error[0][0]) * (
sws->
dst_w + 2));
222 c->convert_unscaled(
c, (
const uint8_t *
const *) in.
data, in.
linesize, y,
h,
223 out->data,
out->linesize);
255 x_pos *= (1 << sub_x) - 1;
256 y_pos *= (1 << sub_y) - 1;
268 y_pos += (256 << sub_y) - 256;
276 *h_chr_pos = sub_x ? x_pos : -513;
277 *v_chr_pos = sub_y ? y_pos : -513;
282 if (
override == -513 ||
override == *chr_pos)
287 "Setting chroma position directly is deprecated, make sure "
288 "the frame is tagged with the correct chroma location.\n");
301 const int unscaled = src_w == dst_w && src_h == dst_h;
302 int align =
c->dst_slice_align;
306 if (
c->cascaded_context[0]) {
307 const int num_cascaded =
c->cascaded_context[2] ? 3 : 2;
308 for (
int i = 0;
i < num_cascaded;
i++) {
310 const int is_last =
i + 1 == num_cascaded;
328 if (
c->srcXYZ && !(
c->dstXYZ && unscaled)) {
379 c2->srcColorspaceTable[
i] =
c->srcColorspaceTable[
i];
380 c2->dstColorspaceTable[
i] =
c->dstColorspaceTable[
i];
385 if (
c->dstXYZ && !(
c->srcXYZ && unscaled)) {
438 int in_full, out_full, brightness, contrast, saturation;
439 const int *inv_table, *
table;
441 (
int **)&
table, &out_full,
442 &brightness, &contrast, &saturation);
452 brightness, contrast, saturation);
502 const int slice_y = jobnr * pass->
slice_h;
528 graph->num_threads = 1;
532 graph->num_threads =
ret;
571 return c1->flags ==
c2->flags &&
572 c1->threads ==
c2->threads &&
573 c1->dither ==
c2->dither &&
574 c1->alpha_blend ==
c2->alpha_blend &&
575 c1->gamma_flag ==
c2->gamma_flag &&
576 c1->src_h_chr_pos ==
c2->src_h_chr_pos &&
577 c1->src_v_chr_pos ==
c2->src_v_chr_pos &&
578 c1->dst_h_chr_pos ==
c2->dst_h_chr_pos &&
579 c1->dst_v_chr_pos ==
c2->dst_v_chr_pos &&
580 !memcmp(
c1->scaler_params,
c2->scaler_params,
sizeof(
c1->scaler_params));
599 const int out_linesize[4],
600 const uint8_t *
const in_data[4],
601 const int in_linesize[4])
605 memcpy(
out->data, out_data,
sizeof(
out->data));
606 memcpy(
out->linesize, out_linesize,
sizeof(
out->linesize));
607 memcpy(in->
data, in_data,
sizeof(in->
data));
static void error(const char *err)
int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation)
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
AVSliceThread * slicethread
Represents a single filter pass in the scaling graph.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
SwsPass ** passes
Sorted sequence of filter passes to apply.
static int init_passes(SwsGraph *graph)
void ff_rgb48Toxyz12(const SwsInternal *c, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h)
SwsImg output
Filter output buffer.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int src_w
Deprecated frame property overrides, for the legacy API only.
enum AVPixelFormat format
void sws_graph_free(SwsGraph **pgraph)
Uninitialize any state associate with this filter graph and free it.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
void(* sws_filter_run_t)(const SwsImg *out, const SwsImg *in, int y, int h, const SwsPass *pass)
Output h lines of filtered data.
SwsFormat src
Currently active format and processing parameters.
void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_main)
Execute slice threading.
@ AVCOL_RANGE_JPEG
Full range content.
static const uint16_t table[]
static SwsPass * pass_add(SwsGraph *graph, void *priv, enum AVPixelFormat fmt, int w, int h, SwsPass *input, int slice_align, sws_filter_run_t run)
unsigned flags
Bitmask of SWS_*.
void(* free)(void *priv)
Optional private state and associated free() function.
Represents a view into a single field of frame data.
static SwsImg shift_img(const SwsImg *img_base, int y)
int ff_sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter, SwsFilter *dstFilter)
int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, void(*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), void(*main_func)(void *priv), int nb_threads)
Create slice threading context.
int src_v_chr_pos
Source vertical chroma position in luma grid / 256.
static SwsContext * slice_ctx(const SwsPass *pass, int y)
av_warn_unused_result int sws_init_context(SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
SwsContext opts_copy
Cached copy of the public options that were used to construct this SwsGraph.
#define FF_ARRAY_ELEMS(a)
static void legacy_chr_pos(SwsGraph *graph, int *chr_pos, int override, int *warned)
SwsDither dither
Dither mode.
int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
Converts AVChromaLocation to swscale x/y chroma position.
void ff_update_palette(SwsInternal *c, const uint32_t *pal)
int flags
Flags modifying the (de)muxer behaviour.
void(* setup)(const SwsImg *out, const SwsImg *in, const SwsPass *pass)
Called once from the main thread before running the filter.
static int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this field
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
void ff_xyz12Torgb48(const SwsInternal *c, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static int pass_append(SwsGraph *graph, void *priv, enum AVPixelFormat fmt, int w, int h, SwsPass **pass, int slice_align, sws_filter_run_t run)
int gamma_flag
Use gamma correct scaling.
static void run_xyz2rgb(const SwsImg *out, const SwsImg *in, int y, int h, const SwsPass *pass)
int sws_graph_reinit(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src, int field, SwsGraph **out_graph)
Wrapper around sws_graph_create that does nothing if the format is unchanged.
int src_range
Source is full range.
void sws_graph_run(SwsGraph *graph, uint8_t *const out_data[4], const int out_linesize[4], const uint8_t *const in_data[4], const int in_linesize[4])
Dispatch the filter graph on a single field.
@ AVCOL_RANGE_UNSPECIFIED
int dst_h_chr_pos
Destination horizontal chroma position.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static void run_legacy_swscale(const SwsImg *out_base, const SwsImg *in, int y, int h, const SwsPass *pass)
int av_opt_copy(void *dst, const void *src)
Copy options from src object into dest object.
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
static int add_legacy_sws_pass(SwsGraph *graph, SwsFormat src, SwsFormat dst, SwsPass *input, SwsPass **output)
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
SwsAlphaBlend alpha_blend
Alpha blending mode.
int src_h
Width and height of the source frame.
@ AVCHROMA_LOC_UNSPECIFIED
int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation)
static const uint8_t *BS_FUNC() align(BSCTX *bc)
Skip bits to a byte boundary.
int dst_format
Destination pixel format.
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
AVChromaLocation
Location of chroma samples.
static SwsContext * sws[3]
static void free_legacy_swscale(void *priv)
#define i(width, name, range_min, range_max)
static int opts_equal(const SwsContext *c1, const SwsContext *c2)
static void run_rgb0(const SwsImg *out, const SwsImg *in, int y, int h, const SwsPass *pass)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static void run_rgb2xyz(const SwsImg *out, const SwsImg *in, int y, int h, const SwsPass *pass)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int dst_h
Width and height of the destination frame.
static void run_copy(const SwsImg *out_base, const SwsImg *in_base, int y, int h, const SwsPass *pass)
void * av_calloc(size_t nmemb, size_t size)
static void get_chroma_pos(SwsGraph *graph, int *h_chr_pos, int *v_chr_pos, const SwsFormat *fmt)
static int vshift(enum AVPixelFormat fmt, int plane)
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
static void setup_legacy_swscale(const SwsImg *out, const SwsImg *in, const SwsPass *pass)
int ff_swscale(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[], int dstSliceY, int dstSliceH)
int sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src, int field, SwsGraph **out_graph)
Allocate and initialize the filter graph.
const int * sws_getCoefficients(int colorspace)
Return a pointer to yuv<->rgb coefficients for the given colorspace suitable for sws_setColorspaceDet...
Filter graph, which represents a 'baked' pixel format conversion.
int src_format
Source pixel format.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int dst_range
Destination is full range.
static int pass_alloc_output(SwsPass *pass)
static void run_legacy_unscaled(const SwsImg *out, const SwsImg *in_base, int y, int h, const SwsPass *pass)
sws_filter_run_t run
Filter main execution function.
void sws_free_context(SwsContext **ctx)
Free the context and everything associated with it, and write NULL to the provided pointer.
static int init_legacy_subpass(SwsGraph *graph, SwsContext *sws, int cascaded, SwsPass *input, SwsPass **output)
void avpriv_slicethread_free(AVSliceThread **pctx)
Destroy slice threading context.
int src_h_chr_pos
Source horizontal chroma position.
static SwsInternal * sws_internal(const SwsContext *sws)
const SwsPass * input
Filter input.
int dst_v_chr_pos
Destination vertical chroma position.
Main external API structure.
static void sws_graph_worker(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads)
struct SwsGraph::@459 exec
Temporary execution state inside sws_graph_run.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)