Exemplo n.º 1
0
        /// <summary>
        /// Gets the final size and PAR of the video, given anamorphic inputs.
        /// </summary>
        /// <param name="anamorphicGeometry">Anamorphic inputs.</param>
        /// <returns>The final size and PAR of the video.</returns>
        public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry)
        {
            string encode = JsonSerializer.Serialize(anamorphicGeometry, JsonSettings.Options);
            IntPtr json   = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
            string result = Marshal.PtrToStringAnsi(json);

            return(JsonSerializer.Deserialize <Geometry>(result, JsonSettings.Options));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the final size and PAR of the video, given anamorphic inputs.
        /// </summary>
        /// <param name="anamorphicGeometry">Anamorphic inputs.</param>
        /// <returns>The final size and PAR of the video.</returns>
        public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry)
        {
            string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            IntPtr json   = hbFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
            string result = Marshal.PtrToStringAnsi(json);

            return(JsonConvert.DeserializeObject <Geometry>(result));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Finds output geometry for the given preview settings and title.
        /// </summary>
        /// <param name="settings">
        /// The preview settings.
        /// </param>
        /// <param name="title">
        /// Information on the title to consider.
        /// </param>
        /// <returns>
        /// Geometry Information
        /// </returns>
        public static Geometry CreateGeometry(PreviewSettings settings, SourceVideoInfo title)
        {
            int settingMode = settings.KeepDisplayAspect ? 0x04 : 0;

            // Sanitize the Geometry First.
            AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry
            {
                SourceGeometry = new Geometry
                {
                    Width  = title.Resolution.Width,
                    Height = title.Resolution.Height,
                    PAR    = new PAR {
                        Num = title.ParVal.Width, Den = title.ParVal.Height
                    }
                },
                DestSettings = new DestSettings
                {
                    AnamorphicMode = (int)settings.Anamorphic,
                    Geometry       =
                    {
                        Width  = settings.Width,
                        Height = settings.Height,
                        PAR    = new PAR
                        {
                            Num = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : settings.PixelAspectX,
                            Den = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : settings.PixelAspectY,
                        }
                    },
                    Keep = settingMode,
                    Crop = new List <int> {
                        settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right
                    },
                    Modulus   = settings.Modulus ?? 16,
                    MaxWidth  = settings.MaxWidth,
                    MaxHeight = settings.MaxHeight,
                    ItuPAR    = false
                }
            };

            if (settings.Anamorphic == Anamorphic.Custom)
            {
                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR {
                    Num = settings.PixelAspectX, Den = settings.PixelAspectY
                };
            }
            else
            {
                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR {
                    Num = title.ParVal.Width, Den = title.ParVal.Height
                };
            }

            return(HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry));
        }
Exemplo n.º 4
0
        /// <summary>
        /// The create geometry.
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        /// <param name="title">
        /// The current title.
        /// </param>
        /// <param name="keepWidthOrHeight">
        /// Keep Width or Height. (Not Display Aspect)
        /// </param>
        /// <returns>
        /// The <see cref="Geometry"/>.
        /// </returns>
        public static Geometry CreateGeometry(EncodeTask job, SourceVideoInfo title, KeepSetting keepWidthOrHeight) // Todo remove the need for these objects. Should use simpler objects.
        {
            int settingMode = (int)keepWidthOrHeight + (job.KeepDisplayAspect ? 0x04 : 0);

            // Sanitize the Geometry First.
            AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry
            {
                SourceGeometry = new Geometry
                {
                    Width  = title.Resolution.Width,
                    Height = title.Resolution.Height,
                    PAR    = new PAR {
                        Num = title.ParVal.Width, Den = title.ParVal.Height
                    }
                },
                DestSettings = new DestSettings
                {
                    AnamorphicMode = (int)job.Anamorphic,
                    Geometry       =
                    {
                        Width  = job.Width ?? 0,
                        Height = job.Height ?? 0,
                        PAR    = new PAR
                        {
                            Num = job.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : job.PixelAspectX,
                            Den = job.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : job.PixelAspectY,
                        }
                    },
                    Keep = settingMode,
                    Crop = new List <int> {
                        job.Cropping.Top, job.Cropping.Bottom, job.Cropping.Left, job.Cropping.Right
                    },
                    Modulus   = job.Modulus ?? 16,
                    MaxWidth  = job.MaxWidth ?? 0,
                    MaxHeight = job.MaxHeight ?? 0,
                    ItuPAR    = false
                }
            };

            if (job.Anamorphic == Anamorphic.Custom)
            {
                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR {
                    Num = job.PixelAspectX, Den = job.PixelAspectY
                };
            }
            else
            {
                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR {
                    Num = title.ParVal.Width, Den = title.ParVal.Height
                };
            }

            return(HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry));
        }
Exemplo n.º 5
0
        /// <summary>
        /// The create geometry.
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        /// <param name="title">
        /// The current title.
        /// </param>
        /// <param name="keepWidthOrHeight">
        /// Keep Width or Height. (Not Display Aspect)
        /// </param>
        /// <returns>
        /// The <see cref="Scan.Geometry"/>.
        /// </returns>
        public static Geometry CreateGeometry(EncodeJob job, Title title, KeepSetting keepWidthOrHeight) // Todo remove the need for these objects. Should use simpler objects.
        {
            int settingMode = (int)keepWidthOrHeight + (job.KeepDisplayAspect ? 0x04 : 0);

            // Sanatise the Geometry First.
            AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry
            {
                SourceGeometry = new SourceGeometry
                {
                    Width  = title.Resolution.Width,
                    Height = title.Resolution.Height,
                    PAR    = new PAR {
                        Num = title.ParVal.Width, Den = title.ParVal.Height
                    }
                },
                DestSettings = new DestSettings
                {
                    AnamorphicMode = (int)job.Anamorphic,
                    Geometry       =
                    {
                        Width = job.Width,                                                                    Height = job.Height,
                        PAR   = new PAR
                        {
                            Num = job.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : job.PixelAspectX,
                            Den = job.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : job.PixelAspectY,
                        }
                    },
                    Keep = settingMode,
                    Crop = new List <int> {
                        job.Cropping.Top, job.Cropping.Bottom, job.Cropping.Left, job.Cropping.Right
                    },
                    Modulus   = job.Modulus,
                    MaxWidth  = job.MaxWidth,
                    MaxHeight = job.MaxHeight,
                    ItuPAR    = false
                }
            };

            if (job.Anamorphic == Anamorphic.Custom)
            {
                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR {
                    Num = job.PixelAspectX, Den = job.PixelAspectY
                };
            }
            else
            {
                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR {
                    Num = title.ParVal.Width, Den = title.ParVal.Height
                };
            }

            string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            IntPtr           json           = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
            string           result         = Marshal.PtrToStringAnsi(json);
            AnamorphicResult resultGeometry = JsonConvert.DeserializeObject <AnamorphicResult>(result);

            // Setup the Destination Gemotry.
            Geometry geometry = new Geometry
            {
                Width  = resultGeometry.Width,
                Height = resultGeometry.Height,
                PAR    = resultGeometry.PAR
            };

            return(geometry);
        }