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;
|
||||
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;
|
||||
|
||||
typedef struct InputStream {
|
||||
|
@ -346,12 +351,6 @@ typedef struct InputStream {
|
|||
enum AVHWDeviceType hwaccel_device_type;
|
||||
char *hwaccel_device;
|
||||
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;
|
||||
|
||||
typedef struct InputFile {
|
||||
|
|
|
@ -445,14 +445,14 @@ static int transcode_subtitles(InputStream *ist, const AVPacket *pkt,
|
|||
if (ret < 0) {
|
||||
av_log(dp, AV_LOG_ERROR, "Error decoding subtitles: %s\n",
|
||||
av_err2str(ret));
|
||||
ist->decode_errors++;
|
||||
dp->dec.decode_errors++;
|
||||
return exit_on_error ? ret : 0;
|
||||
}
|
||||
|
||||
if (!got_output)
|
||||
return pkt ? 0 : AVERROR_EOF;
|
||||
|
||||
ist->frames_decoded++;
|
||||
dp->dec.frames_decoded++;
|
||||
|
||||
// XXX the queue for transferring data to consumers runs
|
||||
// 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));
|
||||
|
||||
if (ret != AVERROR_EOF) {
|
||||
ist->decode_errors++;
|
||||
dp->dec.decode_errors++;
|
||||
if (!exit_on_error)
|
||||
ret = 0;
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
|
|||
return ret;
|
||||
} else if (ret < 0) {
|
||||
av_log(dp, AV_LOG_ERROR, "Decoding error: %s\n", av_err2str(ret));
|
||||
ist->decode_errors++;
|
||||
dp->dec.decode_errors++;
|
||||
|
||||
if (exit_on_error)
|
||||
return ret;
|
||||
|
@ -567,7 +567,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
|
|||
frame->time_base = dec->pkt_timebase;
|
||||
|
||||
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);
|
||||
} 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);
|
||||
if (ret < 0) {
|
||||
|
@ -707,8 +707,8 @@ void *decoder_thread(void *arg)
|
|||
}
|
||||
ret = 0;
|
||||
|
||||
err_rate = (ist->frames_decoded || ist->decode_errors) ?
|
||||
ist->decode_errors / (ist->frames_decoded + ist->decode_errors) : 0.f;
|
||||
err_rate = (dp->dec.frames_decoded || dp->dec.decode_errors) ?
|
||||
dp->dec.decode_errors / (dp->dec.frames_decoded + dp->dec.decode_errors) : 0.f;
|
||||
if (err_rate > max_error_rate) {
|
||||
av_log(dp, AV_LOG_FATAL, "Decode error rate %g exceeds maximum %g\n",
|
||||
err_rate, max_error_rate);
|
||||
|
|
|
@ -796,9 +796,9 @@ static void demux_final_stats(Demuxer *d)
|
|||
if (ist->decoding_needed) {
|
||||
av_log(f, AV_LOG_VERBOSE,
|
||||
"%"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)
|
||||
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, "; ");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue