diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 92e56ee80c..b377871980 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -349,7 +349,6 @@ typedef struct InputStream { AVCodecContext *dec_ctx; const AVCodec *dec; const AVCodecDescriptor *codec_desc; - AVPacket *pkt; AVRational framerate_guessed; diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index c62d10847a..f2040f2d74 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -33,6 +33,7 @@ struct Decoder { AVFrame *frame; + AVPacket *pkt; }; void dec_free(Decoder **pdec) @@ -43,6 +44,7 @@ void dec_free(Decoder **pdec) return; av_frame_free(&dec->frame); + av_packet_free(&dec->pkt); av_freep(pdec); } @@ -61,6 +63,10 @@ static int dec_alloc(Decoder **pdec) if (!dec->frame) goto fail; + dec->pkt = av_packet_alloc(); + if (!dec->pkt) + goto fail; + *pdec = dec; @@ -418,7 +424,7 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof) int ret; if (dec->codec_type == AVMEDIA_TYPE_SUBTITLE) - return transcode_subtitles(ist, pkt ? pkt : ist->pkt); + return transcode_subtitles(ist, pkt ? pkt : d->pkt); // With fate-indeo3-2, we're getting 0-sized packets before EOF for some // reason. This seems like a semi-critical bug. Don't trigger EOF, and diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 29691cf68b..c65c72f556 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -817,7 +817,6 @@ static void ist_free(InputStream **pist) dec_free(&ist->decoder); - av_packet_free(&ist->pkt); av_dict_free(&ist->decoder_opts); avsubtitle_free(&ist->prev_sub.subtitle); av_frame_free(&ist->sub2video.frame); @@ -1197,10 +1196,6 @@ static void add_input_streams(const OptionsContext *o, Demuxer *d) exit_program(1); } - ist->pkt = av_packet_alloc(); - if (!ist->pkt) - report_and_exit(AVERROR(ENOMEM)); - if (o->bitexact) ist->dec_ctx->flags |= AV_CODEC_FLAG_BITEXACT;