Files
mediadevices/pkg/codec/vpx/vpx_image.go
T
Haily Nguyen a68a5ba4a6 Add VPX wrappers (#652)
* Add VPX improvements from pion-mediadevices

- Add vpx_image.go: VpxImage wrapper for vpx_image_t with convenient methods
- Move BitrateTracker to vpx package: More specific to VPX codec usage
- Add bitrate_tracker_test.go: Test coverage for VPX-specific bitrate tracking
- Remove generic codec-level BitrateTracker: Replaced by VPX-specific version

These changes improve VPX codec functionality and organization by:
1. Adding image handling utilities specific to VPX
2. Providing better bitrate tracking for VPX codecs
3. Improving code organization by moving VPX-specific code to VPX package

* Revert bitrate tracker changes

- Remove vpx-specific bitrate tracker files
- Restore original codec-level bitrate tracker and test
- Keep only the vpx_image.go addition from pion-mediadevices

* Add comprehensive unit tests for VpxImage

- Add vpx_image_test.go with full test coverage for VpxImage wrapper
- Test interface compliance and constructor behavior
- Test nil pointer handling (documents expected panic behavior)
- Test common video format constants and plane indices
- All tests pass and integrate with existing VPX test suite

This improves test coverage for the new VpxImage utility from pion-mediadevices.

* Add comprehensive unit tests for VpxImage

- Add vpx_image_test.go with full test coverage for VpxImage wrapper
- Test interface compliance and constructor behavior
- Test nil pointer handling (documents expected panic behavior)
- Test common video format constants and plane indices
- All tests pass and integrate with existing VPX test suite

This improves test coverage for the new VpxImage utility from pion-mediadevices.
2025-10-09 16:15:33 -07:00

41 lines
636 B
Go

package vpx
/*
#cgo pkg-config: vpx
#include <vpx/vpx_image.h>
*/
import "C"
import "unsafe"
type VpxImage struct {
img *C.vpx_image_t
}
func NewImageFromPtr(ptr *C.vpx_image_t) *VpxImage {
return &VpxImage{img: ptr}
}
func (i *VpxImage) Width() int {
return int(i.img.d_w)
}
func (i *VpxImage) Height() int {
return int(i.img.d_h)
}
func (i *VpxImage) YStride() int {
return int(i.img.stride[0])
}
func (i *VpxImage) UStride() int {
return int(i.img.stride[1])
}
func (i *VpxImage) VStride() int {
return int(i.img.stride[2])
}
func (i *VpxImage) Plane(n int) unsafe.Pointer {
return unsafe.Pointer(i.img.planes[n])
}