You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avfilter/lavfutils: Avoid initializing packet
av_read_frame() can handle uninitialized packets. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
@@ -35,8 +35,6 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
|
|||||||
AVPacket pkt;
|
AVPacket pkt;
|
||||||
AVDictionary *opt=NULL;
|
AVDictionary *opt=NULL;
|
||||||
|
|
||||||
av_init_packet(&pkt);
|
|
||||||
|
|
||||||
iformat = av_find_input_format("image2pipe");
|
iformat = av_find_input_format("image2pipe");
|
||||||
if ((ret = avformat_open_input(&format_ctx, filename, iformat, NULL)) < 0) {
|
if ((ret = avformat_open_input(&format_ctx, filename, iformat, NULL)) < 0) {
|
||||||
av_log(log_ctx, AV_LOG_ERROR,
|
av_log(log_ctx, AV_LOG_ERROR,
|
||||||
@@ -89,6 +87,7 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = avcodec_decode_video2(codec_ctx, frame, &frame_decoded, &pkt);
|
ret = avcodec_decode_video2(codec_ctx, frame, &frame_decoded, &pkt);
|
||||||
|
av_packet_unref(&pkt);
|
||||||
if (ret < 0 || !frame_decoded) {
|
if (ret < 0 || !frame_decoded) {
|
||||||
av_log(log_ctx, AV_LOG_ERROR, "Failed to decode image from file\n");
|
av_log(log_ctx, AV_LOG_ERROR, "Failed to decode image from file\n");
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
@@ -107,7 +106,6 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
|
|||||||
av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, *pix_fmt, *w, *h);
|
av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, *pix_fmt, *w, *h);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
av_packet_unref(&pkt);
|
|
||||||
avcodec_free_context(&codec_ctx);
|
avcodec_free_context(&codec_ctx);
|
||||||
avformat_close_input(&format_ctx);
|
avformat_close_input(&format_ctx);
|
||||||
av_frame_free(&frame);
|
av_frame_free(&frame);
|
||||||
|
Reference in New Issue
Block a user