37static void error(
const char *err)
39 fprintf(stderr,
"%s", err);
80static void mapres(
unsigned *r0,
unsigned *r1) {
81 double d = (
double)(*r0*10ll - 9ll*UINT32_MAX) / UINT32_MAX;
82 double a =
exp(d) * 16384 /
exp(1) ;
83 int ai = (int)round(
a);
84 uint64_t maxb = 16384 / ai;
86 *r1 = 1 + (*r1 * maxb) / UINT32_MAX;
97 int gblur_luma = bytestream2_get_byte(gbc);
98 int gblur_chroma = bytestream2_get_byte(gbc);
99 int sharpen_luma = bytestream2_get_byte(gbc);
100 int sharpen_chroma = bytestream2_get_byte(gbc);
101 int hshift_chroma = bytestream2_get_byte(gbc);
102 int vshift_chroma = bytestream2_get_byte(gbc);
104 p->luma_gblur = (gblur_luma - 128) * 100 / 128.0f;
105 p->chroma_gblur = (gblur_chroma - 128) * 100 / 128.0f;
106 p->luma_sharpen = (sharpen_luma - 128) * 100 / 128.0f;
107 p->chroma_sharpen = (sharpen_chroma - 128) * 100 / 128.0f;
108 p->chroma_hshift = (hshift_chroma - 128) * 100 / 128.0f;
109 p->chroma_vshift = (vshift_chroma - 128) * 100 / 128.0f;
115 p->luma_sharpen, p->chroma_sharpen,
116 p->chroma_hshift, p->chroma_vshift, 0);
121 static int default_cpu_flags = -1;
123 if (default_cpu_flags < 0)
130 int srcW= 48, srcH = 48;
131 int dstW= 48, dstH = 48;
132 int srcHShift, srcVShift;
133 int dstHShift, dstVShift;
145 int use_src_filter = 0, use_dst_filter = 0;
156 srcW = bytestream2_get_le32(&gbc);
157 srcH = bytestream2_get_le32(&gbc);
158 dstW = bytestream2_get_le32(&gbc);
159 dstH = bytestream2_get_le32(&gbc);
164 flags = bytestream2_get_le32(&gbc);
184 flags64 = bytestream2_get_le64(&gbc);
188 use_src_filter = flags64 & 0x20;
189 use_dst_filter = flags64 & 0x40;
206 fprintf(stderr,
"%d x %d %s -> %d x %d %s\n", srcW, srcH, desc_src->
name, dstW, dstH, desc_dst->
name);
209 ret =
alloc_plane(
src, srcStride, srcW, srcH, srcFormat, &srcHShift, &srcVShift, 1);
213 ret =
alloc_plane(
dst, dstStride, dstW, dstH, dstFormat, &dstHShift, &dstVShift, 0);
219 int psize = srcStride[p] *
AV_CEIL_RSHIFT(srcH, (p == 1 || p == 2) ? srcVShift : 0);
231 error(
"Failed sws allocation");
246 if (use_src_filter) {
252 if (use_dst_filter) {
263 sws_scale(sws, (
const uint8_t *
const*)
src, srcStride, 0, srcH,
dst, dstStride);
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const char *const format[]
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
#define AV_CEIL_RSHIFT(a, b)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int av_image_fill_plane_sizes(size_t sizes[4], enum AVPixelFormat pix_fmt, int height, const ptrdiff_t linesizes[4])
Fill plane sizes for an image with pixel format pix_fmt and height height.
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
void sws_freeFilter(SwsFilter *filter)
av_warn_unused_result int sws_init_context(SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
SwsFilter * sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen, float chromaHShift, float chromaVShift, int verbose)
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
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.
void sws_freeContext(SwsContext *swsContext)
Free the swscaler context swsContext.
@ SWS_SPLINE
unwindowed natural cubic spline
@ SWS_BICUBIC
2-tap cubic B-spline
@ SWS_BICUBLIN
bicubic luma, bilinear chroma
@ SWS_BILINEAR
bilinear filtering
@ SWS_SINC
unwindowed sinc
@ SWS_LANCZOS
3-tap sinc/sinc
@ SWS_GAUSS
gaussian approximation
@ SWS_FAST_BILINEAR
Scaler selection options.
@ SWS_POINT
nearest neighbor
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
static const uint16_t mask[17]
Memory handling functions.
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_VIDEO_MAX_PLANES
Maximum number of planes in any pixel format.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_NB
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Main external API structure.
static void mapres(unsigned *r0, unsigned *r1)
static void read_filter_params(GetByteContext *gbc, FilterParams *p)
static int alloc_plane(uint8_t *data[AV_VIDEO_MAX_PLANES], int stride[AV_VIDEO_MAX_PLANES], int w, int h, int format, int *hshift, int *vshift, int zero_init)
static SwsFilter * get_filter(const FilterParams *p)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
static void error(const char *err)
static void reset_cpu_flags(void)
static void free_plane(uint8_t *data[AV_VIDEO_MAX_PLANES])