[FFmpeg-cvslog] Merge commit 'c7ab0eb3050acdd3b8cab2c55fc9c1b2e8610a65'
James Almer
git at videolan.org
Tue Apr 4 20:50:07 EEST 2017
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Tue Apr 4 14:47:09 2017 -0300| [81cc33adc68ef43a6de522042e0b1050b54c9d86] | committer: James Almer
Merge commit 'c7ab0eb3050acdd3b8cab2c55fc9c1b2e8610a65'
* commit 'c7ab0eb3050acdd3b8cab2c55fc9c1b2e8610a65':
examples/decode_video: allocate the packet dynamically
Merged-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=81cc33adc68ef43a6de522042e0b1050b54c9d86
---
doc/examples/decode_video.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/doc/examples/decode_video.c b/doc/examples/decode_video.c
index 5c1c42c..613bc5c 100644
--- a/doc/examples/decode_video.c
+++ b/doc/examples/decode_video.c
@@ -92,7 +92,7 @@ int main(int argc, char **argv)
uint8_t *data;
size_t data_size;
int ret;
- AVPacket avpkt;
+ AVPacket *pkt;
if (argc <= 2) {
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
@@ -103,7 +103,9 @@ int main(int argc, char **argv)
avcodec_register_all();
- av_init_packet(&avpkt);
+ pkt = av_packet_alloc();
+ if (!pkt)
+ exit(1);
/* set end of buffer to 0 (this ensures that no overreading happens for damaged MPEG streams) */
memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);
@@ -158,7 +160,7 @@ int main(int argc, char **argv)
/* use the parser to split the data into frames */
data = inbuf;
while (data_size > 0) {
- ret = av_parser_parse2(parser, c, &avpkt.data, &avpkt.size,
+ ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size,
data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
if (ret < 0) {
fprintf(stderr, "Error while parsing\n");
@@ -167,10 +169,10 @@ int main(int argc, char **argv)
data += ret;
data_size -= ret;
- if (avpkt.size)
- decode(c, frame, &avpkt, outfilename);
- }
- }
+ if (pkt->size)
+ decode(c, frame, pkt, outfilename);
+ }
+ }
/* flush the decoder */
decode(c, frame, NULL, outfilename);
@@ -180,6 +182,7 @@ int main(int argc, char **argv)
av_parser_close(parser);
avcodec_free_context(&c);
av_frame_free(&frame);
+ av_packet_free(&pkt);
return 0;
}
======================================================================
diff --cc doc/examples/decode_video.c
index 5c1c42c,d6803ef..613bc5c
--- a/doc/examples/decode_video.c
+++ b/doc/examples/decode_video.c
@@@ -167,19 -162,20 +169,20 @@@ int main(int argc, char **argv
data += ret;
data_size -= ret;
- if (avpkt.size)
- decode(c, frame, &avpkt, outfilename);
- }
- }
+ if (pkt->size)
- decode(c, picture, pkt, outfilename);
++ decode(c, frame, pkt, outfilename);
+ }
+ }
/* flush the decoder */
- decode(c, picture, NULL, outfilename);
+ decode(c, frame, NULL, outfilename);
fclose(f);
av_parser_close(parser);
avcodec_free_context(&c);
- av_frame_free(&picture);
+ av_frame_free(&frame);
+ av_packet_free(&pkt);
return 0;
}
More information about the ffmpeg-cvslog
mailing list