Skip to content

Commit

Permalink
Now checking whether decoder codec supports hardware device type in h…
Browse files Browse the repository at this point in the history
…ardware decode example
  • Loading branch information
asticode committed Nov 23, 2024
1 parent 4f133cd commit 93ff134
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions examples/hardware_decoding/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,17 @@ func main() {
}
defer s.decCodecContext.Free()

// Get codec hardware configs
hcs := s.decCodec.HardwareConfigs()
if len(hcs) == 0 {
log.Fatal(fmt.Errorf("main: decoder %s doesn't support device type %s", s.decCodec, hardwareDeviceType))
}

// Loop through codec hardware configs
for _, p := range s.decCodec.HardwareConfigs() {
for _, hc := range hcs {
// Valid hardware config
if p.MethodFlags().Has(astiav.CodecHardwareConfigMethodFlagHwDeviceCtx) && p.HardwareDeviceType() == hardwareDeviceType {
s.hardwarePixelFormat = p.PixelFormat()
if hc.MethodFlags().Has(astiav.CodecHardwareConfigMethodFlagHwDeviceCtx) && hc.HardwareDeviceType() == hardwareDeviceType {
s.hardwarePixelFormat = hc.PixelFormat()
break
}
}
Expand Down

0 comments on commit 93ff134

Please sign in to comment.