62 { 0, 1, 5, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0 },
63 { 0, 3, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0 }
72 { 0, 2, 2, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
73 { 0, 1, 5, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
77 { 0, 7, 6, 5, 8, 4, 3, 1, 2 },
78 { 0, 2, 3, 4, 5, 6, 7, 1, 8 }
81#define MAX_ENTRIES 162
103 const uint8_t *lens,
const uint8_t *syms)
110 for (
i = 0;
i < 16;
i++) {
111 for (j = 0; j < lens[
i]; j++) {
127 for (
unsigned i = 0,
offset = 0;
i < 2;
i++) {
154 if (
val < (1 << (nbits - 1)))
155 val -= (1 << nbits) - 1;
161 int nb_bits,
int max_depth)
169 int *
block,
int *dc_cache,
170 int bx,
int by, uint16_t *quant_mat)
194 dc += dc_cache[
LEFT];
197 block[0] = dc * quant_mat[0];
216 block[zz_pos] =
val * quant_mat[zz_pos];
220 return pos == 64 ? 0 : -1;
224 uint8_t *
dst[3],
int mb_x,
int mb_y)
229 for (j = 0; j < 2; j++) {
230 for (
i = 0;
i < 2;
i++) {
231 int xpos = mb_x * 2 +
i;
233 c->dc_cache[j][
TOP] =
c->prev_dc[0][mb_x * 2 +
i];
236 xpos, mb_y * 2 + j,
c->quant_mat[0]);
239 c->prev_dc[0][mb_x * 2 +
i] =
c->dc_cache[j][
LEFT];
244 out += 8 *
c->pic->linesize[0];
247 for (
i = 1;
i < 3;
i++) {
249 c->dc_cache[
i + 1][
TOP] =
c->prev_dc[
i][mb_x];
251 c->block,
c->dc_cache[
i + 1], mb_x, mb_y,
255 c->prev_dc[
i][mb_x] =
c->dc_cache[
i + 1][
LEFT];
261 for (j = 0; j < 16; j++) {
262 for (k = 0; k < 8; k++)
263 AV_WN16A(
out + k * 2,
c->imgbuf[
i][k + (j & ~1) * 4] * 0x101);
264 out +=
c->pic->linesize[
i];
272 int *sel_len,
int *prev)
276 for (
i = 2;
i >= 0;
i--) {
282 if (sel_len[
i] > 0) {
285 if (vec_pos[
i] >= pval)
288 vec_pos[
i] = !prev[
i];
292 vec_pos[
i] = prev[
i];
298 int vec_size,
int component,
int shift,
int *prev)
300 if (vec_pos < vec_size)
303 return prev[component];
305 return prev[component];
308#define MKVAL(vals) ((vals)[0] | ((vals)[1] << 3) | ((vals)[2] << 6))
322 uint8_t *picdst[3],
int mb_x,
int mb_y)
326 int sel_len[3], sel_flag[3];
328 int prev_vec1 = 0, prev_split = 0;
330 int prev_pix[3] = { 0 };
331 int prev_mode[16] = { 0 };
334 const int val_shift =
ctx->quality == 100 ? 0 : 2;
336 for (
i = 0;
i < 3;
i++)
339 for (
i = 0;
i < 3;
i++) {
341 for (j = 0; j < vec_len[
i]; j++) {
343 vec[
i][j] +=
ctx->prev_vec[
i][j];
344 ctx->prev_vec[
i][j] = vec[
i][j];
346 sel_flag[
i] = vec_len[
i] > 1;
347 sel_len[
i] = vec_len[
i] > 2 ? vec_len[
i] - 2 : 0;
350 for (j = 0; j < 16; j++) {
355 vals[0] = vals[1] = vals[2] = 0;
362 for (
i = 0;
i < 16;
i++) {
364 vals[0] = prev_mode[
i] & 7;
365 vals[1] = (prev_mode[
i] >> 3) & 7;
366 vals[2] = prev_mode[
i] >> 6;
370 }
else if (
mode == 2) {
374 for (k = 0; k < 3; k++)
377 val_shift, prev_pix);
378 prev_mode[
i] =
MKVAL(vals);
383 if (
split >= prev_split)
390 vals[0] = prev_mode[0] & 7;
391 vals[1] = (prev_mode[0] >> 3) & 7;
392 vals[2] = prev_mode[0] >> 6;
393 for (
i = 0;
i < 3;
i++) {
394 for (k = 0; k <
split; k++) {
396 vec_len[
i],
i, val_shift,
398 prev_mode[k] =
MKVAL(vals);
404 vals[0] = prev_vec1 & 7;
405 vals[1] = (prev_vec1 >> 3) & 7;
406 vals[2] = prev_vec1 >> 6;
409 prev_vec1 =
MKVAL(vals);
411 for (
i = 0;
i < 3;
i++) {
412 for (k = 0; k < 16 -
split; k++) {
414 vec_len[
i],
i, val_shift,
423 for (
i = 0;
i < 3;
i++)
424 for (j = 0; j < 16; j++)
425 memcpy(picdst[
i] + mb_x * 16 + j *
ctx->pic->linesize[
i],
426 ctx->imgbuf[
i] + j * 16, 16);
435 c->dc_cache[0][
TOP] =
c->prev_dc[0][mb_x * 2 + 1];
436 c->dc_cache[0][
LEFT] = 0;
437 c->dc_cache[1][
TOP] = 0;
438 c->dc_cache[1][
LEFT] = 0;
440 for (
i = 0;
i < 2;
i++)
441 c->prev_dc[0][mb_x * 2 +
i] = 0;
443 for (
i = 1;
i < 3;
i++) {
444 c->dc_cache[
i + 1][
TOP] =
c->prev_dc[
i][mb_x];
445 c->dc_cache[
i + 1][
LEFT] = 0;
446 c->prev_dc[
i][mb_x] = 0;
453 const uint8_t *buf = avpkt->
data;
454 int buf_size = avpkt->
size;
460 int x, y,
i, mb_width, mb_height, blk_type;
465 "Frame should have at least %d bytes, got %d instead\n",
471 width = bytestream2_get_be16(&bc);
472 height = bytestream2_get_be16(&bc);
474 quality = bytestream2_get_byte(&bc);
497 "Empty frame found but it is not a skip frame.\n");
524 for (
i = 0;
i < 2;
i++)
530 dst[0] =
c->pic->data[0];
531 dst[1] =
c->pic->data[1];
532 dst[2] =
c->pic->data[2];
534 memset(
c->prev_vec, 0,
sizeof(
c->prev_vec));
535 for (y = 0; y < mb_height; y++) {
536 memset(
c->dc_cache, 0,
sizeof(
c->dc_cache));
537 for (x = 0; x < mb_width; x++) {
543 "Error decoding DCT block %d,%d\n",
551 "Error decoding VQ block %d,%d\n",
566 dst[0] +=
c->pic->linesize[0] * 16;
567 dst[1] +=
c->pic->linesize[1] * 16;
568 dst[2] +=
c->pic->linesize[2] * 16;
585 for (
i = 0;
i < 3;
i++)
597 for (
i = 0;
i < 3;
i++) {
600 if (!
c->prev_dc[
i]) {
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)
static char * split(char *message, char delim)
const FFCodec ff_mts2_decoder
static AVFormatContext * ctx
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static int BS_FUNC decode012(BSCTX *bc)
Return decoded truncated unary code for the values 0, 1, 2.
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)
#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...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
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)
static const uint8_t bits[8]
FrameType
G723.1 frame types.
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 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.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
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.
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
const uint8_t ff_mjpeg_val_ac_chrominance[]
const uint8_t ff_mjpeg_bits_ac_luminance[]
const uint8_t ff_mjpeg_bits_ac_chrominance[]
const uint8_t ff_mjpeg_val_ac_luminance[]
@ SKIP_BLOCK
skipped block
static int shift(int a, int b)
static int ff_thread_once(char *control, void(*routine)(void))
const uint8_t ff_zigzag_direct[64]
Memory handling functions.
void ff_mss34_dct_put(uint8_t *dst, ptrdiff_t stride, int *block)
Transform and output DCT block.
void ff_mss34_gen_quant_mat(uint16_t *qmat, int quality, int luma)
Generate quantisation matrix for given quality.
static int mss4_decode_dct_block(MSS4Context *c, GetBitContext *gb, uint8_t *dst[3], int mb_x, int mb_y)
static const uint8_t vec_len_syms[2][4]
static int mss4_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static const uint8_t mss4_vec_entry_vlc_lens[2][16]
static void mss4_update_dc_cache(MSS4Context *c, int mb_x)
static void read_vec_pos(GetBitContext *gb, int *vec_pos, int *sel_flag, int *sel_len, int *prev)
static av_always_inline int get_coeff_bits(GetBitContext *gb, int nbits)
static av_cold void mss4_init_vlcs(void)
static const uint8_t mss4_vec_entry_vlc_syms[2][9]
static int get_coeff(GetBitContext *gb, const VLC *vlc, int nb_bits, int max_depth)
static const uint8_t mss4_dc_vlc_lens[2][16]
static int mss4_decode_dct(GetBitContext *gb, VLC *dc_vlc, VLC *ac_vlc, int *block, int *dc_cache, int bx, int by, uint16_t *quant_mat)
static VLC vec_entry_vlc[2]
static av_cold int mss4_decode_init(AVCodecContext *avctx)
static int get_value_cached(GetBitContext *gb, int vec_pos, uint8_t *vec, int vec_size, int component, int shift, int *prev)
static av_cold int mss4_decode_end(AVCodecContext *avctx)
static av_cold void mss4_init_vlc(VLC *vlc, unsigned *offset, const uint8_t *lens, const uint8_t *syms)
static int mss4_decode_image_block(MSS4Context *ctx, GetBitContext *gb, uint8_t *picdst[3], int mb_x, int mb_y)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#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.
int64_t max_pixels
The number of pixels per image to maximally accept.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
uint8_t imgbuf[3][16 *16]
uint16_t quant_mat[2][64]
#define av_malloc_array(a, b)
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
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_STATIC_OVERLONG
static const uint8_t quality[]