[FFmpeg-devel] [PATCH] Fix for ticket 6796 (ffprobe show_frames ts dvbsubs infinate loop)
Hendrik Leppkes
h.leppkes at gmail.com
Sat Dec 2 02:05:26 EET 2017
On Sat, Dec 2, 2017 at 12:55 AM, Colin NG <colin_ng at hotmail.com> wrote:
> ---
> fftools/ffprobe.c | 5 +++++
> libavcodec/decode.c | 5 ++++-
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index 0e7a771..20b64ef 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -2276,10 +2276,14 @@ static av_always_inline int process_frame(WriterContext *w,
>
> case AVMEDIA_TYPE_SUBTITLE:
> ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_frame, pkt);
> + if (ret == AVERROR(EINVAL) || ret == AVERROR_INVALIDDATA) {
> + ret = 0;
> + }
Ignoring certain error codes doesn't seem correct. If decoding of a
subtitle fails, it should be handled somewhere, not just ignored.
> @@ -2290,6 +2294,7 @@ static av_always_inline int process_frame(WriterContext *w,
> if (got_frame) {
> int is_sub = (par->codec_type == AVMEDIA_TYPE_SUBTITLE);
> nb_streams_frames[pkt->stream_index]++;
> + got_frame = 0;
> if (do_show_frames)
> if (is_sub)
> show_subtitle(w, &sub, ifile->streams[pkt->stream_index].st, fmt_ctx);
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 3f5b086..d6cc671 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1024,7 +1024,10 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
> if (avctx->pkt_timebase.num && avpkt->pts != AV_NOPTS_VALUE)
> sub->pts = av_rescale_q(avpkt->pts,
> avctx->pkt_timebase, AV_TIME_BASE_Q);
> - ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded);
> + ret = avctx->codec->decode(avctx, sub, &pkt_recoded.size, &pkt_recoded);
> + if (ret == avpkt->size) {
> + *got_sub_ptr = 1;
> + }
> av_assert1((ret >= 0) >= !!*got_sub_ptr &&
> !!*got_sub_ptr >= !!sub->num_rects);
>
This looks definitely wrong. The decode API has a "*got_frame" ptr
there, not any size parameter, and additionally just because it
consumed data it does not mean any data was actually output.
- Hendrik
More information about the ffmpeg-devel
mailing list