19 #include <CoreServices/CoreServices.h>
26 #if CONFIG_VIDEOTOOLBOX
42 CVPixelBufferRef pixbuf = (CVPixelBufferRef)frame->
data[3];
43 OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf);
46 int linesize[4] = { 0 };
52 switch (pixel_format) {
56 #ifdef kCFCoreFoundationVersionNumber10_7
72 err = CVPixelBufferLockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly);
73 if (err != kCVReturnSuccess) {
78 if (CVPixelBufferIsPlanar(pixbuf)) {
80 planes = CVPixelBufferGetPlaneCount(pixbuf);
81 for (i = 0; i < planes; i++) {
82 data[i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i);
83 linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i);
86 data[0] = CVPixelBufferGetBaseAddress(pixbuf);
87 linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf);
95 CVPixelBufferUnlockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly);
116 #if CONFIG_VIDEOTOOLBOX
149 #if CONFIG_VIDEOTOOLBOX
154 CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault,
156 kCFStringEncodingUTF8);
159 CFRelease(pixfmt_str);
168 CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault,
170 kCFStringEncodingUTF8);
173 CFRelease(pixfmt_str);
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx)
This is a convenience function that creates and sets up the VDA context using an internal implementat...
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
Put a string representing the codec tag codec_tag in buf.
void av_vda_default_free(AVCodecContext *ctx)
This function must be called to free the VDA context initialized with av_vda_default_init().
This struct holds all the information that needs to be passed between the caller and libavcodec for i...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
OSType cv_pix_fmt_type
CVPixelBuffer Format Type that VDA will use for decoded frames; set by the caller.
#define AV_LOG_VERBOSE
Detailed information.
int av_vda_default_init(AVCodecContext *avctx)
This is a convenience function that creates and sets up the VDA context using an internal implementat...
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Libavcodec external API header.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Public libavcodec VDA header.
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
OSType cv_pix_fmt_type
CVPixelBuffer Format Type that Videotoolbox will use for decoded frames.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
AVVDAContext * av_vda_alloc_context(void)
Allocate and initialize a VDA context.
This struct holds all the information that needs to be passed between the caller and libavcodec for i...
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void * opaque
Private data of the user, can be used to carry app specific stuff.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.