mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-01 20:42:19 +00:00
ffmpeg: Allocate InputStream.decoded_frame early
Based on a commit by Andreas Rheinhardt. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
ee3d6a20f6
commit
e7f3279ba0
@ -2332,15 +2332,11 @@ static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame)
|
|||||||
static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output,
|
static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output,
|
||||||
int *decode_failed)
|
int *decode_failed)
|
||||||
{
|
{
|
||||||
AVFrame *decoded_frame;
|
AVFrame *decoded_frame = ist->decoded_frame;
|
||||||
AVCodecContext *avctx = ist->dec_ctx;
|
AVCodecContext *avctx = ist->dec_ctx;
|
||||||
int ret, err = 0;
|
int ret, err = 0;
|
||||||
AVRational decoded_frame_tb;
|
AVRational decoded_frame_tb;
|
||||||
|
|
||||||
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
decoded_frame = ist->decoded_frame;
|
|
||||||
|
|
||||||
update_benchmark(NULL);
|
update_benchmark(NULL);
|
||||||
ret = decode(avctx, decoded_frame, got_output, pkt);
|
ret = decode(avctx, decoded_frame, got_output, pkt);
|
||||||
update_benchmark("decode_audio %d.%d", ist->file_index, ist->st->index);
|
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,
|
|||||||
static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *duration_pts, int eof,
|
static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *duration_pts, int eof,
|
||||||
int *decode_failed)
|
int *decode_failed)
|
||||||
{
|
{
|
||||||
AVFrame *decoded_frame;
|
AVFrame *decoded_frame = ist->decoded_frame;
|
||||||
int i, ret = 0, err = 0;
|
int i, ret = 0, err = 0;
|
||||||
int64_t best_effort_timestamp;
|
int64_t best_effort_timestamp;
|
||||||
int64_t dts = AV_NOPTS_VALUE;
|
int64_t dts = AV_NOPTS_VALUE;
|
||||||
@ -2408,9 +2404,6 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_
|
|||||||
if (!eof && pkt && pkt->size == 0)
|
if (!eof && pkt && pkt->size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
decoded_frame = ist->decoded_frame;
|
|
||||||
if (ist->dts != AV_NOPTS_VALUE)
|
if (ist->dts != AV_NOPTS_VALUE)
|
||||||
dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);
|
dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);
|
||||||
if (pkt) {
|
if (pkt) {
|
||||||
|
@ -889,6 +889,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
|||||||
exit_program(1);
|
exit_program(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ist->decoded_frame = av_frame_alloc();
|
||||||
|
if (!ist->decoded_frame)
|
||||||
|
exit_program(1);
|
||||||
|
|
||||||
ist->filter_frame = av_frame_alloc();
|
ist->filter_frame = av_frame_alloc();
|
||||||
if (!ist->filter_frame)
|
if (!ist->filter_frame)
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user