Click here to Skip to main content
15,794,978 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a RGB24 image which I am saved on file, I am using sws_scale to convert it to YUV420 and then I wanted to verify if the conversion was done correctly so I tried converting it back to RGB24 to view the results. And all I see is vertical white and black bars. What am I doint incorrect?

Any help would be greatly appreciated!

I have attached the code here

if (sws_ctx == NULL)
   sws_ctx = sws_getContext(pFrameRGB->width, pFrameRGB->height,
			    AV_PIX_FMT_RGB24, pFrameRGB->width, pFrameRGB->height,
			    AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, 0, 0, 0);
int inLinesize[1] = { 3*pFrameRGB->width }; // RGB stride
sws_scale(sws_ctx, pFrameRGB->data, inLinesize, 0, pFrameRGB->height, frame2->data, frame2->linesize);

if ( final_sws_ctx == NULL )
   final_sws_ctx = sws_getContext(pFrameRGB->width, pFrameRGB->height,
   AV_PIX_FMT_YUV420P, pFrameRGB->width, pFrameRGB->height,

sws_scale(sws_ctx, frame2->data, frame2->linesize, 0, frame2->height, finalRGB->data, finalRGB->linesize);

1 solution

At least, you have wrong typo at
sws_scale(sws_ctx, frame2->data, ..)

You need to change it to
sws_scale(final_sws_ctx, frame2->data, ..)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900