---
doc/APIchanges | 3 +++
libavcodec/vaapi.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
libavcodec/vaapi.h | 17 +++++++++++++++++
3 files changed, 66 insertions(+)
diff --git a/doc/APIchanges b/doc/APIchanges
index 1882fb8..efc96f1 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2012-10-22
API changes, most recent first:
+2013-11-xx - xxxxxxx - lavc 55.28.0 - vaapi.h
+ Add av_vaapi_get_profile().
+
2013-11-xx - xxxxxxx - lavu 52.18.0 - mem.h
Move av_fast_malloc() and av_fast_realloc() for libavcodec to libavutil.
diff --git a/libavcodec/vaapi.c b/libavcodec/vaapi.c
index 0532daf..4c5fb9f 100644
--- a/libavcodec/vaapi.c
+++ b/libavcodec/vaapi.c
@@ -21,6 +21,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <va/va.h>
+
+#include "avcodec.h"
#include "h264.h"
#include "vaapi_internal.h"
@@ -216,4 +219,47 @@ finish:
return ret;
}
+int av_vaapi_get_profile(AVCodecContext *avctx, VAProfile *profile)
+{
+#define PROFILE(prof) \
+do { \
+ *profile = prof; \
+ return 0; \
+} while (0)
+
+ switch (avctx->codec_id) {
+ case AV_CODEC_ID_MPEG1VIDEO: PROFILE(VAProfileMPEG2Main);
+ case AV_CODEC_ID_MPEG2VIDEO:
+ switch (avctx->profile) {
+ case FF_PROFILE_MPEG2_MAIN: PROFILE(VAProfileMPEG2Main);
+ case FF_PROFILE_MPEG2_SIMPLE: PROFILE(VAProfileMPEG2Simple);
+ default: return AVERROR(EINVAL);
+ }
+ case AV_CODEC_ID_H263:
PROFILE(VAProfileMPEG4AdvancedSimple);
+ case AV_CODEC_ID_MPEG4:
+ switch (avctx->profile) {
+ case FF_PROFILE_MPEG4_SIMPLE: PROFILE(VAProfileMPEG4Simple);
+ case FF_PROFILE_MPEG4_ADVANCED_SIMPLE:
PROFILE(VAProfileMPEG4AdvancedSimple);
+ default: return AVERROR(EINVAL);
+ }
+ case AV_CODEC_ID_H264:
+ switch (avctx->profile) {
+ case FF_PROFILE_H264_CONSTRAINED_BASELINE:
PROFILE(VAProfileH264ConstrainedBaseline);
+ case FF_PROFILE_H264_BASELINE:
PROFILE(VAProfileH264Baseline);
+ case FF_PROFILE_H264_MAIN: PROFILE(VAProfileH264Main);
+ case FF_PROFILE_H264_HIGH: PROFILE(VAProfileH264High);
+ default: return AVERROR(EINVAL);
+ }
+ case AV_CODEC_ID_WMV3:
+ case AV_CODEC_ID_VC1:
+ switch (avctx->profile) {
+ case FF_PROFILE_VC1_SIMPLE: PROFILE(VAProfileVC1Simple);
+ case FF_PROFILE_VC1_MAIN: PROFILE(VAProfileVC1Main);
+ case FF_PROFILE_VC1_ADVANCED: PROFILE(VAProfileVC1Advanced);
+ default: return AVERROR(EINVAL);
+ }
+ }
+ return AVERROR(EINVAL);
+}
+
/* @} */
diff --git a/libavcodec/vaapi.h b/libavcodec/vaapi.h
index 39e8825..fbfe572 100644
--- a/libavcodec/vaapi.h
+++ b/libavcodec/vaapi.h
@@ -32,6 +32,10 @@
#include <stdint.h>
+#include <va/va.h>
+
+#include "avcodec.h"
+
/**
* @defgroup lavc_codec_hwaccel_vaapi VA API Decoding
* @ingroup lavc_codec_hwaccel
@@ -168,6 +172,19 @@ struct vaapi_context {
uint32_t slice_data_size;
};
+/**
+ * Get a decoder profile that should be used for initializing a VAAPI config.
+ * Should be called from the AVCodecContext.get_format() callback.
+ *
+ * @param avctx the codec context being used for decoding the stream
+ * @param profile a pointer into which the result will be written on success.
+ * The contents of profile are undefined if this function
returns
+ * an error.
+ *
+ * @return 0 on success (non-negative), a negative AVERROR on failure.
+ */
+int av_vaapi_get_profile(AVCodecContext *avctx, VAProfile *profile);
+
/* @} */
#endif /* AVCODEC_VAAPI_H */
--
1.7.10.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel