| 46 | { |
| 47 | |
| 48 | decoderFFmpeg::decoderFFmpeg(FFmpeg::AVCodecIDWrapper codecID, |
| 49 | Size size, |
| 50 | QByteArray extradata, |
| 51 | video::yuv::PixelFormatYUV pixelFormatYUV, |
| 52 | IntPair profileLevel, |
| 53 | Ratio sampleAspectRatio, |
| 54 | bool cachingDecoder) |
| 55 | : decoderBase(cachingDecoder) |
| 56 | { |
| 57 | // The libraries are only loaded on demand. This way a FFmpegLibraries instance can exist without |
| 58 | // loading the libraries which is slow and uses a lot of memory. |
| 59 | this->ff.loadFFmpegLibraries(); |
| 60 | if (!this->ff.loadingSuccessfull()) |
| 61 | return; |
| 62 | |
| 63 | // Create the cofiguration parameters |
| 64 | auto codecpar = this->ff.allocCodecParameters(); |
| 65 | codecpar.setAVMediaType(FFmpeg::AVMEDIA_TYPE_VIDEO); |
| 66 | codecpar.setAVCodecID(this->ff.getCodecIDFromWrapper(codecID)); |
| 67 | codecpar.setSize(size); |
| 68 | codecpar.setExtradata(extradata); |
| 69 | |
| 70 | auto avPixelFormat = this->ff.getAVPixelFormatFromPixelFormatYUV(pixelFormatYUV); |
| 71 | if (avPixelFormat == FFmpeg::AV_PIX_FMT_NONE) |
| 72 | { |
| 73 | this->setError("Error determining the AVPixelFormat."); |
| 74 | return; |
| 75 | } |
| 76 | codecpar.setAVPixelFormat(avPixelFormat); |
| 77 | |
| 78 | codecpar.setProfileLevel(profileLevel.first, profileLevel.second); |
| 79 | codecpar.setSampleAspectRatio(sampleAspectRatio.num, sampleAspectRatio.den); |
| 80 | |
| 81 | if (!createDecoder(codecID, codecpar)) |
| 82 | { |
| 83 | this->setError("Error creating the needed decoder."); |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | this->flushing = false; |
| 88 | this->internalsSupported = true; |
| 89 | // Fill the padding array |
| 90 | for (int i = 0; i < AV_INPUT_BUFFER_PADDING_SIZE; i++) |
| 91 | this->avPacketPaddingData.append((char)0); |
| 92 | |
| 93 | DEBUG_FFMPEG("decoderFFmpeg::decoderFFmpeg Created new FFmpeg decoder - codec " |
| 94 | << this->getCodecName() << (cachingDecoder ? " - caching" : "")); |
| 95 | } |
| 96 | |
| 97 | decoderFFmpeg::decoderFFmpeg(FFmpeg::AVCodecParametersWrapper codecpar, bool cachingDecoder) |
| 98 | : decoderBase(cachingDecoder) |
nothing calls this directly
no test coverage detected