diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-03-29 07:58:56 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-04-01 18:23:13 +0200 |
commit | 39ecb63d0f082ee3b2ac2ac65577170deb245ec4 (patch) | |
tree | dec03fe40d01b51e21929d00c3e45732163447a5 /libavformat/wtvdec.c | |
parent | b7b73e83e3d5c78a5fea96a6bcae02e1f0a5c45f (diff) | |
download | ffmpeg-39ecb63d0f082ee3b2ac2ac65577170deb245ec4.tar.gz |
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/wtvdec.c')
-rw-r--r-- | libavformat/wtvdec.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index 4b3b7fb407..44ca86d517 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -434,7 +434,6 @@ static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length) char description[1024]; unsigned int filesize; AVStream *st; - int ret; int64_t pos = avio_tell(pb); avio_get_str16le(pb, INT_MAX, mime, sizeof(mime)); @@ -447,19 +446,12 @@ static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length) if (!filesize) goto done; - st = avformat_new_stream(s, NULL); - if (!st) + if (ff_add_attached_pic(s, NULL, pb, NULL, filesize) < 0) goto done; + st = s->streams[s->nb_streams - 1]; av_dict_set(&st->metadata, "title", description, 0); - st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->codec_id = AV_CODEC_ID_MJPEG; st->id = -1; - ret = av_get_packet(pb, &st->attached_pic, filesize); - if (ret < 0) - goto done; - st->attached_pic.stream_index = st->index; - st->attached_pic.flags |= AV_PKT_FLAG_KEY; - st->disposition |= AV_DISPOSITION_ATTACHED_PIC; done: avio_seek(pb, pos + length, SEEK_SET); } |