/* source buffer copy in YUV 420 MB-tiled format with size=16*256*3/2 */ #define CURRENT_WINDOW_BUFFER_MAX_SIZE (16 * 256 * 3 / 2)
/* * 4 lines of pixels (in Luma, Chroma blue and Chroma red) of top MB * for deblocking with size=4*16*MBx*2
*/ #define LOCAL_RECONSTRUCTED_BUFFER_MAX_SIZE(w) (4 * 16 * MB_W(w) * 2)
/* factor for bitrate and cpb buffer size max values if profile >= high */ #define H264_FACTOR_HIGH 1200
/* factor for bitrate and cpb buffer size max values if profile < high */ #define H264_FACTOR_BASELINE 1000
/* number of bytes for NALU_TYPE_FILLER_DATA header and footer */ #define H264_FILLER_DATA_SIZE 6
/* * struct hva_h264_td * * @frame_width: width in pixels of the buffer containing the input frame * @frame_height: height in pixels of the buffer containing the input frame * @frame_num: the parameter to be written in the slice header * @picture_coding_type: type I, P or B * @pic_order_cnt_type: POC mode, as defined in H264 std : can be 0,1,2 * @first_picture_in_sequence: flag telling to encoder that this is the * first picture in a video sequence. * Used for VBR * @slice_size_type: 0 = no constraint to close the slice * 1= a slice is closed as soon as the slice_mb_size limit * is reached * 2= a slice is closed as soon as the slice_byte_size limit * is reached * 3= a slice is closed as soon as either the slice_byte_size * limit or the slice_mb_size limit is reached * @slice_mb_size: defines the slice size in number of macroblocks * (used when slice_size_type=1 or slice_size_type=3) * @ir_param_option: defines the number of macroblocks per frame to be * refreshed by AIR algorithm OR the refresh period * by CIR algorithm * @intra_refresh_type: enables the adaptive intra refresh algorithm. * Disable=0 / Adaptative=1 and Cycle=2 as intra refresh * @use_constrained_intra_flag: constrained_intra_pred_flag from PPS * @transform_mode: controls the use of 4x4/8x8 transform mode * @disable_deblocking_filter_idc: * 0: specifies that all luma and chroma block edges of * the slice are filtered. * 1: specifies that deblocking is disabled for all block * edges of the slice. * 2: specifies that all luma and chroma block edges of * the slice are filtered with exception of the block edges * that coincide with slice boundaries * @slice_alpha_c0_offset_div2: to be written in slice header, * controls deblocking * @slice_beta_offset_div2: to be written in slice header, * controls deblocking * @encoder_complexity: encoder complexity control (IME). * 0 = I_16x16, P_16x16, Full ME Complexity * 1 = I_16x16, I_NxN, P_16x16, Full ME Complexity * 2 = I_16x16, I_NXN, P_16x16, P_WxH, Full ME Complexity * 4 = I_16x16, P_16x16, Reduced ME Complexity * 5 = I_16x16, I_NxN, P_16x16, Reduced ME Complexity * 6 = I_16x16, I_NXN, P_16x16, P_WxH, Reduced ME Complexity * @chroma_qp_index_offset: coming from picture parameter set * (PPS see [H.264 STD] 7.4.2.2) * @entropy_coding_mode: entropy coding mode. * 0 = CAVLC * 1 = CABAC * @brc_type: selects the bit-rate control algorithm * 0 = constant Qp, (no BRC) * 1 = CBR * 2 = VBR * @quant: Quantization param used in case of fix QP encoding (no BRC) * @non_VCL_NALU_Size: size of non-VCL NALUs (SPS, PPS, filler), * used by BRC * @cpb_buffer_size: size of Coded Picture Buffer, used by BRC * @bit_rate: target bitrate, for BRC * @qp_min: min QP threshold * @qp_max: max QP threshold * @framerate_num: target framerate numerator , used by BRC * @framerate_den: target framerate denomurator , used by BRC * @delay: End-to-End Initial Delay * @strict_HRD_compliancy: flag for HDR compliancy (1) * May impact quality encoding * @addr_source_buffer: address of input frame buffer for current frame * @addr_fwd_Ref_Buffer: address of reference frame buffer * @addr_rec_buffer: address of reconstructed frame buffer * @addr_output_bitstream_start: output bitstream start address * @addr_output_bitstream_end: output bitstream end address * @addr_external_sw : address of external search window * @addr_lctx : address of context picture buffer * @addr_local_rec_buffer: address of local reconstructed buffer * @addr_spatial_context: address of spatial context buffer * @bitstream_offset: offset in bits between aligned bitstream start * address and first bit to be written by HVA. * Range value is [0..63] * @sampling_mode: Input picture format . * 0: YUV420 semi_planar Interleaved * 1: YUV422 raster Interleaved * @addr_param_out: address of output parameters structure * @addr_scaling_matrix: address to the coefficient of * the inverse scaling matrix * @addr_scaling_matrix_dir: address to the coefficient of * the direct scaling matrix * @addr_cabac_context_buffer: address of cabac context buffer * @GmvX: Input information about the horizontal global displacement of * the encoded frame versus the previous one * @GmvY: Input information about the vertical global displacement of * the encoded frame versus the previous one * @window_width: width in pixels of the window to be encoded inside * the input frame * @window_height: width in pixels of the window to be encoded inside * the input frame * @window_horizontal_offset: horizontal offset in pels for input window * within input frame * @window_vertical_offset: vertical offset in pels for input window * within input frame * @addr_roi: Map of QP offset for the Region of Interest algorithm and * also used for Error map. * Bit 0-6 used for qp offset (value -64 to 63). * Bit 7 used to force intra * @addr_slice_header: address to slice header * @slice_header_size_in_bits: size in bits of the Slice header * @slice_header_offset0: Slice header offset where to insert * first_Mb_in_slice * @slice_header_offset1: Slice header offset where to insert * slice_qp_delta * @slice_header_offset2: Slice header offset where to insert * num_MBs_in_slice * @slice_synchro_enable: enable "slice ready" interrupt after each slice * @max_slice_number: Maximum number of slice in a frame * (0 is strictly forbidden) * @rgb2_yuv_y_coeff: Four coefficients (C0C1C2C3) to convert from RGB to * YUV for the Y component. * Y = C0*R + C1*G + C2*B + C3 (C0 is on byte 0) * @rgb2_yuv_u_coeff: four coefficients (C0C1C2C3) to convert from RGB to * YUV for the Y component. * Y = C0*R + C1*G + C2*B + C3 (C0 is on byte 0) * @rgb2_yuv_v_coeff: Four coefficients (C0C1C2C3) to convert from RGB to * YUV for the U (Cb) component. * U = C0*R + C1*G + C2*B + C3 (C0 is on byte 0) * @slice_byte_size: maximum slice size in bytes * (used when slice_size_type=2 or slice_size_type=3) * @max_air_intra_mb_nb: Maximum number of intra macroblock in a frame * for the AIR algorithm * @brc_no_skip: Disable skipping in the Bitrate Controller * @addr_brc_in_out_parameter: address of static buffer for BRC parameters
*/ struct hva_h264_td {
u16 frame_width;
u16 frame_height;
u32 frame_num;
u16 picture_coding_type;
u16 reserved1;
u16 pic_order_cnt_type;
u16 first_picture_in_sequence;
u16 slice_size_type;
u16 reserved2;
u32 slice_mb_size;
u16 ir_param_option;
u16 intra_refresh_type;
u16 use_constrained_intra_flag;
u16 transform_mode;
u16 disable_deblocking_filter_idc;
s16 slice_alpha_c0_offset_div2;
s16 slice_beta_offset_div2;
u16 encoder_complexity;
s16 chroma_qp_index_offset;
u16 entropy_coding_mode;
u16 brc_type;
u16 quant;
u32 non_vcl_nalu_size;
u32 cpb_buffer_size;
u32 bit_rate;
u16 qp_min;
u16 qp_max;
u16 framerate_num;
u16 framerate_den;
u16 delay;
u16 strict_hrd_compliancy;
u32 addr_source_buffer;
u32 addr_fwd_ref_buffer;
u32 addr_rec_buffer;
u32 addr_output_bitstream_start;
u32 addr_output_bitstream_end;
u32 addr_external_sw;
u32 addr_lctx;
u32 addr_local_rec_buffer;
u32 addr_spatial_context;
u16 bitstream_offset;
u16 sampling_mode;
u32 addr_param_out;
u32 addr_scaling_matrix;
u32 addr_scaling_matrix_dir;
u32 addr_cabac_context_buffer;
u32 reserved3;
u32 reserved4;
s16 gmv_x;
s16 gmv_y;
u16 window_width;
u16 window_height;
u16 window_horizontal_offset;
u16 window_vertical_offset;
u32 addr_roi;
u32 addr_slice_header;
u16 slice_header_size_in_bits;
u16 slice_header_offset0;
u16 slice_header_offset1;
u16 slice_header_offset2;
u32 reserved5;
u32 reserved6;
u16 reserved7;
u16 reserved8;
u16 slice_synchro_enable;
u16 max_slice_number;
u32 rgb2_yuv_y_coeff;
u32 rgb2_yuv_u_coeff;
u32 rgb2_yuv_v_coeff;
u32 slice_byte_size;
u16 max_air_intra_mb_nb;
u16 brc_no_skip;
u32 addr_temporal_context;
u32 addr_brc_in_out_parameter;
};
staticint hva_h264_fill_slice_header(struct hva_ctx *pctx,
u8 *slice_header_addr, struct hva_controls *ctrls, int frame_num,
u16 *header_size,
u16 *header_offset0,
u16 *header_offset1,
u16 *header_offset2)
{ /* * with this HVA hardware version, part of the slice header is computed * on host and part by hardware. * The part of host is precomputed and available through this array.
*/ struct device *dev = ctx_to_dev(pctx); int cabac = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC; staticconstunsignedchar slice_header[] = {
0x00, 0x00, 0x00, 0x01,
0x41, 0x34, 0x07, 0x00
}; int idr_pic_id = frame_num % 2; enum hva_picture_coding_type type;
u32 frame_order = frame_num % ctrls->gop_size;
if (!(frame_num % ctrls->gop_size))
type = PICTURE_CODING_TYPE_I; else
type = PICTURE_CODING_TYPE_P;
return 0; case SEI_BUFFERING_PERIOD: case SEI_PICTURE_TIMING: case SEI_FRAME_PACKING_ARRANGEMENT: default:
dev_err(dev, "%s sei nal type not supported %d\n",
pctx->name, type); return -EINVAL;
}
}
/* * fill matrix color converter (RGB to YUV) * Y = 0,299 R + 0,587 G + 0,114 B * Cb = -0,1687 R -0,3313 G + 0,5 B + 128 * Cr = 0,5 R - 0,4187 G - 0,0813 B + 128
*/
td->rgb2_yuv_y_coeff = 0x12031008;
td->rgb2_yuv_u_coeff = 0x800EF7FB;
td->rgb2_yuv_v_coeff = 0x80FEF40E;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.