android - how to convert from yv12 to yuv420p -


on camera preview frame data in yv12 format on android side. need convert yuv420p on jni side. how can it? have read many sources in yuv420p format y samples appears first followed u samples. u samples followed v sample. yv12 format same yuv420p except u , v samples appears in reverse order, means y samples followed v , u samples. keeping in mind have used following swapping code produce yuv420p data yv12 data format before encoding.

avpicture_fill((avpicture*)outframe, (uint8_t*)camdata, codecctx->pix_fmt, codecctx->width, codecctx->height);  uint8_t * buf_store = outframe->data[1]; outframe->data[1]=outframe->data[2]; outframe->data[2]=buf_store; 

but not seems working. how should adjust code?

do, t use avpicture_fill. have implemented in application , working fine

  picture->linesize[0] = framewidth; picture->linesize[1] = framewidth/2; picture->linesize[2] = framewidth/2;  picture->data[0] = camdata; picture->data[1] = camdata + picture->linesize[0]*frameheight+picture->linesize[1]*frameheight/2; picture->data[2] = camdata + picture->linesize[0]*frameheight; 

Comments