1da853ecaSopenharmony_ci/*
2da853ecaSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd.
3da853ecaSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4da853ecaSopenharmony_ci * you may not use this file except in compliance with the License.
5da853ecaSopenharmony_ci * You may obtain a copy of the License at
6da853ecaSopenharmony_ci *
7da853ecaSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8da853ecaSopenharmony_ci *
9da853ecaSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10da853ecaSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11da853ecaSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12da853ecaSopenharmony_ci * See the License for the specific language governing permissions and
13da853ecaSopenharmony_ci * limitations under the License.
14da853ecaSopenharmony_ci */
15da853ecaSopenharmony_ci
16da853ecaSopenharmony_ci#ifndef FFMPEG_CONVERTER_H
17da853ecaSopenharmony_ci#define FFMPEG_CONVERTER_H
18da853ecaSopenharmony_ci
19da853ecaSopenharmony_ci#include <string_view>
20da853ecaSopenharmony_ci#include <string>
21da853ecaSopenharmony_ci#include "avcodec_info.h"
22da853ecaSopenharmony_ci#include "avcodec_common.h"
23da853ecaSopenharmony_ci#include "avcodec_audio_common.h"
24da853ecaSopenharmony_ci#include "avcodec_audio_channel_layout.h"
25da853ecaSopenharmony_ci#include "media_description.h"
26da853ecaSopenharmony_ci#ifdef __cplusplus
27da853ecaSopenharmony_ciextern "C" {
28da853ecaSopenharmony_ci#endif
29da853ecaSopenharmony_ci#include "libavcodec/avcodec.h"
30da853ecaSopenharmony_ci#include "libavutil/pixfmt.h"
31da853ecaSopenharmony_ci#include "libavcodec/bsf.h"
32da853ecaSopenharmony_ci#include "libavutil/channel_layout.h"
33da853ecaSopenharmony_ci#ifdef __cplusplus
34da853ecaSopenharmony_ci}
35da853ecaSopenharmony_ci#endif
36da853ecaSopenharmony_cinamespace OHOS {
37da853ecaSopenharmony_cinamespace MediaAVCodec {
38da853ecaSopenharmony_ciclass FFMpegConverter {
39da853ecaSopenharmony_cipublic:
40da853ecaSopenharmony_ci    static ColorPrimary ConvertFFMpegToOHColorPrimaries(AVColorPrimaries ffColorPrimaries);
41da853ecaSopenharmony_ci    static TransferCharacteristic ConvertFFMpegToOHColorTrans(AVColorTransferCharacteristic ffColorTrans);
42da853ecaSopenharmony_ci    static MatrixCoefficient ConvertFFMpegToOHColorMatrix(AVColorSpace ffColorSpace);
43da853ecaSopenharmony_ci    static int ConvertFFMpegToOHColorRange(AVColorRange ffColorRange);
44da853ecaSopenharmony_ci    static ChromaLocation ConvertFFMpegToOHChromaLocation(AVChromaLocation ffChromaLocation);
45da853ecaSopenharmony_ci    static HEVCProfile ConvertFFMpegToOHHEVCProfile(int ffHEVCProfile);
46da853ecaSopenharmony_ci    static HEVCLevel ConvertFFMpegToOHHEVCLevel(int ffHEVCLevel);
47da853ecaSopenharmony_ci    static AudioSampleFormat ConvertFFMpegAVCodecIdToOHAudioFormat(AVCodecID codecId);
48da853ecaSopenharmony_ci    static AudioSampleFormat ConvertFFMpegToOHAudioFormat(AVSampleFormat ffSampleFormat);
49da853ecaSopenharmony_ci    static AVSampleFormat ConvertOHAudioFormatToFFMpeg(AudioSampleFormat sampleFormat);
50da853ecaSopenharmony_ci    static AudioChannelLayout ConvertFFToOHAudioChannelLayout(uint64_t ffChannelLayout);
51da853ecaSopenharmony_ci    static AudioChannelLayout GetDefaultChannelLayout(int channels);
52da853ecaSopenharmony_ci    static AudioChannelLayout ConvertFFToOHAudioChannelLayoutV2(uint64_t ffChannelLayout, int channels);
53da853ecaSopenharmony_ci    static uint64_t ConvertOHAudioChannelLayoutToFFMpeg(AudioChannelLayout channelLayout);
54da853ecaSopenharmony_ci    static std::string_view ConvertOHAudioChannelLayoutToString(AudioChannelLayout layout);
55da853ecaSopenharmony_ci    static int64_t ConvertAudioPtsToUs(int64_t pts, AVRational base);
56da853ecaSopenharmony_ci    static std::string AVStrError(int errnum);
57da853ecaSopenharmony_ci
58da853ecaSopenharmony_ciprivate:
59da853ecaSopenharmony_ci    FFMpegConverter() = delete;
60da853ecaSopenharmony_ci    ~FFMpegConverter() = delete;
61da853ecaSopenharmony_ci};
62da853ecaSopenharmony_ci} // namespace MediaAVCodec
63da853ecaSopenharmony_ci} // namespace OHOS
64da853ecaSopenharmony_ci#endif