Commit c548b0a4 authored by Andreas Rheinhardt's avatar Andreas Rheinhardt Committed by Michael Niedermayer

avformat/aiffenc: Use standard packet list functions

Up until now, aiffenc didn't rely on the standard functions for adding
an element to a linked list and freeing the list, but instead
reimplemented them. This has been changed.
Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: 's avatarMatthieu Bouron <matthieu.bouron@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 93ea21f9
...@@ -36,7 +36,7 @@ typedef struct AIFFOutputContext { ...@@ -36,7 +36,7 @@ typedef struct AIFFOutputContext {
int64_t frames; int64_t frames;
int64_t ssnd; int64_t ssnd;
int audio_stream_idx; int audio_stream_idx;
AVPacketList *pict_list; AVPacketList *pict_list, *pict_list_end;
int write_id3v2; int write_id3v2;
int id3v2_version; int id3v2_version;
} AIFFOutputContext; } AIFFOutputContext;
...@@ -215,9 +215,6 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -215,9 +215,6 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
if (pkt->stream_index == aiff->audio_stream_idx) if (pkt->stream_index == aiff->audio_stream_idx)
avio_write(pb, pkt->data, pkt->size); avio_write(pb, pkt->data, pkt->size);
else { else {
int ret;
AVPacketList *pict_list, *last;
if (s->streams[pkt->stream_index]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) if (s->streams[pkt->stream_index]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
return 0; return 0;
...@@ -229,24 +226,8 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -229,24 +226,8 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
if (s->streams[pkt->stream_index]->nb_frames >= 1) if (s->streams[pkt->stream_index]->nb_frames >= 1)
return 0; return 0;
pict_list = av_mallocz(sizeof(AVPacketList)); return ff_packet_list_put(&aiff->pict_list, &aiff->pict_list_end,
if (!pict_list) pkt, FF_PACKETLIST_FLAG_REF_PACKET);
return AVERROR(ENOMEM);
ret = av_packet_ref(&pict_list->pkt, pkt);
if (ret < 0) {
av_freep(&pict_list);
return ret;
}
if (!aiff->pict_list)
aiff->pict_list = pict_list;
else {
last = aiff->pict_list;
while (last->next)
last = last->next;
last->next = pict_list;
}
} }
return 0; return 0;
...@@ -257,7 +238,6 @@ static int aiff_write_trailer(AVFormatContext *s) ...@@ -257,7 +238,6 @@ static int aiff_write_trailer(AVFormatContext *s)
int ret; int ret;
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
AIFFOutputContext *aiff = s->priv_data; AIFFOutputContext *aiff = s->priv_data;
AVPacketList *pict_list = aiff->pict_list;
AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar; AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar;
/* Chunks sizes must be even */ /* Chunks sizes must be even */
...@@ -293,12 +273,7 @@ static int aiff_write_trailer(AVFormatContext *s) ...@@ -293,12 +273,7 @@ static int aiff_write_trailer(AVFormatContext *s)
avio_flush(pb); avio_flush(pb);
} }
while (pict_list) { ff_packet_list_free(&aiff->pict_list, &aiff->pict_list_end);
AVPacketList *next = pict_list->next;
av_packet_unref(&pict_list->pkt);
av_freep(&pict_list);
pict_list = next;
}
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment