mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-18 04:47:12 +00:00
avformat/ttaenc: use AVPacketList helper functions to queue packets
Simplifies code. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
78b96be758
commit
15ca8311e6
@ -91,22 +91,13 @@ static int tta_write_header(AVFormatContext *s)
|
|||||||
static int tta_write_packet(AVFormatContext *s, AVPacket *pkt)
|
static int tta_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
{
|
{
|
||||||
TTAMuxContext *tta = s->priv_data;
|
TTAMuxContext *tta = s->priv_data;
|
||||||
AVPacketList *pktl = av_mallocz(sizeof(*pktl));
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!pktl)
|
ret = ff_packet_list_put(&tta->queue, &tta->queue_end, pkt,
|
||||||
return AVERROR(ENOMEM);
|
FF_PACKETLIST_FLAG_REF_PACKET);
|
||||||
|
|
||||||
ret = av_packet_ref(&pktl->pkt, pkt);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_free(pktl);
|
|
||||||
return ret;
|
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);
|
avio_wl32(tta->seek_table, pkt->size);
|
||||||
tta->nb_samples += pkt->duration;
|
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)
|
static void tta_queue_flush(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
TTAMuxContext *tta = s->priv_data;
|
TTAMuxContext *tta = s->priv_data;
|
||||||
AVPacketList *pktl;
|
AVPacket pkt;
|
||||||
|
|
||||||
while (pktl = tta->queue) {
|
while (tta->queue) {
|
||||||
AVPacket *pkt = &pktl->pkt;
|
ff_packet_list_get(&tta->queue, &tta->queue_end, &pkt);
|
||||||
avio_write(s->pb, pkt->data, pkt->size);
|
avio_write(s->pb, pkt.data, pkt.size);
|
||||||
av_packet_unref(pkt);
|
av_packet_unref(&pkt);
|
||||||
tta->queue = pktl->next;
|
|
||||||
av_free(pktl);
|
|
||||||
}
|
}
|
||||||
tta->queue_end = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tta_write_trailer(AVFormatContext *s)
|
static int tta_write_trailer(AVFormatContext *s)
|
||||||
|
Loading…
Reference in New Issue
Block a user