--- branches/dev-api-4/xvidcore/vfw/src/codec.c 2003/07/17 10:32:33 1091 +++ branches/dev-api-4/xvidcore/vfw/src/codec.c 2003/12/18 14:51:40 1277 @@ -49,6 +49,7 @@ #include #include +#include #include "vfwext.h" #include @@ -280,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, "[%6i] type=%c Q:%2i length:%6i", + data->frame_num, + type2char(data->type), + data->quant, + data->length); + OutputDebugString(buf); + return 0; } } @@ -371,15 +378,13 @@ 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.kfthreshold = codec->config.kfthreshold; pass2.container_frame_overhead = 24; /* AVI */ plugins[create.num_plugins].func = xvid_plugin_2pass2; @@ -484,9 +489,11 @@ int i; for (i=0; inum_zones && config->zones[i].frame <= framenum; i++) ; - i--; - frame->type = config->zones[i].type; + if (--i < 0) return; /* there are no zones, or we're before the first zone */ + + if (framenum == config->zones[i].frame) + frame->type = config->zones[i].type; if (config->zones[i].greyscale) { frame->vop_flags |= XVID_VOP_GREYSCALE; @@ -544,12 +551,27 @@ if ((profiles[codec->config.profile].flags & PROFILE_GMC) && codec->config.gmc) { frame.vol_flags |= XVID_VOL_GMC; - frame.motion |= XVID_GME_REFINE; + frame.motion |= XVID_ME_GME_REFINE; } if ((profiles[codec->config.profile].flags & PROFILE_INTERLACE) && codec->config.interlacing) frame.vol_flags |= XVID_VOL_INTERLACING; + if (codec->config.ar_mode == 0) { /* PAR */ + if (codec->config.display_aspect_ratio != 5) { + frame.par = codec->config.display_aspect_ratio + 1; + } else { + frame.par = XVID_PAR_EXT; + frame.par_width = codec->config.par_x; + frame.par_height= codec->config.par_y; + } + } else { /* AR */ + /* custom pixel aspect ratio -> calculated from DAR */ + frame.par = XVID_PAR_EXT; + frame.par_width = (100 * inhdr->biHeight) / codec->config.ar_y; + frame.par_height= (100 * inhdr->biWidth) / codec->config.ar_x;; + } + /* vop stuff */ frame.vop_flags |= XVID_VOP_HALFPEL; @@ -566,39 +588,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 : @@ -627,14 +654,7 @@ // force keyframe spacing in 2-pass 1st pass if (codec->config.motion_search == 0) - { frame.type = XVID_TYPE_IVOP; - } - else if (codec->keyspacing < codec->config.min_key_interval && codec->framenum) - { - DPRINTF("current frame forced to p-frame"); - frame.type = XVID_TYPE_PVOP; - } /* frame-based stuff */ apply_zone_modifiers(&frame, &codec->config, codec->framenum);