STRUCT V4L2_CTRL_AV1_FILM_GRAIN(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’… struct v4l2_ctrl_av1_film_grain โ€” AV1 Film Grain parameters

okay bestie, welcome to the Kernel API Manual โœจ this one's about a struct, and not just any struct โ€” it's the whole vibe of AV1 film grain, decoded for you. no cap, it's a lot of fields. grab a snack ๐Ÿ“


๐ŸŒธ NAME

struct v4l2_ctrl_av1_film_grain โ€” the AV1 Film Grain parameters. that's it. that's the whole name. iconic, brief, to the point ๐Ÿ’…


โœจ SYNOPSIS

here's the whole struct, character for character, no edits, no notes:

struct v4l2_ctrl_av1_film_grain {
    __u8 flags;
    __u8 cr_mult;
    __u16 grain_seed;
    __u8 film_grain_params_ref_idx;
    __u8 num_y_points;
    __u8 point_y_value[V4L2_AV1_MAX_NUM_Y_POINTS];
    __u8 point_y_scaling[V4L2_AV1_MAX_NUM_Y_POINTS];
    __u8 num_cb_points;
    __u8 point_cb_value[V4L2_AV1_MAX_NUM_CB_POINTS];
    __u8 point_cb_scaling[V4L2_AV1_MAX_NUM_CB_POINTS];
    __u8 num_cr_points;
    __u8 point_cr_value[V4L2_AV1_MAX_NUM_CR_POINTS];
    __u8 point_cr_scaling[V4L2_AV1_MAX_NUM_CR_POINTS];
    __u8 grain_scaling_minus_8;
    __u8 ar_coeff_lag;
    __u8 ar_coeffs_y_plus_128[V4L2_AV1_AR_COEFFS_SIZE];
    __u8 ar_coeffs_cb_plus_128[V4L2_AV1_AR_COEFFS_SIZE];
    __u8 ar_coeffs_cr_plus_128[V4L2_AV1_AR_COEFFS_SIZE];
    __u8 ar_coeff_shift_minus_6;
    __u8 grain_scale_shift;
    __u8 cb_mult;
    __u8 cb_luma_mult;
    __u8 cr_luma_mult;
    __u16 cb_offset;
    __u16 cr_offset;
    __u8 reserved[4];
 };

like, look at all those little __u8s. they're all doing their best ๐Ÿซถ


๐ŸŽ€ Members

flags โ€” see V4L2_AV1_FILM_GRAIN_{} for what all the bits mean. that's your starting point, bestie.

cr_mult โ€” a multiplier for the cr component, used when deriving the input index to the cr component scaling function.

grain_seed โ€” the starting value for the pseudo-random numbers used during film grain synthesis. yeah, it seeds the randomness. the โœจchaosโœจ begins here.

film_grain_params_ref_idx โ€” tells you which reference frame holds the film grain parameters to be used for this frame. it's giving "borrowed the fit from a friend" ๐ŸŽ€

num_y_points โ€” the number of points for the piece-wise linear scaling function of the luma component.

point_y_value โ€” the x (luma value) coordinate for the i-th point of the piecewise linear scaling function for the luma component. these get signaled on a scale of 0..255. for 10 bit video, these values correspond to luma values divided by 4. for 12 bit video, these values correspond to luma values divided by 16. math girlies rise ๐Ÿงฎ

point_y_scaling โ€” the scaling (output) value for the i-th point of the piecewise linear scaling function for the luma component.

num_cb_points โ€” the number of points for the piece-wise linear scaling function of the cb component.

point_cb_value โ€” the x coordinate for the i-th point of the piecewise linear scaling function for the cb component. these are signaled on the scale of 0..255.

point_cb_scaling โ€” the scaling (output) value for the i-th point of the piecewise linear scaling function for the cb component.

num_cr_points โ€” the number of points for the piece-wise linear scaling function of the cr component. (the original literally says "specifies represents" โ€” we love a typo moment, but the meaning is: this is the count ๐Ÿ’€)

point_cr_value โ€” the x coordinate for the i-th point of the piecewise linear scaling function for the cr component. signaled on the scale of 0..255.

point_cr_scaling โ€” the scaling (output) value for the i-th point of the piecewise linear scaling function for the cr component.

grain_scaling_minus_8 โ€” the shift โ€“ 8 applied to the values of the chroma component. grain_scaling_minus_8 can take values of 0..3 and determines the range and quantization step of the standard deviation of film grain. so like, small but mighty ๐Ÿฆ‹

ar_coeff_lag โ€” the number of auto-regressive coefficients for luma and chroma.

ar_coeffs_y_plus_128 โ€” the auto-regressive coefficients used for the Y plane.

ar_coeffs_cb_plus_128 โ€” the auto-regressive coefficients used for the U plane.

ar_coeffs_cr_plus_128 โ€” the auto-regressive coefficients used for the V plane.

ar_coeff_shift_minus_6 โ€” the range of the auto-regressive coefficients. values of 0, 1, 2, and 3 correspond to the ranges for auto-regressive coefficients of [-2, 2), [-1, 1), [-0.5, 0.5) and [-0.25, 0.25) respectively. yes the brackets are doing something important, don't touch them ๐Ÿ”ฅ

grain_scale_shift โ€” how much the Gaussian random numbers should be scaled down during the grain synthesis process.

cb_mult โ€” a multiplier for the cb component, used when deriving the input index to the cb component scaling function.

cb_luma_mult โ€” a multiplier for the average luma component, used when deriving the input index to the cb component scaling function.

cr_luma_mult โ€” a multiplier for the average luma component, used when deriving the input index to the cr component scaling function.

cb_offset โ€” an offset used in deriving the input index to the cb component scaling function.

cr_offset โ€” an offset used in deriving the input index to the cr component scaling function.

reserved โ€” the padding field. > โš ๏ธ bestie, applications should zero this out. don't leave your junk in there, zero it. it's a padding field, not a storage unit ๐Ÿ™ˆ


๐Ÿ’– Description

these are the Film grain parameters as specified by section 6.8.20 of the AV1 Specification. that's the source of truth, go read it, iykyk ๐Ÿ‘‘


๐ŸŒˆ SEE ALSO

the whole extended friend group, in order, exactly as listed:

  • Kernel file ./include/uapi/linux/v4l2-controls.h enum
  • v4l2_mpeg_video_av1_profile(9)
  • enum v4l2_mpeg_video_av1_level(9)
  • enum v4l2_stateless_h264_decode_mode(9)
  • enum v4l2_stateless_h264_start_code(9)
  • struct v4l2_ctrl_h264_sps(9)
  • struct v4l2_ctrl_h264_pps(9)
  • struct v4l2_ctrl_h264_scaling_matrix(9)
  • struct v4l2_ctrl_h264_pred_weights(9)
  • struct v4l2_h264_reference(9)
  • struct v4l2_ctrl_h264_slice_params(9)
  • struct v4l2_h264_dpb_entry(9)
  • struct v4l2_ctrl_h264_decode_params(9)
  • struct v4l2_ctrl_fwht_params(9)
  • struct v4l2_vp8_segment(9)
  • struct v4l2_vp8_loop_filter(9)
  • struct v4l2_vp8_quantization(9)
  • struct v4l2_vp8_entropy(9)
  • struct v4l2_vp8_entropy_coder_state(9)
  • struct v4l2_ctrl_vp8_frame(9)
  • struct v4l2_ctrl_mpeg2_sequence(9)
  • struct v4l2_ctrl_mpeg2_picture(9)
  • struct v4l2_ctrl_mpeg2_quantisation(9)
  • struct v4l2_ctrl_hevc_sps(9)
  • struct v4l2_ctrl_hevc_pps(9)
  • struct v4l2_hevc_dpb_entry(9)
  • struct v4l2_hevc_pred_weight_table(9)
  • struct v4l2_ctrl_hevc_slice_params(9)
  • struct v4l2_ctrl_hevc_decode_params(9)
  • struct v4l2_ctrl_hevc_scaling_matrix(9)
  • struct v4l2_vp9_loop_filter(9)
  • struct v4l2_vp9_quantization(9)
  • struct v4l2_vp9_segmentation(9)
  • struct v4l2_ctrl_vp9_frame(9)
  • struct v4l2_vp9_mv_probs(9)
  • struct v4l2_ctrl_vp9_compressed_hdr(9)
  • struct v4l2_ctrl_av1_sequence(9)
  • struct v4l2_ctrl_av1_tile_group_entry(9)
  • enum v4l2_av1_warp_model(9)
  • enum v4l2_av1_reference_frame(9)
  • struct v4l2_av1_global_motion(9)
  • enum v4l2_av1_frame_restoration_type(9)
  • struct v4l2_av1_loop_restoration(9)
  • struct v4l2_av1_cdef(9)
  • enum v4l2_av1_segment_feature(9)
  • struct v4l2_av1_segmentation(9)
  • struct v4l2_av1_loop_filter(9)
  • struct v4l2_av1_quantization(9)
  • struct v4l2_av1_tile_info(9)
  • enum v4l2_av1_frame_type(9)
  • enum v4l2_av1_interpolation_filter(9)
  • enum v4l2_av1_tx_mode(9)
  • struct v4l2_ctrl_av1_frame(9)

that's a whole group chat right there and you're on read ๐Ÿ˜ญ go say hi.


source file lives at ./include/uapi/linux, dated October 2026 โ€” and that's the whole page, bestie. mwah, study hard, struct slay ๐Ÿ’œโœจ

๐Ÿ“ฆ where this page comes from