Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INTERFACE_H_ |
| 12 | #define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INTERFACE_H_ |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 13 | |
| 14 | #include <vector> |
| 15 | |
philipel | 9df3353 | 2019-03-04 16:37:50 +0100 | [diff] [blame] | 16 | #include "absl/types/optional.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "api/video/video_frame.h" |
| 18 | #include "api/video_codecs/video_decoder.h" |
| 19 | #include "api/video_codecs/video_encoder.h" |
philipel | 9df3353 | 2019-03-04 16:37:50 +0100 | [diff] [blame] | 20 | #include "common_video/generic_frame_descriptor/generic_frame_info.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 21 | #include "modules/include/module_common_types.h" |
Danil Chapovalov | 7c06777 | 2019-10-07 12:56:24 +0200 | [diff] [blame] | 22 | #include "modules/video_coding/codecs/h264/include/h264_globals.h" |
| 23 | #include "modules/video_coding/codecs/vp9/include/vp9_globals.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 24 | #include "modules/video_coding/include/video_error_codes.h" |
Mirko Bonadei | 66e7679 | 2019-04-02 11:33:59 +0200 | [diff] [blame] | 25 | #include "rtc_base/system/rtc_export.h" |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 26 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 27 | namespace webrtc { |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 28 | |
Elad Alon | f5b216a | 2019-01-28 14:25:17 +0100 | [diff] [blame] | 29 | // Note: If any pointers are added to this struct, it must be fitted |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 30 | // with a copy-constructor. See below. |
Elad Alon | f5b216a | 2019-01-28 14:25:17 +0100 | [diff] [blame] | 31 | // Hack alert - the code assumes that thisstruct is memset when constructed. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 32 | struct CodecSpecificInfoVP8 { |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 33 | bool nonReference; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 34 | uint8_t temporalIdx; |
| 35 | bool layerSync; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 36 | int8_t keyIdx; // Negative value to skip keyIdx. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 37 | |
Elad Alon | f5b216a | 2019-01-28 14:25:17 +0100 | [diff] [blame] | 38 | // Used to generate the list of dependency frames. |
| 39 | // |referencedBuffers| and |updatedBuffers| contain buffer IDs. |
| 40 | // Note that the buffer IDs here have a one-to-one mapping with the actual |
| 41 | // codec buffers, but the exact mapping (i.e. whether 0 refers to Last, |
| 42 | // to Golden or to Arf) is not pre-determined. |
| 43 | // More references may be specified than are strictly necessary, but not less. |
| 44 | // TODO(bugs.webrtc.org/10242): Remove |useExplicitDependencies| once all |
| 45 | // encoder-wrappers are updated. |
| 46 | bool useExplicitDependencies; |
| 47 | static constexpr size_t kBuffersCount = 3; |
| 48 | size_t referencedBuffers[kBuffersCount]; |
| 49 | size_t referencedBuffersCount; |
| 50 | size_t updatedBuffers[kBuffersCount]; |
| 51 | size_t updatedBuffersCount; |
| 52 | }; |
| 53 | static_assert(std::is_pod<CodecSpecificInfoVP8>::value, ""); |
| 54 | |
| 55 | // Hack alert - the code assumes that thisstruct is memset when constructed. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 56 | struct CodecSpecificInfoVP9 { |
Niels Möller | bb894ff | 2018-03-15 12:28:53 +0100 | [diff] [blame] | 57 | bool first_frame_in_picture; // First frame, increment picture_id. |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 58 | bool inter_pic_predicted; // This layer frame is dependent on previously |
| 59 | // coded frame(s). |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 60 | bool flexible_mode; |
| 61 | bool ss_data_available; |
Sergey Silkin | c5a131a | 2018-04-24 20:13:49 +0200 | [diff] [blame] | 62 | bool non_ref_for_inter_layer_pred; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 63 | |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 64 | uint8_t temporal_idx; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 65 | bool temporal_up_switch; |
| 66 | bool inter_layer_predicted; // Frame is dependent on directly lower spatial |
| 67 | // layer frame. |
| 68 | uint8_t gof_idx; |
| 69 | |
| 70 | // SS data. |
| 71 | size_t num_spatial_layers; // Always populated. |
| 72 | bool spatial_layer_resolution_present; |
| 73 | uint16_t width[kMaxVp9NumberOfSpatialLayers]; |
| 74 | uint16_t height[kMaxVp9NumberOfSpatialLayers]; |
| 75 | GofInfoVP9 gof; |
| 76 | |
| 77 | // Frame reference data. |
| 78 | uint8_t num_ref_pics; |
| 79 | uint8_t p_diff[kMaxVp9RefPics]; |
Sergey Silkin | 2a1f183 | 2018-04-04 11:45:41 +0200 | [diff] [blame] | 80 | |
Sergey Silkin | bc0f0d3 | 2018-04-24 21:29:14 +0200 | [diff] [blame] | 81 | bool end_of_picture; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 82 | }; |
Elad Alon | f5b216a | 2019-01-28 14:25:17 +0100 | [diff] [blame] | 83 | static_assert(std::is_pod<CodecSpecificInfoVP9>::value, ""); |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 84 | |
Elad Alon | f5b216a | 2019-01-28 14:25:17 +0100 | [diff] [blame] | 85 | // Hack alert - the code assumes that thisstruct is memset when constructed. |
hta | 9aa9688 | 2016-12-06 05:36:03 -0800 | [diff] [blame] | 86 | struct CodecSpecificInfoH264 { |
| 87 | H264PacketizationMode packetization_mode; |
Johnny Lee | 1a1c52b | 2019-02-08 14:25:40 -0500 | [diff] [blame] | 88 | uint8_t temporal_idx; |
| 89 | bool base_layer_sync; |
| 90 | bool idr_frame; |
hta | 9aa9688 | 2016-12-06 05:36:03 -0800 | [diff] [blame] | 91 | }; |
Elad Alon | f5b216a | 2019-01-28 14:25:17 +0100 | [diff] [blame] | 92 | static_assert(std::is_pod<CodecSpecificInfoH264>::value, ""); |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 93 | |
| 94 | union CodecSpecificInfoUnion { |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 95 | CodecSpecificInfoVP8 VP8; |
| 96 | CodecSpecificInfoVP9 VP9; |
| 97 | CodecSpecificInfoH264 H264; |
| 98 | }; |
Elad Alon | f5b216a | 2019-01-28 14:25:17 +0100 | [diff] [blame] | 99 | static_assert(std::is_pod<CodecSpecificInfoUnion>::value, ""); |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 100 | |
philipel | 9df3353 | 2019-03-04 16:37:50 +0100 | [diff] [blame] | 101 | // Note: if any pointers are added to this struct or its sub-structs, it |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 102 | // must be fitted with a copy-constructor. This is because it is copied |
| 103 | // in the copy-constructor of VCMEncodedFrame. |
Mirko Bonadei | 66e7679 | 2019-04-02 11:33:59 +0200 | [diff] [blame] | 104 | struct RTC_EXPORT CodecSpecificInfo { |
philipel | 9df3353 | 2019-03-04 16:37:50 +0100 | [diff] [blame] | 105 | CodecSpecificInfo(); |
| 106 | CodecSpecificInfo(const CodecSpecificInfo&); |
| 107 | ~CodecSpecificInfo(); |
philipel | d1d0359 | 2019-03-01 13:53:55 +0100 | [diff] [blame] | 108 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 109 | VideoCodecType codecType; |
| 110 | CodecSpecificInfoUnion codecSpecific; |
philipel | 9df3353 | 2019-03-04 16:37:50 +0100 | [diff] [blame] | 111 | absl::optional<GenericFrameInfo> generic_frame_info; |
Danil Chapovalov | c2f5686 | 2019-06-27 12:11:03 +0200 | [diff] [blame] | 112 | absl::optional<FrameDependencyStructure> template_structure; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | } // namespace webrtc |
| 116 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 117 | #endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INTERFACE_H_ |