Exemple #1
0
/* Create the p_sys->p_csd that will be sent via PutInput */
static int CSDDup(decoder_t *p_dec, const struct csd *p_csd, size_t i_count)
{
    decoder_sys_t *p_sys = p_dec->p_sys;

    CSDFree(p_dec);

    p_sys->pp_csd = malloc(i_count * sizeof(block_t *));
    if (!p_sys->pp_csd)
        return VLC_ENOMEM;

    for (size_t i = 0; i < i_count; ++i)
    {
        p_sys->pp_csd[i] = block_Alloc(p_csd[i].i_size);
        if (!p_sys->pp_csd[i])
        {
            CSDFree(p_dec);
            return VLC_ENOMEM;
        }
        p_sys->pp_csd[i]->i_flags = BLOCK_FLAG_CSD;
        memcpy(p_sys->pp_csd[i]->p_buffer, p_csd[i].p_buf, p_csd[i].i_size);
        p_sys->i_csd_count++;
    }

    p_sys->i_csd_send = 0;
    return VLC_SUCCESS;
}
Exemple #2
0
/*****************************************************************************
 * CloseDecoder: Close the decoder instance
 *****************************************************************************/
static void CloseDecoder(vlc_object_t *p_this)
{
    decoder_t *p_dec = (decoder_t *)p_this;
    decoder_sys_t *p_sys = p_dec->p_sys;

    if (!p_sys)
        return;

    StopMediaCodec(p_dec);

    CSDFree(p_dec);
    p_sys->api->clean(p_sys->api);

    if (p_dec->fmt_in.i_cat == VIDEO_ES)
    {
        ArchitectureSpecificCopyHooksDestroy(p_sys->u.video.i_pixel_format,
                                             &p_sys->u.video.ascd);
        free(p_sys->u.video.pp_inflight_pictures);
        if (p_sys->u.video.timestamp_fifo)
            timestamp_FifoRelease(p_sys->u.video.timestamp_fifo);
        if (p_sys->u.video.p_awh)
            AWindowHandler_destroy(p_sys->u.video.p_awh);
    }
    free(p_sys->api);
    free(p_sys->psz_name);
    free(p_sys);
}
Exemple #3
0
/* Create the p_sys->p_csd that will be sent via PutInput */
static int CSDDup(decoder_t *p_dec, const struct csd *p_csd, size_t i_count)
{
    decoder_sys_t *p_sys = p_dec->p_sys;
    unsigned int i_last_csd_count = p_sys->i_csd_count;

    p_sys->i_csd_count = i_count;
    /* free previous p_buf if old count is bigger */
    for (size_t i = p_sys->i_csd_count; i < i_last_csd_count; ++i)
        free(p_sys->p_csd[i].p_buf);

    p_sys->p_csd = realloc_or_free(p_sys->p_csd, p_sys->i_csd_count *
                                   sizeof(struct csd));
    if (!p_sys->p_csd)
    {
        CSDFree(p_dec);
        return VLC_ENOMEM;
    }

    if (p_sys->i_csd_count > i_last_csd_count)
        memset(&p_sys->p_csd[i_last_csd_count], 0,
               (p_sys->i_csd_count - i_last_csd_count) * sizeof(struct csd));

    for (size_t i = 0; i < p_sys->i_csd_count; ++i)
    {
        p_sys->p_csd[i].p_buf = realloc_or_free(p_sys->p_csd[i].p_buf,
                                                p_csd[i].i_size);
        if (!p_sys->p_csd[i].p_buf)
        {
            CSDFree(p_dec);
            return VLC_ENOMEM;
        }
        memcpy(p_sys->p_csd[i].p_buf, p_csd[i].p_buf, p_csd[i].i_size);
        p_sys->p_csd[i].i_size = p_csd[i].i_size;
    }
    return VLC_SUCCESS;
}