32#define BITSTREAM_READER_LE
41#define TSCC2_VLC_BITS 9
58 const uint8_t *lens,
const void *syms,
66 lens, 1, syms, sym_length, sym_length, 0,
85 ac_vlc_lens, ac_vlc_syms, 2);
91#define DEQUANT(val, q) (((q) * (val) + 0x80) >> 8)
92#define DCT1D(d0, d1, d2, d3, s0, s1, s2, s3, OP) \
93 OP(d0, 5 * ((s0) + (s1) + (s2)) + 2 * (s3)); \
94 OP(d1, 5 * ((s0) - (s2) - (s3)) + 2 * (s1)); \
95 OP(d2, 5 * ((s0) - (s2) + (s3)) - 2 * (s1)); \
96 OP(d3, 5 * ((s0) - (s1) + (s2)) - 2 * (s3)); \
98#define COL_OP(a, b) a = (b)
99#define ROW_OP(a, b) a = ((b) + 0x20) >> 6
107 for (
i = 0;
i < 4;
i++) {
108 t0 =
DEQUANT(q[0 + (
i & 1)], in[0 * 4 +
i]);
109 t1 =
DEQUANT(q[1 + (
i & 1)], in[1 * 4 +
i]);
110 t2 =
DEQUANT(q[0 + (
i & 1)], in[2 * 4 +
i]);
111 t3 =
DEQUANT(q[1 + (
i & 1)], in[3 * 4 +
i]);
112 DCT1D(tblk[0 * 4 +
i], tblk[1 * 4 +
i],
113 tblk[2 * 4 +
i], tblk[3 * 4 +
i],
116 for (
i = 0;
i < 4;
i++) {
118 tblk[
i * 4 + 0], tblk[
i * 4 + 1],
119 tblk[
i * 4 + 2], tblk[
i * 4 + 3],
ROW_OP);
128 int prev_dc, dc, nc, ac, bpos,
val;
139 for (
i = 0;
i < 8;
i++) {
140 for (j = 0; j < 16; j++)
149 for (j = 0; j < 2; j++) {
150 for (k = 0; k < 4; k++) {
158 dc = (dc + prev_dc) & 0xFF;
165 memset(
c->block + 1, 0, 15 *
sizeof(*
c->block));
166 for (l = 0; l < nc; l++) {
184 const uint8_t *buf,
int buf_size)
192 for (mb_x = 0; mb_x <
c->mb_width; mb_x++) {
193 q =
c->slice_quants[mb_x +
c->mb_width * mb_y];
195 if (q == 0 || q == 3)
197 for (
i = 0;
i < 3;
i++) {
198 off = mb_x * 16 + mb_y * 8 *
c->pic->linesize[
i];
200 c->pic->data[
i] + off,
c->pic->linesize[
i],
i);
212 const uint8_t *buf = avpkt->
data;
213 int buf_size = avpkt->
size;
218 int num_mb =
c->mb_width *
c->mb_height;
243 c->quant[0] = bytestream2_get_byte(&gb);
244 c->quant[1] = bytestream2_get_byte(&gb);
248 c->quant[0],
c->quant[1]);
252 for (
i = 0;
i < 3;
i++) {
259 size = bytestream2_get_le32(&gb);
266 val = bytestream2_get_byte(&gb);
282 for (
i = 0;
i <
c->mb_height;
i++) {
283 size = bytestream2_peek_byte(&gb);
285 size = bytestream2_get_byte(&gb) - 1;
287 size = bytestream2_get_le32(&gb) >> 1;
290 int skip_row = 1, j, off =
i *
c->mb_width;
291 for (j = 0; j <
c->mb_width; j++) {
292 if (
c->slice_quants[off + j] == 1 ||
293 c->slice_quants[off + j] == 2) {
345 c->slice_quants =
av_malloc(
c->mb_width *
c->mb_height);
346 if (!
c->slice_quants) {
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
const FFCodec ff_tscc2_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static av_always_inline int bytestream2_tell(const GetByteContext *g)
#define i(width, name, range_min, range_max)
static VLCElem dc_vlc[1104]
static VLCElem ac_vlc[554]
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
int(* init)(AVBSFContext *ctx)
bitstream reader API header.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int ff_thread_once(char *control, void(*routine)(void))
static av_const int sign_extend(int val, unsigned bits)
const uint8_t ff_zigzag_scan[16+1]
Memory handling functions.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static const uint16_t table[]
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
static av_cold int tscc2_decode_end(AVCodecContext *avctx)
static void tscc2_idct4_put(int *in, int q[3], uint8_t *dst, int stride)
static VLC nc_vlc[NUM_VLC_SETS]
static av_cold int tscc2_decode_init(AVCodecContext *avctx)
static int tscc2_decode_slice(TSCC2Context *c, int mb_y, const uint8_t *buf, int buf_size)
static int tscc2_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static int tscc2_decode_mb(TSCC2Context *c, int *q, int vlc_set, uint8_t *dst, int stride, int plane)
static av_cold void tscc2_init_vlcs(void)
static av_cold void tscc2_init_vlc(VLC *vlc, int *offset, int nb_codes, const uint8_t *lens, const void *syms, int sym_length)
#define DCT1D(d0, d1, d2, d3, s0, s1, s2, s3, OP)
static const uint8_t tscc2_nc_vlc_syms[NUM_VLC_SETS][16]
static const uint16_t tscc2_ac_vlc_syms[]
static const uint8_t tscc2_ac_vlc_lens[]
static const int tscc2_ac_vlc_sizes[NUM_VLC_SETS]
static const uint16_t tscc2_quants[NUM_VLC_SETS][3]
static const uint8_t tscc2_nc_vlc_lens[NUM_VLC_SETS][16]
static const uint8_t tscc2_dc_vlc_lens[DC_VLC_COUNT]
static const uint16_t tscc2_dc_vlc_syms[DC_VLC_COUNT]
int ff_vlc_init_from_lengths(VLC *vlc, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
#define VLC_INIT_OUTPUT_LE
#define VLC_INIT_STATIC_OVERLONG