Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
bsdec.h File Reference
#include <stdint.h>
Include dependency graph for bsdec.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BsdecProf
 
struct  BsdecResult
 

Enumerations

enum  BsdecError {
  BSDEC_OK = 0 , BSDEC_SHORT , BSDEC_NOT_BS , BSDEC_BAD_VERSION ,
  BSDEC_OUTPUT_TOO_SMALL , BSDEC_TRUNCATED , BSDEC_OVERLONG
}
 

Functions

uint32_t bsdecRlHalfwords (const void *in, uint32_t inBytes)
 How many run-level halfwords a frame decodes to.
 
struct BsdecResult bsdecFrame (const void *in, uint32_t inBytes, uint16_t *out, uint32_t outHalfwords)
 Decode one BS frame into MDEC run-level halfwords.
 

Enumeration Type Documentation

◆ BsdecError

enum BsdecError
Enumerator
BSDEC_OK 
BSDEC_SHORT 
BSDEC_NOT_BS 
BSDEC_BAD_VERSION 
BSDEC_OUTPUT_TOO_SMALL 
BSDEC_TRUNCATED 
BSDEC_OVERLONG 

Function Documentation

◆ bsdecFrame()

struct BsdecResult bsdecFrame ( const void in,
uint32_t  inBytes,
uint16_t *  out,
uint32_t  outHalfwords 
)

Decode one BS frame into MDEC run-level halfwords.

in must be halfword aligned - the bit reader walks the payload in halfword pairs - and in practice it is, since a frame arrives in sector payloads. out needs bsdecRlHalfwords(in, inBytes) entries.

The output is always a complete frame of exactly that many halfwords whenever bsdecUsable() holds, whatever the bitstream did: a partially decoded block is discarded, a short bitstream is padded with end-of-block markers, and a bitstream carrying more than its header declares is cut at the declared length. That is deliberate - a video decoder that refuses a damaged frame outright drops a frame where it could have shown most of one.

◆ bsdecRlHalfwords()

uint32_t bsdecRlHalfwords ( const void in,
uint32_t  inBytes 
)

How many run-level halfwords a frame decodes to.

Read straight out of the header, so it costs two bytes and can be called before every decode. This is the size out must have. Returns 0 if the buffer is too short to hold a header.