MCPcopy Create free account
hub / github.com/IENT/YUView / decoderFFmpeg

Method decoderFFmpeg

YUViewLib/src/decoder/decoderFFmpeg.cpp:48–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46{
47
48decoderFFmpeg::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
97decoderFFmpeg::decoderFFmpeg(FFmpeg::AVCodecParametersWrapper codecpar, bool cachingDecoder)
98 : decoderBase(cachingDecoder)

Callers

nothing calls this directly

Calls 15

getCodecNameMethod · 0.95
createDecoderMethod · 0.95
loadFFmpegLibrariesMethod · 0.80
loadingSuccessfullMethod · 0.80
allocCodecParametersMethod · 0.80
setAVMediaTypeMethod · 0.80
setAVCodecIDMethod · 0.80
getCodecIDFromWrapperMethod · 0.80
setSizeMethod · 0.80
setExtradataMethod · 0.80
setAVPixelFormatMethod · 0.80

Tested by

no test coverage detected