27 #define BITSTREAM_READER_LE
90 #define DEQUANT(val, q) ((q * val + 0x80) >> 8)
91 #define DCT1D(d0, d1, d2, d3, s0, s1, s2, s3, OP) \
92 OP(d0, 5 * ((s0) + (s1) + (s2)) + 2 * (s3)); \
93 OP(d1, 5 * ((s0) - (s2) - (s3)) + 2 * (s1)); \
94 OP(d2, 5 * ((s0) - (s2) + (s3)) - 2 * (s1)); \
95 OP(d3, 5 * ((s0) - (s1) + (s2)) - 2 * (s3)); \
97 #define COL_OP(a, b) a = b
98 #define ROW_OP(a, b) a = ((b) + 0x20) >> 6
106 for (i = 0; i < 4; i++) {
107 t0 =
DEQUANT(q[0 + (i & 1)], in[0 * 4 + i]);
108 t1 =
DEQUANT(q[1 + (i & 1)], in[1 * 4 + i]);
109 t2 =
DEQUANT(q[0 + (i & 1)], in[2 * 4 + i]);
110 t3 =
DEQUANT(q[1 + (i & 1)], in[3 * 4 + i]);
111 DCT1D(tblk[0 * 4 + i], tblk[1 * 4 + i],
112 tblk[2 * 4 + i], tblk[3 * 4 + i],
115 for (i = 0; i < 4; i++) {
116 DCT1D(dst[0], dst[1], dst[2], dst[3],
117 tblk[i * 4 + 0], tblk[i * 4 + 1],
118 tblk[i * 4 + 2], tblk[i * 4 + 3],
ROW_OP);
127 int prev_dc, dc, nc, ac, bpos, val;
133 for (i = 0; i < 8; i++, dst +=
stride)
134 memset(dst, val, 16);
138 for (i = 0; i < 8; i++) {
139 for (j = 0; j < 16; j++)
148 for (j = 0; j < 2; j++) {
149 for (k = 0; k < 4; k++) {
159 dc = (dc + prev_dc) & 0xFF;
168 memset(c->
block + 1, 0, 15 *
sizeof(*c->
block));
169 for (l = 0; l < nc; l++) {
189 const uint8_t *buf,
int buf_size)
196 for (mb_x = 0; mb_x < c->
mb_width; mb_x++) {
199 if (q == 0 || q == 3)
201 for (i = 0; i < 3; i++) {
217 int buf_size = avpkt->
size;
220 uint32_t frame_type,
size;
221 int i, val,
len, pos = 0;
226 frame_type = bytestream2_get_byte(&gb);
227 if (frame_type > 1) {
240 if (frame_type == 0) {
252 c->
quant[0] = bytestream2_get_byte(&gb);
253 c->
quant[1] = bytestream2_get_byte(&gb);
261 for (i = 0; i < 3; i++) {
268 size = bytestream2_get_le32(&gb);
274 for (i = 0; i <
size; i++) {
275 val = bytestream2_get_byte(&gb);
278 if (pos + len > num_mb) {
292 size = bytestream2_peek_byte(&gb);
294 size = bytestream2_get_byte(&gb) - 1;
296 size = bytestream2_get_le32(&gb) >> 1;
struct TSCC2Context TSCC2Context
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static void tscc2_idct4_put(int *in, int q[3], uint8_t *dst, int stride)
This structure describes decoded (raw) audio or video data.
int buffer_hints
codec suggestion on buffer type if != 0
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static const uint16_t tscc2_dc_vlc_syms[DC_VLC_COUNT]
AVFrame * coded_frame
the picture in the bitstream
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static const int tscc2_ac_vlc_sizes[NUM_VLC_SETS]
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static av_cold void free_vlcs(TSCC2Context *c)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static const uint16_t * tscc2_ac_vlc_codes[NUM_VLC_SETS]
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
static int tscc2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
bitstream reader API header.
static const uint8_t tscc2_dc_vlc_bits[DC_VLC_COUNT]
static int init(AVCodecParserContext *s)
static int get_bits_left(GetBitContext *gb)
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static av_cold int tscc2_decode_end(AVCodecContext *avctx)
static int tscc2_decode_mb(TSCC2Context *c, int *q, int vlc_set, uint8_t *dst, int stride, int plane)
int width
picture width / height.
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static const uint16_t tscc2_nc_vlc_codes[NUM_VLC_SETS][16]
static av_always_inline int bytestream2_tell(GetByteContext *g)
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
static const uint16_t tscc2_quants[NUM_VLC_SETS][3]
main external API structure.
static void close(AVCodecParserContext *s)
static const uint8_t tscc2_zigzag[16]
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static const uint8_t * tscc2_ac_vlc_bits[NUM_VLC_SETS]
static av_cold int tscc2_decode_init(AVCodecContext *avctx)
#define FF_BUFFER_HINTS_REUSABLE
static const uint16_t tscc2_dc_vlc_codes[DC_VLC_COUNT]
static av_const int sign_extend(int val, unsigned bits)
#define FF_BUFFER_HINTS_PRESERVE
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define DCT1D(d0, d1, d2, d3, s0, s1, s2, s3, OP)
static av_cold int init_vlcs(TSCC2Context *c)
static int tscc2_decode_slice(TSCC2Context *c, int mb_y, const uint8_t *buf, int buf_size)
#define AVERROR_INVALIDDATA
static const uint8_t tscc2_nc_vlc_bits[NUM_VLC_SETS][16]
static const uint8_t tscc2_nc_vlc_syms[16]
VLC_TYPE(* table)[2]
code, bits
#define FF_BUFFER_HINTS_VALID
static const uint16_t * tscc2_ac_vlc_syms[NUM_VLC_SETS]
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)