| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple, Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef QTPixelBuffer_h | |
| 27 #define QTPixelBuffer_h | |
| 28 | |
| 29 #ifdef QTMOVIEWIN_EXPORTS | |
| 30 #define QTMOVIEWIN_API __declspec(dllexport) | |
| 31 #else | |
| 32 #define QTMOVIEWIN_API __declspec(dllimport) | |
| 33 #endif | |
| 34 | |
| 35 #include <stdint.h> | |
| 36 | |
| 37 typedef struct __CVBuffer *CVBufferRef; | |
| 38 typedef CVBufferRef CVPixelBufferRef; | |
| 39 typedef struct CGImage* CGImageRef; | |
| 40 typedef int32_t CVReturn; | |
| 41 typedef const struct __CFDictionary * CFDictionaryRef; | |
| 42 | |
| 43 // QTPixelBuffer wraps QuickTime's implementation of CVPixelBuffer, so its funct
ions are | |
| 44 // safe to call within WebKit. | |
| 45 class QTMOVIEWIN_API QTPixelBuffer { | |
| 46 public: | |
| 47 enum Type { ConfigureForCGImage, ConfigureForCAImageQueue }; | |
| 48 static CFDictionaryRef createPixelBufferAttributesDictionary(Type); | |
| 49 | |
| 50 QTPixelBuffer(); | |
| 51 QTPixelBuffer(const QTPixelBuffer&); | |
| 52 QTPixelBuffer(CVPixelBufferRef); | |
| 53 QTPixelBuffer& operator=(const QTPixelBuffer&); | |
| 54 ~QTPixelBuffer(); | |
| 55 | |
| 56 void set(CVPixelBufferRef); | |
| 57 CVPixelBufferRef pixelBufferRef(); | |
| 58 void adopt(CVPixelBufferRef); | |
| 59 void clear(); | |
| 60 | |
| 61 CVReturn lockBaseAddress(); | |
| 62 CVReturn unlockBaseAddress(); | |
| 63 void* baseAddress(); | |
| 64 | |
| 65 size_t width() const; | |
| 66 size_t height() const; | |
| 67 unsigned long pixelFormatType() const; | |
| 68 bool pixelFormatIs32ARGB() const; | |
| 69 bool pixelFormatIs32BGRA() const; | |
| 70 size_t bytesPerRow() const; | |
| 71 size_t dataSize() const; | |
| 72 | |
| 73 bool isPlanar() const; | |
| 74 size_t planeCount() const; | |
| 75 size_t widthOfPlane(size_t) const; | |
| 76 size_t heightOfPlane(size_t) const; | |
| 77 void* baseAddressOfPlane(size_t) const; | |
| 78 size_t bytesPerRowOfPlane(size_t) const; | |
| 79 | |
| 80 void getExtendedPixels(size_t* left, size_t* right, size_t* top, size_t* bot
tom) const; | |
| 81 CFDictionaryRef attachments() const; | |
| 82 | |
| 83 // Generic CFRetain/CFRelease callbacks | |
| 84 static void releaseCallback(void* refcon); | |
| 85 static void retainCallback(void* refcon); | |
| 86 | |
| 87 // CAImageQueue callbacks | |
| 88 static void imageQueueReleaseCallback(unsigned int type, uint64_t id, void*
refcon); | |
| 89 | |
| 90 // CGDataProvider callbacks | |
| 91 static void dataProviderReleaseBytePointerCallback(void* refcon, const void*
pointer); | |
| 92 static const void* dataProviderGetBytePointerCallback(void* refcon); | |
| 93 static size_t dataProviderGetBytesAtPositionCallback(void* refcon, void* buf
fer, size_t position, size_t count); | |
| 94 static void dataProviderReleaseInfoCallback(void* refcon); | |
| 95 | |
| 96 private: | |
| 97 CVPixelBufferRef m_pixelBuffer; | |
| 98 }; | |
| 99 | |
| 100 #endif | |
| OLD | NEW |