mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Merge pull request #23657 from asmorkalov:as/uyvy_cvtColor_size_check
Added check that YUYV input of cvtColor has even width.
This commit is contained in:
commit
e09684647a
@ -72,7 +72,7 @@ struct Set<i0, -1, -1>
|
||||
|
||||
enum SizePolicy
|
||||
{
|
||||
TO_YUV, FROM_YUV, NONE
|
||||
TO_YUV, FROM_YUV, FROM_UYVY, NONE
|
||||
};
|
||||
|
||||
template< typename VScn, typename VDcn, typename VDepth, SizePolicy sizePolicy = NONE >
|
||||
@ -104,6 +104,10 @@ struct CvtHelper
|
||||
CV_Assert( sz.width % 2 == 0 && sz.height % 3 == 0);
|
||||
dstSz = Size(sz.width, sz.height * 2 / 3);
|
||||
break;
|
||||
case FROM_UYVY:
|
||||
CV_Assert( sz.width % 2 == 0);
|
||||
dstSz = sz;
|
||||
break;
|
||||
case NONE:
|
||||
default:
|
||||
dstSz = sz;
|
||||
|
@ -354,7 +354,7 @@ void cvtColorYUV2BGR(InputArray _src, OutputArray _dst, int dcn, bool swapb, boo
|
||||
|
||||
void cvtColorOnePlaneYUV2BGR( InputArray _src, OutputArray _dst, int dcn, bool swapb, int uidx, int ycn)
|
||||
{
|
||||
CvtHelper< Set<2>, Set<3, 4>, Set<CV_8U> > h(_src, _dst, dcn);
|
||||
CvtHelper< Set<2>, Set<3, 4>, Set<CV_8U>, FROM_UYVY > h(_src, _dst, dcn);
|
||||
|
||||
hal::cvtOnePlaneYUVtoBGR(h.src.data, h.src.step, h.dst.data, h.dst.step, h.src.cols, h.src.rows,
|
||||
dcn, swapb, uidx, ycn);
|
||||
|
@ -724,4 +724,13 @@ INSTANTIATE_TEST_CASE_P(cvt422, Imgproc_ColorYUV,
|
||||
(int)COLOR_YUV2RGBA_YUY2, (int)COLOR_YUV2BGRA_YUY2, (int)COLOR_YUV2RGBA_YVYU, (int)COLOR_YUV2BGRA_YVYU,
|
||||
(int)COLOR_YUV2GRAY_UYVY, (int)COLOR_YUV2GRAY_YUY2));
|
||||
|
||||
}} // namespace
|
||||
}
|
||||
|
||||
TEST(cvtColorUYVY, size_issue_21035)
|
||||
{
|
||||
Mat input = Mat::zeros(1, 1, CV_8UC2);
|
||||
Mat output;
|
||||
EXPECT_THROW(cv::cvtColor(input, output, cv::COLOR_YUV2BGR_UYVY), cv::Exception);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user