Mercurial > mplayer.hg
comparison libmpcodecs/vd_ffmpeg.c @ 8411:5630321c8026
ffmpeg cleanup/messup support
fixing a typo in vstats (found by Markus Liebl <lieblm at web dot de>)
printing qscale statistics
author | michael |
---|---|
date | Mon, 09 Dec 2002 09:12:23 +0000 |
parents | 03ee1d7deba5 |
children | 2670aec42989 |
comparison
equal
deleted
inserted
replaced
8410:9efd0c6e6307 | 8411:5630321c8026 |
---|---|
51 int vo_inited; | 51 int vo_inited; |
52 int convert; | 52 int convert; |
53 int best_csp; | 53 int best_csp; |
54 int b_age; | 54 int b_age; |
55 int ip_age[2]; | 55 int ip_age[2]; |
56 int qp_stat[32]; | |
57 double qp_sum; | |
58 double inv_qp_sum; | |
56 } vd_ffmpeg_ctx; | 59 } vd_ffmpeg_ctx; |
57 | 60 |
58 //#ifdef FF_POSTPROCESS | 61 //#ifdef FF_POSTPROCESS |
59 //unsigned int lavc_pp=0; | 62 //unsigned int lavc_pp=0; |
60 //#endif | 63 //#endif |
243 | 246 |
244 // uninit driver | 247 // uninit driver |
245 static void uninit(sh_video_t *sh){ | 248 static void uninit(sh_video_t *sh){ |
246 vd_ffmpeg_ctx *ctx = sh->context; | 249 vd_ffmpeg_ctx *ctx = sh->context; |
247 AVCodecContext *avctx = ctx->avctx; | 250 AVCodecContext *avctx = ctx->avctx; |
251 | |
252 if(lavc_param_vstats){ | |
253 int i; | |
254 for(i=1; i<32; i++){ | |
255 printf("QP: %d, count: %d\n", i, ctx->qp_stat[i]); | |
256 } | |
257 printf("Arithmetic mean of QP: %2.4f, Harmonic mean of QP: %2.4f\n", | |
258 ctx->qp_sum / avctx->coded_picture->coded_picture_number, | |
259 1.0/(ctx->inv_qp_sum / avctx->coded_picture->coded_picture_number) | |
260 ); | |
261 } | |
248 | 262 |
249 if (avcodec_close(avctx) < 0) | 263 if (avcodec_close(avctx) < 0) |
250 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec); | 264 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec); |
251 | 265 |
252 if (avctx->extradata_size) | 266 if (avctx->extradata_size) |
427 | 441 |
428 ctx->ip_age[0]++; | 442 ctx->ip_age[0]++; |
429 ctx->ip_age[1]++; | 443 ctx->ip_age[1]++; |
430 ctx->b_age=1; | 444 ctx->b_age=1; |
431 } | 445 } |
432 //pic->age= 256*256*256*64; | 446 #if LIBAVCODEC_BUILD >= 4644 |
433 //printf("G%X %X\n", pic->linesize[0], pic->data[0]); | 447 pic->type= FF_BUFFER_TYPE_USER; |
448 #endif | |
434 return 0; | 449 return 0; |
435 } | 450 } |
436 | 451 |
437 static void release_buffer(struct AVCodecContext *avctx, AVVideoFrame *pic){ | 452 static void release_buffer(struct AVCodecContext *avctx, AVVideoFrame *pic){ |
438 int i; | 453 int i; |
454 | |
455 #if LIBAVCODEC_BUILD >= 4644 | |
456 assert(pic->type == FF_BUFFER_TYPE_USER); | |
457 #endif | |
458 | |
439 for(i=0; i<4; i++){ | 459 for(i=0; i<4; i++){ |
440 pic->data[i]= NULL; | 460 pic->data[i]= NULL; |
441 } | 461 } |
442 //printf("R%X %X\n", pic->linesize[0], pic->data[0]); | 462 //printf("R%X %X\n", pic->linesize[0], pic->data[0]); |
443 } | 463 } |
526 } | 546 } |
527 } | 547 } |
528 | 548 |
529 all_len+=len; | 549 all_len+=len; |
530 all_frametime+=sh->frametime; | 550 all_frametime+=sh->frametime; |
531 fprintf(fvstats, "frame= %5d q= %f2.0d f_size= %6d s_size= %8.0fkB ", | 551 fprintf(fvstats, "frame= %5d q= %2.2f f_size= %6d s_size= %8.0fkB ", |
532 ++frame_number, pic->quality, len, (double)all_len/1024); | 552 ++frame_number, pic->quality, len, (double)all_len/1024); |
533 fprintf(fvstats, "time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", | 553 fprintf(fvstats, "time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", |
534 all_frametime, (double)(len*8)/sh->frametime/1000.0, | 554 all_frametime, (double)(len*8)/sh->frametime/1000.0, |
535 (double)(all_len*8)/all_frametime/1000.0); | 555 (double)(all_len*8)/all_frametime/1000.0); |
536 switch(pic->pict_type){ | 556 switch(pic->pict_type){ |
545 break; | 565 break; |
546 case FF_B_TYPE: | 566 case FF_B_TYPE: |
547 fprintf(fvstats, "type= B\n"); | 567 fprintf(fvstats, "type= B\n"); |
548 break; | 568 break; |
549 } | 569 } |
570 | |
571 ctx->qp_stat[(int)(pic->quality+0.5)]++; | |
572 ctx->qp_sum += pic->quality; | |
573 ctx->inv_qp_sum += 1.0/pic->quality; | |
574 | |
550 break; | 575 break; |
551 } | 576 } |
552 #endif | 577 #endif |
553 //-- | 578 //-- |
554 | 579 |