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

📄 vpar_blocks.c

📁 vlc stand 0.1.99 ist sehr einfach
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* decode length */    i_code = ShowBits(&p_vpar->bit_stream, 5);    if (i_code<31)    {        i_dct_dc_size = ppl_dct_dc_init_table_1[b_chroma][i_code].i_value;        i_length = ppl_dct_dc_init_table_1[b_chroma][i_code].i_length;        RemoveBits( &p_vpar->bit_stream, i_length);    }    else    {        i_code = ShowBits(&p_vpar->bit_stream, (9+b_chroma)) - (0x1f0 * (b_chroma + 1));        i_dct_dc_size = ppl_dct_dc_init_table_2[b_chroma][i_code].i_value;        i_length = ppl_dct_dc_init_table_2[b_chroma][i_code].i_length;        RemoveBits( &p_vpar->bit_stream, i_length);    }     if (i_dct_dc_size == 0)        i_dct_dc_diff = 0;    else    {        i_dct_dc_diff = GetBits( &p_vpar->bit_stream, i_dct_dc_size);        if ((i_dct_dc_diff & (1<<(i_dct_dc_size-1))) == 0)            i_dct_dc_diff -= (1<<i_dct_dc_size) - 1;    }    /* Read the actual code with the good length */    p_vpar->mb.pi_dc_dct_pred[i_cc] += i_dct_dc_diff;    p_mb->ppi_blocks[i_b][0] = ( p_vpar->mb.pi_dc_dct_pred[i_cc] <<                               ( 3 - p_vpar->picture.i_intra_dc_precision ) );    i_nc = ( p_vpar->mb.pi_dc_dct_pred[i_cc] != 0 );        /* Decoding of the AC coefficients */    i_coef = 0;    b_vlc_intra = p_vpar->picture.b_intra_vlc_format;    for( i_parse = 1; !p_vpar->b_die/*i_parse < 64*/; i_parse++ )    {        i_code = ShowBits( &p_vpar->bit_stream, 16 );        /* We use 2 main tables for the coefficients */        if( i_code >= 16384 )        {            i_run =     ppl_dct_tab1[b_vlc_intra][(i_code>>(12-(4*b_vlc_intra)))-4].i_run;            i_level =   ppl_dct_tab1[b_vlc_intra][(i_code>>(12-(4*b_vlc_intra)))-4].i_level;            i_length =  ppl_dct_tab1[b_vlc_intra][(i_code>>(12-(4*b_vlc_intra)))-4].i_length;        }        else        {            i_run =     p_vpar->ppl_dct_coef[b_vlc_intra][i_code].i_run;            i_length =  p_vpar->ppl_dct_coef[b_vlc_intra][i_code].i_length;            i_level =   p_vpar->ppl_dct_coef[b_vlc_intra][i_code].i_level;        }        RemoveBits( &p_vpar->bit_stream, i_length );        switch( i_run )        {            case DCT_ESCAPE:                i_run = GetBits( &p_vpar->bit_stream, 6 );                i_level = GetBits( &p_vpar->bit_stream, 12 );                i_level = (b_sign = ( i_level > 2047 )) ? 4096 - i_level                                                        : i_level;                break;            case DCT_EOB:                if( i_nc <= 1 )                {                    p_mb->pf_idct[i_b] = vdec_SparseIDCT;                    p_mb->pi_sparse_pos[i_b] = i_coef;                }                else                {                    p_mb->pf_idct[i_b] = vdec_IDCT;                }                return;                break;            default:                b_sign = GetBits( &p_vpar->bit_stream, 1 );        }                /* Prepare the next block */        i_coef = i_parse;        i_parse += i_run;        i_nc ++;        if( i_parse >= 64 )        {            /* We have an error in the stream */            break;        }        /* Determine the position of the block in the frame */        i_pos = pi_scan[p_vpar->picture.b_alternate_scan][i_parse];        i_level = ( i_level *                    p_vpar->mb.i_quantizer_scale *                    pi_quant[i_pos] ) >> 4;        p_mb->ppi_blocks[i_b][i_pos] = b_sign ? -i_level : i_level;    }    intf_ErrMsg("vpar error: DCT coeff (intra) is out of bounds\n");    p_vpar->picture.b_error = 1;}/* * Motion vectors *//**************************************************************************** * MotionCode : Parse the next motion code ****************************************************************************/static int MotionCode( vpar_thread_t * p_vpar ){    int i_code;    static lookup_t pl_mv_tab0[8] =        { {-1,0}, {3,3}, {2,2}, {2,2}, {1,1}, {1,1}, {1,1}, {1,1} };    /* Table B-10, motion_code, codes 0000011 ... 000011x */    static lookup_t pl_mv_tab1[8] =        { {-1,0}, {-1,0}, {-1,0}, {7,6}, {6,6}, {5,6}, {4,5}, {4,5} };    /* Table B-10, motion_code, codes 0000001100 ... 000001011x */    static lookup_t pl_mv_tab2[12] = {        {16,9}, {15,9}, {14,9}, {13,9},        {12,9}, {11,9}, {10,8}, {10,8},        {9,8},  {9,8},  {8,8},  {8,8} };    if( GetBits( &p_vpar->bit_stream, 1 ) )    {        return 0;    }    if( (i_code = ShowBits( &p_vpar->bit_stream, 9) ) >= 64 )    {        i_code >>= 6;        RemoveBits( &p_vpar->bit_stream, pl_mv_tab0[i_code].i_length );        return( GetBits( &p_vpar->bit_stream, 1 ) ?            -pl_mv_tab0[i_code].i_value : pl_mv_tab0[i_code].i_value );    }    if( i_code >= 24 )    {        i_code >>= 3;        RemoveBits( &p_vpar->bit_stream, pl_mv_tab1[i_code].i_length );        return( GetBits( &p_vpar->bit_stream, 1 ) ?            -pl_mv_tab1[i_code].i_value : pl_mv_tab1[i_code].i_value );    }    if( (i_code -= 12) < 0 )    {        p_vpar->picture.b_error = 1;        intf_DbgMsg( "vpar debug: Invalid motion_vector code\n" );        return 0;    }    RemoveBits( &p_vpar->bit_stream, pl_mv_tab2[i_code].i_length );    return( GetBits( &p_vpar->bit_stream, 1 ) ?        -pl_mv_tab2[i_code].i_value : pl_mv_tab2[i_code].i_value );}/**************************************************************************** * DecodeMotionVector : Decode a motion_vector ****************************************************************************/static void DecodeMotionVector( int * pi_prediction, int i_r_size,        int i_motion_code, int i_motion_residual, int i_full_pel ){    int i_limit, i_vector;    /* ISO/IEC 13818-1 section 7.6.3.1 */    i_limit = 16 << i_r_size;    i_vector = *pi_prediction >> i_full_pel;    if( i_motion_code > 0 )    {        i_vector += ((i_motion_code-1) << i_r_size) + i_motion_residual + 1;        if( i_vector >= i_limit )            i_vector -= i_limit + i_limit;    }    else if( i_motion_code < 0 )    {        i_vector -= ((-i_motion_code-1) << i_r_size) + i_motion_residual + 1;        if( i_vector < -i_limit )            i_vector += i_limit + i_limit;    }    *pi_prediction = i_vector << i_full_pel;}/**************************************************************************** * MotionVector : Parse the next motion_vector field ****************************************************************************/static void MotionVector( vpar_thread_t * p_vpar,                                     macroblock_t * p_mb, int i_r,                                     int i_s, int i_full_pel, int i_structure ){    int i_motion_code, i_motion_residual;    int i_r_size;    int pi_dm_vector[2];    i_r_size = p_vpar->picture.ppi_f_code[i_s][0] - 1;    i_motion_code = MotionCode( p_vpar );    i_motion_residual = (i_r_size != 0 && i_motion_code != 0) ?                        GetBits( &p_vpar->bit_stream, i_r_size) : 0;    DecodeMotionVector( &p_vpar->mb.pppi_pmv[i_r][i_s][0], i_r_size,                        i_motion_code, i_motion_residual, i_full_pel );    p_mb->pppi_motion_vectors[i_r][i_s][0] = p_vpar->mb.pppi_pmv[i_r][i_s][0];    if( p_vpar->mb.b_dmv )    {        if( GetBits(&p_vpar->bit_stream, 1) )        {            pi_dm_vector[0] = GetBits( &p_vpar->bit_stream, 1 ) ? -1 : 1;        }        else        {            pi_dm_vector[0] = 0;        }    }    i_r_size = p_vpar->picture.ppi_f_code[i_s][1]-1;    i_motion_code = MotionCode( p_vpar );    i_motion_residual = (i_r_size != 0 && i_motion_code != 0) ?                        GetBits( &p_vpar->bit_stream, i_r_size) : 0;    if( (p_vpar->mb.i_mv_format == MOTION_FIELD)        && (i_structure == FRAME_STRUCTURE) )    {         p_vpar->mb.pppi_pmv[i_r][i_s][1] >>= 1;    }    DecodeMotionVector( &p_vpar->mb.pppi_pmv[i_r][i_s][1], i_r_size,                        i_motion_code, i_motion_residual, i_full_pel );    if( (p_vpar->mb.i_mv_format == MOTION_FIELD)        && (i_structure == FRAME_STRUCTURE) )         p_vpar->mb.pppi_pmv[i_r][i_s][1] <<= 1;    p_mb->pppi_motion_vectors[i_r][i_s][1] = p_vpar->mb.pppi_pmv[i_r][i_s][1];    if( p_vpar->mb.b_dmv )    {        if( GetBits(&p_vpar->bit_stream, 1) )        {            pi_dm_vector[1] = GetBits( &p_vpar->bit_stream, 1 ) ? -1 : 1;        }        else        {            pi_dm_vector[1] = 0;        }        /* Dual Prime Arithmetic (ISO/IEC 13818-2 section 7.6.3.6). */#define i_mv_x  p_mb->pppi_motion_vectors[0][0][0]        if( i_structure == FRAME_STRUCTURE )        {#define i_mv_y  (p_mb->pppi_motion_vectors[0][0][1] << 1)            if( p_vpar->picture.b_top_field_first )            {                /* vector for prediction of top field from bottom field */                p_mb->ppi_dmv[0][0] = ((i_mv_x + (i_mv_x > 0)) >> 1) + pi_dm_vector[0];                p_mb->ppi_dmv[0][1] = ((i_mv_y + (i_mv_y > 0)) >> 1) + pi_dm_vector[1] - 1;                /* vector for prediction of bottom field from top field */                p_mb->ppi_dmv[1][0] = ((3*i_mv_x + (i_mv_x > 0)) >> 1) + pi_dm_vector[0];                p_mb->ppi_dmv[1][1] = ((3*i_mv_y + (i_mv_y > 0)) >> 1) + pi_dm_vector[1] + 1;            }            else            {                /* vector for prediction of top field from bottom field */                p_mb->ppi_dmv[0][0] = ((3*i_mv_x + (i_mv_x > 0)) >> 1) + pi_dm_vector[0];                p_mb->ppi_dmv[0][1] = ((3*i_mv_y + (i_mv_y > 0)) >> 1) + pi_dm_vector[1] - 1;                /* vector for prediction of bottom field from top field */                p_mb->ppi_dmv[1][0] = ((i_mv_x + (i_mv_x > 0)) >> 1) + pi_dm_vector[0];                p_mb->ppi_dmv[1][1] = ((i_mv_y + (i_mv_y > 0)) >> 1) + pi_dm_vector[1] + 1;            }#undef i_mv_y        }        else        {#define i_mv_y  p_mb->pppi_motion_vectors[0][0][1]            /* vector for prediction from field of opposite 'parity' */            p_mb->ppi_dmv[0][0] = ((i_mv_x + (i_mv_x > 0)) >> 1) + pi_dm_vector[0];            p_mb->ppi_dmv[0][1] = ((i_mv_y + (i_mv_y > 0)) >> 1) + pi_dm_vector[1];            /* correct for vertical field shift */            if( p_vpar->picture.i_structure == TOP_FIELD )                p_mb->ppi_dmv[0][1]--;            else                p_mb->ppi_dmv[0][1]++;#undef i_mv_y        }#undef i_mv_x    }}/***************************************************************************** * DecodeMVMPEG1 : Parse the next MPEG-1 motion vectors *****************************************************************************/static void DecodeMVMPEG1( vpar_thread_t * p_vpar,                            macroblock_t * p_mb, int i_s, int i_structure ){    MotionVector( p_vpar, p_mb, 0, i_s,                  p_vpar->picture.pb_full_pel_vector[i_s], i_structure );}/***************************************************************************** * DecodeMVMPEG2 : Parse the next MPEG-2 motion_vectors field *****************************************************************************/static void DecodeMVMPEG2( vpar_thread_t * p_vpar,                            macroblock_t * p_mb, int i_s, int i_structure ){    if( p_vpar->mb.i_mv_count == 1 )    {        if( p_vpar->mb.i_mv_format == MOTION_FIELD && !p_vpar->mb.b_dmv )        {            p_mb->ppi_field_select[0][i_s] = p_mb->ppi_field_select[1][i_s]                                            = GetBits( &p_vpar->bit_stream, 1 );        }        MotionVector( p_vpar, p_mb, 0, i_s, 0, i_structure );        p_vpar->mb.pppi_pmv[1][i_s][0] = p_vpar->mb.pppi_pmv[0][i_s][0];        p_vpar->mb.pppi_pmv[1][i_s][1] = p_vpar->mb.pppi_pmv[0][i_s][1];        p_mb->pppi_motion_vectors[1][i_s][0] = p_vpar->mb.pppi_pmv[0][i_s][0];        p_mb->pppi_motion_vectors[1][i_s][1] = p_vpar->mb.pppi_pmv[0][i_s][1];    }    else    {        p_mb->ppi_field_select[0][i_s] = GetBits( &p_vpar->bit_stream, 1 );        MotionVector( p_vpar, p_mb, 0, i_s, 0, i_structure );        p_mb->ppi_field_select[1][i_s] = GetBits( &p_vpar->bit_stream, 1 );        MotionVector( p_vpar, p_mb, 1, i_s, 0, i_structure );    }}/* * Macroblock information structures *//***************************************************************************** * MacroblockAddressIncrement : Get the macroblock_address_increment field

⌨️ 快捷键说明

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