示例#1
0
lsmash_summary_t *lsmash_create_summary( lsmash_summary_type summary_type )
{
    size_t summary_size;
    switch( summary_type )
    {
        case LSMASH_SUMMARY_TYPE_VIDEO :
            summary_size = sizeof(lsmash_video_summary_t);
            break;
        case LSMASH_SUMMARY_TYPE_AUDIO :
            summary_size = sizeof(lsmash_audio_summary_t);
            break;
        default :
            summary_size = sizeof(lsmash_summary_t);
            return NULL;
    }
    lsmash_summary_t *summary = (lsmash_summary_t *)lsmash_malloc_zero( summary_size );
    if( !summary )
        return NULL;
    summary->opaque = (lsmash_codec_specific_list_t *)lsmash_malloc_zero( sizeof(lsmash_codec_specific_list_t) );
    if( !summary->opaque )
    {
        lsmash_free( summary );
        return NULL;
    }
    summary->summary_type   = summary_type;
    summary->data_ref_index = 1;
    return summary;
}
static mp4sys_adts_importer_t *create_mp4sys_adts_importer
(
    importer_t *importer
)
{
    return (mp4sys_adts_importer_t *)lsmash_malloc_zero( sizeof(mp4sys_adts_importer_t) );
}
示例#3
0
lsmash_bs_t *lsmash_bs_create( void )
{
    lsmash_bs_t *bs = lsmash_malloc_zero( sizeof(lsmash_bs_t) );
    if( !bs )
        return NULL;
    bs->unseekable      = 1;
    bs->buffer.internal = 1;
    bs->buffer.max_size = BS_MAX_DEFAULT_READ_SIZE;
    return bs;
}
示例#4
0
static vc1_importer_t *create_vc1_importer( importer_t *importer )
{
    vc1_importer_t *vc1_imp = lsmash_malloc_zero( sizeof(vc1_importer_t) );
    if( !vc1_imp )
        return NULL;
    if( vc1_setup_parser( &vc1_imp->info, 0 ) < 0 )
    {
        remove_vc1_importer( vc1_imp );
        return NULL;
    }
    return vc1_imp;
}
示例#5
0
static vc1_importer_t *create_vc1_importer( importer_t *importer )
{
    vc1_importer_t *vc1_imp = lsmash_malloc_zero( sizeof(vc1_importer_t) );
    if( !vc1_imp )
        return NULL;
    if( vc1_setup_parser( &vc1_imp->info, 0 ) < 0 )
    {
        remove_vc1_importer( vc1_imp );
        return NULL;
    }
    lsmash_bs_t *bs = lsmash_bs_create();
    if( !bs )
    {
        remove_vc1_importer( vc1_imp );
        return NULL;
    }
    bs->stream          = importer->stream;
    bs->read            = lsmash_fread_wrapper;
    bs->seek            = lsmash_fseek_wrapper;
    bs->unseekable      = importer->is_stdin;
    bs->buffer.max_size = BS_MAX_DEFAULT_READ_SIZE;
    vc1_imp->bs = bs;
    return vc1_imp;
}
示例#6
0
static dts_importer_t *create_dts_importer( importer_t *importer )
{
    dts_importer_t *dts_imp = (dts_importer_t *)lsmash_malloc_zero( sizeof(dts_importer_t) );
    if( !dts_imp )
        return NULL;
    dts_info_t *dts_info = &dts_imp->info;
    dts_info->bits = lsmash_bits_create( importer->bs );
    if( !dts_info->bits )
    {
        lsmash_free( dts_imp );
        return NULL;
    }
    dts_imp->au_buffers = lsmash_create_multiple_buffers( 2, DTS_MAX_EXSS_SIZE );
    if( !dts_imp->au_buffers )
    {
        lsmash_bits_cleanup( dts_info->bits );
        lsmash_free( dts_imp );
        return NULL;
    }
    dts_imp->au            = lsmash_withdraw_buffer( dts_imp->au_buffers, 1 );
    dts_imp->incomplete_au = lsmash_withdraw_buffer( dts_imp->au_buffers, 2 );
    dts_setup_parser( dts_info );
    return dts_imp;
}
示例#7
0
lsmash_file_t *lsmash_set_file
(
    lsmash_root_t            *root,
    lsmash_file_parameters_t *param
)
{
    if( !root || !param )
        return NULL;
    lsmash_file_t *file = isom_add_file( root );
    if( !file )
        return NULL;
    lsmash_bs_t *bs = lsmash_bs_create();
    if( !bs )
        goto fail;
    file->bs                  = bs;
    file->flags               = param->mode;
    file->bs->stream          = param->opaque;
    file->bs->read            = param->read;
    file->bs->write           = param->write;
    file->bs->seek            = param->seek;
    file->bs->unseekable      = (param->seek == NULL);
    file->bs->buffer.max_size = param->max_read_size;
    file->max_chunk_duration  = param->max_chunk_duration;
    file->max_async_tolerance = LSMASH_MAX( param->max_async_tolerance, 2 * param->max_chunk_duration );
    file->max_chunk_size      = param->max_chunk_size;
    if( (file->flags & LSMASH_FILE_MODE_WRITE)
     && (file->flags & LSMASH_FILE_MODE_BOX) )
    {
        /* Construction of Segment Index Box requires seekability at our current implementation.
         * If segment is not so large, data rearrangement can be avoided by buffering i.e. the
         * seekability is not essential, but at present we don't support buffering of all materials
         * within segment. */
        if( (file->flags & LSMASH_FILE_MODE_INDEX) && file->bs->unseekable )
            goto fail;
        /* Establish the fragment handler if required. */
        if( file->flags & LSMASH_FILE_MODE_FRAGMENTED )
        {
            file->fragment = lsmash_malloc_zero( sizeof(isom_fragment_manager_t) );
            if( !file->fragment )
                goto fail;
            file->fragment->first_moof_pos = FIRST_MOOF_POS_UNDETERMINED;
            file->fragment->pool = lsmash_create_entry_list();
            if( !file->fragment->pool )
                goto fail;
        }
        else if( file->bs->unseekable )
            /* For unseekable output operations, LSMASH_FILE_MODE_FRAGMENTED shall be set. */
            goto fail;
        /* Establish file types. */
        if( isom_set_brands( file, param->major_brand,
                                   param->minor_version,
                                   param->brands, param->brand_count ) < 0 )
            goto fail;
        /* Create the movie header if the initialization of the streams is required. */
        if( (file->flags & LSMASH_FILE_MODE_INITIALIZATION) && !isom_movie_create( file ) )
            goto fail;
    }
    if( !root->file )
        root->file = file;
    return file;
fail:
    isom_remove_box_by_itself( file );
    return NULL;
}
示例#8
0
static wave_importer_t *create_wave_importer( importer_t *importer )
{
    return (wave_importer_t *)lsmash_malloc_zero( sizeof(wave_importer_t) );
}