LCOV - code coverage report
Current view: top level - media/common/source - TypeConverters.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 83.3 % 18 15
Test Date: 2025-03-21 11:02:39 Functions: 100.0 % 3 3

            Line data    Source code
       1              : /*
       2              :  * If not stated otherwise in this file or this component's LICENSE file the
       3              :  * following copyright and licenses apply:
       4              :  *
       5              :  * Copyright 2024 Sky UK
       6              :  *
       7              :  * Licensed under the Apache License, Version 2.0 (the "License");
       8              :  * you may not use this file except in compliance with the License.
       9              :  * You may obtain a copy of the License at
      10              :  *
      11              :  * http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  * Unless required by applicable law or agreed to in writing, software
      14              :  * distributed under the License is distributed on an "AS IS" BASIS,
      15              :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  * See the License for the specific language governing permissions and
      17              :  * limitations under the License.
      18              :  */
      19              : 
      20              : #include "TypeConverters.h"
      21              : #include <unordered_map>
      22              : 
      23              : namespace firebolt::rialto::common
      24              : {
      25          200 : const char *convertMediaSourceType(const MediaSourceType &mediaSourceType)
      26              : {
      27              :     static const std::unordered_map<MediaSourceType, const char *>
      28              :         kMediaSourceTypeToStr{{MediaSourceType::AUDIO, "Audio"},
      29              :                               {MediaSourceType::VIDEO, "Video"},
      30              :                               {MediaSourceType::SUBTITLE, "Subtitle"},
      31          204 :                               {MediaSourceType::UNKNOWN, "Unknown"}};
      32          200 :     const auto kIt = kMediaSourceTypeToStr.find(mediaSourceType);
      33          200 :     if (kMediaSourceTypeToStr.end() != kIt)
      34              :     {
      35          200 :         return kIt->second;
      36              :     }
      37            0 :     return "Unknown";
      38              : }
      39              : 
      40            2 : const char *convertLayout(const Layout &layout)
      41              : {
      42              :     static const std::unordered_map<Layout, const char *> kLayoutToStr{{Layout::INTERLEAVED, "interleaved"},
      43            4 :                                                                        {Layout::NON_INTERLEAVED, "non-interleaved"}};
      44            2 :     const auto kIt = kLayoutToStr.find(layout);
      45            2 :     if (kLayoutToStr.end() != kIt)
      46              :     {
      47            2 :         return kIt->second;
      48              :     }
      49            0 :     return "";
      50              : }
      51              : 
      52            2 : const char *convertFormat(const Format &format)
      53              : {
      54              :     static const std::unordered_map<Format, const char *> kFormatToStr{{Format::S8, "S8"},
      55              :                                                                        {Format::U8, "U8"},
      56              :                                                                        {Format::S16LE, "S16LE"},
      57              :                                                                        {Format::S16BE, "S16BE"},
      58              :                                                                        {Format::U16LE, "U16LE"},
      59              :                                                                        {Format::U16BE, "U16BE"},
      60              :                                                                        {Format::S24_32LE, "S24_32LE"},
      61              :                                                                        {Format::S24_32BE, "S24_32BE"},
      62              :                                                                        {Format::U24_32LE, "U24_32LE"},
      63              :                                                                        {Format::U24_32BE, "U24_32BE"},
      64              :                                                                        {Format::S32LE, "S32LE"},
      65              :                                                                        {Format::S32BE, "S32BE"},
      66              :                                                                        {Format::U32LE, "U32LE"},
      67              :                                                                        {Format::U32BE, "U32BE"},
      68              :                                                                        {Format::S24LE, "S24LE"},
      69              :                                                                        {Format::S24BE, "S24BE"},
      70              :                                                                        {Format::U24LE, "U24LE"},
      71              :                                                                        {Format::U24BE, "U24BE"},
      72              :                                                                        {Format::S20LE, "S20LE"},
      73              :                                                                        {Format::S20BE, "S20BE"},
      74              :                                                                        {Format::U20LE, "U20LE"},
      75              :                                                                        {Format::U20BE, "U20BE"},
      76              :                                                                        {Format::S18LE, "S18LE"},
      77              :                                                                        {Format::S18BE, "S18BE"},
      78              :                                                                        {Format::U18LE, "U18LE"},
      79              :                                                                        {Format::U18BE, "U18BE"},
      80              :                                                                        {Format::F32LE, "F32LE"},
      81              :                                                                        {Format::F32BE, "F32BE"},
      82              :                                                                        {Format::F64LE, "F64LE"},
      83            4 :                                                                        {Format::F64BE, "F64BE"}};
      84            2 :     const auto kIt = kFormatToStr.find(format);
      85            2 :     if (kFormatToStr.end() != kIt)
      86              :     {
      87            2 :         return kIt->second;
      88              :     }
      89            0 :     return "";
      90              : }
      91              : } // namespace firebolt::rialto::common
        

Generated by: LCOV version 2.0-1