105 "Size and width/height expressions cannot be set at the same time.\n");
116 "Invalid size '%s'\n", scale->
size_str);
119 snprintf(buf,
sizeof(buf)-1,
"%d", scale->
w);
121 snprintf(buf,
sizeof(buf)-1,
"%d", scale->
h);
201 if (s && strstr(s,
"bt709")) {
203 }
else if (s && strstr(s,
"fcc")) {
205 }
else if (s && strstr(s,
"smpte240m")) {
207 }
else if (s && (strstr(s,
"bt601") || strstr(s,
"bt470") || strstr(s,
"smpte170m"))) {
209 }
else if (s && strstr(s,
"bt2020")) {
213 if (colorspace < 1 || colorspace > 10 || colorspace == 8) {
254 if (w > INT_MAX || h > INT_MAX ||
255 (h * inlink->
w) > INT_MAX ||
256 (w * inlink->
h) > INT_MAX)
277 if (inlink0->
w == outlink->
w &&
278 inlink0->
h == outlink->
h &&
287 for (i = 0; i < 3; i++) {
321 in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
325 out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
345 av_log(ctx,
AV_LOG_VERBOSE,
"w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d fmt:%s sar:%d/%d flags:0x%0x\n",
361 outlink->
w = inlink->
w;
362 outlink->
h = inlink->
h;
384 int in_stride[4],out_stride[4];
388 int vsub= ((i+1)&2) ? scale->
vsub : 0;
389 in_stride[i] = cur_pic->
linesize[i] * mul;
390 out_stride[i] = out_buf->
linesize[i] * mul;
391 in[i] = cur_pic->
data[i] + ((y>>vsub)+field) * cur_pic->
linesize[i];
392 out[i] = out_buf->
data[i] + field * out_buf->
linesize[i];
395 in[1] = cur_pic->
data[1];
397 out[1] = out_buf->
data[1];
399 return sws_scale(sws, in, in_stride, y/mul, h,
422 snprintf(buf,
sizeof(buf)-1,
"%d", outlink->
w);
424 snprintf(buf,
sizeof(buf)-1,
"%d", outlink->
h);
467 const int *inv_table, *
table;
470 (
int **)&table, &out_full,
471 &brightness, &contrast, &saturation);
489 brightness, contrast, saturation);
493 brightness, contrast, saturation);
497 brightness, contrast, saturation);
511 int i, slice_h, slice_start,
slice_end = 0;
513 for (i = 0; i < nb_slices; i++) {
515 slice_end = (link->
h * (i+1)) / nb_slices;
516 slice_h = slice_end - slice_start;
517 scale_slice(link, out, in, scale->
sws, slice_start, slice_h, 1, 0);
535 char *res,
int res_len,
int flags)
540 if ( !strcmp(cmd,
"width") || !strcmp(cmd,
"w")
541 || !strcmp(cmd,
"height") || !strcmp(cmd,
"h")) {
543 int old_w = scale->
w;
544 int old_h = scale->
h;
563 #define OFFSET(x) offsetof(ScaleContext, x)
564 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
585 {
"in_v_chr_pos",
"input vertical chroma position in luma grid/256" ,
OFFSET(in_v_chr_pos),
AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512,
FLAGS },
586 {
"in_h_chr_pos",
"input horizontal chroma position in luma grid/256",
OFFSET(in_h_chr_pos),
AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512,
FLAGS },
587 {
"out_v_chr_pos",
"output vertical chroma position in luma grid/256" ,
OFFSET(out_v_chr_pos),
AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512,
FLAGS },
588 {
"out_h_chr_pos",
"output horizontal chroma position in luma grid/256",
OFFSET(out_h_chr_pos),
AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512,
FLAGS },
589 {
"force_original_aspect_ratio",
"decrease or increase w/h if necessary to keep the original AR",
OFFSET(force_original_aspect_ratio),
AV_OPT_TYPE_INT, { .i64 = 0}, 0, 2,
FLAGS,
"force_oar" },
595 {
"nb_slices",
"set the number of slices (debug purpose only)",
OFFSET(nb_slices),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
FLAGS },
631 .description =
NULL_IF_CONFIG_SMALL(
"Scale the input video size and/or convert the image format."),
636 .priv_class = &scale_class,
637 .
inputs = avfilter_vf_scale_inputs,
638 .
outputs = avfilter_vf_scale_outputs,
683 .description =
NULL_IF_CONFIG_SMALL(
"Scale the input video size and/or convert the image format to the given reference."),
688 .priv_class = &scale2ref_class,
689 .
inputs = avfilter_vf_scale2ref_inputs,
690 .
outputs = avfilter_vf_scale2ref_outputs,
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts)
static enum AVPixelFormat pix_fmt
int ff_scale_eval_dimensions(void *log_ctx, const char *w_expr, const char *h_expr, AVFilterLink *inlink, AVFilterLink *outlink, int *ret_w, int *ret_h)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
Parse str and put in width_ptr and height_ptr the detected values.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
Main libavfilter public API header.
int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation)
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
int h
agreed upon image height
static int scale_slice(AVFilterLink *link, AVFrame *out_buf, AVFrame *cur_pic, struct SwsContext *sws, int y, int h, int mul, int field)
int eval_mode
expression evaluation mode
int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
int force_original_aspect_ratio
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
const AVClass * sws_get_class(void)
Get the AVClass for swsContext.
int vsub
chroma subsampling
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
int output_is_pal
set to 1 if the output format is paletted
functionally identical to above
const char * name
Pad name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVFilterLink ** inputs
array of pointers to input links
char * w_expr
width expression string
static int query_formats(AVFilterContext *ctx)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
av_warn_unused_result int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
char * h_expr
height expression string
8 bits with AV_PIX_FMT_RGB32 palette
AVColorSpace
YUV colorspace type.
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16.
static const int * parse_yuv_type(const char *s, enum AVColorSpace colorspace)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static const AVClass scale_class
#define AV_LOG_VERBOSE
Detailed information.
int interlaced_frame
The content of the picture is interlaced.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
A filter pad used for either input or output.
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static const AVClass scale2ref_class
static const AVOption scale_options[]
int av_opt_eval_flags(void *obj, const AVOption *o, const char *val, int *flags_out)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define sws_isSupportedOutput(x)
static const struct endianess table[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
enum AVColorRange color_range
MPEG vs JPEG YUV range.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
enum AVColorSpace colorspace
YUV colorspace type.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static int config_props(AVFilterLink *outlink)
int w
agreed upon image width
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
common internal API header
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
static av_cold void uninit(AVFilterContext *ctx)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static const AVFilterPad avfilter_vf_scale_outputs[]
static int request_frame(AVFilterLink *outlink)
ITU-R BT2020 non-constant luminance system.
static const AVClass * child_class_next(const AVClass *prev)
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted".
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
const int * sws_getCoefficients(int colorspace)
Return a pointer to yuv<->rgb coefficients for the given colorspace suitable for sws_setColorspaceDet...
AVFilterContext * src
source filter
#define sws_isSupportedInput(x)
static const AVFilterPad outputs[]
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation)
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
int format
agreed upon media format
the normal 2^n-1 "JPEG" YUV ranges
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static int config_props_ref(AVFilterLink *outlink)
static int filter_frame_ref(AVFilterLink *link, AVFrame *in)
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
static const AVFilterPad inputs[]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
struct SwsContext * sws
software scaler context
static int request_frame_ref(AVFilterLink *outlink)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const AVFilterPad avfilter_vf_scale_inputs[]
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
static const AVFilterPad avfilter_vf_scale2ref_outputs[]
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.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
int input_is_pal
set to 1 if the input format is paletted
struct SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
AVFilterLink ** outputs
array of pointers to output links
struct SwsContext * isws[2]
software scaler context for interlaced material
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int filter_frame(AVFilterLink *link, AVFrame *in)
the normal 219*2^(n-8) "MPEG" YUV ranges
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
double param[2]
Input parameters for scaling algorithms that need them.
#define AV_OPT_SEARCH_FAKE_OBJ
The obj passed to av_opt_find() is fake – only a double pointer to AVClass instead of a required poin...
#define SWS_PARAM_DEFAULT
int slice_y
top of current output slice
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
AVFilterContext * dst
dest filter
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
#define FFSWAP(type, a, b)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
AVPixelFormat
Pixel format.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
const AVFilter * filter
the AVFilter of which this is an instance
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFilterFormats * out_formats
static const AVFilterPad avfilter_vf_scale2ref_inputs[]
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.