diff options
author | Mikhail Burakov <mburakov@mailbox.org> | 2023-05-14 15:01:56 +0200 |
---|---|---|
committer | Mikhail Burakov <mburakov@mailbox.org> | 2023-05-14 15:01:56 +0200 |
commit | 849bc346ff57fdd2ecdd9e8c62eb9c359d130af1 (patch) | |
tree | 7585975db45e987f111fd7a1453ac98fa120fe56 /hevc.h | |
parent | 0dd18e10061a9ef7ce841d204ac8da59cfd37495 (diff) |
Extract hevc bitstream formatters to separate file
Diffstat (limited to 'hevc.h')
-rw-r--r-- | hevc.h | 84 |
1 files changed, 84 insertions, 0 deletions
@@ -0,0 +1,84 @@ +/* + * Copyright (C) 2023 Mikhail Burakov. This file is part of streamer. + * + * streamer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * streamer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with streamer. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef STREAMER_HEVC_H_ +#define STREAMER_HEVC_H_ + +#include <stdbool.h> +#include <va/va.h> + +// Table 7-1 +enum NalUnitType { + BLA_W_LP = 16, + IDR_W_RADL = 19, + IDR_N_LP = 20, + RSV_IRAP_VCL23 = 23, + VPS_NUT = 32, + SPS_NUT = 33, + PPS_NUT = 34, +}; + +// Table 7-7 +enum SliceType { + B = 0, + P = 1, + I = 2, +}; + +struct Bitstream; + +struct MoreVideoParameters { + uint32_t max_b_depth; + uint32_t time_base_num; + uint32_t time_base_den; +}; + +struct MoreSeqParameters { + uint32_t crop_width; + uint32_t crop_height; + // TODO(mburakov): Why ffmpeg ignores vui section in seq? + bool video_signal_type_present_flag; + bool video_full_range_flag; + bool colour_description_present_flag; + uint8_t colour_primaries; + uint8_t transfer_characteristics; + uint8_t matrix_coeffs; + bool chroma_loc_info_present_flag; + uint32_t chroma_sample_loc_type_top_field; + uint32_t chroma_sample_loc_type_bottom_field; +}; + +struct MoreSliceParamerters { + bool first_slice_segment_in_pic_flag; +}; + +void PackVideoParameterSetNalUnit(struct Bitstream* bitstream, + const VAEncSequenceParameterBufferHEVC* seq, + const struct MoreVideoParameters* mvp); +void PackSeqParameterSetNalUnit(struct Bitstream* bitstream, + const VAEncSequenceParameterBufferHEVC* seq, + const struct MoreVideoParameters* mvp, + const struct MoreSeqParameters* msp); +void PackPicParameterSetNalUnit(struct Bitstream* bitstream, + const VAEncPictureParameterBufferHEVC* pic); +void PackSliceSegmentHeaderNalUnit(struct Bitstream* bitstream, + const VAEncSequenceParameterBufferHEVC* seq, + const VAEncPictureParameterBufferHEVC* pic, + const VAEncSliceParameterBufferHEVC* slice, + const struct MoreSliceParamerters* msp); + +#endif // STREAMER_HEVC_H_ |