Wideband autonomous SDR analysis engine forked from sdr-visual-suite
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

52 行
1.0KB

  1. package gpudemod
  2. type batchSlot struct {
  3. job ExtractJob
  4. out []complex64
  5. rate int
  6. active bool
  7. }
  8. type BatchRunner struct {
  9. eng *Engine
  10. slots []batchSlot
  11. slotBufs []slotBuffers
  12. }
  13. func NewBatchRunner(maxSamples int, sampleRate int) (*BatchRunner, error) {
  14. eng, err := New(maxSamples, sampleRate)
  15. if err != nil {
  16. return nil, err
  17. }
  18. return &BatchRunner{eng: eng}, nil
  19. }
  20. func (r *BatchRunner) Close() {
  21. if r == nil || r.eng == nil {
  22. return
  23. }
  24. r.freeSlotBuffers()
  25. r.eng.Close()
  26. r.eng = nil
  27. r.slots = nil
  28. }
  29. func (r *BatchRunner) prepare(jobs []ExtractJob) {
  30. if cap(r.slots) < len(jobs) {
  31. r.slots = make([]batchSlot, len(jobs))
  32. } else {
  33. r.slots = r.slots[:len(jobs)]
  34. }
  35. for i, job := range jobs {
  36. r.slots[i] = batchSlot{job: job, active: true}
  37. }
  38. }
  39. func (r *BatchRunner) ShiftFilterDecimateBatch(iq []complex64, jobs []ExtractJob) ([][]complex64, []int, error) {
  40. if r == nil || r.eng == nil {
  41. return nil, nil, ErrUnavailable
  42. }
  43. r.prepare(jobs)
  44. return r.shiftFilterDecimateBatchImpl(iq)
  45. }