| 69 | }; |
| 70 | |
| 71 | int64_t conv1d_output_frames(int64_t frames, int64_t kernel, int64_t stride, int64_t padding, int64_t dilation = 1) { |
| 72 | return (frames + 2 * padding - dilation * (kernel - 1) - 1) / stride + 1; |
| 73 | } |
| 74 | |
| 75 | int64_t coco_output_frames(int64_t input_frames, int64_t downsample_rate) { |
| 76 | int64_t frames = input_frames; |
| 77 | int64_t remaining = downsample_rate; |
| 78 | while (remaining > 1 && remaining % 2 == 0) { |
| 79 | frames = conv1d_output_frames(frames, 3, 2, 1); |
| 80 | remaining /= 2; |
| 81 | } |
| 82 | if (remaining != 1) { |
| 83 | throw std::runtime_error("Vevo2 Coco downsample_rate must be a positive power of two"); |
| 84 | } |
no test coverage detected