[Libav-user] avpacket data padding and alignment

Gonzalo Garramuño ggarra13 at gmail.com
Wed Apr 18 20:42:19 EEST 2018



El 16/04/2018 a las 22:11, YIRAN LI escribió:
>
>
> 2018-04-16 12:07 GMT+10:00 YIRAN LI <mrfun.china at gmail.com 
> <mailto:mrfun.china at gmail.com>>:
>
>     Hi guys,
>
>     I know if I call av_new_packet then the data buffer created will
>     be padded and aligned.
>
>
>     But how if I only use ffmpeg to do the muxing?
>
>
>     Say if I get a buffer with size n.  My code looks like this.
>
>
>        AVPacket pkt;
>        ZeroMemory(&pkt, sizeof(pkt));
>        pkt.stream_index = myindex;
>        pkt.pts = myPTS;
>        pkt.data = myPtr; (points to a buffer allocated in my program)
>        pkt.size = mySize;
>        av_write_frame(pFormatCtx, &pkt)
>
>
>     Is above code OK? or do I need to allocate pkt.data with padding +
>     alignment and copy my data into it?
>
>
>     Thanks
>
>
> ​Hi, Can anyone help on this?
>
> Thanks​
>
AFAIK, you need to allocate with alignment taken into account. av_malloc 
(in libavutil/mem.h) and similar should be of help.

-- 
Gonzalo Garramuño

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180418/86eb30f5/attachment.html>


More information about the Libav-user mailing list