[Libav-user] The issue of generating YUV422 image from RGB48

Hao Yang hao at multicorewareinc.com
Wed May 11 11:46:11 CEST 2016


This is part of output file converted by ffmeg:
[image: 内嵌图片 1]
I can just recognize the profile of orignial image from this image, but
very fuzzy...

2016-05-11 17:43 GMT+08:00 Hao Yang <hao at multicorewareinc.com>:

> This is part of original file:
> [image: 内嵌图片 1]
>
> 2016-05-11 17:03 GMT+08:00 Paul B Mahol <onemda at gmail.com>:
>
>> On 5/11/16, Hao Yang <hao at multicorewareinc.com> wrote:
>> > I want to use ffmpeg to convert image from RGB48 into YUV422, then
>> generate
>> > mp4 file finally.
>> >
>> > But I found that conversion result shows the color of YUV422 image is
>> not
>> > same as RGB48. I also tried to convert image from RGB24 (just convert
>> from
>>
>> If its not same, what is it?
>>
>> > RGB48) into YUV422, no issue found.
>> >
>> >
>> > Do anyone know is this the bug in ffmpeg for such conversion or some
>> > mistake in my code?
>> >
>> > Thanks so much in advance!!
>> >
>> >
>> >
>> > The following code is from my project and used to conversion:
>> >
>> >
>> > void conversion()
>> >
>> > {
>> >
>> > //xxxxxxxx;
>> >
>> >
>> >
>> > rgb_pixel_format = AV_PIX_FMT_RGB48BE;
>> >
>> > pCodecCtx->pix_fmt = yuv_pixel_format = AV_PIX_FMT_YUV422P;
>> >
>> > scale_flag = SWS_POINT;
>> >
>> >
>> >
>> > //xxxxxxxx;
>> >
>> >
>> >
>> >     size = avpicture_get_size(pCodecCtx->pix_fmt, pCodecCtx->width,
>> > pCodecCtx->height);
>> >
>> >     yuv_buff = (unsigned char*)av_malloc(size);
>> >
>> >
>> >
>> >     pSwsCtx=
>> > sws_getContext(pCodecCtx->width,pCodecCtx->height,rgb_pixel_format,
>> >
>> >
>> >
>> pCodecCtx->width,pCodecCtx->height,yuv_pixel_format,scale_flag,NULL,NULL,NULL);
>> >
>> >
>> >
>> >
>> >
>> >
>> >     for (file_index = 0; file_index < image_num; file_index ++)
>> >
>> >     {
>> >
>> >         rgb_buff = (unsigned char*)av_malloc(image_data->length);
>> >
>> >         memcpy(rgb_buff, image_data->data, image_data->length);
>> >
>> >
>> >
>> >         avpicture_fill((AVPicture*)pRGBFrame, (unsigned char*)rgb_buff,
>> > rgb_pixel_format, nWidth, nHeight);
>> >
>> >
>> >
>> >         avpicture_fill((AVPicture*)pFrame, (unsigned char*)yuv_buff,
>> > yuv_pixel_format, nWidth, nHeight);
>> >
>> >
>> >
>> >         //rotate RGB image
>> >
>> >         pRGBFrame->data[0]  += pRGBFrame->linesize[0] * (nHeight - 1);
>> >
>> >         pRGBFrame->linesize[0] *= -1;
>> >
>> >         pRGBFrame->data[1]  += pRGBFrame->linesize[1] * (nHeight / 2 -
>> 1);
>> >
>> >
>> >         pRGBFrame->linesize[1] *= -1;
>> >
>> >         pRGBFrame->data[2]  += pRGBFrame->linesize[2] * (nHeight / 2 -
>> 1);
>> >
>> >
>> >         pRGBFrame->linesize[2] *= -1;
>> >
>> >
>> >
>> >         //covert RGB into YUV
>> >
>> >
>> >
>> sws_scale(pSwsCtx,pRGBFrame->data,pRGBFrame->linesize,0,pCodecCtx->height,pFrame->data,pFrame->linesize);
>> >
>> >
>> >             yuv_file = fopen(yuv_rst_file[file_index], "wb");
>> >
>> >
>> >
>> >             fseek(yuv_file, 0L, SEEK_END);
>> >
>> >             rewind(yuv_file);
>> >
>> >
>> >
>> fwrite(pFrame->data[0],(pCodecCtx->width)*(pCodecCtx->height),1,yuv_file);
>> >
>> >
>> >
>> >
>> fwrite(pFrame->data[1],(pCodecCtx->width)*(pCodecCtx->height)/2,1,yuv_file);
>> >
>> >
>> >
>> >
>> fwrite(pFrame->data[2],(pCodecCtx->width)*(pCodecCtx->height)/2,1,yuv_file);
>> >
>> >
>> >             fclose(yuv_file);
>> >
>> >         }
>> >
>> > }
>> >
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160511/babda7b9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rgb48.jpg
Type: image/jpeg
Size: 27157 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160511/babda7b9/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: yuv422.jpg
Type: image/jpeg
Size: 186899 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160511/babda7b9/attachment-0001.jpg>


More information about the Libav-user mailing list