sws_scale에서 풀린 RGB 이미지 반전 문제

1650 단어
AVFrame의 데이터 및 linesize:
YUV: linesize[0] =  width + padding size(16+16),linesize[1]=linesize[0]/2
데이터[0], 데이터[1], 데이터[2]는 각각 yuv를 대표한다
RGB: linesize[0] = width*pixel_RGB 데이터[0]용 size for packet rgb
    AVFrame* pFrame;                   // Frame  
    AVCodecContext* pContext;          // Codec Context 
    int nUsedBytes = avcodec_decode_video(pContext, pFrame,  &nFrame, pSrcBuffer, nSrcLength); 
    if(nUsedBytes > 0) 
    { 
        AVFrame  out_pic; 
        SwsContext* img_convert_ctx = sws_getContext(pContext->width, pContext->height
    , pContext->pix_fmt, nDestW, nDestH,(PixelFormat)PIX_FMT_BGR24,SWS_BICUBIC, NULL, NULL, NULL); 
        if(img_convert_ctx != NULL) 
        { 
            if(avpicture_alloc((AVPicture *)&out_pic, PIX_FMT_RGB24, nDestW, nDestH)>=0) 
            { 
                pFrame->data[0] = pFrame->data[0]+pFrame->linesize[0]*(pContext->height-1); 
                pFrame->data[1] = pFrame->data[1]+pFrame->linesize[0]*pContext->height/4-1; 
           pFrame->data[2] = pFrame->data[2]+pFrame->linesize[0]*pContext->height/4-1; 
                pFrame->linesize[0] *= -1; 
                pFrame->linesize[1] *= -1; 
           pFrame->linesize[2] *= -1; 
           sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0, pContext->height
    , out_pic.data, out_pic.linesize); 
                avpicture_free((AVPicture *)&out_pic); 
            } 
            sws_freeContext(img_convert_ctx); 
        } 
    } 

다음으로 이동:http://www.rosoo.net/a/201112/15492.html

좋은 웹페이지 즐겨찾기