--- trunk/xvidcore/vfw/src/codec.c 2006/02/24 22:59:07 1685 +++ trunk/xvidcore/vfw/src/codec.c 2010/08/10 14:17:40 1890 @@ -421,6 +421,8 @@ xvid_plugin_single_t single; xvid_plugin_2pass1_t pass1; xvid_plugin_2pass2_t pass2; + xvid_plugin_lumimasking_t masking; + xvid_gbl_info_t info; int i; HANDLE hFile; const quality_t* quality_preset = (codec->config.quality==quality_table_num) ? @@ -442,6 +444,10 @@ init.debug = codec->config.debug; codec->xvid_global_func(0, XVID_GBL_INIT, &init, NULL); + memset(&info, 0, sizeof(info)); + info.version = XVID_VERSION; + codec->xvid_global_func(0, XVID_GBL_INFO, &info, NULL); + memset(&create, 0, sizeof(create)); create.version = XVID_VERSION; @@ -541,9 +547,11 @@ } /* lumimasking plugin */ - if ((profiles[codec->config.profile].flags & PROFILE_ADAPTQUANT) && codec->config.lum_masking) { + if ((profiles[codec->config.profile].flags & PROFILE_ADAPTQUANT) && (codec->config.lum_masking>0)) { + memset(&masking, 0, sizeof(masking)); + masking.method = (codec->config.lum_masking==2); plugins[create.num_plugins].func = codec->xvid_plugin_lumimasking_func; - plugins[create.num_plugins].param = NULL; + plugins[create.num_plugins].param = &masking; create.num_plugins++; } @@ -580,24 +588,31 @@ create.global |= XVID_GLOBAL_CLOSED_GOP; - /* dxn: restrict max bframes and enable packed bframes */ - if ((profiles[codec->config.profile].flags & PROFILE_EXTRA)) { - - if (create.max_bframes > profiles[codec->config.profile].xvid_max_bframes) - create.max_bframes = profiles[codec->config.profile].xvid_max_bframes; + /* restrict max bframes */ + if ((create.max_bframes > profiles[codec->config.profile].xvid_max_bframes) && (profiles[codec->config.profile].xvid_max_bframes >= 0)) + create.max_bframes = profiles[codec->config.profile].xvid_max_bframes; + /* DXN: enable packed bframes */ + if ((profiles[codec->config.profile].flags & PROFILE_PACKED)) { create.global |= XVID_GLOBAL_PACKED; } } } - /* dxn: always write divx5 userdata */ - if ((profiles[codec->config.profile].flags & PROFILE_EXTRA)) - create.global |= XVID_GLOBAL_DIVX5_USERDATA; + /* dxn: always write divx5 userdata */ + if ((profiles[codec->config.profile].flags & PROFILE_EXTRA)) + create.global |= XVID_GLOBAL_DIVX5_USERDATA; create.frame_drop_ratio = quality_preset->frame_drop_ratio; - create.num_threads = codec->config.num_threads; + /* Encoder threads */ + if (codec->config.num_threads == 0) + create.num_threads = info.num_threads; /* Autodetect */ + else if (codec->config.num_threads == 1) + create.num_threads = -1; /* Single-threaded, disable SMP */ + else + create.num_threads = codec->config.num_threads; + switch(codec->xvid_encore_func(0, XVID_ENC_CREATE, &create, NULL)) { @@ -984,6 +999,7 @@ LRESULT decompress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput) { + BITMAPINFOHEADER * inhdr = &lpbiInput->bmiHeader; xvid_gbl_init_t init; xvid_dec_create_t create; HKEY hKey; @@ -993,13 +1009,14 @@ memset(&init, 0, sizeof(init)); init.version = XVID_VERSION; init.cpu_flags = codec->config.cpu; - init.debug = codec->config.debug; + init.debug = codec->config.debug; codec->xvid_global_func(0, XVID_GBL_INIT, &init, NULL); memset(&create, 0, sizeof(create)); create.version = XVID_VERSION; create.width = lpbiInput->bmiHeader.biWidth; create.height = lpbiInput->bmiHeader.biHeight; + create.fourcc = inhdr->biCompression; switch(codec->xvid_decore_func(0, XVID_DEC_CREATE, &create, NULL)) { @@ -1021,11 +1038,11 @@ RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT "\\" XVID_REG_CHILD, 0, KEY_READ, &hKey); REG_GET_N("Brightness", pp_brightness, 0); - REG_GET_N("Deblock_Y", pp_dy, 0) - REG_GET_N("Deblock_UV", pp_duv, 0) - REG_GET_N("Dering_Y", pp_dry, 0) - REG_GET_N("Dering_UV", pp_druv, 0) - REG_GET_N("FilmEffect", pp_fe, 0) + REG_GET_N("Deblock_Y", pp_dy, 0); + REG_GET_N("Deblock_UV", pp_duv, 0); + REG_GET_N("Dering_Y", pp_dry, 0); + REG_GET_N("Dering_UV", pp_druv, 0); + REG_GET_N("FilmEffect", pp_fe, 0); RegCloseKey(hKey);