[FFmpeg-cvslog] avformat/mxg: return reference counted packets

James Almer git at videolan.org
Fri Mar 2 18:27:39 EET 2018


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Tue Feb 27 00:09:47 2018 -0300| [6ce5dd228c40159c774543425dd1f94a5d670542] | committer: James Almer

avformat/mxg: return reference counted packets

Reviewed-by: wm4 <nfxjfg at googlemail.com>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6ce5dd228c40159c774543425dd1f94a5d670542
---

 libavformat/mxg.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/libavformat/mxg.c b/libavformat/mxg.c
index 6fbf99cfa3..fe5879ecf0 100644
--- a/libavformat/mxg.c
+++ b/libavformat/mxg.c
@@ -169,11 +169,14 @@ static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt)
                     continue;
                 }
 
+                size = mxg->buffer_ptr - mxg->soi_ptr;
+                ret = av_new_packet(pkt, size);
+                if (ret < 0)
+                    return ret;
+                memcpy(pkt->data, mxg->soi_ptr, size);
+
                 pkt->pts = pkt->dts = mxg->dts;
                 pkt->stream_index = 0;
-                pkt->buf  = NULL;
-                pkt->size = mxg->buffer_ptr - mxg->soi_ptr;
-                pkt->data = mxg->soi_ptr;
 
                 if (mxg->soi_ptr - mxg->buffer > mxg->cache_size) {
                     if (mxg->cache_size > 0) {
@@ -206,12 +209,14 @@ static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt)
                 mxg->buffer_ptr += size;
 
                 if (marker == APP13 && size >= 16) { /* audio data */
+                    ret = av_new_packet(pkt, size - 14);
+                    if (ret < 0)
+                        return ret;
+                    memcpy(pkt->data, startmarker_ptr + 16, size - 14);
+
                     /* time (GMT) of first sample in usec since 1970, little-endian */
                     pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8);
                     pkt->stream_index = 1;
-                    pkt->buf  = NULL;
-                    pkt->size = size - 14;
-                    pkt->data = startmarker_ptr + 16;
 
                     if (startmarker_ptr - mxg->buffer > mxg->cache_size) {
                         if (mxg->cache_size > 0) {



More information about the ffmpeg-cvslog mailing list