• 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    static_assert(PIPE_VIDEO_PROFILE_MAX == 27, "Update table below when adding new video profiles");
36    if (profile == PIPE_VIDEO_PROFILE_AV1_MAIN ||
37        profile == PIPE_VIDEO_PROFILE_AV1_PROFILE2) {
38       if (encode) {
39          if (!VIDEO_CODEC_AV1ENC)
40             return false;
41       } else if (!VIDEO_CODEC_AV1DEC) {
42          return false;
43       }
44    }
45    if (profile == PIPE_VIDEO_PROFILE_VP9_PROFILE0 ||
46        profile == PIPE_VIDEO_PROFILE_VP9_PROFILE2) {
47       if (!VIDEO_CODEC_VP9DEC)
48          return false;
49    }
50    if (profile == PIPE_VIDEO_PROFILE_VC1_SIMPLE ||
51        profile == PIPE_VIDEO_PROFILE_VC1_MAIN ||
52        profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED) {
53       if (!VIDEO_CODEC_VC1DEC)
54          return false;
55    }
56    if (profile >= PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE &&
57        profile <= PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH444) {
58       if (encode) {
59          if (!VIDEO_CODEC_H264ENC)
60             return false;
61       } else if (!VIDEO_CODEC_H264DEC) {
62          return false;
63       }
64    }
65    if (profile >= PIPE_VIDEO_PROFILE_HEVC_MAIN &&
66        profile <= PIPE_VIDEO_PROFILE_HEVC_MAIN_444) {
67       if (encode) {
68          if (!VIDEO_CODEC_H265ENC)
69             return false;
70       } else if (!VIDEO_CODEC_H265DEC) {
71          return false;
72       }
73    }
74 
75    return screen->get_video_param(screen, profile, encode ? PIPE_VIDEO_ENTRYPOINT_ENCODE : PIPE_VIDEO_ENTRYPOINT_BITSTREAM, PIPE_VIDEO_CAP_SUPPORTED);
76 }
77