int
ff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb,
                      AVStream *st, RMStream *ast, AVPacket *pkt)
{
    RMDemuxContext *rm = s->priv_data;
    assert (rm->audio_pkt_cnt > 0);
    if (ast->deint_id == DEINT_ID_VBRF ||
        ast->deint_id == DEINT_ID_VBRS)
        av_get_packet(pb, pkt, ast->sub_packet_lengths[ast->sub_packet_cnt - rm->audio_pkt_cnt]);
    else {
        av_new_packet(pkt, st->codec->block_align);
        memcpy(pkt->data, ast->pkt.data + st->codec->block_align *
               (ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),
               st->codec->block_align);
    }
    rm->audio_pkt_cnt--;
    if ((pkt->pts = ast->audiotimestamp) != AV_NOPTS_VALUE) {
        ast->audiotimestamp = AV_NOPTS_VALUE;
        pkt->flags = AV_PKT_FLAG_KEY;
    } else
        pkt->flags = 0;
    pkt->stream_index = st->index;
    return rm->audio_pkt_cnt;
}
['int\nff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb,\n                      AVStream *st, RMStream *ast, AVPacket *pkt)\n{\n    RMDemuxContext *rm = s->priv_data;\n    assert (rm->audio_pkt_cnt > 0);\n    if (ast->deint_id == DEINT_ID_VBRF ||\n        ast->deint_id == DEINT_ID_VBRS)\n        av_get_packet(pb, pkt, ast->sub_packet_lengths[ast->sub_packet_cnt - rm->audio_pkt_cnt]);\n    else {\n        av_new_packet(pkt, st->codec->block_align);\n        memcpy(pkt->data, ast->pkt.data + st->codec->block_align *\n               (ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),\n               st->codec->block_align);\n    }\n    rm->audio_pkt_cnt--;\n    if ((pkt->pts = ast->audiotimestamp) != AV_NOPTS_VALUE) {\n        ast->audiotimestamp = AV_NOPTS_VALUE;\n        pkt->flags = AV_PKT_FLAG_KEY;\n    } else\n        pkt->flags = 0;\n    pkt->stream_index = st->index;\n    return rm->audio_pkt_cnt;\n}', 'int av_new_packet(AVPacket *pkt, int size)\n{\n    uint8_t *data= NULL;\n    if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)\n        data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);\n    if (data){\n        memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);\n    }else\n        size=0;\n    av_init_packet(pkt);\n    pkt->data = data;\n    pkt->size = size;\n    pkt->destruct = av_destruct_packet;\n    if(!data)\n        return AVERROR(ENOMEM);\n    return 0;\n}', 'void *av_malloc(size_t size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-32) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+32);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&31) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,32,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(32,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}', 'void av_init_packet(AVPacket *pkt)\n{\n    pkt->pts   = AV_NOPTS_VALUE;\n    pkt->dts   = AV_NOPTS_VALUE;\n    pkt->pos   = -1;\n    pkt->duration = 0;\n    pkt->convergence_duration = 0;\n    pkt->flags = 0;\n    pkt->stream_index = 0;\n    pkt->destruct= NULL;\n    pkt->side_data       = NULL;\n    pkt->side_data_elems = 0;\n}']