Mercurial > libavformat.hg
diff utils.c @ 775:c5077fdab490 libavformat
AVPacket.pos
author | michael |
---|---|
date | Thu, 26 May 2005 20:17:12 +0000 |
parents | d3cec742f7c0 |
children | 47c7fa7c2e7c |
line wrap: on
line diff
--- a/utils.c Thu May 26 07:47:51 2005 +0000 +++ b/utils.c Thu May 26 20:17:12 2005 +0000 @@ -195,6 +195,31 @@ return 0; } +/** + * Allocate and read the payload of a packet and intialized its fields to default values. + * + * @param pkt packet + * @param size wanted payload size + * @return >0 (read size) if OK. AVERROR_xxx otherwise. + */ +int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size) +{ + int ret= av_new_packet(pkt, size); + + if(ret<0) + return ret; + + pkt->pos= url_ftell(s); + + ret= get_buffer(s, pkt->data, size); + if(ret<=0) + av_free_packet(pkt); + else + pkt->size= ret; + + return ret; +} + /* This is a hack - the packet memory allocation stuff is broken. The packet is allocated if it was not really allocated */ int av_dup_packet(AVPacket *pkt)