ios - copy CVPixelBufferRef -


the code in copypixelbuffernow long. :-(

@property (nonatomic,assign)cvpixelbufferref pixelbuffernowref;  - (cvpixelbufferref)copypixelbuffernow {     if (_pixelbuffernowref == null) {         return nil;     }      cvpixelbufferref pixelbufferout = null;     cvreturn ret = kcvreturnerror;     size_t height = cvpixelbuffergetheight(_pixelbuffernowref);     size_t width = cvpixelbuffergetwidth(_pixelbuffernowref);     size_t bytersperrow = cvpixelbuffergetbytesperrow(_pixelbuffernowref);     cfdictionaryref attrs = null;     const void *keys[] = { kcvpixelbufferpixelformattypekey };     //      kcvpixelformattype_420ypcbcr8planar yuv420     //      kcvpixelformattype_420ypcbcr8biplanarfullrange nv12     uint32_t v = kcvpixelformattype_420ypcbcr8biplanarfullrange;     const void *values[] = { cfnumbercreate(null, kcfnumbersint32type, &v) };     attrs = cfdictionarycreate(null, keys, values, 1, null, null);      ret = cvpixelbuffercreate(null,                               width,                               height,                               cvpixelbuffergetpixelformattype(_pixelbuffernowref),                               attrs,                               &pixelbufferout);     cvpixelbufferlockbaseaddress(_pixelbuffernowref, kcvpixelbufferlock_readonly);     cvpixelbufferlockbaseaddress(pixelbufferout, kcvpixelbufferlock_readonly);     cfrelease(attrs);     if (ret == kcvreturnsuccess) {         memcpy(cvpixelbuffergetbaseaddress(pixelbufferout), cvpixelbuffergetbaseaddress(_pixelbuffernowref), height * bytersperrow);     } else {         printf("why copy pixlbuffer error %d",ret);     }     cvpixelbufferunlockbaseaddress(_pixelbuffernowref, kcvpixelbufferlock_readonly);     cvpixelbufferunlockbaseaddress(pixelbufferout, kcvpixelbufferlock_readonly);      return pixelbufferout; }  - (void)setpixelbuffernowref:(cvpixelbufferref)sender {     if (_pixelbuffernowref != sender) {         cvpixelbufferrelease(_pixelbuffernowref);         _pixelbuffernowref = sender;         cvpixelbufferretain(_pixelbuffernowref);     } } 

i have property pixelbuffernowref.

how prevent being modified in copypixelbuffernow?


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -