summaryrefslogtreecommitdiff
path: root/libavformat/matroskadec.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-03-29 07:58:56 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-01 18:23:13 +0200
commit39ecb63d0f082ee3b2ac2ac65577170deb245ec4 (patch)
treedec03fe40d01b51e21929d00c3e45732163447a5 /libavformat/matroskadec.c
parentb7b73e83e3d5c78a5fea96a6bcae02e1f0a5c45f (diff)
avformat: Add and use helper function to add attachment streams
All instances of adding attached pictures to a stream or adding a stream and an attached packet to said stream have several things in common like setting the index and flags of the packet, setting the stream disposition etc. This commit therefore factors this out. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r--libavformat/matroskadec.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 1dc188c946..e8c76f9cfb 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3007,18 +3007,9 @@ static int matroska_read_header(AVFormatContext *s)
attachments[j].stream = st;
if (st->codecpar->codec_id != AV_CODEC_ID_NONE) {
- AVPacket *pkt = &st->attached_pic;
-
- st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
- st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
-
- av_packet_unref(pkt);
- pkt->buf = attachments[j].bin.buf;
- attachments[j].bin.buf = NULL;
- pkt->data = attachments[j].bin.data;
- pkt->size = attachments[j].bin.size;
- pkt->stream_index = st->index;
- pkt->flags |= AV_PKT_FLAG_KEY;
+ res = ff_add_attached_pic(s, st, NULL, &attachments[j].bin.buf, 0);
+ if (res < 0)
+ goto fail;
} else {
st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
if (ff_alloc_extradata(st->codecpar, attachments[j].bin.size))