On Thu, 14 Nov 2013 10:31:45 +0100
Anton Khirnov <[email protected]> wrote:

> ---
>  doc/APIchanges       |    3 +++
>  libavcodec/vaapi.c   |   46 ++++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/vaapi.h   |   17 +++++++++++++++++
>  libavcodec/version.h |    2 +-
>  4 files changed, 67 insertions(+), 1 deletion(-)
> 
> 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);

It appears vaapi doesn't always report the presence of this profile,
even if it could be decoded via MAIN. Does the caller have to handle
this?

> +        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 */
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index 38a6064..e9d09ac 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -27,7 +27,7 @@
>   */
>  
>  #define LIBAVCODEC_VERSION_MAJOR 55
> -#define LIBAVCODEC_VERSION_MINOR 27
> +#define LIBAVCODEC_VERSION_MINOR 28
>  #define LIBAVCODEC_VERSION_MICRO  0
>  
>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to