If you convert any RGB format to YUV420 you will lose data. If you want to
just change the format to YCbCr without losing data.. you can try YUV444
format... its 3 bytes per pixel, just like RGB, so you will not lose any
data.

2015-05-27 9:25 GMT-03:00 Jasleen Kaur <[email protected]>:

>  We have ARGB buffer to be compressed and then decoded also.
> But for encoding the data the input as ARGB wasnt accepted.
> The data was converted to YUV and then compressed, and on the receive side
> decoded and then converted back to ARGB.
>
>  *The problem is that, While this conversion happens colours change.*
>
>  Following is the code used to convert from ARGB to YUV and YUV to ARGB
> respectively.
>
>
>  void *ConvertToYUV*(int iWidth, int iHeight, BYTE* pARGBBuff)
> {
> #define RNDTO2(X) ( ( (X) & 0xFFFFFFFE )
> #define RNDTO32(X) ( ( (X) % 32 ) ? ( ( (X) + 32 ) & 0xFFFFFFE0 ) : (X) )
>
>  //int ystride  = RNDTO32 ( iWidth );
>     //int uvstride = RNDTO32 ( iWidth / 2 );
> int ystride  = iWidth;
>     int uvstride = iWidth / 2;
>     int ysize    = ystride * iHeight;
>     int vusize   = uvstride * ( iHeight / 2 );
>     int size     = ysize + ( 2 * vusize );
>
>  if(m_sws_ctx == NULL)
> {
> //SwsFilter
> m_sws_ctx = sws_getContext(iWidth,
> iHeight,
> AV_PIX_FMT_BGRA,
> iWidth, iHeight,
> AV_PIX_FMT_YUV420P,
> SWS_FAST_BILINEAR, 0, 0, 0);
>
>  m_picture_buf = (uint8_t*)malloc(size);
> }
>      //uint8_t *plane[] = { m_picture_buf, m_picture_buf + ysize,
> m_picture_buf + ysize + vusize};
> uint8_t *plane[] = { m_picture_buf, m_picture_buf + ysize + vusize,
> m_picture_buf + ysize};
>     int stride[] = { ystride, uvstride, uvstride};
>
>  uint8_t *inData[1] = { pARGBBuff };
>     int inLinesize[1] = { 4 * iWidth};
>
>      sws_scale(m_sws_ctx, inData, inLinesize, 0, iHeight, plane, stride);
>  }
>
>  void *ConvertToARGB*(int iWidth, int iHeight)
> {
> #define RNDTO2(X) ( ( (X) & 0xFFFFFFFE )
> #define RNDTO32(X) ( ( (X) % 32 ) ? ( ( (X) + 32 ) & 0xFFFFFFE0 ) : (X) )
>
>  int iSize = iWidth * iHeight * 4;
> int ystride  = RNDTO32 ( iWidth );
>     int uvstride = RNDTO32 ( iWidth / 2 );
>     int ysize    = ystride * iHeight;
>     int vusize   = uvstride * ( iHeight / 2 );
>
>
>  if(m_sws_ctx == NULL)
> {
> //SwsFilter
> m_sws_ctx = sws_getContext(iWidth,
> iHeight,
> AV_PIX_FMT_YUV420P,
> iWidth, iHeight,
> AV_PIX_FMT_BGRA,
> SWS_FAST_BILINEAR, 0, 0, 0);
>
>  m_picture_buf = (uint8_t*)malloc(iSize);
> }
>  // src
> int srcstride[] = {ystride, uvstride, uvstride};
>
>  // dest
> uint8_t *destplane[] = {m_picture_buf};
>     int stride[] = { iWidth * 4};
>      int iHeightReturned = sws_scale(m_sws_ctx, m_picture->data,
> srcstride, 0, iHeight, destplane, stride);
>
> *  m_picture is the output of avcodec_decode_video2.*
> }
>
>
>  What correction needs to be done in the code, so that colours remain
> intact.
>
>  Thanks and regards
> Jasleen
>
> _______________________________________________
> Libav-user mailing list
> [email protected]
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>


-- 
 ​ Rafael Lúcio
INOVA COMUNICAÇÕES INTELIGENTES
+55 61 9996 5587
+55 61 3574- 7100
Fax +55 61 3574 7024
http://www.inova.in/


Antes de imprimir, pense em sua responsabilidade com o MEIO AMBIENTE

---- BEGIN SSH2 PUBLIC KEY ----
AAAAB3NzaC1yc2EAAAABJQAAAQEAmEyriiqf7mtO/4kLHp2pbbJ1ScVD73z8RqEK
evHWx1tPEIv749EnghOFVvg7xYdyE0sfk6UT8EAVznsOmzU96F+ENdsRGFZhDIk6
kjL9ZabmLMzIlRqh6naB6aJl7/sut7SGwxV1CIr0DPWXtTIr+pSkBzKfPmR6dZ4o
OIcPsSY3hFaq7zTPLWm/IOnZO/9NWvI7d+v0ULfj3pslHeVkUlaqD8D/sm/A+qar
DXd/3eVaPLE8FyVGqLhLgoqoDRdqL6KCX9kdiigStuXJ6ZxjXeqWUzHbSiHn0YMy
LHtUmcYPnYuEx3dEhPqMLSr/m+RSMHUQBW6umlhyejN2AfeB/w==
---- END SSH2 PUBLIC KEY ----
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to