0032092: Visualization, TKService - Image_VideoRecorder writes garbage from Grayscale...
authorkgv <kgv@opencascade.com>
Thu, 9 Sep 2021 19:34:48 +0000 (22:34 +0300)
committersmoskvin <smoskvin@opencascade.com>
Fri, 10 Sep 2021 17:24:51 +0000 (20:24 +0300)
Image_VideoRecorder::writeVideoFrame(), added protection from API misuse.

src/Image/Image_VideoRecorder.cxx

index 65ed038..e2a3977 100644 (file)
@@ -431,6 +431,11 @@ Standard_Boolean Image_VideoRecorder::openVideoCodec (const Image_VideoParams& t
 Standard_Boolean Image_VideoRecorder::writeVideoFrame (const Standard_Boolean theToFlush)
 {
 #ifdef HAVE_FFMPEG
+  if (myImgSrcRgba.Format() != Image_Format_RGBA)
+  {
+    throw Standard_ProgramError ("Image_VideoRecorder, unsupported image format");
+  }
+
   int aResAv = 0;
   AVCodecContext* aCodecCtx = myVideoStream->codec;
   if (!theToFlush)