| 139 | } |
| 140 | |
| 141 | int YUVProgramContext::updateFrame(std::unique_ptr<IAFFrame> &frame) { |
| 142 | |
| 143 | if (mProgram == 0) { |
| 144 | return -1; |
| 145 | } |
| 146 | |
| 147 | int *lineSize = nullptr; |
| 148 | |
| 149 | if (frame != nullptr) { |
| 150 | IAFFrame::videoInfo &videoInfo = frame->getInfo().video; |
| 151 | if (mFrameWidth != videoInfo.width || mFrameHeight != videoInfo.height || |
| 152 | mDar != videoInfo.dar) { |
| 153 | mDar = videoInfo.dar; |
| 154 | mFrameWidth = videoInfo.width; |
| 155 | mFrameHeight = videoInfo.height; |
| 156 | mRegionChanged = true; |
| 157 | } |
| 158 | |
| 159 | if (mCropRect.left != videoInfo.crop_left || mCropRect.right != videoInfo.crop_right || |
| 160 | mCropRect.top != videoInfo.crop_top || mCropRect.bottom != videoInfo.crop_bottom) { |
| 161 | mCropRect = {videoInfo.crop_left, videoInfo.crop_right, |
| 162 | videoInfo.crop_top, videoInfo.crop_bottom}; |
| 163 | mCoordsChanged = true; |
| 164 | } |
| 165 | |
| 166 | lineSize = frame->getLineSize(); |
| 167 | if (lineSize != nullptr && lineSize[0] != mLineSize[0]) { |
| 168 | |
| 169 | mLineSize[0] = lineSize[0]; |
| 170 | mLineSize[1] = lineSize[1]; |
| 171 | mLineSize[2] = lineSize[2]; |
| 172 | |
| 173 | mCoordsChanged = true; |
| 174 | } |
| 175 | |
| 176 | if(mColorSpace != videoInfo.colorSpace){ |
| 177 | updateColorSpace(); |
| 178 | mColorSpace = videoInfo.colorSpace; |
| 179 | } |
| 180 | |
| 181 | if(mColorRange != videoInfo.colorRange){ |
| 182 | updateColorRange(); |
| 183 | mColorRange = videoInfo.colorRange; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | if(frame == nullptr && !mProjectionChanged && !mRegionChanged && !mCoordsChanged && !mBackgroundColorChanged){ |
| 188 | //frame is null and nothing changed , don`t need redraw. such as paused. |
| 189 | return -1; |
| 190 | } |
| 191 | |
| 192 | bool rendered = false; |
| 193 | if (mRenderingCb) { |
| 194 | CicadaJSONItem params{}; |
| 195 | rendered = mRenderingCb(mRenderingCbUserData, frame.get(), params); |
| 196 | } |
| 197 | |
| 198 | if (rendered) { |
no test coverage detected