Repository: ossrs/srs
File: trunk/src/kernel/srs_kernel_codec.cpp (C++)

Code before:
        if ((err = bs.read_bits_ue(pps->num_tile_rows_minus1)) != srs_success) {
            return srs_error_wrap(err, "num_tile_rows_minus1");
        }

        if (!bs.require_bits(1)) {
            return srs_error_new(ERROR_HEVC_DECODE_ERROR, "uniform_spacing_flag requires 1 only %d bits", bs.left_bits());
        }

        // uniform_spacing_flag  u(1)
        pps->uniform_spacing_flag = bs.read_bit();
        if (!pps->uniform_spacing_flag) {
            pps->column_width_minus1.resize(pps->num_tile_columns_minus1);
            pps->row_height_minus1.resize(pps->num_tile_rows_minus1);

            for (int i = 0; i < (int)pps->num_tile_columns_minus1; i++) {
                // column_width_minus1[i]  ue(v)
                if ((err = bs.read_bits_ue(pps->column_width_minus1[i])) != srs_success) {
                    return srs_error_wrap(err, "column_width_minus1");
                }
            }

            for (int i = 0; i < (int)pps->num_tile_rows_minus1; i++) {
                // row_height_minus1[i]  ue(v)
                if ((err = bs.read_bits_ue(pps->row_height_minus1[i])) != srs_success) {
                    return srs_error_wrap(err, "row_height_minus1");
                }
            }
        }

        if (!bs.require_bits(1)) {
            return srs_error_new(ERROR_HEVC_DECODE_ERROR, "loop_filter_across_tiles_enabled_flag requires 1 only %d bits", bs.left_bits());
        }

        // loop_filter_across_tiles_enabled_flag u(1)
        pps->loop_filter_across_tiles_enabled_flag = bs.read_bit();
    }

    if (!bs.require_bits(2)) {
        return srs_error_new(ERROR_HEVC_DECODE_ERROR, "pps loop deblocking filter requires 2 only %d bits", bs.left_bits());
    }

    // pps_loop_filter_across_slices_enabled_flag u(1)
    pps->pps_loop_filter_across_slices_enabled_flag = bs.read_bit();
    // deblocking_filter_control_present_flag  u(1)
    pps->deblocking_filter_control_present_flag = bs.read_bit();
    if (pps->deblocking_filter_control_present_flag) {
        if (!bs.require_bits(2)) {
            return srs_error_new(ERROR_HEVC_DECODE_ERROR, "pps loop deblocking filter flag requires 2 only %d bits", bs.left_bits());
        }

        // deblocking_filter_override_enabled_flag u(1)

Review comment (suggestion):
If these fields are not parsed, do we also not need to skip them?

If there are subsequent fields that need to be read, will they be reading the data that has not been skipped?

`TRANS_BY_GPT3`

Code after:
                    sld->coefNum = coefNum; // tmp store
                    if (sizeId > 1) {
                        // scaling_list_dc_coef_minus8  se(v)
                        if ((err = bs.read_bits_se(sld->scaling_list_dc_coef_minus8[sizeId - 2][matrixId])) != srs_success) {
                            return srs_error_wrap(err, "scaling_list_dc_coef_minus8");
                        }
                        nextCoef = sld->scaling_list_dc_coef_minus8[sizeId - 2][matrixId] + 8;
                    }

                    for (int i = 0; i < sld->coefNum; i++) {
                        // scaling_list_delta_coef  se(v)
                        int scaling_list_delta_coef = 0;
                        if ((err = bs.read_bits_se(scaling_list_delta_coef)) != srs_success) {
                            return srs_error_wrap(err, "scaling_list_delta_coef");
                        }
                        nextCoef = (nextCoef + scaling_list_delta_coef + 256) % 256;
                        sld->ScalingList[sizeId][matrixId][i] = nextCoef;
                    }
                }
            }
        }
    }

    if (!bs.require_bits(1)) {
        return srs_error_new(ERROR_HEVC_DECODE_ERROR, "lists_modification_present_flag requires 1 only %d bits", bs.left_bits());
    }
    // lists_modification_present_flag  u(1)
    pps->lists_modification_present_flag = bs.read_bit();

    // log2_parallel_merge_level_minus2  ue(v)
    if ((err = bs.read_bits_ue(pps->log2_parallel_merge_level_minus2)) != srs_success) {
        return srs_error_wrap(err, "log2_parallel_merge_level_minus2");
    }

    if (!bs.require_bits(2)) {
        return srs_error_new(ERROR_HEVC_DECODE_ERROR, "extension_present_flag requires 2 only %d bits", bs.left_bits());
    }

    // slice_segment_header_extension_present_flag  u(1)
    pps->slice_segment_header_extension_present_flag = bs.read_bit();
    // pps_extension_present_flag  u(1)
    pps->pps_extension_present_flag = bs.read_bit();
    if (pps->pps_extension_present_flag) {
        if (!bs.require_bits(8)) {
            return srs_error_new(ERROR_HEVC_DECODE_ERROR, "pps_range_extension_flag requires 8 only %d bits", bs.left_bits());
        }

        // pps_range_extension_flag  u(1)
        pps->pps_range_extension_flag = bs.read_bit();
        // pps_multilayer_extension_flag  u(1)
        pps->pps_multilayer_extension_flag = bs.read_bit();