Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
Classes | Macros | Functions
bsdec.c File Reference
#include "bsdec.h"
#include "bsdec-vlc.h"
#include <stdint.h>
#include <string.h>
#include "common/hardware/cop2.h"
#include "common/hardware/pcsxhw.h"
#include "common/kernel/pcdrv.h"
#include "common/syscalls/syscalls.h"
Include dependency graph for bsdec.c:

Classes

struct  BsdecBits
 

Macros

#define PROF2()   0
 
#define PROF2_ACC(t0, acc)   ((void)(t0))
 
#define PROF_COUNT(f)   ((void)0)
 
#define PROF_ADD(f, n)   ((void)0)
 
#define BSDEC_HALF(base, feed)   ((uint32_t)(base)[feed] | ((uint32_t)(base)[(feed) + 1] << 8))
 
#define MAX_IN   (96 * 1024)
 
#define MAX_HW   (64 * 1024)
 
#define testClz32(v)   ((uint32_t)((v) ? __builtin_clz(v) : 32))
 

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.
 
int main ()
 

Macro Definition Documentation

◆ BSDEC_HALF

#define BSDEC_HALF (   base,
  feed 
)    ((uint32_t)(base)[feed] | ((uint32_t)(base)[(feed) + 1] << 8))

◆ MAX_HW

#define MAX_HW   (64 * 1024)

◆ MAX_IN

#define MAX_IN   (96 * 1024)

◆ PROF2

#define PROF2 ( )    0

◆ PROF2_ACC

#define PROF2_ACC (   t0,
  acc 
)    ((void)(t0))

◆ PROF_ADD

#define PROF_ADD (   f,
  n 
)    ((void)0)

◆ PROF_COUNT

#define PROF_COUNT (   f)    ((void)0)

◆ testClz32

#define testClz32 (   v)    ((uint32_t)((v) ? __builtin_clz(v) : 32))

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.

◆ main()

int main ( void  )