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

📄 mpeg4video.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 2 页
字号:
                msg_Warn( p_dec, "waiting for VOL" );                block_Release( p_out );            }            p_sys->b_vop = VLC_FALSE;        }        if( p_start[3] >= 0x20 && p_start[3] <= 0x2f )        {            /* Start of the VOL */            p_vol = p_start;        }        else if( p_start[3] == 0xb3 )        {            /* GOP header */        }        else if( p_start[3] == 0xb6 )        {            /* Parse the VOP */            bs_t s;            int i_modulo_time_base = 0;            int i_time_increment_bits;            int64_t i_time_increment, i_time_ref;            /* FIXME: we don't actually check we received enough data to read             * the VOP time increment. */            bs_init( &s, &p_start[4],                     p_sys->i_buffer - (p_start - p_sys->p_buffer) - 4 );            switch( bs_read( &s, 2 ) )            {                case 0:                    p_sys->i_flags = BLOCK_FLAG_TYPE_I;                    break;                case 1:                    p_sys->i_flags = BLOCK_FLAG_TYPE_P;                    break;                case 2:                    p_sys->i_flags = BLOCK_FLAG_TYPE_B;                    p_sys->b_frame = VLC_TRUE;                    break;                case 3: /* gni ? */                    p_sys->i_flags = BLOCK_FLAG_TYPE_PB;                    break;            }            while( bs_read( &s, 1 ) ) i_modulo_time_base++;            if( !bs_read1( &s ) ) continue; /* Marker */            /* VOP time increment */            i_time_increment_bits = vlc_log2(p_dec->p_sys->i_fps_num - 1) + 1;            if( i_time_increment_bits < 1 ) i_time_increment_bits = 1;            i_time_increment = bs_read( &s, i_time_increment_bits );            /* Interpolate PTS/DTS */            if( !(p_sys->i_flags & BLOCK_FLAG_TYPE_B) )            {                p_sys->i_last_time_ref = p_sys->i_time_ref;                p_sys->i_time_ref +=                    (i_modulo_time_base * p_dec->p_sys->i_fps_num);                i_time_ref = p_sys->i_time_ref;            }            else            {                i_time_ref = p_sys->i_last_time_ref +                    (i_modulo_time_base * p_dec->p_sys->i_fps_num);            }            if( p_dec->p_sys->i_fps_num < 5 && /* Work-around buggy streams */                p_dec->fmt_in.video.i_frame_rate > 0 &&                p_dec->fmt_in.video.i_frame_rate_base > 0 )            {                p_sys->i_interpolated_pts += I64C(1000000) *                    p_dec->fmt_in.video.i_frame_rate_base *                    p_block->i_rate / INPUT_RATE_DEFAULT /                    p_dec->fmt_in.video.i_frame_rate;            }            else if( p_dec->p_sys->i_fps_num )                p_sys->i_interpolated_pts +=                    ( I64C(1000000) * (i_time_ref + i_time_increment -                       p_sys->i_last_time - p_sys->i_last_timeincr) *                      p_block->i_rate / INPUT_RATE_DEFAULT /                      p_dec->p_sys->i_fps_num );            p_sys->i_last_time = i_time_ref;            p_sys->i_last_timeincr = i_time_increment;            /* Correct interpolated dts when we receive a new pts/dts */            if( p_block->i_pts > 0 )                p_sys->i_interpolated_pts = p_block->i_pts;            if( p_block->i_dts > 0 )                p_sys->i_interpolated_dts = p_block->i_dts;            if( (p_sys->i_flags & BLOCK_FLAG_TYPE_B) || !p_sys->b_frame )            {                /* Trivial case (DTS == PTS) */                p_sys->i_interpolated_dts = p_sys->i_interpolated_pts;                if( p_block->i_pts > 0 )                    p_sys->i_interpolated_dts = p_block->i_pts;                if( p_block->i_dts > 0 )                    p_sys->i_interpolated_dts = p_block->i_dts;                p_sys->i_interpolated_pts = p_sys->i_interpolated_dts;            }            else            {                if( p_sys->i_last_ref_pts > 0 )                    p_sys->i_interpolated_dts = p_sys->i_last_ref_pts;                p_sys->i_last_ref_pts = p_sys->i_interpolated_pts;            }            p_sys->b_vop = VLC_TRUE;            /* Don't re-use the same PTS/DTS twice */            p_block->i_pts = p_block->i_dts = 0;        }        p_start += 4; /* Next */    }}/**************************************************************************** * m4v_FindStartCode ****************************************************************************/static int m4v_FindStartCode( uint8_t **pp_start, uint8_t *p_end ){    uint8_t *p = *pp_start;    /* We wait for 4+1 bytes */    for( p = *pp_start; p < p_end - 5; p++ )    {        if( p[0] == 0 && p[1] == 0 && p[2] == 1 )        {            *pp_start = p;            return VLC_SUCCESS;        }    }    *pp_start = p_end;    return VLC_EGENERIC;}/* look at ffmpeg av_log2 ;) */static int vlc_log2( unsigned int v ){    int n = 0;    static const int vlc_log2_table[16] =    {        0,0,1,1,2,2,2,2, 3,3,3,3,3,3,3,3    };    if( v&0xffff0000 )    {        v >>= 16;        n += 16;    }    if( v&0xff00 )    {        v >>= 8;        n += 8;    }    if( v&0xf0 )    {        v >>= 4;        n += 4;    }    n += vlc_log2_table[v];    return n;}/* m4v_VOLParse: *  TODO: *      - support aspect ratio */static int m4v_VOLParse( decoder_t *p_dec, es_format_t *fmt,                         uint8_t *p_vol, int i_vol ){    bs_t s;    int i_vo_type;    int i_vo_ver_id;    int i_ar;    int i_shape;    for( ;; )    {        if( p_vol[0] == 0x00 && p_vol[1] == 0x00 &&            p_vol[2] == 0x01 &&            p_vol[3] >= 0x20 && p_vol[3] <= 0x2f )        {            break;        }        p_vol++;        i_vol--;        if( i_vol <= 4 )        {            return VLC_EGENERIC;        }    }    /* parse the vol */    bs_init( &s, &p_vol[4], i_vol - 4 );    bs_skip( &s, 1 );   /* random access */    i_vo_type = bs_read( &s, 8 );    if( bs_read1( &s ) )    {        i_vo_ver_id = bs_read( &s, 4 );        bs_skip( &s, 3 );    }    else    {        i_vo_ver_id = 1;    }    i_ar = bs_read( &s, 4 );    if( i_ar == 0xf )    {        int i_ar_width, i_ar_height;        i_ar_width = bs_read( &s, 8 );        i_ar_height= bs_read( &s, 8 );    }    if( bs_read1( &s ) )    {        int i_chroma_format;        int i_low_delay;        /* vol control parameter */        i_chroma_format = bs_read( &s, 2 );        i_low_delay = bs_read1( &s );        if( bs_read1( &s ) )        {            bs_skip( &s, 16 );            bs_skip( &s, 16 );            bs_skip( &s, 16 );            bs_skip( &s, 3 );            bs_skip( &s, 11 );            bs_skip( &s, 1 );            bs_skip( &s, 16 );        }    }    /* shape 0->RECT, 1->BIN, 2->BIN_ONLY, 3->GRAY */    i_shape = bs_read( &s, 2 );    if( i_shape == 3 && i_vo_ver_id != 1 )    {        bs_skip( &s, 4 );    }    if( !bs_read1( &s ) ) return VLC_EGENERIC; /* Marker */    p_dec->p_sys->i_fps_num = bs_read( &s, 16 ); /* Time increment resolution*/    if( !p_dec->p_sys->i_fps_num ) p_dec->p_sys->i_fps_num = 1;    if( !bs_read1( &s ) ) return VLC_EGENERIC; /* Marker */    if( bs_read1( &s ) )    {        int i_time_increment_bits =            vlc_log2( p_dec->p_sys->i_fps_num - 1 ) + 1;        if( i_time_increment_bits < 1 ) i_time_increment_bits = 1;        p_dec->p_sys->i_fps_den = bs_read( &s, i_time_increment_bits );    }    if( i_shape == 0 )    {        bs_skip( &s, 1 );        fmt->video.i_width = bs_read( &s, 13 );        bs_skip( &s, 1 );        fmt->video.i_height= bs_read( &s, 13 );        bs_skip( &s, 1 );    }    return VLC_SUCCESS;}

⌨️ 快捷键说明

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