TB2026-YDS Firmware
Loading...
Searching...
No Matches
mp3_frame.h File Reference

Internal MPEG-1/2 Layer III header + VBR-tag (Xing/Info/VBRI) parsing. More...

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  mp3_frame_hdr_t
 Decoded fields of one MPEG Layer III frame header. More...

Functions

bool mp3_frame_parse (const uint8_t *p, size_t len, mp3_frame_hdr_t *out)
 Parse a 4-byte MPEG Layer III frame header at p.
uint32_t mp3_xing_duration_ms (const uint8_t *frame, size_t len, const mp3_frame_hdr_t *hdr)
 Track duration from a Xing/Info/VBRI tag in the first frame, if present.

Detailed Description

Internal MPEG-1/2 Layer III header + VBR-tag (Xing/Info/VBRI) parsing.

Not a public header: shared by the MP3 decoder backend (decoder_mp3.c, for the playing stream's duration) and the track-metadata reader (track_meta.c, for bitrate + duration). Pure byte math with no ESP-IDF or libhelix dependency, so the duration logic lives in one place and is host-testable on its own.

Note
Développé avec l'assistance de Claude Opus 4.8 (Anthropic), sous la direction de Y. Dos Santos : spécification, revue et validation sur cible par l'auteur.

Function Documentation

◆ mp3_frame_parse()

bool mp3_frame_parse ( const uint8_t * p,
size_t len,
mp3_frame_hdr_t * out )

Parse a 4-byte MPEG Layer III frame header at p.

Parameters
pCandidate frame start (the 0xFF sync byte).
lenBytes readable from p (must be >= 4).
outFilled on success.
Returns
true if p holds a valid Layer III header; false otherwise.

◆ mp3_xing_duration_ms()

uint32_t mp3_xing_duration_ms ( const uint8_t * frame,
size_t len,
const mp3_frame_hdr_t * hdr )

Track duration from a Xing/Info/VBRI tag in the first frame, if present.

Parameters
frameFirst frame start (its 0xFF sync byte).
lenBytes readable from frame.
hdrHeader already parsed by mp3_frame_parse() for frame.
Returns
Duration in ms, or 0 when no usable VBR tag is present (duration unknown).