Implementation for SWS scale (#33)

* Draft implementation for SWS scale

* Update go.mod

* Revert "Update go.mod"

This reverts commit 760fb8c427.

* Renaming to AllocSwsContext and remove ChangeResolution this should handled by users

* update example to use new name and remove ChangeResolution

* Follow scaling example from libav, update readme, improve sws

Change scaling example to an similar libav example
Update readme
Add func to UpdateScalingParameters
Rename AllocSwsContext to SwsGetContext
Using a type for scaling algos/flags

* Fix Errors in scale example

* Review Changes

Now using sws context flags
Restructer sws context and adding ned simpler methods to update the ctx
Update the example
Update the test

* Correctly handle error for buffer alloc in PrepareDestinationFrameForScaling

* Add more getter and setter for sws

Get/Set source w,h,pixfmt
Get/Set dst w,h,pixfmt
Get/Set sws flags

* Adding resolution get/set

* Use CachedContext when updating sws ctx

* Review changes

Reorder flags, and update them
# Update Example
Use renaming function to create sws context
Clean up
Use new framdata image funcs
# Sws scale context
New way to update the context
Use sws_scale_frame instead of sws_scale
Reordering funcs for get and set
# Sws sclate context flag
Add "Flag" for algo name
# Update sws test

* fix fmt error args bug

* Review Changes

Simpfy sws update
Use c.int for sws flags
update test
This commit is contained in:
Cacsjep
2024-01-30 10:25:15 +01:00
committed by GitHub
parent 2f469c933d
commit f836d58883
8 changed files with 472 additions and 30 deletions

View File

@@ -70,15 +70,6 @@ func TestFilterCommandFlags(t *testing.T) {
require.False(t, fs.Has(astiav.FilterCommandFlag(2)))
}
func TestFormatContextCtxFlags(t *testing.T) {
fs := astiav.NewFormatContextCtxFlags(astiav.FormatContextCtxFlag(1))
require.True(t, fs.Has(astiav.FormatContextCtxFlag(1)))
fs = fs.Add(astiav.FormatContextCtxFlag(2))
require.True(t, fs.Has(astiav.FormatContextCtxFlag(2)))
fs = fs.Del(astiav.FormatContextCtxFlag(2))
require.False(t, fs.Has(astiav.FormatContextCtxFlag(2)))
}
func TestFormatContextFlags(t *testing.T) {
fs := astiav.NewFormatContextFlags(astiav.FormatContextFlag(1))
require.True(t, fs.Has(astiav.FormatContextFlag(1)))
@@ -88,6 +79,15 @@ func TestFormatContextFlags(t *testing.T) {
require.False(t, fs.Has(astiav.FormatContextFlag(2)))
}
func TestFormatContextCtxFlags(t *testing.T) {
fs := astiav.NewFormatContextCtxFlags(astiav.FormatContextCtxFlag(1))
require.True(t, fs.Has(astiav.FormatContextCtxFlag(1)))
fs = fs.Add(astiav.FormatContextCtxFlag(2))
require.True(t, fs.Has(astiav.FormatContextCtxFlag(2)))
fs = fs.Del(astiav.FormatContextCtxFlag(2))
require.False(t, fs.Has(astiav.FormatContextCtxFlag(2)))
}
func TestFormatEventFlags(t *testing.T) {
fs := astiav.NewFormatEventFlags(astiav.FormatEventFlag(1))
require.True(t, fs.Has(astiav.FormatEventFlag(1)))
@@ -133,6 +133,15 @@ func TestSeekFlags(t *testing.T) {
require.False(t, fs.Has(astiav.SeekFlag(2)))
}
func TestSoftwareScaleContextFlags(t *testing.T) {
fs := astiav.NewSoftwareScaleContextFlags(astiav.SoftwareScaleContextFlag(1))
require.True(t, fs.Has(astiav.SoftwareScaleContextFlag(1)))
fs = fs.Add(astiav.SoftwareScaleContextFlag(2))
require.True(t, fs.Has(astiav.SoftwareScaleContextFlag(2)))
fs = fs.Del(astiav.SoftwareScaleContextFlag(2))
require.False(t, fs.Has(astiav.SoftwareScaleContextFlag(2)))
}
func TestStreamEventFlags(t *testing.T) {
fs := astiav.NewStreamEventFlags(astiav.StreamEventFlag(1))
require.True(t, fs.Has(astiav.StreamEventFlag(1)))