182 { -0.25, 0.5, -0.25 },
209 coeffs = &luma_coefficients[csp];
219 double bscale, rscale;
222 if (coeffs->
cr == 0.25 && coeffs->
cg == 0.5 && coeffs->
cb == 0.25) {
227 rgb2yuv[0][0] = coeffs->
cr;
228 rgb2yuv[0][1] = coeffs->
cg;
229 rgb2yuv[0][2] = coeffs->
cb;
230 bscale = 0.5 / (coeffs->
cb - 1.0);
231 rscale = 0.5 / (coeffs->
cr - 1.0);
232 rgb2yuv[1][0] = bscale * coeffs->
cr;
233 rgb2yuv[1][1] = bscale * coeffs->
cg;
236 rgb2yuv[2][1] = rscale * coeffs->
cg;
237 rgb2yuv[2][2] = rscale * coeffs->
cb;
262 coeffs = &transfer_characteristics[trc];
270 [
WP_D65] = { 0.3127, 0.3290 },
271 [
WP_C] = { 0.3100, 0.3160 },
272 [
WP_DCI] = { 0.3140, 0.3510 },
293 coeffs = &color_primaries[prm];
302 double m00 = in[0][0], m01 = in[0][1], m02 = in[0][2],
303 m10 = in[1][0], m11 = in[1][1], m12 = in[1][2],
304 m20 = in[2][0], m21 = in[2][1], m22 = in[2][2];
308 out[0][0] = (m11 * m22 - m21 * m12);
309 out[0][1] = -(m01 * m22 - m21 * m02);
310 out[0][2] = (m01 * m12 - m11 * m02);
311 out[1][0] = -(m10 * m22 - m20 * m12);
312 out[1][1] = (m00 * m22 - m20 * m02);
313 out[1][2] = -(m00 * m12 - m10 * m02);
314 out[2][0] = (m10 * m21 - m20 * m11);
315 out[2][1] = -(m00 * m21 - m20 * m01);
316 out[2][2] = (m00 * m11 - m10 * m01);
318 det = m00 * out[0][0] + m10 * out[0][1] + m20 * out[0][2];
321 for (i = 0; i < 3; i++) {
322 for (j = 0; j < 3; j++)
332 double in_ialpha = 1.0 / in_alpha, in_igamma = 1.0 / in_gamma, in_idelta = 1.0 / in_delta;
340 for (n = 0; n < 32768; n++) {
341 double v = (n - 2048.0) / 28672.0, d, l;
344 if (v <= -out_beta) {
345 d = -out_alpha * pow(-v, out_gamma) + (out_alpha - 1.0);
346 }
else if (v < out_beta) {
349 d = out_alpha * pow(v, out_gamma) - (out_alpha - 1.0);
355 l = -pow((1.0 - in_alpha - v) * in_ialpha, in_igamma);
356 }
else if (v < in_beta) {
359 l = pow((v + in_alpha - 1.0) * in_ialpha, in_igamma);
371 double rgb2xyz[3][3])
374 double i[3][3], sr, sg, sb, zw;
376 rgb2xyz[0][0] = coeffs->
xr / coeffs->
yr;
377 rgb2xyz[0][1] = coeffs->
xg / coeffs->
yg;
378 rgb2xyz[0][2] = coeffs->
xb / coeffs->
yb;
379 rgb2xyz[1][0] = rgb2xyz[1][1] = rgb2xyz[1][2] = 1.0;
380 rgb2xyz[2][0] = (1.0 - coeffs->
xr - coeffs->
yr) / coeffs->
yr;
381 rgb2xyz[2][1] = (1.0 - coeffs->
xg - coeffs->
yg) / coeffs->
yg;
382 rgb2xyz[2][2] = (1.0 - coeffs->
xb - coeffs->
yb) / coeffs->
yb;
384 zw = 1.0 - wp->
xw - wp->
yw;
385 sr = i[0][0] * wp->
xw + i[0][1] * wp->
yw + i[0][2] * zw;
386 sg = i[1][0] * wp->
xw + i[1][1] * wp->
yw + i[1][2] * zw;
387 sb = i[2][0] * wp->
xw + i[2][1] * wp->
yw + i[2][2] * zw;
399 static void mul3x3(
double dst[3][3],
const double src1[3][3],
const double src2[3][3])
403 for (m = 0; m < 3; m++)
404 for (n = 0; n < 3; n++)
405 dst[m][n] = src2[m][0] * src1[0][n] +
406 src2[m][1] * src1[1][n] +
407 src2[m][2] * src1[2][n];
419 { 0.8951, 0.2664, -0.1614 },
420 { -0.7502, 1.7135, 0.0367 },
421 { 0.0389, -0.0685, 1.0296 },
423 { 0.40024, 0.70760, -0.08081 },
424 { -0.22630, 1.16532, 0.04570 },
425 { 0.00000, 0.00000, 0.91822 },
428 const double (*
ma)[3] = ma_tbl[wp_adapt];
430 double zw_src = 1.0 - wp_src->
xw - wp_src->
yw;
432 double zw_dst = 1.0 - wp_dst->
xw - wp_dst->
yw;
433 double mai[3][3], fac[3][3],
tmp[3][3];
434 double rs, gs, bs, rd, gd, bd;
437 rs =
ma[0][0] * wp_src->
xw +
ma[0][1] * wp_src->
yw +
ma[0][2] * zw_src;
438 gs =
ma[1][0] * wp_src->
xw +
ma[1][1] * wp_src->
yw +
ma[1][2] * zw_src;
439 bs =
ma[2][0] * wp_src->
xw +
ma[2][1] * wp_src->
yw +
ma[2][2] * zw_src;
440 rd =
ma[0][0] * wp_dst->
xw +
ma[0][1] * wp_dst->
yw +
ma[0][2] * zw_dst;
441 gd =
ma[1][0] * wp_dst->
xw +
ma[1][1] * wp_dst->
yw +
ma[1][2] * zw_dst;
442 bd =
ma[2][0] * wp_dst->
xw +
ma[2][1] * wp_dst->
yw +
ma[2][2] * zw_dst;
446 fac[0][1] = fac[0][2] = fac[1][0] = fac[1][2] = fac[2][0] = fac[2][1] = 0.0;
452 int w,
int h,
const int16_t *lut)
456 for (n = 0; n < 3; n++) {
457 int16_t *
data = buf[
n];
459 for (y = 0; y <
h; y++) {
460 for (x = 0; x < w; x++)
461 data[x] = lut[av_clip_uintp2(2048 + data[x], 15)];
478 uint8_t *in_data[3], *out_data[3];
480 int h_in = (td->
in->
height + 1) >> 1;
481 int h1 = 2 * (job_nr * h_in / n_jobs), h2 = 2 * ((job_nr + 1) * h_in / n_jobs);
545 int *y_rng,
int *uv_rng,
559 *off = 16 << (depth - 8);
560 *y_rng = 219 << (depth - 8);
561 *uv_rng = 224 << (depth - 8);
565 *y_rng = *uv_rng = (256 << (depth - 8)) - 1;
580 int emms = 0, m,
n, o, res, fmt_identical, redo_yuv2rgb = 0, redo_rgb2yuv = 0;
582 #define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)
583 #define supported_subsampling(lcw, lch) \
584 (((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1))
585 #define supported_format(d) \
586 ((d) != NULL && (d)->nb_components == 3 && \
587 !((d)->flags & AV_PIX_FMT_FLAG_RGB) && \
588 supported_depth((d)->comp[0].depth) && \
589 supported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h))
593 "Unsupported input format %d (%s) or bitdepth (%d)\n",
600 "Unsupported output format %d (%s) or bitdepth (%d)\n",
602 out_desc ? out_desc->
comp[0].
depth : -1);
624 "Unsupported input primaries %d (%s)\n",
636 "Unsupported output color property %d\n", s->user_all);
640 "Unsupported output primaries %d (%s)\n",
648 double rgb2xyz[3][3], xyz2rgb[3][3], rgb2rgb[3][3];
655 double wpconv[3][3],
tmp[3][3];
659 mul3x3(tmp, rgb2xyz, wpconv);
660 mul3x3(rgb2rgb, tmp, xyz2rgb);
662 mul3x3(rgb2rgb, rgb2xyz, xyz2rgb);
664 for (m = 0; m < 3; m++)
665 for (n = 0; n < 3; n++) {
667 for (o = 1; o < 8; o++)
685 "Unsupported input transfer characteristics %d (%s)\n",
699 "Please specify output transfer characteristics\n");
702 "Unsupported output color property %d\n", s->user_all);
706 "Unsupported output transfer characteristics %d (%s)\n",
734 "Unsupported input colorspace %d (%s)\n",
749 "Please specify output transfer characteristics\n");
752 "Unsupported output color property %d\n", s->user_all);
756 "Unsupported output transfer characteristics %d (%s)\n",
774 int off,
bits, in_rng;
780 "Unsupported input color range %d (%s)\n",
784 for (n = 0; n < 8; n++)
788 bits = 1 << (in_desc->
comp[0].
depth - 1);
789 for (n = 0; n < 3; n++) {
790 for (in_rng = s->
in_y_rng, m = 0; m < 3; m++, in_rng = s->in_uv_rng) {
792 for (o = 1; o < 8; o++)
807 int off, out_rng,
bits;
813 "Unsupported output color range %d (%s)\n",
817 for (n = 0; n < 8; n++)
820 bits = 1 << (29 - out_desc->
comp[0].
depth);
821 for (out_rng = s->
out_y_rng, n = 0; n < 3; n++, out_rng = s->out_uv_rng) {
822 for (m = 0; m < 3; m++) {
824 for (o = 1; o < 8; o++)
844 for (out_rng = s->
out_y_rng, m = 0; m < 3; m++, out_rng = s->out_uv_rng) {
845 for (in_rng = s->
in_y_rng, n = 0; n < 3; n++, in_rng = s->in_uv_rng) {
847 lrint(16384 * yuv2yuv[m][n] * out_rng * (1 << idepth) /
848 (in_rng * (1 << odepth)));
849 for (o = 1; o < 8; o++)
903 ptrdiff_t rgb_stride =
FFALIGN(in->
width *
sizeof(int16_t), 32);
904 unsigned rgb_sz = rgb_stride * in->
height;
932 if (rgb_sz != s->
rgb_sz) {
968 if (!s->
rgb[0] || !s->
rgb[1] || !s->
rgb[2] ||
1037 if (inlink->
w % 2 || inlink->
h % 2) {
1039 inlink->
w, inlink->
h);
1043 outlink->
w = inlink->
w;
1044 outlink->
h = inlink->
h;
1051 #define OFFSET(x) offsetof(ColorSpaceContext, x)
1052 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
1053 #define ENUM(x, y, z) { x, "", 0, AV_OPT_TYPE_CONST, { .i64 = y }, INT_MIN, INT_MAX, FLAGS, z }
1056 {
"all",
"Set all color properties together",
1068 {
"space",
"Output colorspace",
1079 {
"range",
"Output color range",
1087 {
"primaries",
"Output color primaries",
1100 {
"trc",
"Output transfer characteristics",
1117 {
"format",
"Output pixel format",
1130 {
"fast",
"Ignore primary chromaticity and gamma correction",
1134 {
"dither",
"Dithering mode",
1140 {
"wpadapt",
"Whitepoint adaptation method",
1147 {
"iall",
"Set all input color properties together",
1150 {
"ispace",
"Input colorspace",
1153 {
"irange",
"Input color range",
1156 {
"iprimaries",
"Input color primaries",
1159 {
"itrc",
"Input transfer characteristics",
1187 .
name =
"colorspace",
1193 .priv_class = &colorspace_class,
ITU-R BT2020 for 12-bit system.
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
static enum AVColorPrimaries default_prm[CS_NB+1]
ptrdiff_t const GLvoid * data
double yuv2rgb_dbl_coeffs[3][3]
static void fn() rgb2yuv(uint8_t *_yuv[3], const ptrdiff_t yuv_stride[3], int16_t *rgb[3], ptrdiff_t s, int w, int h, const int16_t rgb2yuv_coeffs[3][3][8], const int16_t yuv_offset[8])
static void invert_matrix3x3(const double in[3][3], double out[3][3])
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
int * dither_scratch[3][2]
Main libavfilter public API header.
static int init(AVFilterContext *ctx)
enum AVColorTransferCharacteristic in_trc out_trc user_trc user_itrc
static const AVOption colorspace_options[]
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 void yuv2rgb(uint8_t *out, int ridx, int Y, int U, int V)
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
int16_t yuv2rgb_coeffs[3][3][8]
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
static int get_range_off(AVFilterContext *ctx, int *off, int *y_rng, int *uv_rng, enum AVColorRange rng, int depth)
SMPTE ST 431-2 (2011) / DCI P3.
#define AV_PIX_FMT_YUV420P12
static void fn() yuv2yuv(uint8_t *_dst[3], const ptrdiff_t dst_stride[3], uint8_t *_src[3], const ptrdiff_t src_stride[3], int w, int h, const int16_t c[3][3][8], const int16_t yuv_offset[2][8])
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
AVColorTransferCharacteristic
Color Transfer Characteristic.
functionally identical to above
const char * av_color_space_name(enum AVColorSpace space)
static const struct ColorPrimaries * get_color_primaries(enum AVColorPrimaries prm)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
void(* yuv2rgb_fn)(int16_t *rgb[3], ptrdiff_t rgb_stride, uint8_t *yuv[3], const ptrdiff_t yuv_stride[3], int w, int h, const int16_t yuv2rgb_coeffs[3][3][8], const int16_t yuv_offset[8])
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
AVColorSpace
YUV colorspace type.
const char * av_color_range_name(enum AVColorRange range)
AVFilter ff_vf_colorspace
enum Colorspace user_all user_iall
Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16.
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
static void uninit(AVFilterContext *ctx)
const struct ColorPrimaries * out_primaries
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
ptrdiff_t out_linesize[3]
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
AVColorRange
MPEG vs JPEG YUV range.
#define AV_PIX_FMT_YUV422P12
const struct ColorPrimaries * in_primaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
static const struct LumaCoefficients * get_luma_coefficients(enum AVColorSpace csp)
int lrgb2lrgb_passthrough
A filter pad used for either input or output.
enum AVColorSpace in_csp out_csp user_csp user_icsp
A link between two filters.
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
int width
width and height of the video frame
#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.
double rgb2yuv_dbl_coeffs[3][3]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const struct LumaCoefficients * out_lumacoef
static const uint8_t dither[8][8]
void * priv
private data for use by the filter
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
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...
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
static void fill_rgb2yuv_table(const struct LumaCoefficients *coeffs, double rgb2yuv[3][3])
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.
#define AV_PIX_FMT_YUV444P10
static int create_filtergraph(AVFilterContext *ctx, const AVFrame *in, const AVFrame *out)
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
static const AVFilterPad inputs[]
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
#define supported_format(d)
static void apply_lut(int16_t *buf[3], ptrdiff_t stride, int w, int h, const int16_t *lut)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
void(* yuv2yuv_fn)(uint8_t *yuv_out[3], const ptrdiff_t yuv_out_stride[3], uint8_t *yuv_in[3], const ptrdiff_t yuv_in_stride[3], int w, int h, const int16_t yuv2yuv_coeffs[3][3][8], const int16_t yuv_offset[2][8])
static const struct TransferCharacteristics transfer_characteristics[AVCOL_TRC_NB]
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
colour filters using Illuminant C
void(* rgb2yuv_fsb_fn)(uint8_t *yuv[3], const ptrdiff_t yuv_stride[3], int16_t *rgb[3], ptrdiff_t rgb_stride, int w, int h, const int16_t rgb2yuv_coeffs[3][3][8], const int16_t yuv_offset[8], int *rnd[3][2])
static enum AVColorSpace default_csp[CS_NB+1]
ITU-R BT2020 non-constant luminance system.
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
static const AVFilterPad outputs[]
int16_t lrgb2lrgb_coeffs[3][3][8]
AVFilterContext * src
source filter
static void fill_rgb2xyz_table(const struct ColorPrimaries *coeffs, double rgb2xyz[3][3])
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
the normal 2^n-1 "JPEG" YUV ranges
planar GBR 4:4:4:4 48bpp, little-endian
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
enum AVColorPrimaries in_prm out_prm user_prm user_iprm
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static const double ycgco_matrix[3][3]
static void fill_whitepoint_conv_table(double out[3][3], enum WhitepointAdaptation wp_adapt, enum Whitepoint src, enum Whitepoint dst)
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
static int query_formats(AVFilterContext *ctx)
int16_t yuv2yuv_coeffs[3][3][8]
functionally identical to above
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
void(* multiply3x3)(int16_t *data[3], ptrdiff_t stride, int w, int h, const int16_t m[3][3][8])
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
void(* rgb2yuv_fn)(uint8_t *yuv[3], const ptrdiff_t yuv_stride[3], int16_t *rgb[3], ptrdiff_t rgb_stride, int w, int h, const int16_t rgb2yuv_coeffs[3][3][8], const int16_t yuv_offset[8])
rgb2yuv_fsb_fn rgb2yuv_fsb
yuv2yuv_fn yuv2yuv[NB_BPP][NB_BPP][NB_SS]
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
static int fill_gamma_table(ColorSpaceContext *s)
rgb2yuv_fn rgb2yuv[NB_BPP][NB_SS]
int * dither_scratch_base[3][2]
#define AV_PIX_FMT_YUV420P10
Describe the class of an AVClass context structure.
yuv2rgb_fn yuv2rgb[NB_BPP][NB_SS]
const struct LumaCoefficients * in_lumacoef
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static enum AVColorTransferCharacteristic default_trc[CS_NB+1]
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
static const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB]
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
the normal 219*2^(n-8) "MPEG" YUV ranges
ITU-R BT2020 constant luminance system.
GLint GLenum GLboolean GLsizei stride
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
IEC 61966-2-1 (sRGB or sYCC)
enum WhitepointAdaptation wp_adapt
enum AVColorRange in_rng out_rng user_rng user_irng
void ff_colorspacedsp_init(ColorSpaceDSPContext *dsp)
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
enum AVPixelFormat in_format user_format
static int convert(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
avfilter_execute_func * execute
static const struct TransferCharacteristics * get_transfer_characteristics(enum AVColorTransferCharacteristic trc)
int16_t rgb2yuv_coeffs[3][3][8]
static void mul3x3(double dst[3][3], const double src1[3][3], const double src2[3][3])
static const int16_t coeffs[]
AVFilterContext * dst
dest filter
const struct TransferCharacteristics * in_txchr
const struct TransferCharacteristics * out_txchr
enum AVColorPrimaries color_primaries
AVFILTER_DEFINE_CLASS(colorspace)
ITU-R BT2020 for 10-bit system.
static const struct WhitepointCoefficients whitepoint_coefficients[WP_NB]
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
enum AVColorTransferCharacteristic color_trc
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.
int depth
Number of bits in the component.
static int filter_frame(AVFilterLink *link, AVFrame *in)
static int config_props(AVFilterLink *outlink)
AVPixelFormat
Pixel format.
rgb2yuv_fsb_fn rgb2yuv_fsb[NB_BPP][NB_SS]
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFilterFormats * out_formats