[FFmpeg-cvslog] avformat/ttaenc: use AVPacketList helper functions to queue packets
James Almer
git at videolan.org
Wed Apr 4 06:57:22 EEST 2018
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon Mar 26 15:02:38 2018 -0300| [15ca8311e68d0a88117bce7e22f4bb423737e3d9] | committer: James Almer
avformat/ttaenc: use AVPacketList helper functions to queue packets
Simplifies code.
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=15ca8311e68d0a88117bce7e22f4bb423737e3d9
---
libavformat/ttaenc.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c
index add15873d0..d8e1136ead 100644
--- a/libavformat/ttaenc.c
+++ b/libavformat/ttaenc.c
@@ -91,22 +91,13 @@ static int tta_write_header(AVFormatContext *s)
static int tta_write_packet(AVFormatContext *s, AVPacket *pkt)
{
TTAMuxContext *tta = s->priv_data;
- AVPacketList *pktl = av_mallocz(sizeof(*pktl));
int ret;
- if (!pktl)
- return AVERROR(ENOMEM);
-
- ret = av_packet_ref(&pktl->pkt, pkt);
+ ret = ff_packet_list_put(&tta->queue, &tta->queue_end, pkt,
+ FF_PACKETLIST_FLAG_REF_PACKET);
if (ret < 0) {
- av_free(pktl);
return ret;
}
- if (tta->queue_end)
- tta->queue_end->next = pktl;
- else
- tta->queue = pktl;
- tta->queue_end = pktl;
avio_wl32(tta->seek_table, pkt->size);
tta->nb_samples += pkt->duration;
@@ -131,16 +122,13 @@ static int tta_write_packet(AVFormatContext *s, AVPacket *pkt)
static void tta_queue_flush(AVFormatContext *s)
{
TTAMuxContext *tta = s->priv_data;
- AVPacketList *pktl;
-
- while (pktl = tta->queue) {
- AVPacket *pkt = &pktl->pkt;
- avio_write(s->pb, pkt->data, pkt->size);
- av_packet_unref(pkt);
- tta->queue = pktl->next;
- av_free(pktl);
+ AVPacket pkt;
+
+ while (tta->queue) {
+ ff_packet_list_get(&tta->queue, &tta->queue_end, &pkt);
+ avio_write(s->pb, pkt.data, pkt.size);
+ av_packet_unref(&pkt);
}
- tta->queue_end = NULL;
}
static int tta_write_trailer(AVFormatContext *s)
More information about the ffmpeg-cvslog
mailing list