mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibVideo/VP9: Return Corrupted error when tile range decoder init fails
Previously, we were incorrectly wrapping an error from `BooleanDecoder` initialization in a `DecoderErrorCategory::Memory` error. This caused an incorrect error message in VideoPlayer. Now it will instead return `DecoderErrorCategory::Corrupted`.
This commit is contained in:
parent
b6deb8fd42
commit
8ce4245214
2 changed files with 8 additions and 7 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include <AK/MemoryStream.h>
|
#include <AK/MemoryStream.h>
|
||||||
#include <LibGfx/Size.h>
|
#include <LibGfx/Size.h>
|
||||||
#include <LibVideo/Color/CodingIndependentCodePoints.h>
|
#include <LibVideo/Color/CodingIndependentCodePoints.h>
|
||||||
|
#include <LibVideo/DecoderError.h>
|
||||||
|
|
||||||
#include "BooleanDecoder.h"
|
#include "BooleanDecoder.h"
|
||||||
#include "ContextStorage.h"
|
#include "ContextStorage.h"
|
||||||
|
@ -187,14 +188,14 @@ static NonZeroTokensView create_non_zero_tokens_view(NonZeroTokens& non_zero_tok
|
||||||
|
|
||||||
struct TileContext {
|
struct TileContext {
|
||||||
public:
|
public:
|
||||||
static ErrorOr<TileContext> try_create(FrameContext& frame_context, u32 tile_size, u32 rows_start, u32 rows_end, u32 columns_start, u32 columns_end, PartitionContextView above_partition_context, NonZeroTokensView above_non_zero_tokens, SegmentationPredictionContextView above_segmentation_ids)
|
static DecoderErrorOr<TileContext> try_create(FrameContext& frame_context, u32 tile_size, u32 rows_start, u32 rows_end, u32 columns_start, u32 columns_end, PartitionContextView above_partition_context, NonZeroTokensView above_non_zero_tokens, SegmentationPredictionContextView above_segmentation_ids)
|
||||||
{
|
{
|
||||||
auto width = columns_end - columns_start;
|
auto width = columns_end - columns_start;
|
||||||
auto height = rows_end - rows_start;
|
auto height = rows_end - rows_start;
|
||||||
auto context_view = frame_context.m_block_contexts.view(rows_start, columns_start, height, width);
|
auto context_view = frame_context.m_block_contexts.view(rows_start, columns_start, height, width);
|
||||||
|
|
||||||
auto bit_stream = TRY(try_make<BigEndianInputBitStream>(TRY(try_make<FixedMemoryStream>(frame_context.stream))));
|
auto bit_stream = DECODER_TRY_ALLOC(try_make<BigEndianInputBitStream>(DECODER_TRY_ALLOC(try_make<FixedMemoryStream>(frame_context.stream))));
|
||||||
auto decoder = TRY(BooleanDecoder::initialize(move(bit_stream), tile_size));
|
auto decoder = DECODER_TRY(DecoderErrorCategory::Corrupted, BooleanDecoder::initialize(move(bit_stream), tile_size));
|
||||||
|
|
||||||
return TileContext {
|
return TileContext {
|
||||||
frame_context,
|
frame_context,
|
||||||
|
@ -207,9 +208,9 @@ public:
|
||||||
above_partition_context,
|
above_partition_context,
|
||||||
above_non_zero_tokens,
|
above_non_zero_tokens,
|
||||||
above_segmentation_ids,
|
above_segmentation_ids,
|
||||||
TRY(PartitionContext::create(superblocks_to_blocks(blocks_ceiled_to_superblocks(height)))),
|
DECODER_TRY_ALLOC(PartitionContext::create(superblocks_to_blocks(blocks_ceiled_to_superblocks(height)))),
|
||||||
TRY(create_non_zero_tokens(blocks_to_sub_blocks(height), frame_context.color_config.subsampling_y)),
|
DECODER_TRY_ALLOC(create_non_zero_tokens(blocks_to_sub_blocks(height), frame_context.color_config.subsampling_y)),
|
||||||
TRY(SegmentationPredictionContext::create(height)),
|
DECODER_TRY_ALLOC(SegmentationPredictionContext::create(height)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -888,7 +888,7 @@ DecoderErrorOr<void> Parser::decode_tiles(FrameContext& frame_context)
|
||||||
auto above_non_zero_tokens_view = create_non_zero_tokens_view(above_non_zero_tokens, blocks_to_sub_blocks(columns_start), blocks_to_sub_blocks(columns_end - columns_start), frame_context.color_config.subsampling_x);
|
auto above_non_zero_tokens_view = create_non_zero_tokens_view(above_non_zero_tokens, blocks_to_sub_blocks(columns_start), blocks_to_sub_blocks(columns_end - columns_start), frame_context.color_config.subsampling_x);
|
||||||
auto above_segmentation_ids_for_tile = safe_slice(above_segmentation_ids.span(), columns_start, columns_end - columns_start);
|
auto above_segmentation_ids_for_tile = safe_slice(above_segmentation_ids.span(), columns_start, columns_end - columns_start);
|
||||||
|
|
||||||
auto tile_context = DECODER_TRY_ALLOC(TileContext::try_create(frame_context, tile_size, rows_start, rows_end, columns_start, columns_end, above_partition_context_for_tile, above_non_zero_tokens_view, above_segmentation_ids_for_tile));
|
auto tile_context = TRY(TileContext::try_create(frame_context, tile_size, rows_start, rows_end, columns_start, columns_end, above_partition_context_for_tile, above_non_zero_tokens_view, above_segmentation_ids_for_tile));
|
||||||
TRY(decode_tile(tile_context));
|
TRY(decode_tile(tile_context));
|
||||||
TRY_READ(frame_context.bit_stream.discard(tile_size));
|
TRY_READ(frame_context.bit_stream.discard(tile_size));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue