Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Removing PreviewResolution as this should match Video.
Browse files Browse the repository at this point in the history
  • Loading branch information
techyian committed May 13, 2017
1 parent b32dcec commit 49e338d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
32 changes: 8 additions & 24 deletions src/MMALSharp/Components/MMALCameraComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public MMALCameraComponent() : base(MMALParameters.MMAL_COMPONENT_DEFAULT_CAMERA
this.CameraInfo.MaxHeight,
0,
1,
MMALCameraConfig.PreviewResolution.Width,
MMALCameraConfig.PreviewResolution.Height,
MMALCameraConfig.VideoResolution.Width,
MMALCameraConfig.VideoResolution.Height,
3,
0,
0,
Expand Down Expand Up @@ -138,26 +138,10 @@ internal void Initialise()

private void InitialisePreview()
{
if (MMALCameraConfig.PreviewResolution.Width == 0 || MMALCameraConfig.PreviewResolution.Width > this.CameraInfo.MaxWidth)
{
MMALCameraConfig.PreviewResolution.Width = this.CameraInfo.MaxWidth;
}

if (MMALCameraConfig.PreviewResolution.Height == 0 || MMALCameraConfig.PreviewResolution.Height > this.CameraInfo.MaxHeight)
{
MMALCameraConfig.PreviewResolution.Height = this.CameraInfo.MaxHeight;
}

if (MMALCameraConfig.VideoResolution != null && MMALCameraConfig.PreviewResolution.CompareTo(MMALCameraConfig.VideoResolution) > 0)
{
//HW limitation means Preview must be the same as Video resolution if applicable. Does not apply for still capture.
MMALCameraConfig.PreviewResolution = MMALCameraConfig.VideoResolution;
}

var vFormat = new MMAL_VIDEO_FORMAT_T(
MMALUtil.VCOS_ALIGN_UP(MMALCameraConfig.PreviewResolution.Width, 32),
MMALUtil.VCOS_ALIGN_UP(MMALCameraConfig.PreviewResolution.Height, 16),
new MMAL_RECT_T(0, 0, MMALCameraConfig.PreviewResolution.Width, MMALCameraConfig.PreviewResolution.Height),
MMALUtil.VCOS_ALIGN_UP(MMALCameraConfig.VideoResolution.Width, 32),
MMALUtil.VCOS_ALIGN_UP(MMALCameraConfig.VideoResolution.Height, 16),
new MMAL_RECT_T(0, 0, MMALCameraConfig.VideoResolution.Width, MMALCameraConfig.VideoResolution.Height),
new MMAL_RATIONAL_T(0, 1),
this.PreviewPort.Ptr->Format->es->video.Par,
this.PreviewPort.Ptr->Format->es->video.ColorSpace
Expand Down Expand Up @@ -227,7 +211,7 @@ private void InitialiseStill()
{
MMALCameraConfig.StillResolution.Height = this.CameraInfo.MaxHeight;
}

var vFormat = new MMAL_VIDEO_FORMAT_T();

if (MMALCameraConfig.StillEncoding == MMALEncoding.MMAL_ENCODING_RGB32 ||
Expand Down Expand Up @@ -262,12 +246,12 @@ private void InitialiseStill()
this.StillPort.Ptr->Format->es->video = vFormat;
this.StillPort.Ptr->Format->encoding = MMALCameraConfig.StillEncoding.EncodingVal;
this.StillPort.Ptr->Format->encodingVariant = MMALCameraConfig.StillSubFormat.EncodingVal;

if (MMALCameraConfig.Debug)
Console.WriteLine("Commit still");

this.StillPort.Commit();

this.StillPort.Ptr->BufferNum = Math.Max(this.StillPort.BufferNumRecommended,
this.StillPort.BufferNumMin);

Expand Down
4 changes: 1 addition & 3 deletions src/MMALSharp/MMALCameraConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ public static class MMALCameraConfig
*/
public static MMALEncoding PreviewEncoding { get; set; } = MMALEncoding.MMAL_ENCODING_OPAQUE;
public static MMALEncoding PreviewSubformat { get; set; } = MMALEncoding.MMAL_ENCODING_I420;

public static Resolution PreviewResolution { get; set; } = new Resolution(1024, 768);


/*
* -----------------------------------------------------------------------------------------------------------
* Camera video port specific properties
Expand Down
2 changes: 1 addition & 1 deletion src/MMALSharp/MMALPortBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public int BufferSize
/// <summary>
/// Delegate for native port callback
/// </summary>
public MMALSharp.Native.MMALPort.MMAL_PORT_BH_CB_T NativeCallback { get; set; }
internal MMALSharp.Native.MMALPort.MMAL_PORT_BH_CB_T NativeCallback { get; set; }

/// <summary>
/// Delegate we use to do further processing on buffer headers when they're received by the native callback delegate
Expand Down

0 comments on commit 49e338d

Please sign in to comment.