mirror of https://git.ffmpeg.org/ffmpeg.git
fftools/ffmpeg_dec: move decoding counters from InputStream to Decoder
This is a step towards decoupling Decoder and InputStream.
This commit is contained in:
parent
5b0e4f945e
commit
9be3f80527
|
@ -285,6 +285,11 @@ typedef struct Decoder {
|
||||||
|
|
||||||
const uint8_t *subtitle_header;
|
const uint8_t *subtitle_header;
|
||||||
int subtitle_header_size;
|
int subtitle_header_size;
|
||||||
|
|
||||||
|
// number of frames/samples retrieved from the decoder
|
||||||
|
uint64_t frames_decoded;
|
||||||
|
uint64_t samples_decoded;
|
||||||
|
uint64_t decode_errors;
|
||||||
} Decoder;
|
} Decoder;
|
||||||
|
|
||||||
typedef struct InputStream {
|
typedef struct InputStream {
|
||||||
|
@ -346,12 +351,6 @@ typedef struct InputStream {
|
||||||
enum AVHWDeviceType hwaccel_device_type;
|
enum AVHWDeviceType hwaccel_device_type;
|
||||||
char *hwaccel_device;
|
char *hwaccel_device;
|
||||||
enum AVPixelFormat hwaccel_output_format;
|
enum AVPixelFormat hwaccel_output_format;
|
||||||
|
|
||||||
/* stats */
|
|
||||||
// number of frames/samples retrieved from the decoder
|
|
||||||
uint64_t frames_decoded;
|
|
||||||
uint64_t samples_decoded;
|
|
||||||
uint64_t decode_errors;
|
|
||||||
} InputStream;
|
} InputStream;
|
||||||
|
|
||||||
typedef struct InputFile {
|
typedef struct InputFile {
|
||||||
|
|
|
@ -445,14 +445,14 @@ static int transcode_subtitles(InputStream *ist, const AVPacket *pkt,
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(dp, AV_LOG_ERROR, "Error decoding subtitles: %s\n",
|
av_log(dp, AV_LOG_ERROR, "Error decoding subtitles: %s\n",
|
||||||
av_err2str(ret));
|
av_err2str(ret));
|
||||||
ist->decode_errors++;
|
dp->dec.decode_errors++;
|
||||||
return exit_on_error ? ret : 0;
|
return exit_on_error ? ret : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!got_output)
|
if (!got_output)
|
||||||
return pkt ? 0 : AVERROR_EOF;
|
return pkt ? 0 : AVERROR_EOF;
|
||||||
|
|
||||||
ist->frames_decoded++;
|
dp->dec.frames_decoded++;
|
||||||
|
|
||||||
// XXX the queue for transferring data to consumers runs
|
// XXX the queue for transferring data to consumers runs
|
||||||
// on AVFrames, so we wrap AVSubtitle in an AVBufferRef and put that
|
// on AVFrames, so we wrap AVSubtitle in an AVBufferRef and put that
|
||||||
|
@ -512,7 +512,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
|
||||||
pkt ? "packet" : "EOF", av_err2str(ret));
|
pkt ? "packet" : "EOF", av_err2str(ret));
|
||||||
|
|
||||||
if (ret != AVERROR_EOF) {
|
if (ret != AVERROR_EOF) {
|
||||||
ist->decode_errors++;
|
dp->dec.decode_errors++;
|
||||||
if (!exit_on_error)
|
if (!exit_on_error)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
@ -537,7 +537,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
|
||||||
return ret;
|
return ret;
|
||||||
} else if (ret < 0) {
|
} else if (ret < 0) {
|
||||||
av_log(dp, AV_LOG_ERROR, "Decoding error: %s\n", av_err2str(ret));
|
av_log(dp, AV_LOG_ERROR, "Decoding error: %s\n", av_err2str(ret));
|
||||||
ist->decode_errors++;
|
dp->dec.decode_errors++;
|
||||||
|
|
||||||
if (exit_on_error)
|
if (exit_on_error)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -567,7 +567,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
|
||||||
frame->time_base = dec->pkt_timebase;
|
frame->time_base = dec->pkt_timebase;
|
||||||
|
|
||||||
if (dec->codec_type == AVMEDIA_TYPE_AUDIO) {
|
if (dec->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||||
ist->samples_decoded += frame->nb_samples;
|
dp->dec.samples_decoded += frame->nb_samples;
|
||||||
|
|
||||||
audio_ts_process(dp, frame);
|
audio_ts_process(dp, frame);
|
||||||
} else {
|
} else {
|
||||||
|
@ -579,7 +579,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ist->frames_decoded++;
|
dp->dec.frames_decoded++;
|
||||||
|
|
||||||
ret = sch_dec_send(dp->sch, dp->sch_idx, frame);
|
ret = sch_dec_send(dp->sch, dp->sch_idx, frame);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -707,8 +707,8 @@ void *decoder_thread(void *arg)
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
err_rate = (ist->frames_decoded || ist->decode_errors) ?
|
err_rate = (dp->dec.frames_decoded || dp->dec.decode_errors) ?
|
||||||
ist->decode_errors / (ist->frames_decoded + ist->decode_errors) : 0.f;
|
dp->dec.decode_errors / (dp->dec.frames_decoded + dp->dec.decode_errors) : 0.f;
|
||||||
if (err_rate > max_error_rate) {
|
if (err_rate > max_error_rate) {
|
||||||
av_log(dp, AV_LOG_FATAL, "Decode error rate %g exceeds maximum %g\n",
|
av_log(dp, AV_LOG_FATAL, "Decode error rate %g exceeds maximum %g\n",
|
||||||
err_rate, max_error_rate);
|
err_rate, max_error_rate);
|
||||||
|
|
|
@ -796,9 +796,9 @@ static void demux_final_stats(Demuxer *d)
|
||||||
if (ist->decoding_needed) {
|
if (ist->decoding_needed) {
|
||||||
av_log(f, AV_LOG_VERBOSE,
|
av_log(f, AV_LOG_VERBOSE,
|
||||||
"%"PRIu64" frames decoded; %"PRIu64" decode errors",
|
"%"PRIu64" frames decoded; %"PRIu64" decode errors",
|
||||||
ist->frames_decoded, ist->decode_errors);
|
ist->decoder->frames_decoded, ist->decoder->decode_errors);
|
||||||
if (type == AVMEDIA_TYPE_AUDIO)
|
if (type == AVMEDIA_TYPE_AUDIO)
|
||||||
av_log(f, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded);
|
av_log(f, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->decoder->samples_decoded);
|
||||||
av_log(f, AV_LOG_VERBOSE, "; ");
|
av_log(f, AV_LOG_VERBOSE, "; ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue