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

📄 set.c.svn-base

📁 现在关于h.264的源码很多
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
    bs_write( s, 1, sps->b_vui );    if( sps->b_vui )    {        bs_write1( s, sps->vui.b_aspect_ratio_info_present );        if( sps->vui.b_aspect_ratio_info_present )        {            int i;            static const struct { int w, h; int sar; } sar[] =            {                { 1,   1, 1 }, { 12, 11, 2 }, { 10, 11, 3 }, { 16, 11, 4 },                { 40, 33, 5 }, { 24, 11, 6 }, { 20, 11, 7 }, { 32, 11, 8 },                { 80, 33, 9 }, { 18, 11, 10}, { 15, 11, 11}, { 64, 33, 12},                { 160,99, 13}, { 0, 0, -1 }            };            for( i = 0; sar[i].sar != -1; i++ )            {                if( sar[i].w == sps->vui.i_sar_width &&                    sar[i].h == sps->vui.i_sar_height )                    break;            }            if( sar[i].sar != -1 )            {                bs_write( s, 8, sar[i].sar );            }            else            {                bs_write( s, 8, 255);   /* aspect_ratio_idc (extented) */                bs_write( s, 16, sps->vui.i_sar_width );                bs_write( s, 16, sps->vui.i_sar_height );            }        }        bs_write1( s, sps->vui.b_overscan_info_present );        if( sps->vui.b_overscan_info_present )            bs_write1( s, sps->vui.b_overscan_info );        bs_write1( s, sps->vui.b_signal_type_present );        if( sps->vui.b_signal_type_present )        {            bs_write( s, 3, sps->vui.i_vidformat );            bs_write1( s, sps->vui.b_fullrange );            bs_write1( s, sps->vui.b_color_description_present );            if( sps->vui.b_color_description_present )            {                bs_write( s, 8, sps->vui.i_colorprim );                bs_write( s, 8, sps->vui.i_transfer );                bs_write( s, 8, sps->vui.i_colmatrix );            }        }        bs_write1( s, sps->vui.b_chroma_loc_info_present );        if( sps->vui.b_chroma_loc_info_present )        {            bs_write_ue( s, sps->vui.i_chroma_loc_top );            bs_write_ue( s, sps->vui.i_chroma_loc_bottom );        }        bs_write1( s, sps->vui.b_timing_info_present );        if( sps->vui.b_timing_info_present )        {            bs_write( s, 32, sps->vui.i_num_units_in_tick );            bs_write( s, 32, sps->vui.i_time_scale );            bs_write1( s, sps->vui.b_fixed_frame_rate );        }        bs_write1( s, 0 );      /* nal_hrd_parameters_present_flag */        bs_write1( s, 0 );      /* vcl_hrd_parameters_present_flag */        bs_write1( s, 0 );      /* pic_struct_present_flag */        bs_write1( s, sps->vui.b_bitstream_restriction );        if( sps->vui.b_bitstream_restriction )        {            bs_write1( s, sps->vui.b_motion_vectors_over_pic_boundaries );            bs_write_ue( s, sps->vui.i_max_bytes_per_pic_denom );            bs_write_ue( s, sps->vui.i_max_bits_per_mb_denom );            bs_write_ue( s, sps->vui.i_log2_max_mv_length_horizontal );            bs_write_ue( s, sps->vui.i_log2_max_mv_length_vertical );            bs_write_ue( s, sps->vui.i_num_reorder_frames );            bs_write_ue( s, sps->vui.i_max_dec_frame_buffering );        }    }    bs_rbsp_trailing( s );}void x264_pps_init( x264_pps_t *pps, int i_id, x264_param_t *param, x264_sps_t *sps ){    int i, j;    pps->i_id = i_id;    pps->i_sps_id = sps->i_id;    pps->b_cabac = param->b_cabac;    pps->b_pic_order = 0;    pps->i_num_slice_groups = 1;    pps->i_num_ref_idx_l0_active = 1;    pps->i_num_ref_idx_l1_active = 1;    pps->b_weighted_pred = 0;    pps->b_weighted_bipred = param->analyse.b_weighted_bipred ? 2 : 0;    pps->i_pic_init_qp = param->rc.b_cbr ? 26 : param->rc.i_qp_constant;    pps->i_pic_init_qs = 26;    pps->i_chroma_qp_index_offset = param->analyse.i_chroma_qp_offset;    pps->b_deblocking_filter_control = 1;    pps->b_constrained_intra_pred = 0;    pps->b_redundant_pic_cnt = 0;    pps->b_transform_8x8_mode = param->analyse.b_transform_8x8 ? 1 : 0;    pps->i_cqm_preset = param->i_cqm_preset;    switch( pps->i_cqm_preset )    {    case X264_CQM_FLAT:        for( i = 0; i < 6; i++ )            pps->scaling_list[i] = x264_cqm_flat16;        break;    case X264_CQM_JVT:        for( i = 0; i < 6; i++ )            pps->scaling_list[i] = x264_cqm_jvt[i];        break;    case X264_CQM_CUSTOM:        pps->scaling_list[CQM_4IY] = param->cqm_4iy;        pps->scaling_list[CQM_4IC] = param->cqm_4ic;        pps->scaling_list[CQM_4PY] = param->cqm_4py;        pps->scaling_list[CQM_4PC] = param->cqm_4pc;        pps->scaling_list[CQM_8IY+4] = param->cqm_8iy;        pps->scaling_list[CQM_8PY+4] = param->cqm_8py;        for( i = 0; i < 6; i++ )            for( j = 0; j < (i<4?16:64); j++ )                if( pps->scaling_list[i][j] == 0 )                    pps->scaling_list[i] = x264_cqm_jvt[i];        break;    }}void x264_pps_write( bs_t *s, x264_pps_t *pps ){    bs_write_ue( s, pps->i_id );    bs_write_ue( s, pps->i_sps_id );    bs_write( s, 1, pps->b_cabac );    bs_write( s, 1, pps->b_pic_order );    bs_write_ue( s, pps->i_num_slice_groups - 1 );    bs_write_ue( s, pps->i_num_ref_idx_l0_active - 1 );    bs_write_ue( s, pps->i_num_ref_idx_l1_active - 1 );    bs_write( s, 1, pps->b_weighted_pred );    bs_write( s, 2, pps->b_weighted_bipred );    bs_write_se( s, pps->i_pic_init_qp - 26 );    bs_write_se( s, pps->i_pic_init_qs - 26 );    bs_write_se( s, pps->i_chroma_qp_index_offset );    bs_write( s, 1, pps->b_deblocking_filter_control );    bs_write( s, 1, pps->b_constrained_intra_pred );    bs_write( s, 1, pps->b_redundant_pic_cnt );    if( pps->b_transform_8x8_mode || pps->i_cqm_preset != X264_CQM_FLAT )    {        bs_write( s, 1, pps->b_transform_8x8_mode );        bs_write( s, 1, (pps->i_cqm_preset != X264_CQM_FLAT) );        if( pps->i_cqm_preset != X264_CQM_FLAT )        {            scaling_list_write( s, pps, CQM_4IY );            scaling_list_write( s, pps, CQM_4IC );            bs_write( s, 1, 0 ); // Cr = Cb            scaling_list_write( s, pps, CQM_4PY );            scaling_list_write( s, pps, CQM_4PC );            bs_write( s, 1, 0 ); // Cr = Cb            if( pps->b_transform_8x8_mode )            {                scaling_list_write( s, pps, CQM_8IY+4 );                scaling_list_write( s, pps, CQM_8PY+4 );            }        }        bs_write_se( s, pps->i_chroma_qp_index_offset );    }    bs_rbsp_trailing( s );}void x264_sei_version_write( x264_t *h, bs_t *s ){    int i;    // random ID number generated according to ISO-11578    const uint8_t uuid[16] = {        0xdc, 0x45, 0xe9, 0xbd, 0xe6, 0xd9, 0x48, 0xb7,        0x96, 0x2c, 0xd8, 0x20, 0xd9, 0x23, 0xee, 0xef    };    char version[1200];    int length;    char *opts = x264_param2string( &h->param, 0 );    sprintf( version, "x264 - core %d%s - H.264/MPEG-4 AVC codec - "             "Copyleft 2005 - http://www.videolan.org/x264.html - options: %s",             X264_BUILD, X264_VERSION, opts );    x264_free( opts );    length = strlen(version)+1+16;    bs_write( s, 8, 0x5 ); // payload_type = user_data_unregistered    // payload_size    for( i = 0; i <= length-255; i += 255 )        bs_write( s, 8, 255 );    bs_write( s, 8, length-i );    for( i = 0; i < 16; i++ )        bs_write( s, 8, uuid[i] );    for( i = 0; i < length-16; i++ )        bs_write( s, 8, version[i] );    bs_rbsp_trailing( s );}const x264_level_t x264_levels[] ={    { 10,   1485,    99,   152064,     64,    175,  64, 64,  0, 0, 0, 1 },//  {"1b",  1485,    99,   152064,    128,    350,  64, 64,  0, 0, 0, 1 },    { 11,   3000,   396,   345600,    192,    500, 128, 64,  0, 0, 0, 1 },    { 12,   6000,   396,   912384,    384,   1000, 128, 64,  0, 0, 0, 1 },    { 13,  11880,   396,   912384,    768,   2000, 128, 64,  0, 0, 0, 1 },    { 20,  11880,   396,   912384,   2000,   2000, 128, 64,  0, 0, 0, 1 },    { 21,  19800,   792,  1824768,   4000,   4000, 256, 64,  0, 0, 0, 0 },    { 22,  20250,  1620,  3110400,   4000,   4000, 256, 64,  0, 0, 0, 0 },    { 30,  40500,  1620,  3110400,  10000,  10000, 256, 32, 22, 0, 1, 0 },    { 31, 108000,  3600,  6912000,  14000,  14000, 512, 16, 60, 1, 1, 0 },    { 32, 216000,  5120,  7864320,  20000,  20000, 512, 16, 60, 1, 1, 0 },    { 40, 245760,  8192, 12582912,  20000,  25000, 512, 16, 60, 1, 1, 0 },    { 41, 245760,  8192, 12582912,  50000,  62500, 512, 16, 24, 1, 1, 0 },    { 42, 522240,  8704, 13369344,  50000,  62500, 512, 16, 24, 1, 1, 1 },    { 50, 589824, 22080, 42393600, 135000, 135000, 512, 16, 24, 1, 1, 1 },    { 51, 983040, 36864, 70778880, 240000, 240000, 512, 16, 24, 1, 1, 1 },    { 0 }};void x264_validate_levels( x264_t *h ){    int mbs;    const x264_level_t *l = x264_levels;    while( l->level_idc != 0 && l->level_idc != h->param.i_level_idc )        l++;    mbs = h->sps->i_mb_width * h->sps->i_mb_height;    if( l->frame_size < mbs        || l->frame_size*8 < h->sps->i_mb_width * h->sps->i_mb_width        || l->frame_size*8 < h->sps->i_mb_height * h->sps->i_mb_height )        x264_log( h, X264_LOG_WARNING, "frame MB size (%dx%d) > level limit (%d)\n",                  h->sps->i_mb_width, h->sps->i_mb_height, l->frame_size );#define CHECK( name, limit, val ) \    if( (val) > (limit) ) \        x264_log( h, X264_LOG_WARNING, name " (%d) > level limit (%d)\n", (int)(val), (limit) );    CHECK( "DPB size", l->dpb, mbs * 384 * h->sps->i_num_ref_frames );    CHECK( "VBV bitrate", l->bitrate, h->param.rc.i_vbv_max_bitrate );    CHECK( "VBV buffer", l->cpb, h->param.rc.i_vbv_buffer_size );    CHECK( "MV range", l->mv_range, h->param.analyse.i_mv_range );    if( h->param.i_fps_den > 0 )        CHECK( "MB rate", l->mbps, (int64_t)mbs * h->param.i_fps_num / h->param.i_fps_den );    /* TODO check the rest of the limits */}

⌨️ 快捷键说明

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