Based on a commit by Andreas Rheinhardt.
Unified · Split
| @@ -2332,15 +2332,11 @@ static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame) · 2331 unmodified lines | ||
| 2332 | 2332 | static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, |
| 2333 | 2333 | int *decode_failed) |
| 2334 | 2334 | { |
| 2335 | − AVFrame *decoded_frame; | |
| 2335 | + AVFrame *decoded_frame = ist->decoded_frame; | |
| 2336 | 2336 | AVCodecContext *avctx = ist->dec_ctx; |
| 2337 | 2337 | int ret, err = 0; |
| 2338 | 2338 | AVRational decoded_frame_tb; |
| 2339 | 2339 | |
| 2340 | − if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) | |
| 2341 | − return AVERROR(ENOMEM); | |
| 2342 | − decoded_frame = ist->decoded_frame; | |
| 2343 | − | |
| 2344 | 2340 | update_benchmark(NULL); |
| 2345 | 2341 | ret = decode(avctx, decoded_frame, got_output, pkt); |
| 2346 | 2342 | update_benchmark("decode_audio %d.%d", ist->file_index, ist->st->index); |
| @@ -2397,7 +2393,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, · 50 unmodified lines | ||
| 2397 | 2393 | static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *duration_pts, int eof, |
| 2398 | 2394 | int *decode_failed) |
| 2399 | 2395 | { |
| 2400 | − AVFrame *decoded_frame; | |
| 2396 | + AVFrame *decoded_frame = ist->decoded_frame; | |
| 2401 | 2397 | int i, ret = 0, err = 0; |
| 2402 | 2398 | int64_t best_effort_timestamp; |
| 2403 | 2399 | int64_t dts = AV_NOPTS_VALUE; |
| @@ -2408,9 +2404,6 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_ · 4 unmodified lines | ||
| 2408 | 2404 | if (!eof && pkt && pkt->size == 0) |
| 2409 | 2405 | return 0; |
| 2410 | 2406 | |
| 2411 | − if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) | |
| 2412 | − return AVERROR(ENOMEM); | |
| 2413 | − decoded_frame = ist->decoded_frame; | |
| 2414 | 2407 | if (ist->dts != AV_NOPTS_VALUE) |
| 2415 | 2408 | dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base); |
| 2416 | 2409 | if (pkt) { |
| @@ -889,6 +889,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) · 888 unmodified lines | ||
| 889 | 889 | exit_program(1); |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | + ist->decoded_frame = av_frame_alloc(); | |
| 893 | + if (!ist->decoded_frame) | |
| 894 | + exit_program(1); | |
| 895 | + | |
| 892 | 896 | ist->filter_frame = av_frame_alloc(); |
| 893 | 897 | if (!ist->filter_frame) |
| 894 | 898 | exit_program(1); |