You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avformat/matroskadec: Don't copy attached pictures
This commit replaces copying attached pictures by using references to the already existing buffers. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
committed by
James Almer
parent
1beeb3b877
commit
07d4056052
@@ -2715,15 +2715,19 @@ static int matroska_read_header(AVFormatContext *s)
|
|||||||
attachments[j].stream = st;
|
attachments[j].stream = st;
|
||||||
|
|
||||||
if (st->codecpar->codec_id != AV_CODEC_ID_NONE) {
|
if (st->codecpar->codec_id != AV_CODEC_ID_NONE) {
|
||||||
|
AVPacket *pkt = &st->attached_pic;
|
||||||
|
|
||||||
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
|
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
|
|
||||||
av_init_packet(&st->attached_pic);
|
av_init_packet(pkt);
|
||||||
if ((res = av_new_packet(&st->attached_pic, attachments[j].bin.size)) < 0)
|
pkt->buf = av_buffer_ref(attachments[j].bin.buf);
|
||||||
return res;
|
if (!pkt->buf)
|
||||||
memcpy(st->attached_pic.data, attachments[j].bin.data, attachments[j].bin.size);
|
return AVERROR(ENOMEM);
|
||||||
st->attached_pic.stream_index = st->index;
|
pkt->data = attachments[j].bin.data;
|
||||||
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
|
pkt->size = attachments[j].bin.size;
|
||||||
|
pkt->stream_index = st->index;
|
||||||
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
} else {
|
} else {
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
|
st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
|
||||||
if (ff_alloc_extradata(st->codecpar, attachments[j].bin.size))
|
if (ff_alloc_extradata(st->codecpar, attachments[j].bin.size))
|
||||||
|
Reference in New Issue
Block a user