| 255 | } |
| 256 | |
| 257 | bool FFmpegVersionHandler::configureDecoder(AVCodecContextWrapper & decCtx, |
| 258 | AVCodecParametersWrapper &codecpar) |
| 259 | { |
| 260 | if (this->lib.avcodec.newParametersAPIAvailable) |
| 261 | { |
| 262 | // Use the new avcodec_parameters_to_context function. |
| 263 | auto origin_par = codecpar.getCodecParameters(); |
| 264 | if (!origin_par) |
| 265 | return false; |
| 266 | auto ret = this->lib.avcodec.avcodec_parameters_to_context(decCtx.getCodec(), origin_par); |
| 267 | if (ret < 0) |
| 268 | { |
| 269 | this->log( |
| 270 | QString( |
| 271 | "Could not copy codec parameters (avcodec_parameters_to_context). Return code %1.") |
| 272 | .arg(ret)); |
| 273 | return false; |
| 274 | } |
| 275 | } |
| 276 | else |
| 277 | { |
| 278 | // TODO: Is this even necessary / what is really happening here? |
| 279 | |
| 280 | // The new parameters API is not available. Perform what the function would do. |
| 281 | // This is equal to the implementation of avcodec_parameters_to_context. |
| 282 | // AVCodecContext *ctxSrc = videoStream.getCodec().getCodec(); |
| 283 | // int ret = lib.AVCodecContextCopyParameters(ctxSrc, decCtx.getCodec()); |
| 284 | // return setOpeningError(QStringLiteral("Could not copy decoder parameters from stream |
| 285 | // decoder.")); |
| 286 | } |
| 287 | return true; |
| 288 | } |
| 289 | |
| 290 | int FFmpegVersionHandler::pushPacketToDecoder(AVCodecContextWrapper &decCtx, AVPacketWrapper &pkt) |
| 291 | { |
no test coverage detected