[FFmpeg-cvslog] ffmpeg: factorize quality calculation
Michael Niedermayer
git at videolan.org
Fri May 13 04:46:00 CEST 2011
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Apr 6 21:17:32 2011 +0200| [5da116a3fde9013846bd7b385cdde5ce2951869c] | committer: Anton Khirnov
ffmpeg: factorize quality calculation
Calculate quality value once per stream in print_report().
Also fix segfault, as coded_frame can be NULL.
Signed-off-by: Anton Khirnov <anton at khirnov.net>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5da116a3fde9013846bd7b385cdde5ce2951869c
---
ffmpeg.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/ffmpeg.c b/ffmpeg.c
index b5ff4cf..1c1be7c 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1322,26 +1322,25 @@ static void print_report(AVFormatContext **output_files,
ti1 = 1e10;
vid = 0;
for(i=0;i<nb_ostreams;i++) {
+ float q = -1;
ost = ost_table[i];
enc = ost->st->codec;
+ if (!ost->st->stream_copy && enc->coded_frame)
+ q = enc->coded_frame->quality/(float)FF_QP2LAMBDA;
if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
- snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ",
- !ost->st->stream_copy ?
- enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q);
}
if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
float t = (av_gettime()-timer_start) / 1000000.0;
frame_number = ost->frame_number;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
- frame_number, (t>1)?(int)(frame_number/t+0.5) : 0,
- !ost->st->stream_copy ?
- enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
+ frame_number, (t>1)?(int)(frame_number/t+0.5) : 0, q);
if(is_last_report)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
if(qp_hist){
int j;
- int qp= lrintf(enc->coded_frame->quality/(float)FF_QP2LAMBDA);
+ int qp = lrintf(q);
if(qp>=0 && qp<FF_ARRAY_ELEMS(qp_histogram))
qp_histogram[qp]++;
for(j=0; j<32; j++)
More information about the ffmpeg-cvslog
mailing list