<HTML><BODY>Hi all!<br><br>I use libav to decode MJPEG frames from IP-camera and to show some pixels from them on a SDL-surface.<br>SDL takes only RGB pixels so I have to convert YUV from MJPEG frame to RGB.<br>I have AVFrame after avcodec_decode_video() and as I see, there data[0] stands for Y component, data[1] - V component and data[2] - U component.<br>Also, U and V components arrays are twice shorter, so that 1 U or V component stands for 2 Y components.<br>Then I use formulas found in wikipedia to convert YUV to RGB:<br><br>R=Y + 1.370705*(U - 128);<br>G=Y - 0.698001*(V - 128) - 0.337633*(U - 128);<br>B=Y + 1.732446*(V - 128);<span></span><br><br>But in final picture I got colors mismatch in highly white and highly black regions.<br>For example in pixels that should be black, I have blue or red pixels, and in white regions - only green.<br><br>So I have two questions:<br>1) Am I right in my vision of YUV components position in AVFrame->data arrays ?<br>2) Is there any way to solve problems with colors mismatch?<br><br><br></BODY></HTML>