comparison libmpcodecs/vd_ffmpeg.c @ 34240:43b60a64debf

Detect codecs requiring too many references for DR also when they use buffer_hints.
author reimar
date Tue, 08 Nov 2011 20:24:35 +0000
parents 12bcb27faa26
children a52c5ff01dcd
comparison
equal deleted inserted replaced
34239:4e2f4bd081ce 34240:43b60a64debf
538 if (pic->buffer_hints) { 538 if (pic->buffer_hints) {
539 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Buffer hints: %u\n", pic->buffer_hints); 539 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Buffer hints: %u\n", pic->buffer_hints);
540 type = MP_IMGTYPE_TEMP; 540 type = MP_IMGTYPE_TEMP;
541 if (pic->buffer_hints & FF_BUFFER_HINTS_READABLE) 541 if (pic->buffer_hints & FF_BUFFER_HINTS_READABLE)
542 flags |= MP_IMGFLAG_READABLE; 542 flags |= MP_IMGFLAG_READABLE;
543 if (pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE) { 543 if (pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE ||
544 type = MP_IMGTYPE_IP; 544 pic->buffer_hints & FF_BUFFER_HINTS_REUSABLE) {
545 flags |= MP_IMGFLAG_PRESERVE; 545 ctx->ip_count++;
546 }
547 if (pic->buffer_hints & FF_BUFFER_HINTS_REUSABLE) {
548 type = MP_IMGTYPE_IP; 546 type = MP_IMGTYPE_IP;
549 flags |= MP_IMGFLAG_PRESERVE; 547 flags |= MP_IMGFLAG_PRESERVE;
550 } 548 }
551 flags|=(avctx->skip_idct<=AVDISCARD_DEFAULT && avctx->skip_frame<=AVDISCARD_DEFAULT && ctx->do_slices) ? 549 flags|=(avctx->skip_idct<=AVDISCARD_DEFAULT && avctx->skip_frame<=AVDISCARD_DEFAULT && ctx->do_slices) ?
552 MP_IMGFLAG_DRAW_CALLBACK:0; 550 MP_IMGFLAG_DRAW_CALLBACK:0;
559 }else{ 557 }else{
560 ctx->ip_count++; 558 ctx->ip_count++;
561 flags|= MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE 559 flags|= MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE
562 | (ctx->do_slices ? MP_IMGFLAG_DRAW_CALLBACK : 0); 560 | (ctx->do_slices ? MP_IMGFLAG_DRAW_CALLBACK : 0);
563 } 561 }
562 if(avctx->has_b_frames || ctx->b_count){
563 type= MP_IMGTYPE_IPB;
564 }else{
565 type= MP_IMGTYPE_IP;
566 }
564 } 567 }
565 568
566 if(init_vo(sh, avctx->pix_fmt) < 0){ 569 if(init_vo(sh, avctx->pix_fmt) < 0){
567 avctx->release_buffer= avcodec_default_release_buffer; 570 avctx->release_buffer= avcodec_default_release_buffer;
568 avctx->get_buffer= avcodec_default_get_buffer; 571 avctx->get_buffer= avcodec_default_get_buffer;
573 } 576 }
574 577
575 if (IMGFMT_IS_HWACCEL(ctx->best_csp)) { 578 if (IMGFMT_IS_HWACCEL(ctx->best_csp)) {
576 type = MP_IMGTYPE_NUMBERED | (0xffff << 16); 579 type = MP_IMGTYPE_NUMBERED | (0xffff << 16);
577 } else 580 } else
578 if (!pic->buffer_hints) { 581 if (type == MP_IMGTYPE_IP || type == MP_IMGTYPE_IPB) {
579 if(ctx->b_count>1 || ctx->ip_count>2){ 582 if(ctx->b_count>1 || ctx->ip_count>2){
580 mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_DRIFailure); 583 mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_DRIFailure);
581 584
582 ctx->do_dr1=0; //FIXME 585 ctx->do_dr1=0; //FIXME
583 // For frame-multithreading these contexts aren't 586 // For frame-multithreading these contexts aren't
589 if (pic->data[0]) 592 if (pic->data[0])
590 release_buffer(avctx, pic); 593 release_buffer(avctx, pic);
591 return avctx->get_buffer(avctx, pic); 594 return avctx->get_buffer(avctx, pic);
592 } 595 }
593 596
594 if(avctx->has_b_frames || ctx->b_count){
595 type= MP_IMGTYPE_IPB;
596 }else{
597 type= MP_IMGTYPE_IP;
598 }
599 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, type== MP_IMGTYPE_IPB ? "using IPB\n" : "using IP\n"); 597 mp_msg(MSGT_DECVIDEO, MSGL_DBG2, type== MP_IMGTYPE_IPB ? "using IPB\n" : "using IP\n");
600 } 598 }
601 599
602 if (ctx->best_csp == IMGFMT_RGB8 || ctx->best_csp == IMGFMT_BGR8) 600 if (ctx->best_csp == IMGFMT_RGB8 || ctx->best_csp == IMGFMT_BGR8)
603 flags |= MP_IMGFLAG_RGB_PALETTE; 601 flags |= MP_IMGFLAG_RGB_PALETTE;