1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/(aiff|flac|mov|mp3|tta)enc: Don't create unnecessary references

The packet given to muxers is not used afterwards; it is always
unreferenced by libavformat. Ergo muxers are allowed to keep
the references in the packets and e.g. move the ownership to
a packet list. This is what this commit does.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2021-12-15 23:21:25 +01:00
parent f0fb005f59
commit 3485e79f07
5 changed files with 9 additions and 5 deletions

View File

@ -219,7 +219,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
return 0; return 0;
return avpriv_packet_list_put(&aiff->pict_list, &aiff->pict_list_end, return avpriv_packet_list_put(&aiff->pict_list, &aiff->pict_list_end,
pkt, av_packet_ref, 0); pkt, NULL, 0);
} }
return 0; return 0;

View File

@ -360,7 +360,7 @@ static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
if (pkt->stream_index == c->audio_stream_idx) { if (pkt->stream_index == c->audio_stream_idx) {
if (c->waiting_pics) { if (c->waiting_pics) {
/* buffer audio packets until we get all the pictures */ /* buffer audio packets until we get all the pictures */
ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, av_packet_ref, 0); ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, NULL, 0);
if (ret < 0) { if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n"); av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n");
c->waiting_pics = 0; c->waiting_pics = 0;

View File

@ -6187,9 +6187,11 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
/* The following will reset pkt and is only allowed to be used
* because we return immediately. afterwards. */
if ((ret = avpriv_packet_list_put(&trk->squashed_packet_queue, if ((ret = avpriv_packet_list_put(&trk->squashed_packet_queue,
&trk->squashed_packet_queue_end, &trk->squashed_packet_queue_end,
pkt, av_packet_ref, 0)) < 0) { pkt, NULL, 0)) < 0) {
return ret; return ret;
} }

View File

@ -524,7 +524,8 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
if (pkt->stream_index == mp3->audio_stream_idx) { if (pkt->stream_index == mp3->audio_stream_idx) {
if (mp3->pics_to_write) { if (mp3->pics_to_write) {
/* buffer audio packets until we get all the pictures */ /* buffer audio packets until we get all the pictures */
int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end, pkt, av_packet_ref, 0); int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end,
pkt, NULL, 0);
if (ret < 0) { if (ret < 0) {
av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n"); av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n");

View File

@ -95,10 +95,11 @@ static int tta_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret; int ret;
ret = avpriv_packet_list_put(&tta->queue, &tta->queue_end, pkt, ret = avpriv_packet_list_put(&tta->queue, &tta->queue_end, pkt,
av_packet_ref, 0); NULL, 0);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
pkt = &tta->queue_end->pkt;
avio_wl32(tta->seek_table, pkt->size); avio_wl32(tta->seek_table, pkt->size);
tta->nb_samples += pkt->duration; tta->nb_samples += pkt->duration;