[Libav-user] Converting yuvj420p to AV_PIX_FMT_BGRA‏‏

C Lai for_rmcer at hotmail.com
Wed May 11 01:23:13 CEST 2016


Here are the code related to converting yuvj420p to AV_PIX_FMIT_BGRA
......
               vp->width = srcFrame->width;
                vp->height = srcFrame->height;

                int numBytes = avpicture_get_size(imgPixFormat, vp->width, vp->height);
                vp->bmp = new uint8_t[numBytes*sizeof(uint8_t)];
                avpicture_fill((AVPicture *)vp->frame, vp->bmp, imgPixFormat, vp->width, vp->height);
......
                videoState->imgConvertContext = sws_getCachedContext(videoState->imgConvertContext,
                    vp->width, vp->height, (AVPixelFormat) srcFrame->format, vp->width, vp->height,
                    imgPixFormat, swsFlags, NULL, NULL, NULL);

                sws_scale(videoState->imgConvertContext, srcFrame->data, srcFrame->linesize,
                          0, vp->height, vp->frame->data, vp->frame->linesize);

The following is the print for the width, height, and lines size for the source frame(yuvj420p) and the target frame(AV_PIX_FMT_BGRA)
source width 432 height 240 linesize 432 216 216 432
target width 432 height 240 linesize 1728 0 0 1728

source width 320 height 240 linesize 320 160 160 320
target width 320 height 240 linesize 1280 0 0 1280

The part that confuses me is the lines size for source frame.  I don't understand why linessize of srcFrame are different between size 432x240 and size 320x240?  Aren't they the same height but why linessize[1] and linesize[2] are different numbers?

 		 	   		  


More information about the Libav-user mailing list