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.
Unified · Split
| @@ -13,6 +13,9 @@ libavutil: 2014-08-09 · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | API changes, most recent first: |
| 15 | 15 | |
| 16 | +2015-xx-xx - xxxxxxx - lavc 56.23.0 | |
| 17 | + Add av_vda_default_init2. | |
| 18 | + | |
| 16 | 19 | 2015-xx-xx - xxxxxxx - lavu 54.12.0 |
| 17 | 20 | Add AV_LOG_TRACE for extremely verbose debugging. |
| 18 | 21 | |
| @@ -28,15 +28,22 @@ AVVDAContext *av_vda_alloc_context(void) · 27 unmodified lines | ||
| 28 | 28 | { |
| 29 | 29 | AVVDAContext *ret = av_mallocz(sizeof(*ret)); |
| 30 | 30 | |
| 31 | − if (ret) | |
| 31 | + if (ret) { | |
| 32 | 32 | ret->output_callback = ff_vda_output_callback; |
| 33 | + ret->cv_pix_fmt_type = kCVPixelFormatType_422YpCbCr8; | |
| 34 | + } | |
| 33 | 35 | |
| 34 | 36 | return ret; |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | int 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 | + | |
| 44 | +int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx) | |
| 45 | +{ | |
| 46 | + avctx->hwaccel_context = vdactx ?: av_vda_alloc_context(); | |
| 40 | 47 | if (!avctx->hwaccel_context) |
| 41 | 48 | return AVERROR(ENOMEM); |
| 42 | 49 | return ff_vda_default_init(avctx); |
| @@ -153,6 +153,12 @@ typedef struct AVVDAContext { · 152 unmodified lines | ||
| 153 | 153 | * Set by av_vda_alloc_context(). |
| 154 | 154 | */ |
| 155 | 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 | 162 | } AVVDAContext; |
| 157 | 163 | |
| 158 | 164 | /** |
| @@ -180,6 +186,17 @@ AVVDAContext *av_vda_alloc_context(void); · 21 unmodified lines | ||
| 180 | 186 | */ |
| 181 | 187 | int 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 | + */ | |
| 198 | +int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx); | |
| 199 | + | |
| 183 | 200 | /** |
| 184 | 201 | * This function must be called to free the VDA context initialized with |
| 185 | 202 | * av_vda_default_init(). |
| @@ -380,7 +380,7 @@ int ff_vda_default_init(AVCodecContext *avctx) · 379 unmodified lines | ||
| 380 | 380 | CFMutableDictionaryRef buffer_attributes; |
| 381 | 381 | CFMutableDictionaryRef io_surface_properties; |
| 382 | 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 | 385 | // kCVPixelFormatType_420YpCbCr8Planar; |
| 386 | 386 | |
| @@ -29,8 +29,8 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "libavutil/version.h" |
| 30 | 30 | |
| 31 | 31 | #define LIBAVCODEC_VERSION_MAJOR 56 |
| 32 | −#define LIBAVCODEC_VERSION_MINOR 23 | |
| 33 | −#define LIBAVCODEC_VERSION_MICRO 2 | |
| 32 | +#define LIBAVCODEC_VERSION_MINOR 24 | |
| 33 | +#define LIBAVCODEC_VERSION_MICRO 0 | |
| 34 | 34 | |
| 35 | 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 36 | 36 | LIBAVCODEC_VERSION_MINOR, \ |