Revision 0888fd22 ffmpeg.c

View differences:

ffmpeg.c
162 162
extern int loop_input; /* currently a hack */
163 163
static int loop_output = AVFMT_NOOUTPUTLOOP;
164 164
static int genpts = 0;
165
static int qp_hist = 0;
165 166

  
166 167
static int gop_size = 12;
167 168
static int intra_only = 0;
......
1054 1055
    int frame_number, vid, i;
1055 1056
    double bitrate, ti1, pts;
1056 1057
    static int64_t last_time = -1;
1058
    static int qp_histogram[52];
1057 1059

  
1058 1060
    if (!is_last_report) {
1059 1061
        int64_t cur_time;
......
1086 1088
        }
1087 1089
        if (!vid && enc->codec_type == CODEC_TYPE_VIDEO) {
1088 1090
            frame_number = ost->frame_number;
1089
            snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d q=%2.1f ",
1090
                    frame_number, enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : 0);
1091
            snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d q=%3.1f ",
1092
                    frame_number, enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
1091 1093
            if(is_last_report)
1092 1094
                snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
1095
            if(qp_hist && enc->coded_frame){
1096
                int j;
1097
                int qp= lrintf(enc->coded_frame->quality/(float)FF_QP2LAMBDA);
1098
                if(qp>=0 && qp<sizeof(qp_histogram)/sizeof(int))
1099
                    qp_histogram[qp]++;
1100
                for(j=0; j<32; j++)
1101
                    snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log(qp_histogram[j]+1)/log(2)));
1102
            }
1093 1103
            if (enc->flags&CODEC_FLAG_PSNR){
1094 1104
                int j;
1095 1105
                double error, error_sum=0;
......
4097 4107
    { "skip_exp", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&frame_skip_exp}, "frame skip exponent", "exponent" },
4098 4108
    { "newvideo", OPT_VIDEO, {(void*)opt_new_video_stream}, "add a new video stream to the current output stream" },
4099 4109
    { "genpts", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&genpts }, "generate pts" },
4110
    { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show QP histogram" },
4100 4111

  
4101 4112
    /* audio options */
4102 4113
    { "ab", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_bitrate}, "set audio bitrate (in kbit/s)", "bitrate", },

Also available in: Unified diff