1 /* 2 * Copyright 2019 The libgav1 Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef LIBGAV1_SRC_GAV1_DECODER_SETTINGS_H_ 18 #define LIBGAV1_SRC_GAV1_DECODER_SETTINGS_H_ 19 20 #if defined(__cplusplus) 21 #include <cstdint> 22 #else 23 #include <stdint.h> 24 #endif // defined(__cplusplus) 25 26 #include "gav1/frame_buffer.h" 27 #include "gav1/symbol_visibility.h" 28 29 // All the declarations in this file are part of the public ABI. 30 31 #if defined(__cplusplus) 32 extern "C" { 33 #endif 34 35 // This callback is invoked by the decoder when it is done using an input frame 36 // buffer. When frame_parallel is set to true, this callback must not be 37 // nullptr. Otherwise, this callback is optional. 38 // 39 // |buffer_private_data| is the value passed in the EnqueueFrame() call. 40 typedef void (*Libgav1ReleaseInputBufferCallback)(void* callback_private_data, 41 void* buffer_private_data); 42 43 typedef struct Libgav1DecoderSettings { 44 // Number of threads to use when decoding. Must be greater than 0. The library 45 // will create at most |threads| new threads. Defaults to 1 (no new threads 46 // will be created). 47 int threads; 48 // A boolean. Indicate to the decoder that frame parallel decoding is allowed. 49 // Note that this is just a request and the decoder will decide the number of 50 // frames to be decoded in parallel based on the video stream being decoded. 51 int frame_parallel; 52 // A boolean. In frame parallel mode, should Libgav1DecoderDequeueFrame wait 53 // until a enqueued frame is available for dequeueing. 54 // 55 // If frame_parallel is 0, this setting is ignored. 56 int blocking_dequeue; 57 // Called when the first sequence header or a sequence header with a 58 // different frame size (which includes bitdepth, monochrome, subsampling_x, 59 // subsampling_y, maximum frame width, or maximum frame height) is received. 60 Libgav1FrameBufferSizeChangedCallback on_frame_buffer_size_changed; 61 // Get frame buffer callback. 62 Libgav1GetFrameBufferCallback get_frame_buffer; 63 // Release frame buffer callback. 64 Libgav1ReleaseFrameBufferCallback release_frame_buffer; 65 // Release input frame buffer callback. This callback must be set when 66 // |frame_parallel| is true. 67 Libgav1ReleaseInputBufferCallback release_input_buffer; 68 // Passed as the private_data argument to the callbacks. 69 void* callback_private_data; 70 // A boolean. If set to 1, the decoder will output all the spatial and 71 // temporal layers. 72 int output_all_layers; 73 // Index of the operating point to decode. 74 int operating_point; 75 // Mask indicating the post processing filters that need to be applied to the 76 // reconstructed frame. Note this is an advanced setting and does not 77 // typically need to be changed. 78 // From LSB: 79 // Bit 0: Loop filter (deblocking filter). 80 // Bit 1: Cdef. 81 // Bit 2: SuperRes. 82 // Bit 3: Loop restoration. 83 // Bit 4: Film grain synthesis. 84 // All the bits other than the last 5 are ignored. 85 uint8_t post_filter_mask; 86 // A boolean. If set to 1, the decoder will only parse the bitstream, i.e., no 87 // decoding will take place. 88 int parse_only; 89 } Libgav1DecoderSettings; 90 91 LIBGAV1_PUBLIC void Libgav1DecoderSettingsInitDefault( 92 Libgav1DecoderSettings* settings); 93 94 #if defined(__cplusplus) 95 } // extern "C" 96 97 namespace libgav1 { 98 99 using ReleaseInputBufferCallback = Libgav1ReleaseInputBufferCallback; 100 101 // Applications must populate this structure before creating a decoder instance. 102 struct DecoderSettings { 103 // Number of threads to use when decoding. Must be greater than 0. The library 104 // will create at most |threads| new threads. Defaults to 1 (no new threads 105 // will be created). 106 int threads = 1; 107 // Indicate to the decoder that frame parallel decoding is allowed. Note that 108 // this is just a request and the decoder will decide the number of frames to 109 // be decoded in parallel based on the video stream being decoded. 110 bool frame_parallel = false; 111 // In frame parallel mode, should DequeueFrame wait until a enqueued frame is 112 // available for dequeueing. 113 // 114 // If frame_parallel is false, this setting is ignored. 115 bool blocking_dequeue = false; 116 // Called when the first sequence header or a sequence header with a 117 // different frame size (which includes bitdepth, monochrome, subsampling_x, 118 // subsampling_y, maximum frame width, or maximum frame height) is received. 119 FrameBufferSizeChangedCallback on_frame_buffer_size_changed = nullptr; 120 // Get frame buffer callback. 121 GetFrameBufferCallback get_frame_buffer = nullptr; 122 // Release frame buffer callback. 123 ReleaseFrameBufferCallback release_frame_buffer = nullptr; 124 // Release input frame buffer callback. This callback must be set when 125 // |frame_parallel| is true. 126 ReleaseInputBufferCallback release_input_buffer = nullptr; 127 // Passed as the private_data argument to the callbacks. 128 void* callback_private_data = nullptr; 129 // If set to true, the decoder will output all the spatial and temporal 130 // layers. 131 bool output_all_layers = false; 132 // Index of the operating point to decode. 133 int operating_point = 0; 134 // Mask indicating the post processing filters that need to be applied to the 135 // reconstructed frame. Note this is an advanced setting and does not 136 // typically need to be changed. 137 // From LSB: 138 // Bit 0: Loop filter (deblocking filter). 139 // Bit 1: Cdef. 140 // Bit 2: SuperRes. 141 // Bit 3: Loop restoration. 142 // Bit 4: Film grain synthesis. 143 // All the bits other than the last 5 are ignored. 144 uint8_t post_filter_mask = 0x1f; 145 // If set to true, the decoder will only parse the bitstream, i.e., no 146 // decoding will take place. 147 bool parse_only = false; 148 }; 149 150 } // namespace libgav1 151 #endif // defined(__cplusplus) 152 #endif // LIBGAV1_SRC_GAV1_DECODER_SETTINGS_H_ 153