Home | History | Annotate | Line # | Download | only in dsc
      1 /*	$NetBSD: rc_calc.h,v 1.2 2021/12/18 23:45:04 riastradh Exp $	*/
      2 
      3 
      4 /*
      5  * Copyright 2017 Advanced Micro Devices, Inc.
      6  *
      7  * Permission is hereby granted, free of charge, to any person obtaining a
      8  * copy of this software and associated documentation files (the "Software"),
      9  * to deal in the Software without restriction, including without limitation
     10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     11  * and/or sell copies of the Software, and to permit persons to whom the
     12  * Software is furnished to do so, subject to the following conditions:
     13  *
     14  * The above copyright notice and this permission notice shall be included in
     15  * all copies or substantial portions of the Software.
     16  *
     17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     20  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     23  * OTHER DEALINGS IN THE SOFTWARE.
     24  *
     25  * Authors: AMD
     26  *
     27  */
     28 
     29 #ifndef __RC_CALC_H__
     30 #define __RC_CALC_H__
     31 
     32 
     33 #define QP_SET_SIZE 15
     34 
     35 typedef int qp_set[QP_SET_SIZE];
     36 
     37 struct rc_params {
     38 	int      rc_quant_incr_limit0;
     39 	int      rc_quant_incr_limit1;
     40 	int      initial_fullness_offset;
     41 	int      initial_xmit_delay;
     42 	int      first_line_bpg_offset;
     43 	int      second_line_bpg_offset;
     44 	int      flatness_min_qp;
     45 	int      flatness_max_qp;
     46 	int      flatness_det_thresh;
     47 	qp_set   qp_min;
     48 	qp_set   qp_max;
     49 	qp_set   ofs;
     50 	int      rc_model_size;
     51 	int      rc_edge_factor;
     52 	int      rc_tgt_offset_hi;
     53 	int      rc_tgt_offset_lo;
     54 	int      rc_buf_thresh[QP_SET_SIZE - 1];
     55 };
     56 
     57 enum colour_mode {
     58 	CM_RGB,   /* 444 RGB */
     59 	CM_444,   /* 444 YUV or simple 422 */
     60 	CM_422,   /* native 422 */
     61 	CM_420    /* native 420 */
     62 };
     63 
     64 enum bits_per_comp {
     65 	BPC_8  =  8,
     66 	BPC_10 = 10,
     67 	BPC_12 = 12
     68 };
     69 
     70 enum max_min {
     71 	MM_MIN = 0,
     72 	MM_MAX = 1
     73 };
     74 
     75 struct qp_entry {
     76 	float         bpp;
     77 	const qp_set  qps;
     78 };
     79 
     80 typedef struct qp_entry qp_table[];
     81 
     82 void calc_rc_params(struct rc_params *rc, enum colour_mode cm, enum bits_per_comp bpc, float bpp, int slice_width, int slice_height, int minor_version);
     83 
     84 #endif
     85 
     86