⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mp4parse.c

📁 audio-video-codecs.rar语音编解码器
💻 C
📖 第 1 页 / 共 4 页
字号:
    }
    VOL->is_vol_control_parameters = mp4_GetBit(pInfo);
    if (VOL->type_indication == MP4_VIDEO_OBJECT_TYPE_SIMPLE || VOL->type_indication != MP4_VIDEO_OBJECT_TYPE_ADVANCED_REAL_TIME_SIMPLE)
        VOL->VOLControlParameters.low_delay = 1;
    if (VOL->is_vol_control_parameters) {
        VOL->VOLControlParameters.chroma_format = mp4_GetBits9(pInfo, 2);
        if (VOL->VOLControlParameters.chroma_format != MP4_CHROMA_FORMAT_420) {
            mp4_Error("Error: chroma_format != 4:2:0");
            return MP4_STATUS_PARSE_ERROR;
        }
        VOL->VOLControlParameters.low_delay = mp4_GetBit(pInfo);
        VOL->VOLControlParameters.vbv_parameters = mp4_GetBit(pInfo);
        if (VOL->VOLControlParameters.vbv_parameters) {
            VOL->VOLControlParameters.bit_rate = mp4_GetBits(pInfo, 15) << 15;
            if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
            VOL->VOLControlParameters.bit_rate += mp4_GetBits(pInfo, 15);
            if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
            if (VOL->VOLControlParameters.bit_rate == 0) {
                mp4_Error("Error: vbv_parameters bit_rate == 0");
                return MP4_STATUS_PARSE_ERROR;
            }
            VOL->VOLControlParameters.vbv_buffer_size = mp4_GetBits(pInfo, 15) << 3;
            if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
            VOL->VOLControlParameters.vbv_buffer_size += mp4_GetBits9(pInfo, 3);
            if (VOL->VOLControlParameters.vbv_buffer_size == 0) {
                mp4_Error("Error: vbv_parameters vbv_buffer_size == 0");
                return MP4_STATUS_PARSE_ERROR;
            }
            VOL->VOLControlParameters.vbv_occupancy = mp4_GetBits(pInfo, 11) << 15;
            if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
            VOL->VOLControlParameters.vbv_occupancy += mp4_GetBits(pInfo, 15);
            if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
        }
    }
    VOL->shape = mp4_GetBits9(pInfo, 2);
    if (VOL->shape != MP4_SHAPE_TYPE_RECTANGULAR) {
        mp4_Error("Error: video_object_layer_shape != rectangular (not supported)");
        return MP4_STATUS_PARSE_ERROR;
    }
    if (VOL->verid != 1 && VOL->shape == MP4_SHAPE_TYPE_GRAYSCALE) {
        VOL->shape_extension = mp4_GetBits9(pInfo, 4);
        if (VOL->shape_extension >= MP4_SHAPE_EXT_NUM) {
            mp4_Error("Error: wrong value of video_object_layer_shape_extension");
            return MP4_STATUS_PARSE_ERROR;
        }
    } else
        VOL->shape_extension = MP4_SHAPE_EXT_NUM;
    if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
    VOL->vop_time_increment_resolution = mp4_GetBits(pInfo, 16);
    if (VOL->vop_time_increment_resolution == 0) {
        mp4_Error("Error: wrong value of vop_time_increment_resolution");
        return MP4_STATUS_PARSE_ERROR;
    }
    if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
    // define number bits in vop_time_increment_resolution
    code = VOL->vop_time_increment_resolution - 1;
    i = 0;
    do {
        code >>= 1;
        i ++;
    } while (code);
    VOL->vop_time_increment_resolution_bits = i;
    VOL->fixed_vop_rate = mp4_GetBit(pInfo);
    if (VOL->fixed_vop_rate) {
        VOL->fixed_vop_time_increment = mp4_GetBits(pInfo, VOL->vop_time_increment_resolution_bits);
        if (VOL->fixed_vop_time_increment == 0) {
            mp4_Error("Error: wrong value of fixed_vop_time_increment");
            return MP4_STATUS_PARSE_ERROR;
        }
    }
    if (VOL->shape != MP4_SHAPE_TYPE_BINARYONLY) {
        if (VOL->shape == MP4_SHAPE_TYPE_RECTANGULAR) {
            if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
            VOL->width = mp4_GetBits(pInfo, 13);
            if (VOL->width == 0) {
                mp4_Error("Error: wrong value of video_object_layer_width");
                return MP4_STATUS_PARSE_ERROR;
            }
            if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
            VOL->height = mp4_GetBits(pInfo, 13);
            if (VOL->height == 0) {
                mp4_Error("Error: wrong value of video_object_layer_height");
                return MP4_STATUS_PARSE_ERROR;
            }
            if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
        }
        VOL->interlaced = mp4_GetBit(pInfo);
        VOL->obmc_disable = mp4_GetBit(pInfo);
        VOL->sprite_enable = mp4_GetBits9(pInfo, VOL->verid != 1 ? 2 : 1);
        if (VOL->sprite_enable == MP4_SPRITE_STATIC || VOL->sprite_enable == MP4_SPRITE_GMC) {
            if (VOL->sprite_enable == MP4_SPRITE_STATIC) {
                VOL->sprite_width = mp4_GetBits(pInfo, 13);
                if (VOL->sprite_width == 0) {
                    mp4_Error("Error: wrong value of sprite_width");
                    return MP4_STATUS_PARSE_ERROR;
                }
                if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
                VOL->sprite_height = mp4_GetBits(pInfo, 13);
                if (VOL->sprite_height == 0) {
                    mp4_Error("Error: wrong value of sprite_height");
                    return MP4_STATUS_PARSE_ERROR;
                }
                if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
                VOL->sprite_left_coordinate = mp4_GetBits(pInfo, 13);
                VOL->sprite_left_coordinate <<= (32 - 13);
                VOL->sprite_left_coordinate >>= (32 - 13);
                if (VOL->sprite_left_coordinate & 1) {
                    mp4_Error("Error: sprite_left_coordinate must be divisible by 2");
                    return MP4_STATUS_PARSE_ERROR;
                }
                if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
                VOL->sprite_top_coordinate = mp4_GetBits(pInfo, 13);
                VOL->sprite_top_coordinate <<= (32 - 13);
                VOL->sprite_top_coordinate >>= (32 - 13);
                if (VOL->sprite_top_coordinate & 1) {
                    mp4_Error("Error: sprite_top_coordinate must be divisible by 2");
                    return MP4_STATUS_PARSE_ERROR;
                }
                if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
            }
            VOL->sprite_warping_points = mp4_GetBits9(pInfo, 6);
            if (VOL->sprite_warping_points > 4 || (VOL->sprite_warping_points == 4 && VOL->sprite_enable == MP4_SPRITE_GMC)) {
                mp4_Error("Error: bad no_of_sprite_warping_points");
                return MP4_STATUS_PARSE_ERROR;
            }
            VOL->sprite_warping_accuracy = mp4_GetBits9(pInfo, 2);
            VOL->sprite_brightness_change = mp4_GetBit(pInfo);
            if (VOL->sprite_enable == MP4_SPRITE_GMC) {
                if (VOL->sprite_brightness_change) {
                    mp4_Error("Error: sprite_brightness_change should be 0 for GMC sprites");
                    return MP4_STATUS_PARSE_ERROR;
                }
            }
            if (VOL->sprite_enable != MP4_SPRITE_GMC) {
                VOL->low_latency_sprite_enable = mp4_GetBit(pInfo);
                if (VOL->low_latency_sprite_enable) {
                    mp4_Error("Error: low_latency_sprite is not supported");
                    return MP4_STATUS_PARSE_ERROR;
                }
            }
        }
        if (VOL->verid != 1 && VOL->shape != MP4_SHAPE_TYPE_RECTANGULAR) {
            VOL->sadct_disable = mp4_GetBit(pInfo);
            if (!VOL->sadct_disable) {
                mp4_Error("Error: Shape Adaptive DCT is not supported");
                return MP4_STATUS_PARSE_ERROR;
            }
        }
        VOL->not_8_bit = mp4_GetBit(pInfo);
        if (VOL->not_8_bit) {
            mp4_Error("Error: only 8-bits data is supported");
            return MP4_STATUS_PARSE_ERROR;
        }
        if (VOL->not_8_bit) {
            VOL->quant_precision = mp4_GetBits9(pInfo, 4);
            if (VOL->quant_precision < 3 || VOL->quant_precision > 9) {
                mp4_Error("Error: quant_precision must be in range [3; 9]");
                return MP4_STATUS_PARSE_ERROR;
            }
            VOL->bits_per_pixel = mp4_GetBits9(pInfo, 4);
            if (VOL->bits_per_pixel < 4 || VOL->bits_per_pixel > 12) {
                mp4_Error("Error: bits_per_pixel must be in range [4; 12]");
                return MP4_STATUS_PARSE_ERROR;
            }
        } else {
            VOL->quant_precision = 5;
            VOL->bits_per_pixel = 8;
        }
        if (VOL->shape == MP4_SHAPE_TYPE_GRAYSCALE) {
            VOL->no_gray_quant_update = mp4_GetBit(pInfo);
            VOL->composition_method = mp4_GetBit(pInfo);
            VOL->linear_composition = mp4_GetBit(pInfo);
        }
        VOL->quant_type = mp4_GetBit(pInfo);
        if (VOL->quant_type) {
            VOL->load_intra_quant_mat = mp4_GetBit(pInfo);
            if (VOL->load_intra_quant_mat) {
                if (mp4_Parse_QuantMatrix(pInfo, VOL->intra_quant_mat) != MP4_STATUS_OK)
                    return MP4_STATUS_PARSE_ERROR;
            } else
                ippsCopy_8u(mp4_DefaultIntraQuantMatrix, VOL->intra_quant_mat, 64);
            VOL->load_nonintra_quant_mat = mp4_GetBit(pInfo);
            if (VOL->load_nonintra_quant_mat) {
                if (mp4_Parse_QuantMatrix(pInfo, VOL->nonintra_quant_mat) != MP4_STATUS_OK)
                    return MP4_STATUS_PARSE_ERROR;
            } else
                ippsCopy_8u(mp4_DefaultNonIntraQuantMatrix, VOL->nonintra_quant_mat, 64);
            if (VOL->shape == MP4_SHAPE_TYPE_GRAYSCALE) {
                Ipp32s   ac, i;

                ac = mp4_aux_comp_count[VOL->shape_extension];
                for (i = 0; i < ac; i ++) {
                    VOL->load_intra_quant_mat_grayscale[i] = mp4_GetBit(pInfo);
                    if (VOL->load_intra_quant_mat_grayscale[i]) {
                        if (mp4_Parse_QuantMatrix(pInfo, VOL->intra_quant_mat_grayscale[i]) != MP4_STATUS_OK)
                            return MP4_STATUS_PARSE_ERROR;
                    } else
                        ippsCopy_8u(mp4_DefaultIntraQuantMatrix, VOL->intra_quant_mat_grayscale[i], 64);
                    VOL->load_nonintra_quant_mat_grayscale[i] = mp4_GetBit(pInfo);
                    if (VOL->load_nonintra_quant_mat_grayscale[i]) {
                        if (mp4_Parse_QuantMatrix(pInfo, VOL->nonintra_quant_mat_grayscale[i]) != MP4_STATUS_OK)
                            return MP4_STATUS_PARSE_ERROR;
                    } else
                        ippsCopy_8u(mp4_DefaultNonIntraQuantMatrix, VOL->nonintra_quant_mat_grayscale[i], 64);
                }
            }
        }
        if (VOL->verid != 1)
            VOL->quarter_sample = mp4_GetBit(pInfo);
        VOL->complexity_estimation_disable = mp4_GetBit(pInfo);
        if (!VOL->complexity_estimation_disable) {
            VOL->ComplexityEstimation.estimation_method = mp4_GetBits9(pInfo, 2);
            if (VOL->ComplexityEstimation.estimation_method <= 1) {
                VOL->ComplexityEstimation.shape_complexity_estimation_disable = mp4_GetBit(pInfo);
                if (!VOL->ComplexityEstimation.shape_complexity_estimation_disable) {
                    VOL->ComplexityEstimation.opaque =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.transparent =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.intra_cae =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.inter_cae =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.no_update =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.upsampling =  mp4_GetBit(pInfo);
                }
                VOL->ComplexityEstimation.texture_complexity_estimation_set_1_disable =  mp4_GetBit(pInfo);
                if (!VOL->ComplexityEstimation.texture_complexity_estimation_set_1_disable) {
                    VOL->ComplexityEstimation.intra_blocks =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.inter_blocks =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.inter4v_blocks =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.not_coded_blocks =  mp4_GetBit(pInfo);
                }
                if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
                VOL->ComplexityEstimation.texture_complexity_estimation_set_2_disable =  mp4_GetBit(pInfo);
                if (!VOL->ComplexityEstimation.texture_complexity_estimation_set_2_disable) {
                    VOL->ComplexityEstimation.dct_coefs =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.dct_lines =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.vlc_symbols =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.vlc_bits =  mp4_GetBit(pInfo);
                }
                VOL->ComplexityEstimation.motion_compensation_complexity_disable =  mp4_GetBit(pInfo);
                if (!VOL->ComplexityEstimation.motion_compensation_complexity_disable) {
                    VOL->ComplexityEstimation.apm =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.npm =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.interpolate_mc_q =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.forw_back_mc_q =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.halfpel2 =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.halfpel4 =  mp4_GetBit(pInfo);
                }
            }
            if (!mp4_GetMarkerBit(pInfo)) return MP4_STATUS_PARSE_ERROR;
            if (VOL->ComplexityEstimation.estimation_method == 1) {
                // verid != 1
                VOL->ComplexityEstimation.version2_complexity_estimation_disable =  mp4_GetBit(pInfo);
                if (!VOL->ComplexityEstimation.version2_complexity_estimation_disable) {
                    VOL->ComplexityEstimation.sadct =  mp4_GetBit(pInfo);
                    VOL->ComplexityEstimation.quarterpel =  mp4_GetBit(pInfo);
                }
            }
        }
        VOL->resync_marker_disable = mp4_GetBit(pInfo);
        VOL->data_partitioned = mp4_GetBit(pInfo);
//f GrayScale Shapes does not support data_part
        if (VOL->data_partitioned)
            VOL->reversible_vlc = mp4_GetBit(pInfo);
        if (VOL->verid != 1) {
            VOL->newpred_enable = mp4_GetBit(pInfo);
            if (VOL->newpred_enable) {
                VOL->requested_upstream_message_type = mp4_GetBits9(pInfo, 2);
                VOL->newpred_segment_type = mp4_GetBit(pInfo);
                mp4_Error("Warning: NEWPRED mode is not fully supported");
//f                return MP4_STATUS_PARSE_ERROR;
            }
            VOL->reduced_resolution_vop_enable = mp4_GetBit(pInfo);
            if (VOL->reduced_resolution_vop_enable) {
                mp4_Error("Error: Reduced Resolution VOP is not supported");
                return MP4_STATUS_PARSE_ERROR;
            }
        }
        VOL->scalability = mp4_GetBit(pInfo);
        if (VOL->scalability) {
            mp4_Error("Error: VOL scalability is not supported");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -