• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CVPixelBufferCreateWithPlanarBytes does not execute callback when released
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVPixelBufferCreateWithPlanarBytes does not execute callback when released


  • Subject: CVPixelBufferCreateWithPlanarBytes does not execute callback when released
  • From: Matthieu Bouron <email@hidden>
  • Date: Sun, 10 Nov 2013 22:50:26 +0000

Hello,

First of all, sorry in advance if i'm not addressing the right mailing
list.

I'm currently using the CVPixelBufferRef API and more precisely
the CVPixelBufferCreateWithPlanarBytes function so I can use my own video
buffers.

This function let the user provide a callback so the user can provide
a function to free its buffer on release. However I can't get my own
callback to be executed which leads to severe memory leaks in my
application.

You can find attached to this email, an example to reproduce the issue.
Note that the first example with CVPixelBufferCreateWithBytes works but
the CVPixelBufferCreateWithPlanarBytes one don't.
Maybe i'm missing something ?

I'm facing this issue on OSX 10.9.

To compile the example:
gcc -framework CoreVideo test_cvbuffer.m -o test_cvbuffer

Thanks in advance for your help.

Best regards,
Matthieu Bouron
#import <CoreVideo/CoreVideo.h>

void release_cb (void *releaseRefCon, const void *dataPtr)
{
    printf ("release cb\n");
}

void release_planar_cb (void * releaseRefConf, const void *dataPtr,
    size_t dataSize, size_t numberOfPlanes, const void *planeAddresses[])
{
    printf ("release planar cb\n");
}

int main(int argc, const char * argv[])
{
    int ret;
    size_t width = 1280;
    size_t height = 720;
    size_t depth = 4;

    /* Fake packed buffer: 32BGRA */
    uint8_t *p = malloc (width * height * depth);

    /* Fake planar contiguous buffer: 420v */
    size_t p2_size = width * height + ((width * height) / 4);
    uint8_t *p2 = malloc (p2_size);

    size_t widths[2] = { 1280, 1280 / 2 };
    size_t heights[2] = { 720, 720 / 2 };
    size_t rows[2] = { 1280 ,  1280 };

    CVPixelBufferRef buffer;

    ret = CVPixelBufferCreateWithBytes (NULL, width, height, kCVPixelFormatType_32BGRA,
                                        p, width * 4, release_cb, NULL, NULL, &buffer);
    printf ("ret = %d\n", ret);

    CVPixelBufferRelease (buffer);
    buffer = NULL;

    ret = CVPixelBufferCreateWithPlanarBytes(NULL, width, height,kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, NULL, p2_size,
        2, (void **)&p2, widths, heights, rows, release_planar_cb, NULL, NULL, &buffer);

    printf ("ret = %d\n", ret);

    CVPixelBufferRelease (buffer);

    free(p);
    free(p2);

    return 0;
}

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: CVPixelBufferCreateWithPlanarBytes does not execute callback when released
      • From: Matthieu Bouron <email@hidden>
  • Prev by Date: Re: Resolving a file reference from the iTunes plist
  • Next by Date: dataWithPDFInsideRect: subview positions when using layer backed views
  • Previous by thread: Re: Xcode Issue Navigator
  • Next by thread: Re: CVPixelBufferCreateWithPlanarBytes does not execute callback when released
  • Index(es):
    • Date
    • Thread