Display YUV in OpenGL

前端 未结 3 1250
天命终不由人
天命终不由人 2021-01-31 12:01

I am having trouble displaying a raw YUV file that it is in NV12 format.

I can display a selected frame, however, it is still mainly in black and white with certain shade

3条回答
  •  不知归路
    2021-01-31 12:41

    I think you're addressing U and V values incorrectly. Rather than:

    float U = lookupTableU [uvBuffer [ ((y / 2) * (x / 2) + (x/2)) * 2  ] ]; 
    float V = lookupTableV [uvBuffer [  ((y / 2) * (x / 2) + (x/2)) * 2 + 1] ];
    

    It should be something along the lines of

    float U = lookupTableU [uvBuffer [ ((y / 2) * (YUV_WIDTH / 2) + (x/2)) * 2  ] ]; 
    float V = lookupTableV [uvBuffer [  ((y / 2) * (YUV_WIDTH / 2) + (x/2)) * 2 + 1] ];
    

提交回复
热议问题