aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/ttaenc.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-03-26 15:02:38 -0300
committerJames Almer <jamrial@gmail.com>2018-04-04 00:15:38 -0300
commit15ca8311e68d0a88117bce7e22f4bb423737e3d9 (patch)
treef8ac4fa5934f35bfd8c57c8f3bf66b0031b8f9e5 /libavformat/ttaenc.c
parent78b96be7580ea0d02f6366414e84cb344a8214ca (diff)
downloadffmpeg-15ca8311e68d0a88117bce7e22f4bb423737e3d9.tar.gz
avformat/ttaenc: use AVPacketList helper functions to queue packets
Simplifies code. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/ttaenc.c')
-rw-r--r--libavformat/ttaenc.c28
1 files 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)