• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 } Libgav1DecoderSettings;
87 
88 LIBGAV1_PUBLIC void Libgav1DecoderSettingsInitDefault(
89     Libgav1DecoderSettings* settings);
90 
91 #if defined(__cplusplus)
92 }  // extern "C"
93 
94 namespace libgav1 {
95 
96 using ReleaseInputBufferCallback = Libgav1ReleaseInputBufferCallback;
97 
98 // Applications must populate this structure before creating a decoder instance.
99 struct DecoderSettings {
100   // Number of threads to use when decoding. Must be greater than 0. The library
101   // will create at most |threads| new threads. Defaults to 1 (no new threads
102   // will be created).
103   int threads = 1;
104   // Indicate to the decoder that frame parallel decoding is allowed. Note that
105   // this is just a request and the decoder will decide the number of frames to
106   // be decoded in parallel based on the video stream being decoded.
107   bool frame_parallel = false;
108   // In frame parallel mode, should DequeueFrame wait until a enqueued frame is
109   // available for dequeueing.
110   //
111   // If frame_parallel is false, this setting is ignored.
112   bool blocking_dequeue = false;
113   // Called when the first sequence header or a sequence header with a
114   // different frame size (which includes bitdepth, monochrome, subsampling_x,
115   // subsampling_y, maximum frame width, or maximum frame height) is received.
116   FrameBufferSizeChangedCallback on_frame_buffer_size_changed = nullptr;
117   // Get frame buffer callback.
118   GetFrameBufferCallback get_frame_buffer = nullptr;
119   // Release frame buffer callback.
120   ReleaseFrameBufferCallback release_frame_buffer = nullptr;
121   // Release input frame buffer callback. This callback must be set when
122   // |frame_parallel| is true.
123   ReleaseInputBufferCallback release_input_buffer = nullptr;
124   // Passed as the private_data argument to the callbacks.
125   void* callback_private_data = nullptr;
126   // If set to true, the decoder will output all the spatial and temporal
127   // layers.
128   bool output_all_layers = false;
129   // Index of the operating point to decode.
130   int operating_point = 0;
131   // Mask indicating the post processing filters that need to be applied to the
132   // reconstructed frame. Note this is an advanced setting and does not
133   // typically need to be changed.
134   // From LSB:
135   //   Bit 0: Loop filter (deblocking filter).
136   //   Bit 1: Cdef.
137   //   Bit 2: SuperRes.
138   //   Bit 3: Loop restoration.
139   //   Bit 4: Film grain synthesis.
140   //   All the bits other than the last 5 are ignored.
141   uint8_t post_filter_mask = 0x1f;
142 };
143 
144 }  // namespace libgav1
145 #endif  // defined(__cplusplus)
146 #endif  // LIBGAV1_SRC_GAV1_DECODER_SETTINGS_H_
147