You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-06-14 22:15:12 +02:00
avformat/matroskadec: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@ -381,6 +381,8 @@ typedef struct MatroskaDemuxContext {
|
|||||||
/* byte position of the segment inside the stream */
|
/* byte position of the segment inside the stream */
|
||||||
int64_t segment_start;
|
int64_t segment_start;
|
||||||
|
|
||||||
|
AVPacket *pkt;
|
||||||
|
|
||||||
/* the packet queue */
|
/* the packet queue */
|
||||||
PacketList *queue;
|
PacketList *queue;
|
||||||
PacketList *queue_end;
|
PacketList *queue_end;
|
||||||
@ -2943,6 +2945,10 @@ static int matroska_read_header(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
ebml_free(ebml_syntax, &ebml);
|
ebml_free(ebml_syntax, &ebml);
|
||||||
|
|
||||||
|
matroska->pkt = av_packet_alloc();
|
||||||
|
if (!matroska->pkt)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
/* The next thing is a segment. */
|
/* The next thing is a segment. */
|
||||||
pos = avio_tell(matroska->ctx->pb);
|
pos = avio_tell(matroska->ctx->pb);
|
||||||
res = ebml_parse(matroska, matroska_segments, matroska);
|
res = ebml_parse(matroska, matroska_segments, matroska);
|
||||||
@ -3006,7 +3012,7 @@ static int matroska_read_header(AVFormatContext *s)
|
|||||||
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(pkt);
|
av_packet_unref(pkt);
|
||||||
pkt->buf = attachments[j].bin.buf;
|
pkt->buf = attachments[j].bin.buf;
|
||||||
attachments[j].bin.buf = NULL;
|
attachments[j].bin.buf = NULL;
|
||||||
pkt->data = attachments[j].bin.data;
|
pkt->data = attachments[j].bin.data;
|
||||||
@ -3238,7 +3244,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
|
|||||||
|
|
||||||
while (track->audio.pkt_cnt) {
|
while (track->audio.pkt_cnt) {
|
||||||
int ret;
|
int ret;
|
||||||
AVPacket pktl, *pkt = &pktl;
|
AVPacket *pkt = matroska->pkt;
|
||||||
|
|
||||||
ret = av_new_packet(pkt, a);
|
ret = av_new_packet(pkt, a);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -3375,7 +3381,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska,
|
|||||||
uint64_t duration,
|
uint64_t duration,
|
||||||
int64_t pos)
|
int64_t pos)
|
||||||
{
|
{
|
||||||
AVPacket pktl, *pkt = &pktl;
|
AVPacket *pkt = matroska->pkt;
|
||||||
uint8_t *id, *settings, *text, *buf;
|
uint8_t *id, *settings, *text, *buf;
|
||||||
int id_len, settings_len, text_len;
|
int id_len, settings_len, text_len;
|
||||||
uint8_t *p, *q;
|
uint8_t *p, *q;
|
||||||
@ -3492,7 +3498,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
|
|||||||
{
|
{
|
||||||
uint8_t *pkt_data = data;
|
uint8_t *pkt_data = data;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
AVPacket pktl, *pkt = &pktl;
|
AVPacket *pkt = matroska->pkt;
|
||||||
|
|
||||||
if (st->codecpar->codec_id == AV_CODEC_ID_WAVPACK) {
|
if (st->codecpar->codec_id == AV_CODEC_ID_WAVPACK) {
|
||||||
res = matroska_parse_wavpack(track, &pkt_data, &pkt_size);
|
res = matroska_parse_wavpack(track, &pkt_data, &pkt_size);
|
||||||
@ -3522,7 +3528,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
|
|||||||
if (!pkt_size && !additional_size)
|
if (!pkt_size && !additional_size)
|
||||||
goto no_output;
|
goto no_output;
|
||||||
|
|
||||||
av_init_packet(pkt);
|
av_packet_unref(pkt);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
pkt->buf = av_buffer_create(pkt_data, pkt_size + AV_INPUT_BUFFER_PADDING_SIZE,
|
pkt->buf = av_buffer_create(pkt_data, pkt_size + AV_INPUT_BUFFER_PADDING_SIZE,
|
||||||
NULL, NULL, 0);
|
NULL, NULL, 0);
|
||||||
@ -3896,6 +3902,7 @@ static int matroska_read_close(AVFormatContext *s)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
matroska_clear_queue(matroska);
|
matroska_clear_queue(matroska);
|
||||||
|
av_packet_free(&matroska->pkt);
|
||||||
|
|
||||||
for (n = 0; n < matroska->tracks.nb_elem; n++)
|
for (n = 0; n < matroska->tracks.nb_elem; n++)
|
||||||
if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO)
|
if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO)
|
||||||
|
Reference in New Issue
Block a user