Updated on 2022-03-13 GMT+08:00

CSC Configuration

After confirming the image formats before and after AIPP (that is, the image format of the model input and image format during model training), you can determine the CSC parameter values. (The value of matrix_r*c* is fixed and does not need to be adjusted.) The following describes some configuration references.

Before AIPP, the following two typical CSC configurations are provided for the images or videos (in various color encoding modes such as YUV420SP_U8, XRGB8888_U8, RGB888_U8, and YUV400_U8) input to the model:

  • For JPEG image files (such as JPG, JPEG, JPG, and JPEG), you can select from the CSC configurations in the JPEG columns in the following tables.
  • For the decoded video data, the CSC parameters can be configured according to different color video digital standards (such as BT.601 and BT.709).

YUV420SP_U8 to YVU444SP_U8

aipp_op {
    aipp_mode: static
    input_format : YUV420SP_U8
    csc_switch : false
    rbuv_swap_switch : true
}

YUV420SP_U8 to RGB888_U8

Table 1 YUV420SP_U8 to RGB888_U8

JPEG

BT-601NARROW

BT-709NARROW

aipp_op {
    aipp_mode: static
    input_format : YUV420SP_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 256
    matrix_r0c1 : 0
    matrix_r0c2 : 359
    matrix_r1c0 : 256
    matrix_r1c1 : -88
    matrix_r1c2 : -183
    matrix_r2c0 : 256
    matrix_r2c1 : 454
    matrix_r2c2 : 0
    input_bias_0 : 0
    input_bias_1 : 128
    input_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : YUV420SP_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 298
    matrix_r0c1 : 0
    matrix_r0c2 : 409
    matrix_r1c0 : 298
    matrix_r1c1 : -100
    matrix_r1c2 : -208
    matrix_r2c0 : 298
    matrix_r2c1 : 516
    matrix_r2c2 : 0
    input_bias_0 : 16
    input_bias_1 : 128
    input_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : YUV420SP_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 298
    matrix_r0c1 : 0
    matrix_r0c2 : 459
    matrix_r1c0 : 298
    matrix_r1c1 : -55
    matrix_r1c2 : -136
    matrix_r2c0 : 298
    matrix_r2c1 : 541
    matrix_r2c2 : 0
    input_bias_0 : 16
    input_bias_1 : 128
    input_bias_2 : 128
}

YUV420SP_U8 to BGR888_U8

Table 2 YUV420SP_U8 to BGR888_U8

JPEG

BT-601NARROW

BT-709NARROW

aipp_op {
    aipp_mode: static
    input_format : YUV420SP_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 256
    matrix_r0c1 : 454
    matrix_r0c2 : 0
    matrix_r1c0 : 256
    matrix_r1c1 : -88
    matrix_r1c2 : -183
    matrix_r2c0 : 256
    matrix_r2c1 : 0
    matrix_r2c2 : 359
    input_bias_0 : 0
    input_bias_1 : 128
    input_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : YUV420SP_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 298
    matrix_r0c1 : 516
    matrix_r0c2 : 0
    matrix_r1c0 : 298
    matrix_r1c1 : -100
    matrix_r1c2 : -208
    matrix_r2c0 : 298
    matrix_r2c1 : 0
    matrix_r2c2 : 409
    input_bias_0 : 16
    input_bias_1 : 128
    input_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : YUV420SP_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 298
    matrix_r0c1 : 541
    matrix_r0c2 : 0
    matrix_r1c0 : 298
    matrix_r1c1 : -55
    matrix_r1c2 : -136
    matrix_r2c0 : 298
    matrix_r2c1 : 0
    matrix_r2c2 : 459
    input_bias_0 : 16
    input_bias_1 : 128
    input_bias_2 : 128
}

YUV420SP_U8 to Gray

aipp_op {
    aipp_mode: static
    input_format : YUV420SP_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 256
    matrix_r0c1 : 0
    matrix_r0c2 : 0
    matrix_r1c0 : 0
    matrix_r1c1 : 0
    matrix_r1c2 : 0
    matrix_r2c0 : 0
    matrix_r2c1 : 0
    matrix_r2c2 : 0
    input_bias_0 : 0
    input_bias_1 : 0
    input_bias_2 : 0
}

XRGB8888_U8 to YUV444SP_U8

Table 3 XRGB8888_U8 to YUV444SP_U8

JPEG

BT-601NARROW

BT-709NARROW

aipp_op {
    aipp_mode: static
    input_format : XRGB8888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 77
    matrix_r0c1 : 150
    matrix_r0c2 : 29
    matrix_r1c0 : -43
    matrix_r1c1 : -85
    matrix_r1c2 : 128
    matrix_r2c0 : 128
    matrix_r2c1 : -107
    matrix_r2c2 : -21
    output_bias_0 : 0
    output_bias_1 : 128
    output_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : XRGB8888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 66
    matrix_r0c1 : 129
    matrix_r0c2 : 25
    matrix_r1c0 : -38
    matrix_r1c1 : -74
    matrix_r1c2 : 112
    matrix_r2c0 : 112
    matrix_r2c1 : -94
    matrix_r2c2 : -18
    output_bias_0 : 16
    output_bias_1 : 128
    output_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : XRGB8888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 47
    matrix_r0c1 : 157
    matrix_r0c2 : 16
    matrix_r1c0 : -26
    matrix_r1c1 : -87
    matrix_r1c2 : 112
    matrix_r2c0 : 112
    matrix_r2c1 : -102
    matrix_r2c2 : -10
    output_bias_0 : 16
    output_bias_1 : 128
    output_bias_2 : 128
}

XRGB8888_U8 to YVU444SP_U8

Table 4 XRGB8888_U8 to YVU444SP_U8

JPEG

BT-601NARROW

BT-709NARROW

aipp_op {
    aipp_mode: static
    input_format : XRGB8888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 77
    matrix_r0c1 : 150
    matrix_r0c2 : 29
    matrix_r1c0 : 128
    matrix_r1c1 : -107
    matrix_r1c2 : -21
    matrix_r2c0 : -43
    matrix_r2c1 : -85
    matrix_r2c2 : 128
    output_bias_0 : 0
    output_bias_1 : 128
    output_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : XRGB8888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 66
    matrix_r0c1 : 129
    matrix_r0c2 : 25
    matrix_r1c0 : 112
    matrix_r1c1 : -94
    matrix_r1c2 : -18
    matrix_r2c0 : -38
    matrix_r2c1 : -74
    matrix_r2c2 : 112
    output_bias_0 : 16
    output_bias_1 : 128
    output_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : XRGB8888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 47
    matrix_r0c1 : 157
    matrix_r0c2 : 16
    matrix_r1c0 : 112
    matrix_r1c1 : -102
    matrix_r1c2 : -10
    matrix_r2c0 : -26
    matrix_r2c1 : -87
    matrix_r2c2 : 112
    output_bias_0 : 16
    output_bias_1 : 128
    output_bias_2 : 128
}

XRGB8888_U8 to Gray

aipp_op {
    aipp_mode: static
    input_format : XRGB8888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 76
    matrix_r0c1 : 150
    matrix_r0c2 : 30
    matrix_r1c0 : 0
    matrix_r1c1 : 0
    matrix_r1c2 : 0
    matrix_r2c0 : 0
    matrix_r2c1 : 0
    matrix_r2c2 : 0
    output_bias_0 : 0
    output_bias_1 : 0
    output_bias_2 : 0
}

RGB888_U8 to BGR888_U8

aipp_op {
    aipp_mode: static
    input_format : RGB888_U8
    csc_switch : false
    rbuv_swap_switch : true
}

RGB888_U8 to YUV444SP_U8

Table 5 RGB888_U8 to YUV444SP_U8

JPEG

BT-601NARROW

BT-709NARROW

aipp_op {
    aipp_mode: static
    input_format : RGB888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 77
    matrix_r0c1 : 150
    matrix_r0c2 : 29
    matrix_r1c0 : -43
    matrix_r1c1 : -85
    matrix_r1c2 : 128
    matrix_r2c0 : 128
    matrix_r2c1 : -107
    matrix_r2c2 : -21
    output_bias_0 : 0
    output_bias_1 : 128
    output_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : RGB888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 66
    matrix_r0c1 : 129
    matrix_r0c2 : 25
    matrix_r1c0 : -38
    matrix_r1c1 : -74
    matrix_r1c2 : 112
    matrix_r2c0 : 112
    matrix_r2c1 : -94
    matrix_r2c2 : -18
    output_bias_0 : 16
    output_bias_1 : 128
    output_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : RGB888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 47
    matrix_r0c1 : 157
    matrix_r0c2 : 16
    matrix_r1c0 : -26
    matrix_r1c1 : -87
    matrix_r1c2 : 112
    matrix_r2c0 : 112
    matrix_r2c1 : -102
    matrix_r2c2 : -10
    output_bias_0 : 16
    output_bias_1 : 128
    output_bias_2 : 128
}

RGB888_U8 to YVU444SP_U8

Table 6 RGB888_U8 to YVU444SP_U8

JPEG

BT-601NARROW

BT-709NARROW

aipp_op {
    aipp_mode: static
    input_format : RGB888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 77
    matrix_r0c1 : 150
    matrix_r0c2 : 29
    matrix_r1c0 : 128
    matrix_r1c1 : -107
    matrix_r1c2 : -21
    matrix_r2c0 : -43
    matrix_r2c1 : -85
    matrix_r2c2 : 128
    output_bias_0 : 0
    output_bias_1 : 128
    output_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : RGB888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 66
    matrix_r0c1 : 129
    matrix_r0c2 : 25
    matrix_r1c0 : 112
    matrix_r1c1 : -94
    matrix_r1c2 : -18
    matrix_r2c0 : -38
    matrix_r2c1 : -74
    matrix_r2c2 : 112
    output_bias_0 : 16
    output_bias_1 : 128
    output_bias_2 : 128
}
aipp_op {
    aipp_mode: static
    input_format : RGB888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 47
    matrix_r0c1 : 157
    matrix_r0c2 : 16
    matrix_r1c0 : 112
    matrix_r1c1 : -102
    matrix_r1c2 : -10
    matrix_r2c0 : -26
    matrix_r2c1 : -87
    matrix_r2c2 : 112
    output_bias_0 : 16
    output_bias_1 : 128
    output_bias_2 : 128
}

RGB888_U8 to Gray

aipp_op {
    aipp_mode: static
    input_format : RGB888_U8
    csc_switch : true
    rbuv_swap_switch : false
    matrix_r0c0 : 76
    matrix_r0c1 : 150
    matrix_r0c2 : 30
    matrix_r1c0 : 0
    matrix_r1c1 : 0
    matrix_r1c2 : 0
    matrix_r2c0 : 0
    matrix_r2c1 : 0
    matrix_r2c2 : 0
    output_bias_0 : 0
    output_bias_1 : 0
    output_bias_2 : 0
}