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

📄 libavi.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
             (char*)&p_strz->i_chunk_fourcc, p_strz->p_type, p_strz->p_str);#endif    AVI_READCHUNK_EXIT( VLC_SUCCESS );}static void AVI_ChunkFree_strz( avi_chunk_t *p_chk ){    avi_chunk_STRING_t *p_strz = (avi_chunk_STRING_t*)p_chk;    FREENULL( p_strz->p_type );    FREENULL( p_strz->p_str );}static int AVI_ChunkRead_nothing( stream_t *s, avi_chunk_t *p_chk ){    return AVI_NextChunk( s, p_chk );}static void AVI_ChunkFree_nothing( avi_chunk_t *p_chk ){    VLC_UNUSED( p_chk );}static const struct{    vlc_fourcc_t i_fourcc;    int   (*AVI_ChunkRead_function)( stream_t *s, avi_chunk_t *p_chk );    void  (*AVI_ChunkFree_function)( avi_chunk_t *p_chk );} AVI_Chunk_Function [] ={    { AVIFOURCC_RIFF, AVI_ChunkRead_list, AVI_ChunkFree_nothing },    { AVIFOURCC_ON2,  AVI_ChunkRead_list, AVI_ChunkFree_nothing },    { AVIFOURCC_LIST, AVI_ChunkRead_list, AVI_ChunkFree_nothing },    { AVIFOURCC_avih, AVI_ChunkRead_avih, AVI_ChunkFree_nothing },    { AVIFOURCC_ON2h, AVI_ChunkRead_avih, AVI_ChunkFree_nothing },    { AVIFOURCC_strh, AVI_ChunkRead_strh, AVI_ChunkFree_nothing },    { AVIFOURCC_strf, AVI_ChunkRead_strf, AVI_ChunkFree_strf },    { AVIFOURCC_strd, AVI_ChunkRead_strd, AVI_ChunkFree_strd },    { AVIFOURCC_idx1, AVI_ChunkRead_idx1, AVI_ChunkFree_idx1 },    { AVIFOURCC_indx, AVI_ChunkRead_indx, AVI_ChunkFree_indx },    { AVIFOURCC_JUNK, AVI_ChunkRead_nothing, AVI_ChunkFree_nothing },    { AVIFOURCC_IARL, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IARL, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IART, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ICMS, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ICMT, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ICOP, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ICRD, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ICRP, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IDIM, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IDPI, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IENG, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IGNR, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IKEY, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ILGT, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IMED, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_INAM, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IPLT, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IPRD, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ISBJ, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ISFT, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ISHP, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ISRC, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ISRF, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ITCH, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_ISMP, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_IDIT, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { AVIFOURCC_strn, AVI_ChunkRead_strz, AVI_ChunkFree_strz },    { 0,           NULL,               NULL }};static int AVI_ChunkFunctionFind( vlc_fourcc_t i_fourcc ){    unsigned int i_index;    for( i_index = 0; ; i_index++ )    {        if( ( AVI_Chunk_Function[i_index].i_fourcc == i_fourcc )||            ( AVI_Chunk_Function[i_index].i_fourcc == 0 ) )        {            return i_index;        }    }}int  _AVI_ChunkRead( stream_t *s, avi_chunk_t *p_chk, avi_chunk_t *p_father ){    int i_index;    if( !p_chk )    {        return VLC_EGENERIC;    }    if( AVI_ChunkReadCommon( s, p_chk ) )    {        msg_Warn( (vlc_object_t*)s, "cannot read one chunk" );        return VLC_EGENERIC;    }    if( p_chk->common.i_chunk_fourcc == VLC_FOURCC( 0, 0, 0, 0 ) )    {        msg_Warn( (vlc_object_t*)s, "found null fourcc chunk (corrupted file?)" );        return VLC_EGENERIC;    }    p_chk->common.p_father = p_father;    i_index = AVI_ChunkFunctionFind( p_chk->common.i_chunk_fourcc );    if( AVI_Chunk_Function[i_index].AVI_ChunkRead_function )    {        return AVI_Chunk_Function[i_index].AVI_ChunkRead_function( s, p_chk );    }    else if( ( ((char*)&p_chk->common.i_chunk_fourcc)[0] == 'i' &&               ((char*)&p_chk->common.i_chunk_fourcc)[1] == 'x' ) ||             ( ((char*)&p_chk->common.i_chunk_fourcc)[2] == 'i' &&               ((char*)&p_chk->common.i_chunk_fourcc)[3] == 'x' ) )    {        p_chk->common.i_chunk_fourcc = AVIFOURCC_indx;        return AVI_ChunkRead_indx( s, p_chk );    }    msg_Warn( (vlc_object_t*)s, "unknown chunk (not loaded)" );    return AVI_NextChunk( s, p_chk );}void _AVI_ChunkFree( stream_t *s,                     avi_chunk_t *p_chk ){    int i_index;    avi_chunk_t *p_child, *p_next;    if( !p_chk )    {        return;    }    /* Free all child chunk */    p_child = p_chk->common.p_first;    while( p_child )    {        p_next = p_child->common.p_next;        AVI_ChunkFree( s, p_child );        free( p_child );        p_child = p_next;    }    i_index = AVI_ChunkFunctionFind( p_chk->common.i_chunk_fourcc );    if( AVI_Chunk_Function[i_index].AVI_ChunkFree_function )    {#ifdef AVI_DEBUG        msg_Dbg( (vlc_object_t*)s, "free chunk %4.4s",                 (char*)&p_chk->common.i_chunk_fourcc );#endif        AVI_Chunk_Function[i_index].AVI_ChunkFree_function( p_chk);    }    else    {        msg_Warn( (vlc_object_t*)s, "unknown chunk (not unloaded)" );    }    p_chk->common.p_first = NULL;    p_chk->common.p_last  = NULL;    return;}static void AVI_ChunkDumpDebug_level( vlc_object_t *p_obj,                                      avi_chunk_t  *p_chk, int i_level ){    char str[1024];    int i;    avi_chunk_t *p_child;    memset( str, ' ', sizeof( str ) );    for( i = 1; i < i_level; i++ )    {        str[i * 5] = '|';    }    if( p_chk->common.i_chunk_fourcc == AVIFOURCC_RIFF ||        p_chk->common.i_chunk_fourcc == AVIFOURCC_ON2  ||        p_chk->common.i_chunk_fourcc == AVIFOURCC_LIST )    {        sprintf( str + i_level * 5,                 "%c %4.4s-%4.4s size:%"PRIu64" pos:%"PRIu64,                 i_level ? '+' : '*',                 (char*)&p_chk->common.i_chunk_fourcc,                 (char*)&p_chk->list.i_type,                 p_chk->common.i_chunk_size,                 p_chk->common.i_chunk_pos );    }    else    {        sprintf( str + i_level * 5,                 "+ %4.4s size:%"PRIu64" pos:%"PRIu64,                 (char*)&p_chk->common.i_chunk_fourcc,                 p_chk->common.i_chunk_size,                 p_chk->common.i_chunk_pos );    }    msg_Dbg( p_obj, "%s", str );    p_child = p_chk->common.p_first;    while( p_child )    {        AVI_ChunkDumpDebug_level( p_obj, p_child, i_level + 1 );        p_child = p_child->common.p_next;    }}int AVI_ChunkReadRoot( stream_t *s, avi_chunk_t *p_root ){    avi_chunk_list_t *p_list = (avi_chunk_list_t*)p_root;    avi_chunk_t      *p_chk;    bool b_seekable;    stream_Control( s, STREAM_CAN_FASTSEEK, &b_seekable );    p_list->i_chunk_pos  = 0;    p_list->i_chunk_size = stream_Size( s );    p_list->i_chunk_fourcc = AVIFOURCC_LIST;    p_list->p_father = NULL;    p_list->p_next  = NULL;    p_list->p_first = NULL;    p_list->p_last  = NULL;    p_list->i_type = VLC_FOURCC( 'r', 'o', 'o', 't' );    for( ; ; )    {        p_chk = malloc( sizeof( avi_chunk_t ) );        memset( p_chk, 0, sizeof( avi_chunk_t ) );        if( !p_root->common.p_first )        {            p_root->common.p_first = p_chk;        }        else        {            p_root->common.p_last->common.p_next = p_chk;        }        p_root->common.p_last = p_chk;        if( AVI_ChunkRead( s, p_chk, p_root ) ||           ( stream_Tell( s ) >=              (off_t)p_chk->common.p_father->common.i_chunk_pos +               (off_t)__EVEN( p_chk->common.p_father->common.i_chunk_size ) ) )        {            break;        }        /* If we can't seek then stop when we 've found first RIFF-AVI */        if( p_chk->common.i_chunk_fourcc == AVIFOURCC_RIFF &&            p_chk->list.i_type == AVIFOURCC_AVI && !b_seekable )        {            break;        }    }    AVI_ChunkDumpDebug_level( (vlc_object_t*)s, p_root, 0 );    return VLC_SUCCESS;}void AVI_ChunkFreeRoot( stream_t *s,                        avi_chunk_t  *p_chk ){    AVI_ChunkFree( s, p_chk );}int  _AVI_ChunkCount( avi_chunk_t *p_chk, vlc_fourcc_t i_fourcc ){    int i_count;    avi_chunk_t *p_child;    if( !p_chk )    {        return 0;    }    i_count = 0;    p_child = p_chk->common.p_first;    while( p_child )    {        if( p_child->common.i_chunk_fourcc == i_fourcc ||            ( p_child->common.i_chunk_fourcc == AVIFOURCC_LIST &&              p_child->list.i_type == i_fourcc ) )        {            i_count++;        }        p_child = p_child->common.p_next;    }    return i_count;}void *_AVI_ChunkFind( avi_chunk_t *p_chk,                      vlc_fourcc_t i_fourcc, int i_number ){    avi_chunk_t *p_child;    if( !p_chk )    {        return NULL;    }    p_child = p_chk->common.p_first;    while( p_child )    {        if( p_child->common.i_chunk_fourcc == i_fourcc ||            ( p_child->common.i_chunk_fourcc == AVIFOURCC_LIST &&              p_child->list.i_type == i_fourcc ) )        {            if( i_number == 0 )            {                /* We found it */                return p_child;            }            i_number--;        }        p_child = p_child->common.p_next;    }    return NULL;}

⌨️ 快捷键说明

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