Пример #1
0
        /// <summary>
        /// Get default number of ref-frames for given parameters
        /// </summary>
        /// <param name="oPreset">encoding preset</param>
        /// <param name="oTuningMode">tuning mode</param>
        /// <param name="oDevice">target device</param>
        /// <param name="iLevel">AVC-Level</param>
        /// <param name="hRes">horizontal resolution</param>
        /// <param name="vRes">vertical resolution</param>
        /// <returns>number of ref frames</returns>
        public static int GetDefaultNumberOfRefFrames(int oPreset, int oTuningMode, X264Device oDevice, int iLevel, int hRes, int vRes)
        {
            var iDefaultSetting = 1;

            switch (oPreset)
            {
            case 0:
            case 1:
            case 2: iDefaultSetting = 1; break;

            case 3:
            case 4: iDefaultSetting = 2; break;

            case 5: iDefaultSetting = 3; break;

            case 6: iDefaultSetting = 5; break;

            case 7: iDefaultSetting = 8; break;

            case 8:
            case 9: iDefaultSetting = 16; break;
            }

            if (oTuningMode == 1 && iDefaultSetting > 1) // animation
            {
                iDefaultSetting *= 2;
            }

            if (iDefaultSetting > 16)
            {
                iDefaultSetting = 16;
            }

            if (oDevice != null && oDevice.ReferenceFrames > -1)
            {
                iDefaultSetting = Math.Min(oDevice.ReferenceFrames, iDefaultSetting);
            }

            if (iLevel <= -1 || hRes <= 0 || vRes <= 0)
            {
                return(iDefaultSetting);
            }

            var iMaxRefForLevel = GetMaxRefForLevel(iLevel, hRes, vRes);

            if (iMaxRefForLevel > -1 && iMaxRefForLevel < iDefaultSetting)
            {
                iDefaultSetting = iMaxRefForLevel;
            }

            return(iDefaultSetting);
        }
Пример #2
0
 /// <summary>
 /// Get default number of ref-frames for given parameters
 /// </summary>
 /// <param name="oPreset">encoding preset</param>
 /// <param name="oTuningMode">tuning mode</param>
 /// <param name="oDevice">target device</param>
 /// <returns>number of ref frames</returns>
 public static int GetDefaultNumberOfRefFrames(int oPreset, int oTuningMode, X264Device oDevice)
 {
     return(GetDefaultNumberOfRefFrames(oPreset, oTuningMode, oDevice, -1, -1, -1));
 }
Пример #3
0
        /// <summary>
        /// Get default number of B-frames for given parameters
        /// </summary>
        /// <param name="oPresetLevel">encoding preset</param>
        /// <param name="oTuningMode">tuning mode</param>
        /// <param name="oAvcProfile">AVC-Profile</param>
        /// <param name="oDevice">Target device</param>
        /// <returns>number of b-frames</returns>
        public static int GetDefaultNumberOfBFrames(int oPresetLevel, int oTuningMode, int oAvcProfile, X264Device oDevice)
        {
            var iDefaultSetting = 0;

            if (oAvcProfile == 0) // baseline
            {
                return(iDefaultSetting);
            }

            switch (oPresetLevel)
            {
            case 0: iDefaultSetting = 0; break;

            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7: iDefaultSetting = 3; break;

            case 8: iDefaultSetting = 8; break;

            case 9: iDefaultSetting = 16; break;
            }

            if (oTuningMode == 1) // animation
            {
                iDefaultSetting += 2;
            }
            if (iDefaultSetting > 16)
            {
                iDefaultSetting = 16;
            }

            if (oDevice != null && oDevice.BFrames > -1)
            {
                return(Math.Min(oDevice.BFrames, iDefaultSetting));
            }
            return(iDefaultSetting);
        }