Add a new FLACNavigator class that can scan for frames both forward and backward from a byte offset to get the exact buffered ranges. The reads are done in chunks, which keeps each call pretty cheap. The ranges themselves are resolved by its ScanningContainerNavigator base class, which reconciles cached ranges against the incoming ones to avoid repeating work unnecessarily. With those combined optimizations, the calls normally take under 1 microsecond.
25 lines
457 B
C++
25 lines
457 B
C++
/*
|
|
* Copyright (c) 2026-present, the Ladybird developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Optional.h>
|
|
#include <LibMedia/Forward.h>
|
|
|
|
namespace Media::Codecs {
|
|
|
|
class FLAC {
|
|
public:
|
|
struct FrameInfo {
|
|
u64 sample_number;
|
|
u16 block_size;
|
|
};
|
|
|
|
static bool is_sync_code(u16);
|
|
static Optional<FrameInfo> parse_frame_header(MediaStreamCursor&, u16 sync_code, u16 fixed_block_size);
|
|
};
|
|
|
|
}
|