You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avformat/wc3movie: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@@ -69,7 +69,7 @@ typedef struct Wc3DemuxContext {
|
|||||||
int video_stream_index;
|
int video_stream_index;
|
||||||
int audio_stream_index;
|
int audio_stream_index;
|
||||||
|
|
||||||
AVPacket vpkt;
|
AVPacket *vpkt;
|
||||||
|
|
||||||
} Wc3DemuxContext;
|
} Wc3DemuxContext;
|
||||||
|
|
||||||
@@ -77,8 +77,7 @@ static int wc3_read_close(AVFormatContext *s)
|
|||||||
{
|
{
|
||||||
Wc3DemuxContext *wc3 = s->priv_data;
|
Wc3DemuxContext *wc3 = s->priv_data;
|
||||||
|
|
||||||
if (wc3->vpkt.size > 0)
|
av_packet_free(&wc3->vpkt);
|
||||||
av_packet_unref(&wc3->vpkt);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -110,8 +109,9 @@ static int wc3_read_header(AVFormatContext *s)
|
|||||||
wc3->height = WC3_DEFAULT_HEIGHT;
|
wc3->height = WC3_DEFAULT_HEIGHT;
|
||||||
wc3->pts = 0;
|
wc3->pts = 0;
|
||||||
wc3->video_stream_index = wc3->audio_stream_index = 0;
|
wc3->video_stream_index = wc3->audio_stream_index = 0;
|
||||||
av_init_packet(&wc3->vpkt);
|
wc3->vpkt = av_packet_alloc();
|
||||||
wc3->vpkt.data = NULL; wc3->vpkt.size = 0;
|
if (!wc3->vpkt)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
/* skip the first 3 32-bit numbers */
|
/* skip the first 3 32-bit numbers */
|
||||||
avio_skip(pb, 12);
|
avio_skip(pb, 12);
|
||||||
@@ -162,7 +162,7 @@ static int wc3_read_header(AVFormatContext *s)
|
|||||||
case PALT_TAG:
|
case PALT_TAG:
|
||||||
/* one of several palettes */
|
/* one of several palettes */
|
||||||
avio_seek(pb, -8, SEEK_CUR);
|
avio_seek(pb, -8, SEEK_CUR);
|
||||||
av_append_packet(pb, &wc3->vpkt, 8 + PALETTE_SIZE);
|
av_append_packet(pb, wc3->vpkt, 8 + PALETTE_SIZE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -248,18 +248,17 @@ static int wc3_read_packet(AVFormatContext *s,
|
|||||||
case SHOT_TAG:
|
case SHOT_TAG:
|
||||||
/* load up new palette */
|
/* load up new palette */
|
||||||
avio_seek(pb, -8, SEEK_CUR);
|
avio_seek(pb, -8, SEEK_CUR);
|
||||||
av_append_packet(pb, &wc3->vpkt, 8 + 4);
|
av_append_packet(pb, wc3->vpkt, 8 + 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VGA__TAG:
|
case VGA__TAG:
|
||||||
/* send out video chunk */
|
/* send out video chunk */
|
||||||
avio_seek(pb, -8, SEEK_CUR);
|
avio_seek(pb, -8, SEEK_CUR);
|
||||||
ret= av_append_packet(pb, &wc3->vpkt, 8 + size);
|
ret= av_append_packet(pb, wc3->vpkt, 8 + size);
|
||||||
// ignore error if we have some data
|
// ignore error if we have some data
|
||||||
if (wc3->vpkt.size > 0)
|
if (wc3->vpkt->size > 0)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
*pkt = wc3->vpkt;
|
av_packet_move_ref(pkt, wc3->vpkt);
|
||||||
wc3->vpkt.data = NULL; wc3->vpkt.size = 0;
|
|
||||||
pkt->stream_index = wc3->video_stream_index;
|
pkt->stream_index = wc3->video_stream_index;
|
||||||
pkt->pts = wc3->pts;
|
pkt->pts = wc3->pts;
|
||||||
packet_read = 1;
|
packet_read = 1;
|
||||||
|
Reference in New Issue
Block a user