Commit 928db513 authored by Clément Bœsch's avatar Clément Bœsch

Merge commit '27085d1b'

* commit '27085d1b':
  avconv: only retry decoding on actual decoding errors
Merged-by: 's avatarClément Bœsch <u@pkh.me>
parents 204b4a7e 27085d1b
......@@ -2288,7 +2288,8 @@ static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame)
return ret;
}
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)
{
AVFrame *decoded_frame;
AVCodecContext *avctx = ist->dec_ctx;
......@@ -2304,6 +2305,8 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
update_benchmark(NULL);
ret = decode(avctx, decoded_frame, got_output, pkt);
update_benchmark("decode_audio %d.%d", ist->file_index, ist->st->index);
if (ret < 0)
*decode_failed = 1;
if (ret >= 0 && avctx->sample_rate <= 0) {
av_log(avctx, AV_LOG_ERROR, "Sample rate %d invalid\n", avctx->sample_rate);
......@@ -2349,7 +2352,8 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
return err < 0 ? err : ret;
}
static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int eof)
static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int eof,
int *decode_failed)
{
AVFrame *decoded_frame;
int i, ret = 0, err = 0;
......@@ -2388,6 +2392,8 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int eo
update_benchmark(NULL);
ret = decode(ist->dec_ctx, decoded_frame, got_output, pkt ? &avpkt : NULL);
update_benchmark("decode_video %d.%d", ist->file_index, ist->st->index);
if (ret < 0)
*decode_failed = 1;
// The following line may be required in some cases where there is no parser
// or the parser does not has_b_frames correctly
......@@ -2478,7 +2484,8 @@ fail:
return err < 0 ? err : ret;
}
static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output,
int *decode_failed)
{
AVSubtitle subtitle;
int free_sub = 1;
......@@ -2488,6 +2495,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
check_decode_result(NULL, got_output, ret);
if (ret < 0 || !*got_output) {
*decode_failed = 1;
if (!pkt->size)
sub2video_flush(ist);
return ret;
......@@ -2606,16 +2614,19 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
while (ist->decoding_needed) {
int duration = 0;
int got_output = 0;
int decode_failed = 0;
ist->pts = ist->next_pts;
ist->dts = ist->next_dts;
switch (ist->dec_ctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ret = decode_audio (ist, repeating ? NULL : &avpkt, &got_output);
ret = decode_audio (ist, repeating ? NULL : &avpkt, &got_output,
&decode_failed);
break;
case AVMEDIA_TYPE_VIDEO:
ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output, !pkt);
ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output, !pkt,
&decode_failed);
if (!repeating || !pkt || got_output) {
if (pkt && pkt->duration) {
duration = av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
......@@ -2638,7 +2649,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
case AVMEDIA_TYPE_SUBTITLE:
if (repeating)
break;
ret = transcode_subtitles(ist, &avpkt, &got_output);
ret = transcode_subtitles(ist, &avpkt, &got_output, &decode_failed);
if (!pkt && ret >= 0)
ret = AVERROR_EOF;
break;
......@@ -2652,9 +2663,14 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
}
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n",
ist->file_index, ist->st->index, av_err2str(ret));
if (exit_on_error)
if (decode_failed) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n",
ist->file_index, ist->st->index, av_err2str(ret));
} else {
av_log(NULL, AV_LOG_FATAL, "Error while processing the decoded "
"data for stream #%d:%d\n", ist->file_index, ist->st->index);
}
if (!decode_failed || exit_on_error)
exit_program(1);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment