--- branches/dev-api-4/xvidcore/vfw/src/codec.c 2003/06/09 01:25:19 1053 +++ branches/dev-api-4/xvidcore/vfw/src/codec.c 2003/11/11 16:25:39 1203 @@ -49,11 +49,13 @@ #include #include +#include #include "vfwext.h" #include #include "debug.h" #include "codec.h" +#include "status.h" static const int pmvfast_presets[7] = { @@ -207,7 +209,7 @@ if (lpbiOutput == NULL) { - return sizeof(BITMAPV4HEADER); + return sizeof(BITMAPINFOHEADER); } memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); @@ -279,11 +281,17 @@ { xvid_plg_data_t *data = (xvid_plg_data_t *) param1; - DPRINTF("[%5i] type=%c Q:%2i length:%6i", - data->frame_num, - type2char(data->type), - data->quant, - data->length); + /* We don't use DPRINTF here because it's active only for _DEBUG + * builds and that activates lot of other debug printfs. We only + * want these all the time */ + char buf[1024]; + sprintf(buf, "[%5i] type=%c Q:%2i length:%6i", + data->frame_num, + type2char(data->type), + data->quant, + data->length); + OutputDebugString(buf); + return 0; } } @@ -362,17 +370,19 @@ case RC_MODE_2PASS2 : memset(&pass2, 0, sizeof(pass2)); pass2.version = XVID_VERSION; - pass2.bitrate = codec->config.bitrate * CONFIG_KBPS; + if (codec->config.use_2pass_bitrate) { + pass2.bitrate = codec->config.bitrate * CONFIG_KBPS; + }else{ + pass2.bitrate = -codec->config.desired_size; /* kilobytes */ + } pass2.filename = codec->config.stats; pass2.keyframe_boost = codec->config.keyframe_boost; /* keyframe boost percentage: [0..100...]; */ - pass2.payback_method = codec->config.bitrate_payback_method; - pass2.bitrate_payback_delay = codec->config.bitrate_payback_delay; pass2.curve_compression_high = codec->config.curve_compression_high; pass2.curve_compression_low = codec->config.curve_compression_low; + pass2.overflow_control_strength = codec->config.overflow_control_strength; pass2.max_overflow_improvement = codec->config.twopass_max_overflow_improvement; pass2.max_overflow_degradation = codec->config.twopass_max_overflow_degradation; - pass2.kftreshold = codec->config.kftreshold; pass2.kfreduction = codec->config.kfreduction; pass2.min_key_interval = codec->config.min_key_interval; pass2.container_frame_overhead = 24; /* AVI */ @@ -451,18 +461,25 @@ codec->framenum = 0; codec->keyspacing = 0; + if (codec->config.display_status) { + status_destroy_always(&codec->status); + status_create(&codec->status, codec->fincr, codec->fbase); + } + return ICERR_OK; } LRESULT compress_end(CODEC * codec) { - if (codec->ehandle != NULL) - { + if (codec->ehandle != NULL) { xvid_encore(codec->ehandle, XVID_ENC_DESTROY, NULL, NULL); codec->ehandle = NULL; } + if (codec->config.display_status) + status_destroy(&codec->status); + return ICERR_OK; } @@ -474,6 +491,8 @@ for (i=0; inum_zones && config->zones[i].frame <= framenum; i++) ; i--; + frame->type = config->zones[i].type; + if (config->zones[i].greyscale) { frame->vop_flags |= XVID_VOP_GREYSCALE; } @@ -517,7 +536,7 @@ } } - if ((profiles[codec->config.profile].flags & PROFILE_REDUCED) && + if ((profiles[codec->config.profile].flags & PROFILE_REDUCED) && codec->config.reduced_resolution) { frame.vol_flags |= XVID_VOL_REDUCED_ENABLE; frame.vop_flags |= XVID_VOP_REDUCED; /* XXX: need auto decion mode */ @@ -528,8 +547,10 @@ frame.motion |= XVID_ME_QUARTERPELREFINE16 | XVID_ME_QUARTERPELREFINE8; } - if ((profiles[codec->config.profile].flags & PROFILE_GMC) && codec->config.gmc) + if ((profiles[codec->config.profile].flags & PROFILE_GMC) && codec->config.gmc) { frame.vol_flags |= XVID_VOL_GMC; + frame.motion |= XVID_ME_GME_REFINE; + } if ((profiles[codec->config.profile].flags & PROFILE_INTERLACE) && codec->config.interlacing) frame.vol_flags |= XVID_VOL_INTERLACING; @@ -550,39 +571,44 @@ frame.vop_flags |= XVID_VOP_INTER4V; if (codec->config.chromame) - frame.vop_flags |= XVID_ME_CHROMA16 + XVID_ME_CHROMA8; + frame.motion |= XVID_ME_CHROMA_PVOP + XVID_ME_CHROMA_BVOP; + + if (codec->config.cartoon_mode) { + frame.vop_flags |= XVID_VOP_CARTOON; + frame.motion |= XVID_ME_DETECT_STATIC_MOTION; + } frame.motion |= pmvfast_presets[codec->config.motion_search]; switch (codec->config.vhq_mode) { case VHQ_MODE_DECISION : - frame.vop_flags |= XVID_VOP_MODEDECISION_BITS; + frame.vop_flags |= XVID_VOP_MODEDECISION_RD; break; case VHQ_LIMITED_SEARCH : - frame.vop_flags |= XVID_VOP_MODEDECISION_BITS; - frame.motion |= XVID_ME_HALFPELREFINE16_BITS; - frame.motion |= XVID_ME_QUARTERPELREFINE16_BITS; + frame.vop_flags |= XVID_VOP_MODEDECISION_RD; + frame.motion |= XVID_ME_HALFPELREFINE16_RD; + frame.motion |= XVID_ME_QUARTERPELREFINE16_RD; break; case VHQ_MEDIUM_SEARCH : - frame.vop_flags |= XVID_VOP_MODEDECISION_BITS; - frame.motion |= XVID_ME_HALFPELREFINE16_BITS; - frame.motion |= XVID_ME_HALFPELREFINE8_BITS; - frame.motion |= XVID_ME_QUARTERPELREFINE16_BITS; - frame.motion |= XVID_ME_QUARTERPELREFINE8_BITS; - frame.motion |= XVID_ME_CHECKPREDICTION_BITS; + frame.vop_flags |= XVID_VOP_MODEDECISION_RD; + frame.motion |= XVID_ME_HALFPELREFINE16_RD; + frame.motion |= XVID_ME_HALFPELREFINE8_RD; + frame.motion |= XVID_ME_QUARTERPELREFINE16_RD; + frame.motion |= XVID_ME_QUARTERPELREFINE8_RD; + frame.motion |= XVID_ME_CHECKPREDICTION_RD; break; case VHQ_WIDE_SEARCH : - frame.vop_flags |= XVID_VOP_MODEDECISION_BITS; - frame.motion |= XVID_ME_HALFPELREFINE16_BITS; - frame.motion |= XVID_ME_HALFPELREFINE8_BITS; - frame.motion |= XVID_ME_QUARTERPELREFINE16_BITS; - frame.motion |= XVID_ME_QUARTERPELREFINE8_BITS; - frame.motion |= XVID_ME_CHECKPREDICTION_BITS; - frame.motion |= XVID_ME_EXTSEARCH_BITS; + frame.vop_flags |= XVID_VOP_MODEDECISION_RD; + frame.motion |= XVID_ME_HALFPELREFINE16_RD; + frame.motion |= XVID_ME_HALFPELREFINE8_RD; + frame.motion |= XVID_ME_QUARTERPELREFINE16_RD; + frame.motion |= XVID_ME_QUARTERPELREFINE8_RD; + frame.motion |= XVID_ME_CHECKPREDICTION_RD; + frame.motion |= XVID_ME_EXTSEARCH_RD; break; default : @@ -644,6 +670,10 @@ return ICERR_UNSUPPORTED; } + if (codec->config.display_status && stats.type>0) { + status_update(&codec->status, stats.type, stats.length, stats.quant); + } + DPRINTF("{type=%i len=%i} length=%i", stats.type, stats.length, length); if (length == 0) /* no encoder output */