FFmpeg
Macros | Functions | Variables
swscale.c File Reference
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/avassert.h"
#include "libavutil/bswap.h"
#include "libavutil/common.h"
#include "libavutil/cpu.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixdesc.h"
#include "config.h"
#include "swscale_internal.h"
#include "swscale.h"

Go to the source code of this file.

Macros

#define DEBUG_SWSCALE_BUFFERS   0
 
#define DEBUG_BUFFERS(...)
 
#define RGB2YUV_SHIFT   15
 
#define BY   ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
 
#define BV   (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
 
#define BU   ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
 
#define GY   ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
 
#define GV   (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
 
#define GU   (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
 
#define RY   ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
 
#define RV   ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
 
#define RU   (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
 

Functions

static av_always_inline void fillPlane (uint8_t *plane, int stride, int width, int height, int y, uint8_t val)
 
static void hScale16To19_c (SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
 
static void hScale16To15_c (SwsContext *c, int16_t *dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
 
static void hScale8To15_c (SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
 
static void hScale8To19_c (SwsContext *c, int16_t *_dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
 
static void chrRangeToJpeg_c (int16_t *dstU, int16_t *dstV, int width)
 
static void chrRangeFromJpeg_c (int16_t *dstU, int16_t *dstV, int width)
 
static void lumRangeToJpeg_c (int16_t *dst, int width)
 
static void lumRangeFromJpeg_c (int16_t *dst, int width)
 
static void chrRangeToJpeg16_c (int16_t *_dstU, int16_t *_dstV, int width)
 
static void chrRangeFromJpeg16_c (int16_t *_dstU, int16_t *_dstV, int width)
 
static void lumRangeToJpeg16_c (int16_t *_dst, int width)
 
static void lumRangeFromJpeg16_c (int16_t *_dst, int width)
 
static int swscale (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[], int dstSliceY, int dstSliceH)
 
av_cold void ff_sws_init_range_convert (SwsContext *c)
 
static av_cold void sws_init_swscale (SwsContext *c)
 
void ff_sws_init_scale (SwsContext *c)
 
static void reset_ptr (const uint8_t *src[], enum AVPixelFormat format)
 
static int check_image_pointers (const uint8_t *const data[4], enum AVPixelFormat pix_fmt, const int linesizes[4])
 
static void xyz12Torgb48 (struct SwsContext *c, uint16_t *dst, const uint16_t *src, int stride, int h)
 
static void rgb48Toxyz12 (struct SwsContext *c, uint16_t *dst, const uint16_t *src, int stride, int h)
 
static void update_palette (SwsContext *c, const uint32_t *pal)
 
static int scale_internal (SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstSlice[], const int dstStride[], int dstSliceY, int dstSliceH)
 
static int scale_gamma (SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstSlice[], const int dstStride[], int dstSliceY, int dstSliceH)
 
static int scale_cascaded (SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstSlice[], const int dstStride[], int dstSliceY, int dstSliceH)
 
void sws_frame_end (struct SwsContext *c)
 Finish the scaling process for a pair of source/destination frames previously submitted with sws_frame_start(). More...
 
int sws_frame_start (struct SwsContext *c, AVFrame *dst, const AVFrame *src)
 Initialize the scaling process for a given pair of source/destination frames. More...
 
int sws_send_slice (struct SwsContext *c, unsigned int slice_start, unsigned int slice_height)
 Indicate that a horizontal slice of input data is available in the source frame previously provided to sws_frame_start(). More...
 
unsigned int sws_receive_slice_alignment (const struct SwsContext *c)
 
int sws_receive_slice (struct SwsContext *c, unsigned int slice_start, unsigned int slice_height)
 Request a horizontal slice of the output data to be written into the frame previously provided to sws_frame_start(). More...
 
int sws_scale_frame (struct SwsContext *c, AVFrame *dst, const AVFrame *src)
 Scale source data from src and write the output to dst. More...
 
int attribute_align_arg sws_scale (struct SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
 swscale wrapper, so we don't need to export the SwsContext. More...
 
void ff_sws_slice_worker (void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads)
 

Variables

const uint8_t ff_dither_8x8_128 [9][8]
 
static const uint8_t sws_pb_64 [8]
 

Macro Definition Documentation

◆ DEBUG_SWSCALE_BUFFERS

#define DEBUG_SWSCALE_BUFFERS   0

Definition at line 229 of file swscale.c.

◆ DEBUG_BUFFERS

#define DEBUG_BUFFERS (   ...)
Value:
av_log(c, AV_LOG_DEBUG, __VA_ARGS__)

Definition at line 230 of file swscale.c.

◆ RGB2YUV_SHIFT

#define RGB2YUV_SHIFT   15

◆ BY

#define BY   ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

◆ BV

#define BV   (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

◆ BU

#define BU   ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

◆ GY

#define GY   ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

◆ GV

#define GV   (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

◆ GU

#define GU   (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

◆ RY

#define RY   ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

◆ RV

#define RV   ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

◆ RU

#define RU   (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))

Function Documentation

◆ fillPlane()

static av_always_inline void fillPlane ( uint8_t *  plane,
int  stride,
int  width,
int  height,
int  y,
uint8_t  val 
)
static

Definition at line 52 of file swscale.c.

Referenced by swscale().

◆ hScale16To19_c()

static void hScale16To19_c ( SwsContext c,
int16_t *  _dst,
int  dstW,
const uint8_t *  _src,
const int16_t *  filter,
const int32_t filterPos,
int  filterSize 
)
static

Definition at line 63 of file swscale.c.

Referenced by sws_init_swscale().

◆ hScale16To15_c()

static void hScale16To15_c ( SwsContext c,
int16_t *  dst,
int  dstW,
const uint8_t *  _src,
const int16_t *  filter,
const int32_t filterPos,
int  filterSize 
)
static

Definition at line 93 of file swscale.c.

Referenced by sws_init_swscale().

◆ hScale8To15_c()

static void hScale8To15_c ( SwsContext c,
int16_t *  dst,
int  dstW,
const uint8_t *  src,
const int16_t *  filter,
const int32_t filterPos,
int  filterSize 
)
static

Definition at line 122 of file swscale.c.

Referenced by sws_init_swscale().

◆ hScale8To19_c()

static void hScale8To19_c ( SwsContext c,
int16_t *  _dst,
int  dstW,
const uint8_t *  src,
const int16_t *  filter,
const int32_t filterPos,
int  filterSize 
)
static

Definition at line 138 of file swscale.c.

Referenced by sws_init_swscale().

◆ chrRangeToJpeg_c()

static void chrRangeToJpeg_c ( int16_t *  dstU,
int16_t *  dstV,
int  width 
)
static

Definition at line 157 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ chrRangeFromJpeg_c()

static void chrRangeFromJpeg_c ( int16_t *  dstU,
int16_t *  dstV,
int  width 
)
static

Definition at line 166 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ lumRangeToJpeg_c()

static void lumRangeToJpeg_c ( int16_t *  dst,
int  width 
)
static

Definition at line 175 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ lumRangeFromJpeg_c()

static void lumRangeFromJpeg_c ( int16_t *  dst,
int  width 
)
static

Definition at line 182 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ chrRangeToJpeg16_c()

static void chrRangeToJpeg16_c ( int16_t *  _dstU,
int16_t *  _dstV,
int  width 
)
static

Definition at line 189 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ chrRangeFromJpeg16_c()

static void chrRangeFromJpeg16_c ( int16_t *  _dstU,
int16_t *  _dstV,
int  width 
)
static

Definition at line 200 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ lumRangeToJpeg16_c()

static void lumRangeToJpeg16_c ( int16_t *  _dst,
int  width 
)
static

Definition at line 211 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ lumRangeFromJpeg16_c()

static void lumRangeFromJpeg16_c ( int16_t *  _dst,
int  width 
)
static

Definition at line 220 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ swscale()

static int swscale ( SwsContext c,
const uint8_t *  src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *  dst[],
int  dstStride[],
int  dstSliceY,
int  dstSliceH 
)
static

Definition at line 234 of file swscale.c.

Referenced by ffprobe_show_library_versions(), print_all_libs_info(), and scale_internal().

◆ ff_sws_init_range_convert()

av_cold void ff_sws_init_range_convert ( SwsContext c)

Definition at line 532 of file swscale.c.

Referenced by sws_init_swscale(), and sws_setColorspaceDetails().

◆ sws_init_swscale()

static av_cold void sws_init_swscale ( SwsContext c)
static

Definition at line 557 of file swscale.c.

Referenced by ff_sws_init_scale().

◆ ff_sws_init_scale()

void ff_sws_init_scale ( SwsContext c)

◆ reset_ptr()

static void reset_ptr ( const uint8_t *  src[],
enum AVPixelFormat  format 
)
static

Definition at line 604 of file swscale.c.

Referenced by scale_internal().

◆ check_image_pointers()

static int check_image_pointers ( const uint8_t *const  data[4],
enum AVPixelFormat  pix_fmt,
const int  linesizes[4] 
)
static

Definition at line 616 of file swscale.c.

Referenced by scale_internal().

◆ xyz12Torgb48()

static void xyz12Torgb48 ( struct SwsContext c,
uint16_t *  dst,
const uint16_t *  src,
int  stride,
int  h 
)
static

Definition at line 633 of file swscale.c.

Referenced by scale_internal().

◆ rgb48Toxyz12()

static void rgb48Toxyz12 ( struct SwsContext c,
uint16_t *  dst,
const uint16_t *  src,
int  stride,
int  h 
)
static

Definition at line 689 of file swscale.c.

Referenced by scale_internal().

◆ update_palette()

static void update_palette ( SwsContext c,
const uint32_t *  pal 
)
static

Definition at line 745 of file swscale.c.

Referenced by reconfigure_at_keyframe(), and scale_internal().

◆ scale_internal()

static int scale_internal ( SwsContext c,
const uint8_t *const  srcSlice[],
const int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *const  dstSlice[],
const int  dstStride[],
int  dstSliceY,
int  dstSliceH 
)
static

◆ scale_gamma()

static int scale_gamma ( SwsContext c,
const uint8_t *const  srcSlice[],
const int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *const  dstSlice[],
const int  dstStride[],
int  dstSliceY,
int  dstSliceH 
)
static

Definition at line 826 of file swscale.c.

Referenced by scale_internal().

◆ scale_cascaded()

static int scale_cascaded ( SwsContext c,
const uint8_t *const  srcSlice[],
const int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t *const  dstSlice[],
const int  dstStride[],
int  dstSliceY,
int  dstSliceH 
)
static

Definition at line 860 of file swscale.c.

Referenced by scale_internal().

◆ ff_sws_slice_worker()

void ff_sws_slice_worker ( void *  priv,
int  jobnr,
int  threadnr,
int  nb_jobs,
int  nb_threads 
)

Definition at line 1214 of file swscale.c.

Referenced by context_init_threaded().

Variable Documentation

◆ ff_dither_8x8_128

const uint8_t ff_dither_8x8_128[9][8]
Initial value:
= {
{ 36, 68, 60, 92, 34, 66, 58, 90, },
{ 100, 4, 124, 28, 98, 2, 122, 26, },
{ 52, 84, 44, 76, 50, 82, 42, 74, },
{ 116, 20, 108, 12, 114, 18, 106, 10, },
{ 32, 64, 56, 88, 38, 70, 62, 94, },
{ 96, 0, 120, 24, 102, 6, 126, 30, },
{ 48, 80, 40, 72, 54, 86, 46, 78, },
{ 112, 16, 104, 8, 118, 22, 110, 14, },
{ 36, 68, 60, 92, 34, 66, 58, 90, },
}

Definition at line 36 of file swscale.c.

Referenced by swscale().

◆ sws_pb_64

const uint8_t sws_pb_64[8]
static
Initial value:
= {
64, 64, 64, 64, 64, 64, 64, 64
}

Definition at line 48 of file swscale.c.

Referenced by swscale().

AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
c
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
Definition: undefined.txt:32
DEBUG_SWSCALE_BUFFERS
#define DEBUG_SWSCALE_BUFFERS
Definition: swscale.c:229