diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-03 23:04:50 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-10-03 20:50:49 +0200 |
commit | f495604361be7d662610cc046f31d50717cd648f (patch) | |
tree | fb21dedd7676bb6c51ac570cd4755b3b770cc4df | |
parent | 0230d125cb1252dbfeabe223ac6620d95fc37f2b (diff) | |
download | ffmpeg-f495604361be7d662610cc046f31d50717cd648f.tar.gz |
examples/extract_mvs: Do not use stack packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | doc/examples/extract_mvs.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c index 84f071075a..cc1311da91 100644 --- a/doc/examples/extract_mvs.c +++ b/doc/examples/extract_mvs.c @@ -124,7 +124,7 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type) int main(int argc, char **argv) { int ret = 0; - AVPacket pkt = { 0 }; + AVPacket *pkt = NULL; if (argc != 2) { fprintf(stderr, "Usage: %s <video>\n", argv[0]); @@ -159,13 +159,20 @@ int main(int argc, char **argv) goto end; } + pkt = av_packet_alloc(); + if (!pkt) { + fprintf(stderr, "Could not allocate AVPacket\n"); + ret = AVERROR(ENOMEM); + goto end; + } + printf("framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags\n"); /* read frames from the file */ - while (av_read_frame(fmt_ctx, &pkt) >= 0) { - if (pkt.stream_index == video_stream_idx) - ret = decode_packet(&pkt); - av_packet_unref(&pkt); + while (av_read_frame(fmt_ctx, pkt) >= 0) { + if (pkt->stream_index == video_stream_idx) + ret = decode_packet(pkt); + av_packet_unref(pkt); if (ret < 0) break; } @@ -177,5 +184,6 @@ end: avcodec_free_context(&video_dec_ctx); avformat_close_input(&fmt_ctx); av_frame_free(&frame); + av_packet_free(&pkt); return ret < 0; } |