[FFmpeg-devel] [PATCH 3/3] ffmpeg: allocate decoded_frame in init_input_stream.
Nicolas George
nicolas.george at normalesup.org
Sun Aug 19 17:53:16 CEST 2012
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
ffmpeg.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/ffmpeg.c b/ffmpeg.c
index 0d8abb4..57e7a5a 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1398,10 +1398,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
int i, ret, resample_changed;
AVRational decoded_frame_tb;
- if (!ist->decoded_frame && !(ist->decoded_frame = avcodec_alloc_frame()))
- return AVERROR(ENOMEM);
- else
- avcodec_get_frame_defaults(ist->decoded_frame);
+ avcodec_get_frame_defaults(ist->decoded_frame);
decoded_frame = ist->decoded_frame;
update_benchmark(NULL);
@@ -1522,10 +1519,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
AVRational *frame_sample_aspect;
float quality;
- if (!ist->decoded_frame && !(ist->decoded_frame = avcodec_alloc_frame()))
- return AVERROR(ENOMEM);
- else
- avcodec_get_frame_defaults(ist->decoded_frame);
+ avcodec_get_frame_defaults(ist->decoded_frame);
decoded_frame = ist->decoded_frame;
pkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);
@@ -1860,6 +1854,12 @@ static int init_input_stream(int ist_index, char *error, int error_len)
}
assert_codec_experimental(ist->st->codec, 0);
assert_avoptions(ist->opts);
+
+ if ((codec->type == AVMEDIA_TYPE_VIDEO || codec->type == AVMEDIA_TYPE_AUDIO) &&
+ !(ist->decoded_frame = avcodec_alloc_frame())) {
+ av_log(NULL, AV_LOG_FATAL, "Out of memory\n");
+ exit_program(1);
+ }
}
ist->next_pts = AV_NOPTS_VALUE;
--
1.7.10.4
More information about the ffmpeg-devel
mailing list