History

vda: Make output CVPixelBuffer format configurable

This is useful for client programs to ask for nv12 surfaces instead of the current default (uyvy), since those are more efficient to decode to.

Stefano Pigozzi committed 11 years ago

Commit e7c5e171 parent 3b5e5e65 files · +32 −5Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. libavcodec/vda.c +9 −2
  3. libavcodec/vda.h +17 −0
  4. libavcodec/vda_h264.c +1 −1
  5. libavcodec/version.h +2 −2
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2014-08-09 · 12 unmodified lines
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162015-xx-xx - xxxxxxx - lavc 56.23.0
17 Add av_vda_default_init2.
18
162015-xx-xx - xxxxxxx - lavu 54.12.0192015-xx-xx - xxxxxxx - lavu 54.12.0
17 Add AV_LOG_TRACE for extremely verbose debugging.20 Add AV_LOG_TRACE for extremely verbose debugging.
18 21
libavcodec/vda.c+9−2
@@ -28,15 +28,22 @@ AVVDAContext *av_vda_alloc_context(void) · 27 unmodified lines
28{28{
29 AVVDAContext *ret = av_mallocz(sizeof(*ret));29 AVVDAContext *ret = av_mallocz(sizeof(*ret));
30 30
31 if (ret)31 if (ret) {
32 ret->output_callback = ff_vda_output_callback;32 ret->output_callback = ff_vda_output_callback;
33 ret->cv_pix_fmt_type = kCVPixelFormatType_422YpCbCr8;
34 }
33 35
34 return ret;36 return ret;
35}37}
36 38
37int av_vda_default_init(AVCodecContext *avctx)39int av_vda_default_init(AVCodecContext *avctx)
38{40{
39 avctx->hwaccel_context = av_vda_alloc_context();41 return av_vda_default_init2(avctx, NULL);
42}
43
44int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx)
45{
46 avctx->hwaccel_context = vdactx ?: av_vda_alloc_context();
40 if (!avctx->hwaccel_context)47 if (!avctx->hwaccel_context)
41 return AVERROR(ENOMEM);48 return AVERROR(ENOMEM);
42 return ff_vda_default_init(avctx);49 return ff_vda_default_init(avctx);
libavcodec/vda.h+17−0
@@ -153,6 +153,12 @@ typedef struct AVVDAContext { · 152 unmodified lines
153 * Set by av_vda_alloc_context().153 * Set by av_vda_alloc_context().
154 */154 */
155 VDADecoderOutputCallback output_callback;155 VDADecoderOutputCallback output_callback;
156
157 /**
158 * CVPixelBuffer Format Type that VDA will use for decoded frames; set by
159 * the caller.
160 */
161 OSType cv_pix_fmt_type;
156} AVVDAContext;162} AVVDAContext;
157 163
158/**164/**
@@ -180,6 +186,17 @@ AVVDAContext *av_vda_alloc_context(void); · 21 unmodified lines
180 */186 */
181int av_vda_default_init(AVCodecContext *avctx);187int av_vda_default_init(AVCodecContext *avctx);
182 188
189/**
190 * This is a convenience function that creates and sets up the VDA context using
191 * an internal implementation.
192 *
193 * @param avctx the corresponding codec context
194 * @param vdactx the VDA context to use
195 *
196 * @return >= 0 on success, a negative AVERROR code on failure
197 */
198int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx);
199
183/**200/**
184 * This function must be called to free the VDA context initialized with201 * This function must be called to free the VDA context initialized with
185 * av_vda_default_init().202 * av_vda_default_init().
libavcodec/vda_h264.c+1−1
@@ -380,7 +380,7 @@ int ff_vda_default_init(AVCodecContext *avctx) · 379 unmodified lines
380 CFMutableDictionaryRef buffer_attributes;380 CFMutableDictionaryRef buffer_attributes;
381 CFMutableDictionaryRef io_surface_properties;381 CFMutableDictionaryRef io_surface_properties;
382 CFNumberRef cv_pix_fmt;382 CFNumberRef cv_pix_fmt;
383 int32_t fmt = 'avc1', pix_fmt = kCVPixelFormatType_422YpCbCr8;383 int32_t fmt = 'avc1', pix_fmt = vda_ctx->cv_pix_fmt_type;
384 384
385 // kCVPixelFormatType_420YpCbCr8Planar;385 // kCVPixelFormatType_420YpCbCr8Planar;
386 386
libavcodec/version.h+2−2
@@ -29,8 +29,8 @@ · 28 unmodified lines
29#include "libavutil/version.h"29#include "libavutil/version.h"
30 30
31#define LIBAVCODEC_VERSION_MAJOR 5631#define LIBAVCODEC_VERSION_MAJOR 56
32#define LIBAVCODEC_VERSION_MINOR 2332#define LIBAVCODEC_VERSION_MINOR 24
33#define LIBAVCODEC_VERSION_MICRO 233#define LIBAVCODEC_VERSION_MICRO 0
34 34
35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
36 LIBAVCODEC_VERSION_MINOR, \36 LIBAVCODEC_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t