| 150 | AnnexBNalSplitter splitter; |
| 151 | |
| 152 | bool init(String filename) { |
| 153 | decoderStorage = h264bsdAlloc(); |
| 154 | if (!decoderStorage) { |
| 155 | Error("VideoNode: failed to allocate decoder storage"); |
| 156 | return false; |
| 157 | } |
| 158 | |
| 159 | u32 result = h264bsdInit(decoderStorage, 1); // 0 = enable output reordering |
| 160 | if (result != H264BSD_RDY) { |
| 161 | Error("VideoNode: failed to initialize decoder, error code: {}", result); |
| 162 | h264bsdFree(decoderStorage); |
| 163 | decoderStorage = nullptr; |
| 164 | return false; |
| 165 | } |
| 166 | |
| 167 | std::string fullPath = SharedContent.getFullPath(filename); |
| 168 | fileHandle = SDL_RWFromFile(fullPath.c_str(), "rb"); |
| 169 | if (!fileHandle) { |
| 170 | Error("VideoNode: failed to open file: {}, error: {}", fullPath, SDL_GetError()); |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | while (readFileChunk(true)) { |
| 175 | if (videoWidth > 0 && videoHeight > 0) { |
| 176 | break; |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | if (videoWidth == 0 || videoHeight == 0 || frameRate == 0) { |
| 181 | Error("VideoNode: failed to get video parameters from file {}", fullPath); |
| 182 | return false; |
| 183 | } |
| 184 | |
| 185 | return true; |
| 186 | } |
| 187 | |
| 188 | bool readFileChunk(bool init = false) { |
| 189 | if (!fileHandle) return false; |
nothing calls this directly
no test coverage detected