Skip to content

Commit

Permalink
Frame.Copy(dst *Frame) (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
oldma3095 authored and asticode committed Jan 7, 2025
1 parent a6280c7 commit ac7a8c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,8 @@ func (f *Frame) IsWritable() bool {
func (f *Frame) MakeWritable() error {
return newError(C.av_frame_make_writable(f.c))
}

// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#gaec4e92f6e1e75ffaf76e07586fb0c9ed
func (f *Frame) Copy(dst *Frame) error {
return newError(C.av_frame_copy(dst.c, f.c))
}
16 changes: 16 additions & 0 deletions frame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,20 @@ func TestFrame(t *testing.T) {
require.False(t, f6.IsWritable())
require.NoError(t, f6.MakeWritable())
require.True(t, f6.IsWritable())

f7 := AllocFrame()
require.NotNil(t, f7)
defer f7.Free()
align = 1
f7.SetHeight(f6.Height())
f7.SetPixelFormat(f6.PixelFormat())
f7.SetWidth(f6.Width())
require.NoError(t, f7.AllocBuffer(align))
require.NoError(t, f7.AllocImage(align))
require.NoError(t, f6.Copy(f7))
f6b, err := f6.Data().Bytes(align)
require.NoError(t, err)
f7b, err := f7.Data().Bytes(align)
require.NoError(t, err)
require.Equal(t, f6b, f7b)
}

0 comments on commit ac7a8c3

Please sign in to comment.