Skip to content

Commit

Permalink
Adding resolution get/set
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacsjep committed Jan 25, 2024
1 parent 5a50f31 commit 7a4e56a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
48 changes: 34 additions & 14 deletions software_scale_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,12 @@ func (ssc *SoftwareScaleContext) DestinationPixelFormat() PixelFormat {
return PixelFormat(ssc.dstFormat)
}

func (ssc *SoftwareScaleContext) DestinationWidth() int {
return int(ssc.dstW)
}

func (ssc *SoftwareScaleContext) SourceHeight() int {
return int(ssc.srcH)
}

func (ssc *SoftwareScaleContext) SourcePixelFormat() PixelFormat {
return PixelFormat(ssc.srcFormat)
func (ssc *SoftwareScaleContext) DestinationResolution() (int, int) {
return int(ssc.dstW), int(ssc.dstH)
}

func (ssc *SoftwareScaleContext) SourceWidth() int {
return int(ssc.srcW)
func (ssc *SoftwareScaleContext) DestinationWidth() int {
return int(ssc.dstW)
}

func (ssc *SoftwareScaleContext) Flags() SoftwareScaleContextFlags {
Expand All @@ -121,11 +113,21 @@ func (ssc *SoftwareScaleContext) SetDestinationPixelFormat(p PixelFormat) error
return ssc.updateContext()
}

func (ssc *SoftwareScaleContext) SetDestinationResolution(w int, h int) error {
ssc.dstW = C.int(w)
ssc.dstH = C.int(h)
return ssc.updateContext()
}

func (ssc *SoftwareScaleContext) SetDestinationWidth(i int) error {
ssc.dstW = C.int(i)
return ssc.updateContext()
}

func (ssc *SoftwareScaleContext) SetFlags(swscf SoftwareScaleContextFlags) {
ssc.flags = swscf
}

func (ssc *SoftwareScaleContext) SetSourceHeight(i int) error {
ssc.srcH = C.int(i)
return ssc.updateContext()
Expand All @@ -136,13 +138,31 @@ func (ssc *SoftwareScaleContext) SetSourcePixelFormat(p PixelFormat) error {
return ssc.updateContext()
}

func (ssc *SoftwareScaleContext) SetSourceResolution(w int, h int) error {
ssc.srcW = C.int(w)
ssc.srcH = C.int(h)
return ssc.updateContext()
}

func (ssc *SoftwareScaleContext) SetSourceWidth(i int) error {
ssc.srcW = C.int(i)
return ssc.updateContext()
}

func (ssc *SoftwareScaleContext) SetFlags(swscf SoftwareScaleContextFlags) {
ssc.flags = swscf
func (ssc *SoftwareScaleContext) SourceHeight() int {
return int(ssc.srcH)
}

func (ssc *SoftwareScaleContext) SourcePixelFormat() PixelFormat {
return PixelFormat(ssc.srcFormat)
}

func (ssc *SoftwareScaleContext) SourceResolution() (int, int) {
return int(ssc.srcW), int(ssc.srcH)
}

func (ssc *SoftwareScaleContext) SourceWidth() int {
return int(ssc.srcW)
}

func (sc *SoftwareScaleContext) Free() {
Expand Down
10 changes: 10 additions & 0 deletions software_scale_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,15 @@ func TestSoftwareScaleContext(t *testing.T) {
_, ycbcrOk := i2.(*image.YCbCr)
require.True(t, ycbcrOk)

require.NoError(t, swsc.SetDestinationResolution(640, 480))
w, h := swsc.DestinationResolution()
require.Equal(t, w, 640)
require.Equal(t, h, 480)

require.NoError(t, swsc.SetSourceResolution(480, 270))
w, h = swsc.SourceResolution()
require.Equal(t, w, 480)
require.Equal(t, h, 270)

defer swsc.Free()
}

0 comments on commit 7a4e56a

Please sign in to comment.