FFmpeg
Loading...
Searching...
No Matches
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/emms.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixdesc.h"
#include "libavutil/hwcontext.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 VALIDATE(field, min, max)
 

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 (SwsInternal *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
 
static void hScale16To15_c (SwsInternal *c, int16_t *dst, int dstW, const uint8_t *_src, const int16_t *filter, const int32_t *filterPos, int filterSize)
 
static void hScale8To15_c (SwsInternal *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
 
static void hScale8To19_c (SwsInternal *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, uint32_t _coeff, int64_t _offset)
 
static void chrRangeFromJpeg_c (int16_t *dstU, int16_t *dstV, int width, uint32_t _coeff, int64_t _offset)
 
static void lumRangeToJpeg_c (int16_t *dst, int width, uint32_t _coeff, int64_t _offset)
 
static void lumRangeFromJpeg_c (int16_t *dst, int width, uint32_t _coeff, int64_t _offset)
 
static void chrRangeToJpeg16_c (int16_t *_dstU, int16_t *_dstV, int width, uint32_t coeff, int64_t offset)
 
static void chrRangeFromJpeg16_c (int16_t *_dstU, int16_t *_dstV, int width, uint32_t coeff, int64_t offset)
 
static void lumRangeToJpeg16_c (int16_t *_dst, int width, uint32_t coeff, int64_t offset)
 
static void lumRangeFromJpeg16_c (int16_t *_dst, int width, uint32_t coeff, int64_t offset)
 
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)
 
static void solve_range_convert (uint16_t src_min, uint16_t src_max, uint16_t dst_min, uint16_t dst_max, int src_bits, int src_shift, int mult_shift, uint32_t *coeff, int64_t *offset)
 
static void init_range_convert_constants (SwsInternal *c)
 
av_cold void ff_sws_init_range_convert (SwsInternal *c)
 
static av_cold void sws_init_swscale (SwsInternal *c)
 
void ff_sws_init_scale (SwsInternal *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_c (const SwsInternal *c, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h)
 
static void rgb48Toxyz12_c (const SwsInternal *c, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h)
 
av_cold void ff_sws_init_xyzdsp (SwsInternal *c)
 
void ff_update_palette (SwsInternal *c, const uint32_t *pal)
 
static int scale_internal (SwsContext *sws, 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 (SwsInternal *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 (SwsInternal *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 (SwsContext *sws)
 Finish the scaling process for a pair of source/destination frames previously submitted with sws_frame_start().
 
static int ptr_in_buf (const uint8_t *ptr, const AVBufferRef *buf)
 
static int frame_ref (AVFrame *dst, const AVFrame *src, const int plane_copy[4])
 
static int frame_alloc_buffers (SwsContext *sws, AVFrame *frame)
 
int sws_frame_start (SwsContext *sws, AVFrame *dst, const AVFrame *src)
 Initialize the scaling process for a given pair of source/destination frames.
 
int sws_send_slice (SwsContext *sws, 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().
 
unsigned int sws_receive_slice_alignment (const SwsContext *sws)
 Get the alignment required for slices.
 
int sws_receive_slice (SwsContext *sws, 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().
 
int sws_scale_frame (SwsContext *sws, AVFrame *dst, const AVFrame *src)
 Scale source data from src and write the output to dst.
 
static int validate_params (SwsContext *ctx)
 
int sws_frame_setup (SwsContext *ctx, const AVFrame *dst, const AVFrame *src)
 Like sws_scale_frame, but without actually scaling.
 
int attribute_align_arg sws_scale (SwsContext *sws, 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.
 
int 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 258 of file swscale.c.

◆ DEBUG_BUFFERS

#define DEBUG_BUFFERS ( ...)
Value:
av_log(c, AV_LOG_DEBUG, __VA_ARGS__)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define DEBUG_SWSCALE_BUFFERS
Definition swscale.c:258
static double c[64]

Definition at line 259 of file swscale.c.

Referenced by ff_swscale().

◆ VALIDATE

#define VALIDATE ( field,
min,
max )
Value:
if (ctx->field < min || ctx->field > max) { \
av_log(ctx, AV_LOG_ERROR, "'%s' (%d) out of range [%d, %d]\n", \
#field, (int) ctx->field, min, max); \
return AVERROR(EINVAL); \
}
static AVFormatContext * ctx
#define min(a, b)
#define max(a, b)
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210

Referenced by validate_params().

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 58 of file swscale.c.

Referenced by ff_swscale().

◆ hScale16To19_c()

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

Definition at line 69 of file swscale.c.

Referenced by sws_init_swscale().

◆ hScale16To15_c()

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

Definition at line 99 of file swscale.c.

Referenced by sws_init_swscale().

◆ hScale8To15_c()

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

Definition at line 128 of file swscale.c.

Referenced by sws_init_swscale().

◆ hScale8To19_c()

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

Definition at line 144 of file swscale.c.

Referenced by sws_init_swscale().

◆ chrRangeToJpeg_c()

static void chrRangeToJpeg_c ( int16_t * dstU,
int16_t * dstV,
int width,
uint32_t _coeff,
int64_t _offset )
static

Definition at line 163 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,
uint32_t _coeff,
int64_t _offset )
static

Definition at line 177 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ lumRangeToJpeg_c()

static void lumRangeToJpeg_c ( int16_t * dst,
int width,
uint32_t _coeff,
int64_t _offset )
static

Definition at line 189 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ lumRangeFromJpeg_c()

static void lumRangeFromJpeg_c ( int16_t * dst,
int width,
uint32_t _coeff,
int64_t _offset )
static

Definition at line 201 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,
uint32_t coeff,
int64_t offset )
static

Definition at line 211 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,
uint32_t coeff,
int64_t offset )
static

Definition at line 225 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ lumRangeToJpeg16_c()

static void lumRangeToJpeg16_c ( int16_t * _dst,
int width,
uint32_t coeff,
int64_t offset )
static

Definition at line 237 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ lumRangeFromJpeg16_c()

static void lumRangeFromJpeg16_c ( int16_t * _dst,
int width,
uint32_t coeff,
int64_t offset )
static

Definition at line 248 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ ff_swscale()

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 )

Definition at line 263 of file swscale.c.

Referenced by run_legacy_swscale(), and scale_internal().

◆ solve_range_convert()

static void solve_range_convert ( uint16_t src_min,
uint16_t src_max,
uint16_t dst_min,
uint16_t dst_max,
int src_bits,
int src_shift,
int mult_shift,
uint32_t * coeff,
int64_t * offset )
static

Definition at line 577 of file swscale.c.

Referenced by init_range_convert_constants().

◆ init_range_convert_constants()

static void init_range_convert_constants ( SwsInternal * c)
static

Definition at line 591 of file swscale.c.

Referenced by ff_sws_init_range_convert().

◆ ff_sws_init_range_convert()

av_cold void ff_sws_init_range_convert ( SwsInternal * c)

Definition at line 626 of file swscale.c.

Referenced by sws_init_swscale(), and sws_setColorspaceDetails().

◆ sws_init_swscale()

static av_cold void sws_init_swscale ( SwsInternal * c)
static

Definition at line 662 of file swscale.c.

Referenced by ff_sws_init_scale().

◆ ff_sws_init_scale()

◆ reset_ptr()

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

Definition at line 716 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 728 of file swscale.c.

Referenced by scale_internal().

◆ xyz12Torgb48_c()

static void xyz12Torgb48_c ( const SwsInternal * c,
uint8_t * dst,
int dst_stride,
const uint8_t * src,
int src_stride,
int w,
int h )
static

Definition at line 745 of file swscale.c.

Referenced by ff_sws_init_xyzdsp().

◆ rgb48Toxyz12_c()

static void rgb48Toxyz12_c ( const SwsInternal * c,
uint8_t * dst,
int dst_stride,
const uint8_t * src,
int src_stride,
int w,
int h )
static

Definition at line 804 of file swscale.c.

Referenced by ff_sws_init_xyzdsp().

◆ ff_sws_init_xyzdsp()

av_cold void ff_sws_init_xyzdsp ( SwsInternal * c)

Definition at line 863 of file swscale.c.

Referenced by check_xyz12Torgb48le(), ff_get_unscaled_swscale(), and sws_init_swscale().

◆ ff_update_palette()

void ff_update_palette ( SwsInternal * c,
const uint32_t * pal )

Definition at line 873 of file swscale.c.

Referenced by scale_internal(), and setup_legacy_swscale().

◆ scale_internal()

static int scale_internal ( SwsContext * sws,
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 ( SwsInternal * 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 959 of file swscale.c.

Referenced by scale_internal().

◆ scale_cascaded()

static int scale_cascaded ( SwsInternal * 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 993 of file swscale.c.

Referenced by scale_internal().

◆ ptr_in_buf()

static int ptr_in_buf ( const uint8_t * ptr,
const AVBufferRef * buf )
static

Definition at line 1229 of file swscale.c.

Referenced by frame_ref().

◆ frame_ref()

static int frame_ref ( AVFrame * dst,
const AVFrame * src,
const int plane_copy[4] )
static

◆ frame_alloc_buffers()

static int frame_alloc_buffers ( SwsContext * sws,
AVFrame * frame )
static

Definition at line 1273 of file swscale.c.

Referenced by sws_scale_frame().

◆ validate_params()

static int validate_params ( SwsContext * ctx)
static

Definition at line 1482 of file swscale.c.

Referenced by sws_frame_setup().

◆ ff_sws_slice_worker()

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

Definition at line 1645 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 42 of file swscale.c.

Referenced by ff_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 54 of file swscale.c.

Referenced by ff_swscale().