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_TILE_H_ 18 #define LIBGAV1_SRC_TILE_H_ 19 20 #include <algorithm> 21 #include <array> 22 #include <cassert> 23 #include <condition_variable> // NOLINT (unapproved c++11 header) 24 #include <cstddef> 25 #include <cstdint> 26 #include <memory> 27 #include <mutex> // NOLINT (unapproved c++11 header) 28 #include <vector> 29 30 #include "src/buffer_pool.h" 31 #include "src/decoder_state.h" 32 #include "src/dsp/common.h" 33 #include "src/dsp/constants.h" 34 #include "src/dsp/dsp.h" 35 #include "src/frame_scratch_buffer.h" 36 #include "src/loop_restoration_info.h" 37 #include "src/obu_parser.h" 38 #include "src/post_filter.h" 39 #include "src/quantizer.h" 40 #include "src/residual_buffer_pool.h" 41 #include "src/symbol_decoder_context.h" 42 #include "src/tile_scratch_buffer.h" 43 #include "src/utils/array_2d.h" 44 #include "src/utils/block_parameters_holder.h" 45 #include "src/utils/blocking_counter.h" 46 #include "src/utils/common.h" 47 #include "src/utils/compiler_attributes.h" 48 #include "src/utils/constants.h" 49 #include "src/utils/entropy_decoder.h" 50 #include "src/utils/memory.h" 51 #include "src/utils/segmentation_map.h" 52 #include "src/utils/threadpool.h" 53 #include "src/utils/types.h" 54 #include "src/yuv_buffer.h" 55 56 namespace libgav1 { 57 58 // Indicates what the ProcessSuperBlock() and TransformBlock() functions should 59 // do. "Parse" refers to consuming the bitstream, reading the transform 60 // coefficients and performing the dequantization. "Decode" refers to computing 61 // the prediction, applying the inverse transforms and adding the residual. 62 enum ProcessingMode { 63 kProcessingModeParseOnly, 64 kProcessingModeDecodeOnly, 65 kProcessingModeParseAndDecode, 66 }; 67 68 // The alignment requirement is due to the SymbolDecoderContext member 69 // symbol_decoder_context_. 70 class Tile : public MaxAlignedAllocable { 71 public: Create(int tile_number,const uint8_t * const data,size_t size,const ObuSequenceHeader & sequence_header,const ObuFrameHeader & frame_header,RefCountedBuffer * const current_frame,const DecoderState & state,FrameScratchBuffer * const frame_scratch_buffer,const WedgeMaskArray & wedge_masks,const QuantizerMatrix & quantizer_matrix,SymbolDecoderContext * const saved_symbol_decoder_context,const SegmentationMap * prev_segment_ids,PostFilter * const post_filter,const dsp::Dsp * const dsp,ThreadPool * const thread_pool,BlockingCounterWithStatus * const pending_tiles,bool frame_parallel,bool use_intra_prediction_buffer)72 static std::unique_ptr<Tile> Create( 73 int tile_number, const uint8_t* const data, size_t size, 74 const ObuSequenceHeader& sequence_header, 75 const ObuFrameHeader& frame_header, RefCountedBuffer* const current_frame, 76 const DecoderState& state, FrameScratchBuffer* const frame_scratch_buffer, 77 const WedgeMaskArray& wedge_masks, 78 const QuantizerMatrix& quantizer_matrix, 79 SymbolDecoderContext* const saved_symbol_decoder_context, 80 const SegmentationMap* prev_segment_ids, PostFilter* const post_filter, 81 const dsp::Dsp* const dsp, ThreadPool* const thread_pool, 82 BlockingCounterWithStatus* const pending_tiles, bool frame_parallel, 83 bool use_intra_prediction_buffer) { 84 std::unique_ptr<Tile> tile(new (std::nothrow) Tile( 85 tile_number, data, size, sequence_header, frame_header, current_frame, 86 state, frame_scratch_buffer, wedge_masks, quantizer_matrix, 87 saved_symbol_decoder_context, prev_segment_ids, post_filter, dsp, 88 thread_pool, pending_tiles, frame_parallel, 89 use_intra_prediction_buffer)); 90 return (tile != nullptr && tile->Init()) ? std::move(tile) : nullptr; 91 } 92 93 // Move only. 94 Tile(Tile&& tile) noexcept; 95 Tile& operator=(Tile&& tile) noexcept; 96 Tile(const Tile&) = delete; 97 Tile& operator=(const Tile&) = delete; 98 99 struct Block; // Defined after this class. 100 101 // Parses the entire tile. 102 bool Parse(); 103 // Decodes the entire tile. |superblock_row_progress| and 104 // |superblock_row_progress_condvar| are arrays of size equal to the number of 105 // superblock rows in the frame. Increments |superblock_row_progress[i]| after 106 // each superblock row at index |i| is decoded. If the count reaches the 107 // number of tile columns, then it notifies 108 // |superblock_row_progress_condvar[i]|. 109 bool Decode(std::mutex* mutex, int* superblock_row_progress, 110 std::condition_variable* superblock_row_progress_condvar); 111 // Parses and decodes the entire tile. Depending on the configuration of this 112 // Tile, this function may do multithreaded decoding. 113 bool ParseAndDecode(); // 5.11.2. 114 // Processes all the columns of the superblock row at |row4x4| that are within 115 // this Tile. If |save_symbol_decoder_context| is true, then 116 // SaveSymbolDecoderContext() is invoked for the last superblock row. 117 template <ProcessingMode processing_mode, bool save_symbol_decoder_context> 118 bool ProcessSuperBlockRow(int row4x4, TileScratchBuffer* scratch_buffer); 119 sequence_header()120 const ObuSequenceHeader& sequence_header() const { return sequence_header_; } frame_header()121 const ObuFrameHeader& frame_header() const { return frame_header_; } current_frame()122 const RefCountedBuffer& current_frame() const { return current_frame_; } motion_field()123 const TemporalMotionField& motion_field() const { return motion_field_; } reference_frame_sign_bias()124 const std::array<bool, kNumReferenceFrameTypes>& reference_frame_sign_bias() 125 const { 126 return reference_frame_sign_bias_; 127 } 128 IsRow4x4Inside(int row4x4)129 bool IsRow4x4Inside(int row4x4) const { 130 return row4x4 >= row4x4_start_ && row4x4 < row4x4_end_; 131 } 132 133 // 5.11.51. IsInside(int row4x4,int column4x4)134 bool IsInside(int row4x4, int column4x4) const { 135 return IsRow4x4Inside(row4x4) && column4x4 >= column4x4_start_ && 136 column4x4 < column4x4_end_; 137 } 138 IsLeftInside(int column4x4)139 bool IsLeftInside(int column4x4) const { 140 // We use "larger than" as the condition. Don't pass in the left column 141 // offset column4x4 - 1. 142 assert(column4x4 <= column4x4_end_); 143 return column4x4 > column4x4_start_; 144 } 145 IsTopInside(int row4x4)146 bool IsTopInside(int row4x4) const { 147 // We use "larger than" as the condition. Don't pass in the top row offset 148 // row4x4 - 1. 149 assert(row4x4 <= row4x4_end_); 150 return row4x4 > row4x4_start_; 151 } 152 IsTopLeftInside(int row4x4,int column4x4)153 bool IsTopLeftInside(int row4x4, int column4x4) const { 154 // We use "larger than" as the condition. Don't pass in the top row offset 155 // row4x4 - 1 or the left column offset column4x4 - 1. 156 assert(row4x4 <= row4x4_end_); 157 assert(column4x4 <= column4x4_end_); 158 return row4x4 > row4x4_start_ && column4x4 > column4x4_start_; 159 } 160 IsBottomRightInside(int row4x4,int column4x4)161 bool IsBottomRightInside(int row4x4, int column4x4) const { 162 assert(row4x4 >= row4x4_start_); 163 assert(column4x4 >= column4x4_start_); 164 return row4x4 < row4x4_end_ && column4x4 < column4x4_end_; 165 } 166 BlockParametersAddress(int row4x4,int column4x4)167 BlockParameters** BlockParametersAddress(int row4x4, int column4x4) const { 168 return block_parameters_holder_.Address(row4x4, column4x4); 169 } 170 BlockParametersStride()171 int BlockParametersStride() const { 172 return block_parameters_holder_.columns4x4(); 173 } 174 175 // Returns true if Parameters() can be called with |row| and |column| as 176 // inputs, false otherwise. HasParameters(int row,int column)177 bool HasParameters(int row, int column) const { 178 return block_parameters_holder_.Find(row, column) != nullptr; 179 } Parameters(int row,int column)180 const BlockParameters& Parameters(int row, int column) const { 181 return *block_parameters_holder_.Find(row, column); 182 } 183 number()184 int number() const { return number_; } superblock_rows()185 int superblock_rows() const { return superblock_rows_; } superblock_columns()186 int superblock_columns() const { return superblock_columns_; } row4x4_start()187 int row4x4_start() const { return row4x4_start_; } column4x4_start()188 int column4x4_start() const { return column4x4_start_; } column4x4_end()189 int column4x4_end() const { return column4x4_end_; } 190 191 private: 192 // Stores the transform tree state when reading variable size transform trees 193 // and when applying the transform tree. When applying the transform tree, 194 // |depth| is not used. 195 struct TransformTreeNode { 196 // The default constructor is invoked by the Stack<TransformTreeNode, n> 197 // constructor. Stack<> does not use the default-constructed elements, so it 198 // is safe for the default constructor to not initialize the members. 199 TransformTreeNode() = default; 200 TransformTreeNode(int x, int y, TransformSize tx_size, int depth = -1) xTransformTreeNode201 : x(x), y(y), tx_size(tx_size), depth(depth) {} 202 203 int x; 204 int y; 205 TransformSize tx_size; 206 int depth; 207 }; 208 209 // Enum to track the processing state of a superblock. 210 enum SuperBlockState : uint8_t { 211 kSuperBlockStateNone, // Not yet parsed or decoded. 212 kSuperBlockStateParsed, // Parsed but not yet decoded. 213 kSuperBlockStateScheduled, // Scheduled for decoding. 214 kSuperBlockStateDecoded // Parsed and decoded. 215 }; 216 217 // Parameters used to facilitate multi-threading within the Tile. 218 struct ThreadingParameters { 219 std::mutex mutex; 220 // 2d array of size |superblock_rows_| by |superblock_columns_| containing 221 // the processing state of each superblock. 222 Array2D<SuperBlockState> sb_state LIBGAV1_GUARDED_BY(mutex); 223 // Variable used to indicate either parse or decode failure. 224 bool abort LIBGAV1_GUARDED_BY(mutex) = false; 225 int pending_jobs LIBGAV1_GUARDED_BY(mutex) = 0; 226 std::condition_variable pending_jobs_zero_condvar; 227 }; 228 229 // The residual pointer is used to traverse the |residual_buffer_|. It is 230 // used in two different ways. 231 // If |split_parse_and_decode_| is true: 232 // The pointer points to the beginning of the |residual_buffer_| when the 233 // "parse" and "decode" steps begin. It is then moved forward tx_size in 234 // each iteration of the "parse" and the "decode" steps. In this case, the 235 // ResidualPtr variable passed into various functions starting from 236 // ProcessSuperBlock is used as an in/out parameter to keep track of the 237 // residual pointer. 238 // If |split_parse_and_decode_| is false: 239 // The pointer is reset to the beginning of the |residual_buffer_| for 240 // every transform block. 241 using ResidualPtr = uint8_t*; 242 243 Tile(int tile_number, const uint8_t* data, size_t size, 244 const ObuSequenceHeader& sequence_header, 245 const ObuFrameHeader& frame_header, RefCountedBuffer* current_frame, 246 const DecoderState& state, FrameScratchBuffer* frame_scratch_buffer, 247 const WedgeMaskArray& wedge_masks, 248 const QuantizerMatrix& quantizer_matrix, 249 SymbolDecoderContext* saved_symbol_decoder_context, 250 const SegmentationMap* prev_segment_ids, PostFilter* post_filter, 251 const dsp::Dsp* dsp, ThreadPool* thread_pool, 252 BlockingCounterWithStatus* pending_tiles, bool frame_parallel, 253 bool use_intra_prediction_buffer); 254 255 // Performs member initializations that may fail. Helper function used by 256 // Create(). 257 LIBGAV1_MUST_USE_RESULT bool Init(); 258 259 // Saves the symbol decoder context of this tile into 260 // |saved_symbol_decoder_context_| if necessary. 261 void SaveSymbolDecoderContext(); 262 263 // Entry point for multi-threaded decoding. This function performs the same 264 // functionality as ParseAndDecode(). The current thread does the "parse" step 265 // while the worker threads do the "decode" step. 266 bool ThreadedParseAndDecode(); 267 268 // Returns whether or not the prerequisites for decoding the superblock at 269 // |row_index| and |column_index| are satisfied. |threading_.mutex| must be 270 // held when calling this function. 271 bool CanDecode(int row_index, int column_index) const; 272 273 // This function is run by the worker threads when multi-threaded decoding is 274 // enabled. Once a superblock is decoded, this function will set the 275 // corresponding |threading_.sb_state| entry to kSuperBlockStateDecoded. On 276 // failure, |threading_.abort| will be set to true. If at any point 277 // |threading_.abort| becomes true, this function will return as early as it 278 // can. If the decoding succeeds, this function will also schedule the 279 // decoding jobs for the superblock to the bottom-left and the superblock to 280 // the right of this superblock (if it is allowed). 281 void DecodeSuperBlock(int row_index, int column_index, int block_width4x4); 282 283 // If |use_intra_prediction_buffer_| is true, then this function copies the 284 // last row of the superblockrow starting at |row4x4| into the 285 // |intra_prediction_buffer_| (which may be used by the intra prediction 286 // process for the next superblock row). 287 void PopulateIntraPredictionBuffer(int row4x4); 288 289 uint16_t* GetPartitionCdf(int row4x4, int column4x4, BlockSize block_size); 290 bool ReadPartition(int row4x4, int column4x4, BlockSize block_size, 291 bool has_rows, bool has_columns, Partition* partition); 292 // Processes the Partition starting at |row4x4_start|, |column4x4_start| 293 // iteratively. It performs a DFS traversal over the partition tree to process 294 // the blocks in the right order. 295 bool ProcessPartition( 296 int row4x4_start, int column4x4_start, TileScratchBuffer* scratch_buffer, 297 ResidualPtr* residual); // Iterative implementation of 5.11.4. 298 bool ProcessBlock(int row4x4, int column4x4, BlockSize block_size, 299 TileScratchBuffer* scratch_buffer, 300 ResidualPtr* residual); // 5.11.5. 301 void ResetCdef(int row4x4, int column4x4); // 5.11.55. 302 303 // This function is used to decode a superblock when the parsing has already 304 // been done for that superblock. 305 bool DecodeSuperBlock(int sb_row_index, int sb_column_index, 306 TileScratchBuffer* scratch_buffer); 307 // Helper function used by DecodeSuperBlock(). Note that the decode_block() 308 // function in the spec is equivalent to ProcessBlock() in the code. 309 bool DecodeBlock(int row4x4, int column4x4, BlockSize block_size, 310 TileScratchBuffer* scratch_buffer, ResidualPtr* residual); 311 312 void ClearBlockDecoded(TileScratchBuffer* scratch_buffer, int row4x4, 313 int column4x4); // 5.11.3. 314 bool ProcessSuperBlock(int row4x4, int column4x4, 315 TileScratchBuffer* scratch_buffer, 316 ProcessingMode mode); 317 void ResetLoopRestorationParams(); 318 void ReadLoopRestorationCoefficients(int row4x4, int column4x4, 319 BlockSize block_size); // 5.11.57. 320 321 // Helper functions for DecodeBlock. 322 bool ReadSegmentId(const Block& block); // 5.11.9. 323 bool ReadIntraSegmentId(const Block& block); // 5.11.8. 324 void ReadSkip(const Block& block); // 5.11.11. 325 bool ReadSkipMode(const Block& block); // 5.11.10. 326 void ReadCdef(const Block& block); // 5.11.56. 327 // Returns the new value. |cdf| is an array of size kDeltaSymbolCount + 1. 328 int ReadAndClipDelta(uint16_t* cdf, int delta_small, int scale, int min_value, 329 int max_value, int value); 330 void ReadQuantizerIndexDelta(const Block& block); // 5.11.12. 331 void ReadLoopFilterDelta(const Block& block); // 5.11.13. 332 // Populates |BlockParameters::deblock_filter_level| for the given |block| 333 // using |deblock_filter_levels_|. 334 void PopulateDeblockFilterLevel(const Block& block); 335 void PopulateCdefSkip(const Block& block); 336 void ReadPredictionModeY(const Block& block, bool intra_y_mode); 337 void ReadIntraAngleInfo(const Block& block, 338 PlaneType plane_type); // 5.11.42 and 5.11.43. 339 void ReadPredictionModeUV(const Block& block); 340 void ReadCflAlpha(const Block& block); // 5.11.45. 341 int GetPaletteCache(const Block& block, PlaneType plane_type, 342 uint16_t* cache); 343 void ReadPaletteColors(const Block& block, Plane plane); 344 void ReadPaletteModeInfo(const Block& block); // 5.11.46. 345 void ReadFilterIntraModeInfo(const Block& block); // 5.11.24. 346 int ReadMotionVectorComponent(const Block& block, 347 int component); // 5.11.32. 348 void ReadMotionVector(const Block& block, int index); // 5.11.31. 349 bool DecodeIntraModeInfo(const Block& block); // 5.11.7. 350 int8_t ComputePredictedSegmentId(const Block& block) const; // 5.11.21. 351 bool ReadInterSegmentId(const Block& block, bool pre_skip); // 5.11.19. 352 void ReadIsInter(const Block& block, bool skip_mode); // 5.11.20. 353 bool ReadIntraBlockModeInfo(const Block& block, 354 bool intra_y_mode); // 5.11.22. 355 CompoundReferenceType ReadCompoundReferenceType(const Block& block); 356 template <bool is_single, bool is_backward, int index> 357 uint16_t* GetReferenceCdf(const Block& block, CompoundReferenceType type = 358 kNumCompoundReferenceTypes); 359 void ReadReferenceFrames(const Block& block, bool skip_mode); // 5.11.25. 360 void ReadInterPredictionModeY(const Block& block, 361 const MvContexts& mode_contexts, 362 bool skip_mode); 363 void ReadRefMvIndex(const Block& block); 364 void ReadInterIntraMode(const Block& block, bool is_compound, 365 bool skip_mode); // 5.11.28. IsScaled(ReferenceFrameType type)366 bool IsScaled(ReferenceFrameType type) const { // Part of 5.11.27. 367 const int index = 368 frame_header_.reference_frame_index[type - kReferenceFrameLast]; 369 return reference_frames_[index]->upscaled_width() != frame_header_.width || 370 reference_frames_[index]->frame_height() != frame_header_.height; 371 } 372 void ReadMotionMode(const Block& block, bool is_compound, 373 bool skip_mode); // 5.11.27. 374 uint16_t* GetIsExplicitCompoundTypeCdf(const Block& block); 375 uint16_t* GetIsCompoundTypeAverageCdf(const Block& block); 376 void ReadCompoundType(const Block& block, bool is_compound, bool skip_mode, 377 bool* is_explicit_compound_type, 378 bool* is_compound_type_average); // 5.11.29. 379 uint16_t* GetInterpolationFilterCdf(const Block& block, int direction); 380 void ReadInterpolationFilter(const Block& block, bool skip_mode); 381 bool ReadInterBlockModeInfo(const Block& block, bool skip_mode); // 5.11.23. 382 bool DecodeInterModeInfo(const Block& block); // 5.11.18. 383 bool DecodeModeInfo(const Block& block); // 5.11.6. 384 bool IsMvValid(const Block& block, bool is_compound) const; // 6.10.25. 385 bool AssignInterMv(const Block& block, bool is_compound); // 5.11.26. 386 bool AssignIntraMv(const Block& block); // 5.11.26. 387 int GetTopTransformWidth(const Block& block, int row4x4, int column4x4, 388 bool ignore_skip); 389 int GetLeftTransformHeight(const Block& block, int row4x4, int column4x4, 390 bool ignore_skip); 391 TransformSize ReadFixedTransformSize(const Block& block); // 5.11.15. 392 // Iterative implementation of 5.11.17. 393 void ReadVariableTransformTree(const Block& block, int row4x4, int column4x4, 394 TransformSize tx_size); 395 void DecodeTransformSize(const Block& block); // 5.11.16. 396 bool ComputePrediction(const Block& block); // 5.11.33. 397 // |x4| and |y4| are the column and row positions of the 4x4 block. |w4| and 398 // |h4| are the width and height in 4x4 units of |tx_size|. 399 int GetTransformAllZeroContext(const Block& block, Plane plane, 400 TransformSize tx_size, int x4, int y4, int w4, 401 int h4); 402 TransformSet GetTransformSet(TransformSize tx_size, 403 bool is_inter) const; // 5.11.48. 404 TransformType ComputeTransformType(const Block& block, Plane plane, 405 TransformSize tx_size, int block_x, 406 int block_y); // 5.11.40. 407 void ReadTransformType(const Block& block, int x4, int y4, 408 TransformSize tx_size); // 5.11.47. 409 template <typename ResidualType> 410 void ReadCoeffBase2D( 411 const uint16_t* scan, TransformSize tx_size, int adjusted_tx_width_log2, 412 int eob, 413 uint16_t coeff_base_cdf[kCoeffBaseContexts][kCoeffBaseSymbolCount + 1], 414 uint16_t coeff_base_range_cdf[kCoeffBaseRangeContexts] 415 [kCoeffBaseRangeSymbolCount + 1], 416 ResidualType* quantized_buffer, uint8_t* level_buffer); 417 template <typename ResidualType> 418 void ReadCoeffBaseHorizontal( 419 const uint16_t* scan, TransformSize tx_size, int adjusted_tx_width_log2, 420 int eob, 421 uint16_t coeff_base_cdf[kCoeffBaseContexts][kCoeffBaseSymbolCount + 1], 422 uint16_t coeff_base_range_cdf[kCoeffBaseRangeContexts] 423 [kCoeffBaseRangeSymbolCount + 1], 424 ResidualType* quantized_buffer, uint8_t* level_buffer); 425 template <typename ResidualType> 426 void ReadCoeffBaseVertical( 427 const uint16_t* scan, TransformSize tx_size, int adjusted_tx_width_log2, 428 int eob, 429 uint16_t coeff_base_cdf[kCoeffBaseContexts][kCoeffBaseSymbolCount + 1], 430 uint16_t coeff_base_range_cdf[kCoeffBaseRangeContexts] 431 [kCoeffBaseRangeSymbolCount + 1], 432 ResidualType* quantized_buffer, uint8_t* level_buffer); 433 int GetDcSignContext(int x4, int y4, int w4, int h4, Plane plane); 434 void SetEntropyContexts(int x4, int y4, int w4, int h4, Plane plane, 435 uint8_t coefficient_level, int8_t dc_category); 436 void InterIntraPrediction( 437 uint16_t* prediction_0, const uint8_t* prediction_mask, 438 ptrdiff_t prediction_mask_stride, 439 const PredictionParameters& prediction_parameters, int prediction_width, 440 int prediction_height, int subsampling_x, int subsampling_y, 441 uint8_t* dest, 442 ptrdiff_t dest_stride); // Part of section 7.11.3.1 in the spec. 443 void CompoundInterPrediction( 444 const Block& block, const uint8_t* prediction_mask, 445 ptrdiff_t prediction_mask_stride, int prediction_width, 446 int prediction_height, int subsampling_x, int subsampling_y, 447 int candidate_row, int candidate_column, uint8_t* dest, 448 ptrdiff_t dest_stride); // Part of section 7.11.3.1 in the spec. 449 GlobalMotion* GetWarpParams(const Block& block, Plane plane, 450 int prediction_width, int prediction_height, 451 const PredictionParameters& prediction_parameters, 452 ReferenceFrameType reference_type, 453 bool* is_local_valid, 454 GlobalMotion* global_motion_params, 455 GlobalMotion* local_warp_params) 456 const; // Part of section 7.11.3.1 in the spec. 457 bool InterPrediction(const Block& block, Plane plane, int x, int y, 458 int prediction_width, int prediction_height, 459 int candidate_row, int candidate_column, 460 bool* is_local_valid, 461 GlobalMotion* local_warp_params); // 7.11.3.1. 462 void ScaleMotionVector(const MotionVector& mv, Plane plane, 463 int reference_frame_index, int x, int y, int* start_x, 464 int* start_y, int* step_x, int* step_y); // 7.11.3.3. 465 // If the method returns false, the caller only uses the output parameters 466 // *ref_block_start_x and *ref_block_start_y. If the method returns true, the 467 // caller uses all four output parameters. 468 static bool GetReferenceBlockPosition( 469 int reference_frame_index, bool is_scaled, int width, int height, 470 int ref_start_x, int ref_last_x, int ref_start_y, int ref_last_y, 471 int start_x, int start_y, int step_x, int step_y, int left_border, 472 int right_border, int top_border, int bottom_border, 473 int* ref_block_start_x, int* ref_block_start_y, int* ref_block_end_x, 474 int* ref_block_end_y); 475 476 template <typename Pixel> 477 void BuildConvolveBlock(Plane plane, int reference_frame_index, 478 bool is_scaled, int height, int ref_start_x, 479 int ref_last_x, int ref_start_y, int ref_last_y, 480 int step_y, int ref_block_start_x, 481 int ref_block_end_x, int ref_block_start_y, 482 uint8_t* block_buffer, 483 ptrdiff_t convolve_buffer_stride, 484 ptrdiff_t block_extended_width); 485 bool BlockInterPrediction(const Block& block, Plane plane, 486 int reference_frame_index, const MotionVector& mv, 487 int x, int y, int width, int height, 488 int candidate_row, int candidate_column, 489 uint16_t* prediction, bool is_compound, 490 bool is_inter_intra, uint8_t* dest, 491 ptrdiff_t dest_stride); // 7.11.3.4. 492 bool BlockWarpProcess(const Block& block, Plane plane, int index, 493 int block_start_x, int block_start_y, int width, 494 int height, GlobalMotion* warp_params, bool is_compound, 495 bool is_inter_intra, uint8_t* dest, 496 ptrdiff_t dest_stride); // 7.11.3.5. 497 bool ObmcBlockPrediction(const Block& block, const MotionVector& mv, 498 Plane plane, int reference_frame_index, int width, 499 int height, int x, int y, int candidate_row, 500 int candidate_column, 501 ObmcDirection blending_direction); 502 bool ObmcPrediction(const Block& block, Plane plane, int width, 503 int height); // 7.11.3.9. 504 void DistanceWeightedPrediction(void* prediction_0, void* prediction_1, 505 int width, int height, int candidate_row, 506 int candidate_column, uint8_t* dest, 507 ptrdiff_t dest_stride); // 7.11.3.15. 508 // This function specializes the parsing of DC coefficient by removing some of 509 // the branches when i == 0 (since scan[0] is always 0 and scan[i] is always 510 // non-zero for all other possible values of i). |dc_category| is an output 511 // parameter that is populated when |is_dc_coefficient| is true. 512 // |coefficient_level| is an output parameter which accumulates the 513 // coefficient level. 514 template <typename ResidualType, bool is_dc_coefficient> 515 LIBGAV1_ALWAYS_INLINE bool ReadSignAndApplyDequantization( 516 const uint16_t* scan, int i, int q_value, const uint8_t* quantizer_matrix, 517 int shift, int max_value, uint16_t* dc_sign_cdf, int8_t* dc_category, 518 int* coefficient_level, 519 ResidualType* residual_buffer); // Part of 5.11.39. 520 int ReadCoeffBaseRange(uint16_t* cdf); // Part of 5.11.39. 521 // Returns the number of non-zero coefficients that were read. |tx_type| is an 522 // output parameter that stores the computed transform type for the plane 523 // whose coefficients were read. Returns -1 on failure. 524 template <typename ResidualType> 525 int ReadTransformCoefficients(const Block& block, Plane plane, int start_x, 526 int start_y, TransformSize tx_size, 527 TransformType* tx_type); // 5.11.39. 528 bool TransformBlock(const Block& block, Plane plane, int base_x, int base_y, 529 TransformSize tx_size, int x, int y, 530 ProcessingMode mode); // 5.11.35. 531 // Iterative implementation of 5.11.36. 532 bool TransformTree(const Block& block, int start_x, int start_y, 533 BlockSize plane_size, ProcessingMode mode); 534 void ReconstructBlock(const Block& block, Plane plane, int start_x, 535 int start_y, TransformSize tx_size, 536 TransformType tx_type, 537 int non_zero_coeff_count); // Part of 7.12.3. 538 bool Residual(const Block& block, ProcessingMode mode); // 5.11.34. 539 // part of 5.11.5 (reset_block_context() in the spec). 540 void ResetEntropyContext(const Block& block); 541 // Populates the |color_context| and |color_order| for the |i|th iteration 542 // with entries counting down from |start| to |end| (|start| > |end|). 543 void PopulatePaletteColorContexts( 544 const Block& block, PlaneType plane_type, int i, int start, int end, 545 uint8_t color_order[kMaxPaletteSquare][kMaxPaletteSize], 546 uint8_t color_context[kMaxPaletteSquare]); // 5.11.50. 547 bool ReadPaletteTokens(const Block& block); // 5.11.49. 548 template <typename Pixel> 549 void IntraPrediction(const Block& block, Plane plane, int x, int y, 550 bool has_left, bool has_top, bool has_top_right, 551 bool has_bottom_left, PredictionMode mode, 552 TransformSize tx_size); 553 int GetIntraEdgeFilterType(const Block& block, 554 Plane plane) const; // 7.11.2.8. 555 template <typename Pixel> 556 void DirectionalPrediction(const Block& block, Plane plane, int x, int y, 557 bool has_left, bool has_top, bool needs_left, 558 bool needs_top, int prediction_angle, int width, 559 int height, int max_x, int max_y, 560 TransformSize tx_size, Pixel* top_row, 561 Pixel* left_column); // 7.11.2.4. 562 template <typename Pixel> 563 void PalettePrediction(const Block& block, Plane plane, int start_x, 564 int start_y, int x, int y, 565 TransformSize tx_size); // 7.11.4. 566 template <typename Pixel> 567 void ChromaFromLumaPrediction(const Block& block, Plane plane, int start_x, 568 int start_y, 569 TransformSize tx_size); // 7.11.5. 570 // Section 7.19. Applies some filtering and reordering to the motion vectors 571 // for the given |block| and stores them into |current_frame_|. 572 void StoreMotionFieldMvsIntoCurrentFrame(const Block& block); 573 574 // SetCdfContext*() functions will populate the |left_context_| and 575 // |top_context_| for the |block|. 576 void SetCdfContextUsePredictedSegmentId(const Block& block, 577 bool use_predicted_segment_id); 578 void SetCdfContextCompoundType(const Block& block, 579 bool is_explicit_compound_type, 580 bool is_compound_type_average); 581 void SetCdfContextSkipMode(const Block& block, bool skip_mode); 582 void SetCdfContextPaletteSize(const Block& block); 583 void SetCdfContextUVMode(const Block& block); 584 585 // Returns the zero-based index of the super block that contains |row4x4| 586 // relative to the start of this tile. SuperBlockRowIndex(int row4x4)587 int SuperBlockRowIndex(int row4x4) const { 588 return (row4x4 - row4x4_start_) >> 589 (sequence_header_.use_128x128_superblock ? 5 : 4); 590 } 591 592 // Returns the zero-based index of the super block that contains |column4x4| 593 // relative to the start of this tile. SuperBlockColumnIndex(int column4x4)594 int SuperBlockColumnIndex(int column4x4) const { 595 return (column4x4 - column4x4_start_) >> 596 (sequence_header_.use_128x128_superblock ? 5 : 4); 597 } 598 599 // Returns the zero-based index of the block that starts at row4x4 or 600 // column4x4 relative to the start of the superblock that contains the block. 601 // This is used to index into the members of |left_context_| and 602 // |top_context_|. CdfContextIndex(int row_or_column4x4)603 int CdfContextIndex(int row_or_column4x4) const { 604 return row_or_column4x4 - 605 (row_or_column4x4 & 606 (sequence_header_.use_128x128_superblock ? ~31 : ~15)); 607 } 608 SuperBlockSize()609 BlockSize SuperBlockSize() const { 610 return sequence_header_.use_128x128_superblock ? kBlock128x128 611 : kBlock64x64; 612 } PlaneCount()613 int PlaneCount() const { 614 return sequence_header_.color_config.is_monochrome ? kMaxPlanesMonochrome 615 : kMaxPlanes; 616 } 617 618 const int number_; 619 const int row_; 620 const int column_; 621 const uint8_t* const data_; 622 size_t size_; 623 int row4x4_start_; 624 int row4x4_end_; 625 int column4x4_start_; 626 int column4x4_end_; 627 int superblock_rows_; 628 int superblock_columns_; 629 bool read_deltas_; 630 const int8_t subsampling_x_[kMaxPlanes]; 631 const int8_t subsampling_y_[kMaxPlanes]; 632 633 // The dimensions (in order) are: segment_id, level_index (based on plane and 634 // direction), reference_frame and mode_id. 635 uint8_t deblock_filter_levels_[kMaxSegments][kFrameLfCount] 636 [kNumReferenceFrameTypes][2]; 637 638 // current_quantizer_index_ is in the range [0, 255]. 639 uint8_t current_quantizer_index_; 640 // These two arrays (|coefficient_levels_| and |dc_categories_|) are used to 641 // store the entropy context. Their dimensions are as follows: First - 642 // left/top; Second - plane; Third - row4x4 (if first dimension is 643 // left)/column4x4 (if first dimension is top). 644 // 645 // This is equivalent to the LeftLevelContext and AboveLevelContext arrays in 646 // the spec. In the spec, it stores values from 0 through 63 (inclusive). The 647 // stored values are used to compute the left and top contexts in 648 // GetTransformAllZeroContext. In that function, we only care about the 649 // following values: 0, 1, 2, 3 and >= 4. So instead of clamping to 63, we 650 // clamp to 4 (i.e.) all the values greater than 4 are stored as 4. 651 std::array<Array2D<uint8_t>, 2> coefficient_levels_; 652 // This is equivalent to the LeftDcContext and AboveDcContext arrays in the 653 // spec. In the spec, it can store 3 possible values: 0, 1 and 2 (where 1 654 // means the value is < 0, 2 means the value is > 0 and 0 means the value is 655 // equal to 0). 656 // 657 // The stored values are used in two places: 658 // * GetTransformAllZeroContext: Here, we only care about whether the 659 // value is 0 or not (whether it is 1 or 2 is irrelevant). 660 // * GetDcSignContext: Here, we do the following computation: if the 661 // stored value is 1, we decrement a counter. If the stored value is 2 662 // we increment a counter. 663 // 664 // Based on this usage, we can simply replace 1 with -1 and 2 with 1 and 665 // use that value to compute the counter. 666 // 667 // The usage on GetTransformAllZeroContext is unaffected since there we 668 // only care about whether it is 0 or not. 669 std::array<Array2D<int8_t>, 2> dc_categories_; 670 const ObuSequenceHeader& sequence_header_; 671 const ObuFrameHeader& frame_header_; 672 const std::array<bool, kNumReferenceFrameTypes>& reference_frame_sign_bias_; 673 const std::array<RefCountedBufferPtr, kNumReferenceFrameTypes>& 674 reference_frames_; 675 TemporalMotionField& motion_field_; 676 const std::array<uint8_t, kNumReferenceFrameTypes>& reference_order_hint_; 677 const WedgeMaskArray& wedge_masks_; 678 const QuantizerMatrix& quantizer_matrix_; 679 EntropyDecoder reader_; 680 SymbolDecoderContext symbol_decoder_context_; 681 SymbolDecoderContext* const saved_symbol_decoder_context_; 682 const SegmentationMap* prev_segment_ids_; 683 const dsp::Dsp& dsp_; 684 PostFilter& post_filter_; 685 BlockParametersHolder& block_parameters_holder_; 686 Quantizer quantizer_; 687 // When there is no multi-threading within the Tile, |residual_buffer_| is 688 // used. When there is multi-threading within the Tile, 689 // |residual_buffer_threaded_| is used. In the following comment, 690 // |residual_buffer| refers to either |residual_buffer_| or 691 // |residual_buffer_threaded_| depending on whether multi-threading is enabled 692 // within the Tile or not. 693 // The |residual_buffer| is used to help with the dequantization and the 694 // inverse transform processes. It is declared as a uint8_t, but is always 695 // accessed either as an int16_t or int32_t depending on |bitdepth|. Here is 696 // what it stores at various stages of the decoding process (in the order 697 // which they happen): 698 // 1) In ReadTransformCoefficients(), this buffer is used to store the 699 // dequantized values. 700 // 2) In Reconstruct(), this buffer is used as the input to the row 701 // transform process. 702 // The size of this buffer would be: 703 // For |residual_buffer_|: (4096 + 32 * |kResidualPaddingVertical|) * 704 // |residual_size_|. Where 4096 = 64x64 which is the maximum transform 705 // size, and 32 * |kResidualPaddingVertical| is the padding to avoid 706 // bottom boundary checks when parsing quantized coefficients. This 707 // memory is allocated and owned by the Tile class. 708 // For |residual_buffer_threaded_|: See the comment below. This memory is 709 // not allocated or owned by the Tile class. 710 AlignedUniquePtr<uint8_t> residual_buffer_; 711 // This is a 2d array of pointers of size |superblock_rows_| by 712 // |superblock_columns_| where each pointer points to a ResidualBuffer for a 713 // single super block. The array is populated when the parsing process begins 714 // by calling |residual_buffer_pool_->Get()| and the memory is released back 715 // to the pool by calling |residual_buffer_pool_->Release()| when the decoding 716 // process is complete. 717 Array2D<std::unique_ptr<ResidualBuffer>> residual_buffer_threaded_; 718 // sizeof(int16_t or int32_t) depending on |bitdepth|. 719 const size_t residual_size_; 720 // Number of superblocks on the top-right that will have to be decoded before 721 // the current superblock can be decoded. This will be 1 if allow_intrabc is 722 // false. If allow_intrabc is true, then this value will be 723 // use_128x128_superblock ? 3 : 5. This is the allowed range of reference for 724 // the top rows for intrabc. 725 const int intra_block_copy_lag_; 726 727 // In the Tile class, we use the "current_frame" in two ways: 728 // 1) To write the decoded output into (using the |buffer_| view). 729 // 2) To read the pixels for intra block copy (using the |current_frame_| 730 // reference). 731 // 732 // When intra block copy is off, |buffer_| and |current_frame_| may or may not 733 // point to the same plane pointers. But it is okay since |current_frame_| is 734 // never used in this case. 735 // 736 // When intra block copy is on, |buffer_| and |current_frame_| always point to 737 // the same plane pointers (since post filtering is disabled). So the usage in 738 // both case 1 and case 2 remain valid. 739 Array2DView<uint8_t> buffer_[kMaxPlanes]; 740 RefCountedBuffer& current_frame_; 741 742 Array2D<int8_t>& cdef_index_; 743 Array2D<uint8_t>& cdef_skip_; 744 Array2D<TransformSize>& inter_transform_sizes_; 745 std::array<RestorationUnitInfo, kMaxPlanes> reference_unit_info_; 746 // If |thread_pool_| is nullptr, the calling thread will do the parsing and 747 // the decoding in one pass. If |thread_pool_| is not nullptr, then the main 748 // thread will do the parsing while the thread pool workers will do the 749 // decoding. 750 ThreadPool* const thread_pool_; 751 ThreadingParameters threading_; 752 ResidualBufferPool* const residual_buffer_pool_; 753 TileScratchBufferPool* const tile_scratch_buffer_pool_; 754 BlockingCounterWithStatus* const pending_tiles_; 755 bool split_parse_and_decode_; 756 // This is used only when |split_parse_and_decode_| is false. 757 std::unique_ptr<PredictionParameters> prediction_parameters_ = nullptr; 758 // Stores the |transform_type| for the super block being decoded at a 4x4 759 // granularity. The spec uses absolute indices for this array but it is 760 // sufficient to use indices relative to the super block being decoded. 761 TransformType transform_types_[32][32]; 762 // delta_lf_[i] is in the range [-63, 63]. 763 int8_t delta_lf_[kFrameLfCount]; 764 // True if all the values in |delta_lf_| are zero. False otherwise. 765 bool delta_lf_all_zero_; 766 const bool frame_parallel_; 767 const bool use_intra_prediction_buffer_; 768 // Buffer used to store the unfiltered pixels that are necessary for decoding 769 // the next superblock row (for the intra prediction process). Used only if 770 // |use_intra_prediction_buffer_| is true. The |frame_scratch_buffer| contains 771 // one row buffer for each tile row. This tile will have to use the buffer 772 // corresponding to this tile's row. 773 IntraPredictionBuffer* const intra_prediction_buffer_; 774 // Stores the progress of the reference frames. This will be used to avoid 775 // unnecessary calls into RefCountedBuffer::WaitUntil(). 776 std::array<int, kNumReferenceFrameTypes> reference_frame_progress_cache_; 777 // Stores the CDF contexts necessary for the "left" block. 778 BlockCdfContext left_context_; 779 // Stores the CDF contexts necessary for the "top" block. The size of this 780 // buffer is the number of superblock columns in this tile. For each block, 781 // the access index will be the corresponding SuperBlockColumnIndex()'th 782 // entry. 783 DynamicBuffer<BlockCdfContext> top_context_; 784 }; 785 786 struct Tile::Block { BlockBlock787 Block(Tile* tile_ptr, BlockSize size, int row4x4, int column4x4, 788 TileScratchBuffer* const scratch_buffer, ResidualPtr* residual) 789 : tile(*tile_ptr), 790 size(size), 791 row4x4(row4x4), 792 column4x4(column4x4), 793 width(kBlockWidthPixels[size]), 794 height(kBlockHeightPixels[size]), 795 width4x4(width >> 2), 796 height4x4(height >> 2), 797 scratch_buffer(scratch_buffer), 798 residual(residual), 799 top_context(tile.top_context_.get() + 800 tile.SuperBlockColumnIndex(column4x4)), 801 top_context_index(tile.CdfContextIndex(column4x4)), 802 left_context_index(tile.CdfContextIndex(row4x4)) { 803 assert(size != kBlockInvalid); 804 residual_size[kPlaneY] = kPlaneResidualSize[size][0][0]; 805 residual_size[kPlaneU] = residual_size[kPlaneV] = 806 kPlaneResidualSize[size][tile.subsampling_x_[kPlaneU]] 807 [tile.subsampling_y_[kPlaneU]]; 808 assert(residual_size[kPlaneY] != kBlockInvalid); 809 if (tile.PlaneCount() > 1) { 810 assert(residual_size[kPlaneU] != kBlockInvalid); 811 } 812 if ((row4x4 & 1) == 0 && 813 (tile.sequence_header_.color_config.subsampling_y & height4x4) == 1) { 814 has_chroma = false; 815 } else if ((column4x4 & 1) == 0 && 816 (tile.sequence_header_.color_config.subsampling_x & width4x4) == 817 1) { 818 has_chroma = false; 819 } else { 820 has_chroma = !tile.sequence_header_.color_config.is_monochrome; 821 } 822 top_available[kPlaneY] = tile.IsTopInside(row4x4); 823 left_available[kPlaneY] = tile.IsLeftInside(column4x4); 824 if (has_chroma) { 825 // top_available[kPlaneU] and top_available[kPlaneV] are valid only if 826 // has_chroma is true. 827 // The next 3 lines are equivalent to: 828 // top_available[kPlaneU] = top_available[kPlaneV] = 829 // top_available[kPlaneY] && 830 // ((tile.sequence_header_.color_config.subsampling_y & height4x4) == 831 // 0 || tile.IsTopInside(row4x4 - 1)); 832 top_available[kPlaneU] = top_available[kPlaneV] = tile.IsTopInside( 833 row4x4 - 834 (tile.sequence_header_.color_config.subsampling_y & height4x4)); 835 // left_available[kPlaneU] and left_available[kPlaneV] are valid only if 836 // has_chroma is true. 837 // The next 3 lines are equivalent to: 838 // left_available[kPlaneU] = left_available[kPlaneV] = 839 // left_available[kPlaneY] && 840 // ((tile.sequence_header_.color_config.subsampling_x & width4x4) == 0 841 // || tile.IsLeftInside(column4x4 - 1)); 842 left_available[kPlaneU] = left_available[kPlaneV] = tile.IsLeftInside( 843 column4x4 - 844 (tile.sequence_header_.color_config.subsampling_x & width4x4)); 845 } 846 const ptrdiff_t stride = tile.BlockParametersStride(); 847 BlockParameters** const bps = 848 tile.BlockParametersAddress(row4x4, column4x4); 849 bp = *bps; 850 // bp_top is valid only if top_available[kPlaneY] is true. 851 if (top_available[kPlaneY]) { 852 bp_top = *(bps - stride); 853 } 854 // bp_left is valid only if left_available[kPlaneY] is true. 855 if (left_available[kPlaneY]) { 856 bp_left = *(bps - 1); 857 } 858 } 859 HasChromaBlock860 bool HasChroma() const { return has_chroma; } 861 862 // These return values of these group of functions are valid only if the 863 // corresponding top_available or left_available is true. TopReferenceBlock864 ReferenceFrameType TopReference(int index) const { 865 return bp_top->reference_frame[index]; 866 } 867 LeftReferenceBlock868 ReferenceFrameType LeftReference(int index) const { 869 return bp_left->reference_frame[index]; 870 } 871 IsTopIntraBlock872 bool IsTopIntra() const { return TopReference(0) <= kReferenceFrameIntra; } IsLeftIntraBlock873 bool IsLeftIntra() const { return LeftReference(0) <= kReferenceFrameIntra; } 874 IsTopSingleBlock875 bool IsTopSingle() const { return TopReference(1) <= kReferenceFrameIntra; } IsLeftSingleBlock876 bool IsLeftSingle() const { return LeftReference(1) <= kReferenceFrameIntra; } 877 CountReferencesBlock878 int CountReferences(ReferenceFrameType type) const { 879 return static_cast<int>(top_available[kPlaneY] && 880 bp_top->reference_frame[0] == type) + 881 static_cast<int>(top_available[kPlaneY] && 882 bp_top->reference_frame[1] == type) + 883 static_cast<int>(left_available[kPlaneY] && 884 bp_left->reference_frame[0] == type) + 885 static_cast<int>(left_available[kPlaneY] && 886 bp_left->reference_frame[1] == type); 887 } 888 889 // 7.10.3. 890 // Checks if there are any inter blocks to the left or above. If so, it 891 // returns true indicating that the block has neighbors that are suitable for 892 // use by overlapped motion compensation. HasOverlappableCandidatesBlock893 bool HasOverlappableCandidates() const { 894 const ptrdiff_t stride = tile.BlockParametersStride(); 895 BlockParameters** const bps = tile.BlockParametersAddress(0, 0); 896 if (top_available[kPlaneY]) { 897 BlockParameters** bps_top = bps + (row4x4 - 1) * stride + (column4x4 | 1); 898 const int columns = std::min(tile.frame_header_.columns4x4 - column4x4, 899 static_cast<int>(width4x4)); 900 BlockParameters** const bps_top_end = bps_top + columns; 901 do { 902 if ((*bps_top)->reference_frame[0] > kReferenceFrameIntra) { 903 return true; 904 } 905 bps_top += 2; 906 } while (bps_top < bps_top_end); 907 } 908 if (left_available[kPlaneY]) { 909 BlockParameters** bps_left = bps + (row4x4 | 1) * stride + column4x4 - 1; 910 const int rows = std::min(tile.frame_header_.rows4x4 - row4x4, 911 static_cast<int>(height4x4)); 912 BlockParameters** const bps_left_end = bps_left + rows * stride; 913 do { 914 if ((*bps_left)->reference_frame[0] > kReferenceFrameIntra) { 915 return true; 916 } 917 bps_left += 2 * stride; 918 } while (bps_left < bps_left_end); 919 } 920 return false; 921 } 922 923 Tile& tile; 924 bool has_chroma; 925 const BlockSize size; 926 bool top_available[kMaxPlanes]; 927 bool left_available[kMaxPlanes]; 928 BlockSize residual_size[kMaxPlanes]; 929 const int row4x4; 930 const int column4x4; 931 const int width; 932 const int height; 933 const int width4x4; 934 const int height4x4; 935 const BlockParameters* bp_top; 936 const BlockParameters* bp_left; 937 BlockParameters* bp; 938 TileScratchBuffer* const scratch_buffer; 939 ResidualPtr* const residual; 940 BlockCdfContext* const top_context; 941 const int top_context_index; 942 const int left_context_index; 943 }; 944 945 extern template bool 946 Tile::ProcessSuperBlockRow<kProcessingModeDecodeOnly, false>( 947 int row4x4, TileScratchBuffer* scratch_buffer); 948 extern template bool 949 Tile::ProcessSuperBlockRow<kProcessingModeParseAndDecode, true>( 950 int row4x4, TileScratchBuffer* scratch_buffer); 951 952 } // namespace libgav1 953 954 #endif // LIBGAV1_SRC_TILE_H_ 955