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_INTERNAL_FRAME_BUFFER_LIST_H_ 18 #define LIBGAV1_SRC_INTERNAL_FRAME_BUFFER_LIST_H_ 19 20 #include <cstddef> 21 #include <cstdint> 22 #include <memory> 23 24 #include "src/gav1/frame_buffer.h" 25 #include "src/utils/memory.h" 26 #include "src/utils/vector.h" 27 28 namespace libgav1 { 29 30 extern "C" Libgav1StatusCode OnInternalFrameBufferSizeChanged( 31 void* callback_private_data, int bitdepth, Libgav1ImageFormat image_format, 32 int width, int height, int left_border, int right_border, int top_border, 33 int bottom_border, int stride_alignment); 34 35 extern "C" Libgav1StatusCode GetInternalFrameBuffer( 36 void* callback_private_data, int bitdepth, Libgav1ImageFormat image_format, 37 int width, int height, int left_border, int right_border, int top_border, 38 int bottom_border, int stride_alignment, Libgav1FrameBuffer* frame_buffer); 39 40 extern "C" void ReleaseInternalFrameBuffer(void* callback_private_data, 41 void* buffer_private_data); 42 43 class InternalFrameBufferList : public Allocable { 44 public: 45 InternalFrameBufferList() = default; 46 47 // Not copyable or movable. 48 InternalFrameBufferList(const InternalFrameBufferList&) = delete; 49 InternalFrameBufferList& operator=(const InternalFrameBufferList&) = delete; 50 51 ~InternalFrameBufferList() = default; 52 53 Libgav1StatusCode OnFrameBufferSizeChanged(int bitdepth, 54 Libgav1ImageFormat image_format, 55 int width, int height, 56 int left_border, int right_border, 57 int top_border, int bottom_border, 58 int stride_alignment); 59 60 Libgav1StatusCode GetFrameBuffer(int bitdepth, 61 Libgav1ImageFormat image_format, int width, 62 int height, int left_border, 63 int right_border, int top_border, 64 int bottom_border, int stride_alignment, 65 Libgav1FrameBuffer* frame_buffer); 66 67 void ReleaseFrameBuffer(void* buffer_private_data); 68 69 private: 70 struct Buffer : public Allocable { 71 std::unique_ptr<uint8_t[], MallocDeleter> data; 72 size_t size = 0; 73 bool in_use = false; 74 }; 75 76 Vector<std::unique_ptr<Buffer>> buffers_; 77 }; 78 79 } // namespace libgav1 80 81 #endif // LIBGAV1_SRC_INTERNAL_FRAME_BUFFER_LIST_H_ 82