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
1313
1414 API changes, most recent first:
1515
16+2015-xx-xx - xxxxxxx - lavc 56.23.0
17+ Add av_vda_default_init2.
18+
1619 2015-xx-xx - xxxxxxx - lavu 54.12.0
1720 Add AV_LOG_TRACE for extremely verbose debugging.
1821
libavcodec/vda.c+9−2
@@ -28,15 +28,22 @@ AVVDAContext *av_vda_alloc_context(void) · 27 unmodified lines
2828 {
2929 AVVDAContext *ret = av_mallocz(sizeof(*ret));
3030
31− if (ret)
31+ if (ret) {
3232 ret->output_callback = ff_vda_output_callback;
33+ ret->cv_pix_fmt_type = kCVPixelFormatType_422YpCbCr8;
34+ }
3335
3436 return ret;
3537 }
3638
3739 int av_vda_default_init(AVCodecContext *avctx)
3840 {
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();
4047 if (!avctx->hwaccel_context)
4148 return AVERROR(ENOMEM);
4249 return ff_vda_default_init(avctx);
libavcodec/vda.h+17−0
@@ -153,6 +153,12 @@ typedef struct AVVDAContext { · 152 unmodified lines
153153 * Set by av_vda_alloc_context().
154154 */
155155 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;
156162 } AVVDAContext;
157163
158164 /**
@@ -180,6 +186,17 @@ AVVDAContext *av_vda_alloc_context(void); · 21 unmodified lines
180186 */
181187 int av_vda_default_init(AVCodecContext *avctx);
182188
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+
183200 /**
184201 * This function must be called to free the VDA context initialized with
185202 * av_vda_default_init().
libavcodec/vda_h264.c+1−1
@@ -380,7 +380,7 @@ int ff_vda_default_init(AVCodecContext *avctx) · 379 unmodified lines
380380 CFMutableDictionaryRef buffer_attributes;
381381 CFMutableDictionaryRef io_surface_properties;
382382 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;
384384
385385 // kCVPixelFormatType_420YpCbCr8Planar;
386386
libavcodec/version.h+2−2
@@ -29,8 +29,8 @@ · 28 unmodified lines
2929 #include "libavutil/version.h"
3030
3131 #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
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3636 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