• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*--------------------------------------------------------------------------
2 Copyright (c) 2017, The Linux Foundation. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are
6 met:
7     * Redistributions of source code must retain the above copyright
8       notice, this list of conditions and the following disclaimer.
9     * Redistributions in binary form must reproduce the above
10       copyright notice, this list of conditions and the following
11       disclaimer in the documentation and/or other materials provided
12       with the distribution.
13     * Neither the name of The Linux Foundation nor the names of its
14       contributors may be used to endorse or promote products derived
15       from this software without specific prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 --------------------------------------------------------------------------*/
29 #include <unordered_map>
30 
31 using pl_map = std::unordered_map<int, int>;
32 using codec_map = std::unordered_map<int, pl_map *>;
33 
34 class profile_level_converter {
35     static pl_map        profile_avc_omx_to_v4l2;
36     static pl_map        profile_hevc_omx_to_v4l2;
37     static pl_map        profile_mpeg2_omx_to_v4l2;
38     static pl_map        profile_vp9_omx_to_v4l2;
39     static pl_map        profile_tme_omx_to_v4l2;
40     static pl_map        level_avc_omx_to_v4l2;
41     static pl_map        level_hevc_omx_to_v4l2;
42     static pl_map        level_vp8_omx_to_v4l2;
43     static pl_map        level_mpeg2_omx_to_v4l2;
44     static pl_map        level_vp9_omx_to_v4l2;
45     static pl_map        level_tme_omx_to_v4l2;
46     static pl_map        profile_avc_v4l2_to_omx;
47     static pl_map        profile_hevc_v4l2_to_omx;
48     static pl_map        profile_mpeg2_v4l2_to_omx;
49     static pl_map        profile_vp9_v4l2_to_omx;
50     static pl_map        profile_tme_v4l2_to_omx;
51     static pl_map        level_avc_v4l2_to_omx;
52     static pl_map        level_hevc_v4l2_to_omx;
53     static pl_map        level_vp8_v4l2_to_omx;
54     static pl_map        level_mpeg2_v4l2_to_omx;
55     static pl_map        level_vp9_v4l2_to_omx;
56     static pl_map        level_tme_v4l2_to_omx;
57 
58     static codec_map     profile_omx_to_v4l2_map;
59     static codec_map     profile_v4l2_to_omx_map;
60     static codec_map     level_omx_to_v4l2_map;
61     static codec_map     level_v4l2_to_omx_map;
62 
63     //Constructor that initializes and performs the mapping
64     profile_level_converter() = delete;
65     static bool find_item(const pl_map &map, int key, int *value);
66     static bool find_map(const codec_map &map, int key, pl_map **value_map);
67 
68     public:
69     static void init();
70     static bool convert_v4l2_profile_to_omx(int codec, int v4l2_profile, int *omx_profile);
71     static bool convert_omx_profile_to_v4l2(int codec, int omx_profile, int *v4l2_profile);
72     static bool convert_v4l2_level_to_omx(int codec, int v4l2_level, int *omx_level);
73     static bool convert_omx_level_to_v4l2(int codec, int omx_level, int *v4l2_level);
74 };
75