Go to the documentation of this file.
   26     for (
i = 0; 
i < 2; ++
i) {
 
   27         int n = 
s->plane[
i].available_lines;
 
   29         for (j = 0; j < n; ++j) {
 
   32                s->plane[
i].line[j+n] = 
NULL;
 
   36     for (
i = 0; 
i < 4; ++
i)
 
   37         memset(
s->plane[
i].line, 0, 
sizeof(uint8_t*) * 
s->plane[
i].available_lines * (
s->is_ring ? 3 : 1));
 
   38     s->should_free_lines = 0;
 
   50     s->should_free_lines = 1;
 
   53     for (
i = 0; 
i < 2; ++
i) {
 
   54         int n = 
s->plane[
i].available_lines;
 
   59         for (j = 0; j < n; ++j) {
 
   63             if (!
s->plane[
i].line[j]) {
 
   67             s->plane[ii].line[j] = 
s->plane[
i].line[j] + 
size + 16;
 
   69                s->plane[
i].line[j+n] = 
s->plane[
i].line[j];
 
   70                s->plane[ii].line[j+n] = 
s->plane[ii].line[j];
 
   81     int size[4] = { lumLines,
 
   86     s->h_chr_sub_sample = h_sub_sample;
 
   87     s->v_chr_sub_sample = v_sub_sample;
 
   90     s->should_free_lines = 0;
 
   92     for (
i = 0; 
i < 4; ++
i) {
 
   93         int n = 
size[
i] * ( ring == 0 ? 1 : 3);
 
   95         if (!
s->plane[
i].line)
 
   98         s->plane[
i].tmp = ring ? 
s->plane[
i].line + 
size[
i] * 2 : 
NULL;
 
   99         s->plane[
i].available_lines = 
size[
i];
 
  100         s->plane[
i].sliceY = 0;
 
  101         s->plane[
i].sliceH = 0;
 
  110         if (
s->should_free_lines)
 
  112         for (
i = 0; 
i < 4; ++
i) {
 
  123         for (
i = 0; 
i < 4; 
i+=3) {
 
  124             int n = 
s->plane[
i].available_lines;
 
  125             int l = 
lum - 
s->plane[
i].sliceY;
 
  128                 s->plane[
i].sliceY += n;
 
  129                 s->plane[
i].sliceH -= n;
 
  134         for (
i = 1; 
i < 3; ++
i) {
 
  135             int n = 
s->plane[
i].available_lines;
 
  136             int l = chr - 
s->plane[
i].sliceY;
 
  139                 s->plane[
i].sliceY += n;
 
  140                 s->plane[
i].sliceH -= n;
 
  151     const int start[4] = {lumY,
 
  156     const int end[4] = {lumY +lumH,
 
  164         uint8_t *
const src_i = 
src[
i] + (relative ? 0 : start[
i]) * 
stride[
i];
 
  166         int first = 
s->plane[
i].sliceY;
 
  167         int n = 
s->plane[
i].available_lines;
 
  168         int lines = end[
i] - start[
i];
 
  169         int tot_lines = end[
i] - 
first;
 
  171         if (start[
i] >= 
first && n >= tot_lines) {
 
  172             s->plane[
i].sliceH = 
FFMAX(tot_lines, 
s->plane[
i].sliceH);
 
  173             for (j = 0; j < lines; j+= 1)
 
  176             s->plane[
i].sliceY = start[
i];
 
  177             lines = lines > n ? n : lines;
 
  178             s->plane[
i].sliceH = lines;
 
  179             for (j = 0; j < lines; j+= 1)
 
  180                 s->plane[
i].line[j] = src_i +  j * 
stride[
i];
 
  190     int i, j, k, 
size, end;
 
  192     for (
i = 0; 
i < 4; ++
i) {
 
  193         size = 
s->plane[
i].available_lines;
 
  194         for (j = 0; j < 
size; ++j) {
 
  197                 for (k = 0; k < end; ++k)
 
  198                     ((
int32_t*)(
s->plane[
i].line[j]))[k] = 1<<18;
 
  199             } 
else if (bpc == 32) {
 
  201                 for (k = 0; k < end; ++k)
 
  202                     ((int64_t*)(
s->plane[
i].line[j]))[k] = 1LL<<34;
 
  205                 for (k = 0; k < end; ++k)
 
  206                     ((int16_t*)(
s->plane[
i].line[j]))[k] = 1<<14;
 
  223     int chrDstH = 
c->chrDstH;
 
  224     int *lumFilterPos = 
c->vLumFilterPos;
 
  225     int *chrFilterPos = 
c->vChrFilterPos;
 
  226     int lumFilterSize = 
c->vLumFilterSize;
 
  227     int chrFilterSize = 
c->vChrFilterSize;
 
  228     int chrSubSample = 
c->chrSrcVSubSample;
 
  230     *out_lum_size = lumFilterSize;
 
  231     *out_chr_size = chrFilterSize;
 
  233     for (lumY = 0; lumY < dstH; lumY++) {
 
  234         int chrY      = (int64_t)lumY * chrDstH / dstH;
 
  235         int nextSlice = 
FFMAX(lumFilterPos[lumY] + lumFilterSize - 1,
 
  236                               ((chrFilterPos[chrY] + chrFilterSize - 1)
 
  239         nextSlice >>= chrSubSample;
 
  240         nextSlice <<= chrSubSample;
 
  241         (*out_lum_size) = 
FFMAX((*out_lum_size), nextSlice - lumFilterPos[lumY]);
 
  242         (*out_chr_size) = 
FFMAX((*out_chr_size), (nextSlice >> chrSubSample) - chrFilterPos[chrY]);
 
  255     int need_lum_conv = 
c->lumToYV12 || 
c->readLumPlanar || 
c->alpToYV12 || 
c->readAlpPlanar;
 
  256     int need_chr_conv = 
c->chrToYV12 || 
c->readChrPlanar;
 
  257     int need_gamma = 
c->is_internal_gamma;
 
  259     int dst_stride = 
FFALIGN(
c->dstW * 
sizeof(int16_t) + 66, 16);
 
  261     uint32_t * pal = 
usePal(
c->srcFormat) ? 
c->pal_yuv : (uint32_t*)
c->input_rgb2yuv_table;
 
  277     num_ydesc = need_lum_conv ? 2 : 1;
 
  278     num_cdesc = need_chr_conv ? 2 : 1;
 
  280     c->numSlice = 
FFMAX(num_ydesc, num_cdesc) + 2;
 
  281     c->numDesc = num_ydesc + num_cdesc + num_vdesc + (need_gamma ? 2 : 0);
 
  282     c->descIndex[0] = num_ydesc + (need_gamma ? 1 : 0);
 
  283     c->descIndex[1] = num_ydesc + num_cdesc + (need_gamma ? 1 : 0);
 
  296     res = 
alloc_slice(&
c->slice[0], 
c->srcFormat, 
c->srcH, 
c->chrSrcH, 
c->chrSrcHSubSample, 
c->chrSrcVSubSample, 0);
 
  298     for (
i = 1; 
i < 
c->numSlice-2; ++
i) {
 
  299         res = 
alloc_slice(&
c->slice[
i], 
c->srcFormat, lumBufSize, chrBufSize, 
c->chrSrcHSubSample, 
c->chrSrcVSubSample, 0);
 
  305     res = 
alloc_slice(&
c->slice[
i], 
c->srcFormat, lumBufSize, chrBufSize, 
c->chrDstHSubSample, 
c->chrDstVSubSample, 1);
 
  314     res = 
alloc_slice(&
c->slice[
i], 
c->dstFormat, 
c->dstH, 
c->chrDstH, 
c->chrDstHSubSample, 
c->chrDstVSubSample, 0);
 
  330         c->desc[
index].alpha = 
c->needAlpha;
 
  336     dstIdx = 
FFMAX(num_ydesc, num_cdesc);
 
  339     c->desc[
index].alpha = 
c->needAlpha;
 
  353         dstIdx = 
FFMAX(num_ydesc, num_cdesc);
 
  354         if (
c->needs_hcscale)
 
  363         srcIdx = 
c->numSlice - 2;
 
  364         dstIdx = 
c->numSlice - 1;
 
  386         for (
i = 0; 
i < 
c->numDesc; ++
i)
 
  392         for (
i = 0; 
i < 
c->numSlice; ++
i)
 
  
int ff_init_desc_cfmt_convert(SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst, uint32_t *pal)
initializes chr pixel format conversion descriptor
 
AVPixelFormat
Pixel format.
 
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
 
static void fill_ones(SwsSlice *s, int n, int bpc)
 
static void get_min_buffer_size(SwsContext *c, int *out_lum_size, int *out_chr_size)
 
int ff_rotate_slice(SwsSlice *s, int lum, int chr)
 
static av_cold void cleanup(FlashSV2Context *s)
 
int ff_init_desc_hscale(SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst, uint16_t *filter, int *filter_pos, int filter_size, int xInc)
initializes lum horizontal scaling descriptor
 
int ff_init_desc_no_chr(SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst)
 
int ff_init_filters(SwsContext *c)
 
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
 
#define av_assert0(cond)
assert() equivalent, that is always enabled.
 
int ff_init_desc_chscale(SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst, uint16_t *filter, int *filter_pos, int filter_size, int xInc)
initializes chr horizontal scaling descriptor
 
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 free_lines(SwsSlice *s)
 
static int alloc_lines(SwsSlice *s, int size, int width)
 
static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
 
static void free_slice(SwsSlice *s)
 
static int alloc_slice(SwsSlice *s, enum AVPixelFormat fmt, int lumLines, int chrLines, int h_sub_sample, int v_sub_sample, int ring)
 
#define i(width, name, range_min, range_max)
 
int ff_init_gamma_convert(SwsFilterDescriptor *desc, SwsSlice *src, uint16_t *table)
initializes gamma conversion descriptor
 
int ff_free_filters(SwsContext *c)
 
Struct which defines a slice of an image to be scaled or an output for a scaled slice.
 
void * av_calloc(size_t nmemb, size_t size)
 
int ff_init_slice_from_src(SwsSlice *s, uint8_t *src[4], int stride[4], int srcW, int lumY, int lumH, int chrY, int chrH, int relative)
 
static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
 
int ff_init_vscale(SwsContext *c, SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst)
initializes vertical scaling descriptors
 
static double lum(void *priv, double x, double y, int plane)
 
int ff_init_desc_fmt_convert(SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst, uint32_t *pal)
initializes lum pixel format conversion descriptor