[FFmpeg-cvslog] examples/extract_mvs: Do not use stack packet
Andreas Rheinhardt
git at videolan.org
Sun Oct 3 23:48:30 EEST 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Sep 3 23:04:50 2021 +0200| [f495604361be7d662610cc046f31d50717cd648f] | committer: Andreas Rheinhardt
examples/extract_mvs: Do not use stack packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f495604361be7d662610cc046f31d50717cd648f
---
doc/examples/extract_mvs.c | 18 +++++++++++++-----
1 file 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;
}
More information about the ffmpeg-cvslog
mailing list