Merge commit '27085d1b47c3741cc0fac284c916127c4066d049'
* commit '27085d1b47c3741cc0fac284c916127c4066d049': avconv: only retry decoding on actual decoding errors Merged-by: Clément Bœsch <u@pkh.me>
This commit is contained in:
commit
928db51344
34
ffmpeg.c
34
ffmpeg.c
@ -2288,7 +2288,8 @@ static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame)
|
|||||||
return ret;
|
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;
|
AVFrame *decoded_frame;
|
||||||
AVCodecContext *avctx = ist->dec_ctx;
|
AVCodecContext *avctx = ist->dec_ctx;
|
||||||
@ -2304,6 +2305,8 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
|
|||||||
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);
|
||||||
|
if (ret < 0)
|
||||||
|
*decode_failed = 1;
|
||||||
|
|
||||||
if (ret >= 0 && avctx->sample_rate <= 0) {
|
if (ret >= 0 && avctx->sample_rate <= 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Sample rate %d invalid\n", avctx->sample_rate);
|
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;
|
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;
|
AVFrame *decoded_frame;
|
||||||
int i, ret = 0, err = 0;
|
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);
|
update_benchmark(NULL);
|
||||||
ret = decode(ist->dec_ctx, decoded_frame, got_output, pkt ? &avpkt : 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);
|
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
|
// The following line may be required in some cases where there is no parser
|
||||||
// or the parser does not has_b_frames correctly
|
// or the parser does not has_b_frames correctly
|
||||||
@ -2478,7 +2484,8 @@ fail:
|
|||||||
return err < 0 ? err : ret;
|
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;
|
AVSubtitle subtitle;
|
||||||
int free_sub = 1;
|
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);
|
check_decode_result(NULL, got_output, ret);
|
||||||
|
|
||||||
if (ret < 0 || !*got_output) {
|
if (ret < 0 || !*got_output) {
|
||||||
|
*decode_failed = 1;
|
||||||
if (!pkt->size)
|
if (!pkt->size)
|
||||||
sub2video_flush(ist);
|
sub2video_flush(ist);
|
||||||
return ret;
|
return ret;
|
||||||
@ -2606,16 +2614,19 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
|
|||||||
while (ist->decoding_needed) {
|
while (ist->decoding_needed) {
|
||||||
int duration = 0;
|
int duration = 0;
|
||||||
int got_output = 0;
|
int got_output = 0;
|
||||||
|
int decode_failed = 0;
|
||||||
|
|
||||||
ist->pts = ist->next_pts;
|
ist->pts = ist->next_pts;
|
||||||
ist->dts = ist->next_dts;
|
ist->dts = ist->next_dts;
|
||||||
|
|
||||||
switch (ist->dec_ctx->codec_type) {
|
switch (ist->dec_ctx->codec_type) {
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
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;
|
break;
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
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 (!repeating || !pkt || got_output) {
|
||||||
if (pkt && pkt->duration) {
|
if (pkt && pkt->duration) {
|
||||||
duration = av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
|
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:
|
case AVMEDIA_TYPE_SUBTITLE:
|
||||||
if (repeating)
|
if (repeating)
|
||||||
break;
|
break;
|
||||||
ret = transcode_subtitles(ist, &avpkt, &got_output);
|
ret = transcode_subtitles(ist, &avpkt, &got_output, &decode_failed);
|
||||||
if (!pkt && ret >= 0)
|
if (!pkt && ret >= 0)
|
||||||
ret = AVERROR_EOF;
|
ret = AVERROR_EOF;
|
||||||
break;
|
break;
|
||||||
@ -2652,9 +2663,14 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n",
|
if (decode_failed) {
|
||||||
ist->file_index, ist->st->index, av_err2str(ret));
|
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n",
|
||||||
if (exit_on_error)
|
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);
|
exit_program(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user