android - Get yuv size size stored by Mediabuffer -
i use openmax decode video frame,my sample this:
file* fp = fopen("/data/local/tmp/test.yuv", "wb"); while(!isexit) { mediabuffer *mvideobuffer; mediasource::readoptions options; status_t err = mvideodecoder->read(&mvideobuffer, &options); if (err == ok) { if (mvideobuffer->range_length() > 0) { // if video frame availabe, render mnativewindow int w = 0; int h = 0; int dw = 0; int dh = 0; int stride = 0; sp<metadata> metadata = mvideobuffer->meta_data(); sp<metadata> outformat = mvideodecoder->getformat(); outformat->findint32(kkeywidth , &w); outformat->findint32(kkeyheight, &h); int64_t timeus = 0; metadata->findint64(kkeytime, &timeus); metadata->findint32(kkeydisplayheight, &dh); metadata->findint32(kkeydisplaywidth, &dw); metadata->findint32(kkeystride, &stride); printf("out format w:%d h:%d dw:%d dh:%d stride:%d timestamp:%lld\n", w, h, dw, dh, stride, timeus); if(fp) { printf("decode frame, range_length = %d range_offset = %d size = %d width = %d height = %d\n", mvideobuffer->range_length(), mvideobuffer->range_offset(), mvideobuffer->size(), w, h); fwrite(mvideobuffer->data( ) + mvideobuffer->range_offset( ), 1, mvideobuffer->range_length(), fp); } metadata->setint32(kkeyrendered, 1); } mvideobuffer->release(); } else { printf("end of file\n"); isexit = true; } } fclose(fp);
the output this:
out format w:1280 h:720 dw:0 dh:0 stride:0 timestamp:44044 decode frame, range_length = 1417216 range_offset = 0 size = 1417216 width = 1280 height = 720
my question how know yuv realy size stored mediabuffer, because 1280 x 736 (stride 32, guess) x 1.5 = 1413120,but mvideobuffer's range_length() 1417216, there no regular can yuv size, please me, !
the mediabuffer
being read part read
method initialized here. please note info.msize
set def.nbuffersize
same allocated size. information not updated reflect actual size filled decoder.
the allocation 1280 x 736 x 1.5 height
aligned 32. stride
not required 1280 aligned number.
Comments
Post a Comment