Skip to content

Commit

Permalink
StAVImage - map grayf32 pixel format from FFmpeg to StImagePlane::Img…
Browse files Browse the repository at this point in the history
…GrayF
  • Loading branch information
gkv311 committed Jan 16, 2025
1 parent 186c9cf commit a7f8767
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions StShared/StAVImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int StAVImage::getAVPixelFormat(const StImage& theImage) {
case StImagePlane::ImgBGRA: return stAV::PIX_FMT::BGRA32;
case StImagePlane::ImgGray: return stAV::PIX_FMT::GRAY8;
case StImagePlane::ImgGray16: return stAV::PIX_FMT::GRAY16;
case StImagePlane::ImgGrayF: return stAV::PIX_FMT::GRAYF32;
default: return stAV::PIX_FMT::NONE;
}
}
Expand Down Expand Up @@ -168,6 +169,7 @@ static int getAVPixelFormatForPlane(const StImagePlane& theImage) {
case StImagePlane::ImgBGRA: return stAV::PIX_FMT::BGRA32;
case StImagePlane::ImgGray: return stAV::PIX_FMT::GRAY8;
case StImagePlane::ImgGray16: return stAV::PIX_FMT::GRAY16;
case StImagePlane::ImgGrayF: return stAV::PIX_FMT::GRAYF32;
default: return stAV::PIX_FMT::NONE;
}
}
Expand Down Expand Up @@ -559,6 +561,11 @@ bool StAVImage::loadExtra(const StString& theFilePath,
changePlane(0).initWrapper(StImagePlane::ImgGray16, myFrame.getPlane(0),
myCodecCtx->width, myCodecCtx->height,
myFrame.getLineSize(0));
} else if(myCodecCtx->pix_fmt == stAV::PIX_FMT::GRAYF32) {
setColorModel(StImage::ImgColor_GRAY);
changePlane(0).initWrapper(StImagePlane::ImgGrayF, myFrame.getPlane(0),
myCodecCtx->width, myCodecCtx->height,
myFrame.getLineSize(0));
} else if(myCodecCtx->pix_fmt == stAV::PIX_FMT::RGB48) {
setColorModel(StImage::ImgColor_RGB);
changePlane(0).initWrapper(StImagePlane::ImgRGB48, myFrame.getPlane(0),
Expand Down
3 changes: 3 additions & 0 deletions StShared/stAV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const AVPixelFormat stAV::PIX_FMT::YUVA420P = ST_AV_GETPIXFMT("yuva420p");
const AVPixelFormat stAV::PIX_FMT::PAL8 = ST_AV_GETPIXFMT("pal8");
const AVPixelFormat stAV::PIX_FMT::GRAY8 = ST_AV_GETPIXFMT("gray");
const AVPixelFormat stAV::PIX_FMT::GRAY16 = ST_AV_GETPIXFMT("gray16");
const AVPixelFormat stAV::PIX_FMT::GRAYF32 = ST_AV_GETPIXFMT("grayf32");
const AVPixelFormat stAV::PIX_FMT::YUV422P = ST_AV_GETPIXFMT("yuv422p");
const AVPixelFormat stAV::PIX_FMT::YUVA422P = ST_AV_GETPIXFMT("yuva422p");
const AVPixelFormat stAV::PIX_FMT::YUV444P = ST_AV_GETPIXFMT("yuv444p");
Expand Down Expand Up @@ -165,6 +166,8 @@ StCString stAV::PIX_FMT::getString(const AVPixelFormat theFrmt) {
return stCString("gray8");
} else if(theFrmt == stAV::PIX_FMT::GRAY16) {
return stCString("gray16");
} else if(theFrmt == stAV::PIX_FMT::GRAYF32) {
return stCString("grayf32");
} else if(theFrmt == stAV::PIX_FMT::YUV422P) {
return stCString("yuv422p");
} else if(theFrmt == stAV::PIX_FMT::YUVA422P) {
Expand Down
1 change: 1 addition & 0 deletions include/StAV/stAV.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ namespace stAV {

ST_SHARED_CPPEXPORT AVPixelFormat GRAY8; //!< Y, 8bpp
ST_SHARED_CPPEXPORT AVPixelFormat GRAY16; //!< Y, 16bpp
ST_SHARED_CPPEXPORT AVPixelFormat GRAYF32; //!< Y, 32bpp float
// planar YUV formats
ST_SHARED_CPPEXPORT AVPixelFormat YUV420P; //!< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
ST_SHARED_CPPEXPORT AVPixelFormat YUVA420P; //!< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Expand Down

0 comments on commit a7f8767

Please sign in to comment.