From: SeokYeon Hwang Date: Fri, 5 Sep 2014 12:57:52 +0000 (+0900) Subject: vaapi: support various profile X-Git-Tag: TizenStudio_2.0_p3.0~398^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F27174%2F5;p=sdk%2Femulator%2Fqemu.git vaapi: support various profile Change-Id: I85469eb2afce718211a3cfdd7da593e616aa932e Signed-off-by: SeokYeon Hwang --- diff --git a/tizen/src/hw/pci/maru_brillcodec_vaapi.c b/tizen/src/hw/pci/maru_brillcodec_vaapi.c index b34afa0..f9171d7 100644 --- a/tizen/src/hw/pci/maru_brillcodec_vaapi.c +++ b/tizen/src/hw/pci/maru_brillcodec_vaapi.c @@ -44,7 +44,6 @@ #include "maru_brillcodec_plugin.h" #define SURFACE_COUNT 4 -#define PROFILE VAProfileH264High #ifndef VA_SURFACE_ATTRIB_SETTABLE #define vaCreateSurfaces(d, f, w, h, s, ns, a, na) \ @@ -65,12 +64,11 @@ static void *va_display; // FIXME static VAPluginContext *va_ctx = &(VAPluginContext) {}; -static int create_surfaces(AVCodecContext *ctx, int width, int height) +static int create_surfaces(AVCodecContext *ctx, int width, int height, VAProfile profile) { assert(width > 0 && height > 0); VAConfigID config_id; - VAProfile profile = PROFILE; // FIXME /* Create a VA configuration */ VAConfigAttrib attrib; @@ -171,11 +169,65 @@ static bool setup(AVCodecContext *ctx, int width, int height) { } } - if(create_surfaces(ctx, width, height)) { + VAProfile profile; + + int codec_id = ctx->codec_id; + switch(codec_id) + { + case AV_CODEC_ID_MPEG1VIDEO: + case AV_CODEC_ID_MPEG2VIDEO: + profile = VAProfileMPEG2Main; + break; + case AV_CODEC_ID_MPEG4: + profile = VAProfileMPEG4AdvancedSimple; + break; + case AV_CODEC_ID_WMV3: + profile = VAProfileVC1Main; + break; + case AV_CODEC_ID_VC1: + profile = VAProfileVC1Advanced; + break; + case AV_CODEC_ID_H264: + profile = VAProfileH264High; + break;; + default: + goto error; + } + + int num_profiles = vaMaxNumProfiles(va_display); + VAProfile *profiles_list = calloc(num_profiles, sizeof(VAProfile)); + bool is_supported_profile; + int i; + + if (!profiles_list) { + goto error; + } + + VAStatus status = vaQueryConfigProfiles(va_display, profiles_list, &num_profiles); + if (status == VA_STATUS_SUCCESS) { + for (i = 0; i < num_profiles; ++i) { + if (profiles_list[i] == profile) { + is_supported_profile = true; + break; + } + } + } + free(profiles_list); + if (!is_supported_profile) + { + printf("Codec and profile not supported by the VAAPI device"); + goto error; + } + + if(create_surfaces(ctx, width, height, profile)) { printf("Failed to initialize the VAAPI device\n"); } return true; + +error: + // TODO: error handling + return false; } static void copy_plane(uint8_t *dst,