• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2022 Red Hat
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 #include "pipe/p_video_codec.h"
28 
29 #include "vl_codec.h"
30 
vl_codec_supported(struct pipe_screen * screen,enum pipe_video_profile profile,bool encode)31 bool vl_codec_supported(struct pipe_screen *screen,
32                         enum pipe_video_profile profile,
33                         bool encode)
34 {
35    if (profile == PIPE_VIDEO_PROFILE_VC1_SIMPLE ||
36        profile == PIPE_VIDEO_PROFILE_VC1_MAIN ||
37        profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED) {
38       if (!VIDEO_CODEC_VC1DEC)
39          return false;
40    }
41    if (profile >= PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE &&
42        profile <= PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH444) {
43       if (encode) {
44          if (!VIDEO_CODEC_H264ENC)
45             return false;
46       } else if (!VIDEO_CODEC_H264DEC) {
47          return false;
48       }
49    }
50    if (profile >= PIPE_VIDEO_PROFILE_HEVC_MAIN &&
51        profile <= PIPE_VIDEO_PROFILE_HEVC_MAIN_444) {
52       if (encode) {
53          if (!VIDEO_CODEC_H265ENC)
54             return false;
55       } else if (!VIDEO_CODEC_H265DEC) {
56          return false;
57       }
58    }
59 
60    return screen->get_video_param(screen, profile, encode ? PIPE_VIDEO_ENTRYPOINT_ENCODE : PIPE_VIDEO_ENTRYPOINT_BITSTREAM, PIPE_VIDEO_CAP_SUPPORTED);
61 }
62