60 { 0, 1, 5, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0 },
61 { 0, 3, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0 }
70 { 0, 2, 2, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
71 { 0, 1, 5, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
75 { 0, 7, 6, 5, 8, 4, 3, 1, 2 },
76 { 0, 2, 3, 4, 5, 6, 7, 1, 8 }
79 #define MAX_ENTRIES 162
108 for (
i = 0;
i < 16;
i++) {
109 for (j = 0; j < lens[
i]; j++) {
125 for (
unsigned i = 0,
offset = 0;
i < 2;
i++) {
152 if (
val < (1 << (nbits - 1)))
153 val -= (1 << nbits) - 1;
166 int *
block,
int *dc_cache,
167 int bx,
int by, uint16_t *quant_mat)
213 block[zz_pos] =
val * quant_mat[zz_pos];
217 return pos == 64 ? 0 : -1;
221 uint8_t *dst[3],
int mb_x,
int mb_y)
226 for (j = 0; j < 2; j++) {
227 for (
i = 0;
i < 2;
i++) {
228 int xpos = mb_x * 2 +
i;
230 c->dc_cache[j][
TOP] =
c->prev_dc[0][mb_x * 2 +
i];
233 xpos, mb_y * 2 + j,
c->quant_mat[0]);
236 c->prev_dc[0][mb_x * 2 +
i] =
c->dc_cache[j][
LEFT];
241 out += 8 *
c->pic->linesize[0];
244 for (
i = 1;
i < 3;
i++) {
246 c->dc_cache[
i + 1][
TOP] =
c->prev_dc[
i][mb_x];
248 c->block,
c->dc_cache[
i + 1], mb_x, mb_y,
252 c->prev_dc[
i][mb_x] =
c->dc_cache[
i + 1][
LEFT];
255 out = dst[
i] + mb_x * 16;
258 for (j = 0; j < 16; j++) {
259 for (k = 0; k < 8; k++)
260 AV_WN16A(
out + k * 2,
c->imgbuf[
i][k + (j & ~1) * 4] * 0x101);
261 out +=
c->pic->linesize[
i];
269 int *sel_len,
int *prev)
273 for (
i = 2;
i >= 0;
i--) {
279 if (sel_len[
i] > 0) {
282 if (vec_pos[
i] >= pval)
285 vec_pos[
i] = !prev[
i];
289 vec_pos[
i] = prev[
i];
295 int vec_size,
int component,
int shift,
int *prev)
297 if (vec_pos < vec_size)
300 return prev[component];
302 return prev[component];
305 #define MKVAL(vals) ((vals)[0] | ((vals)[1] << 3) | ((vals)[2] << 6))
319 uint8_t *picdst[3],
int mb_x,
int mb_y)
323 int sel_len[3], sel_flag[3];
325 int prev_vec1 = 0, prev_split = 0;
327 int prev_pix[3] = { 0 };
328 int prev_mode[16] = { 0 };
331 const int val_shift =
ctx->quality == 100 ? 0 : 2;
333 for (
i = 0;
i < 3;
i++)
334 dst[
i] =
ctx->imgbuf[
i];
338 for (j = 0; j < vec_len[
i]; j++) {
340 vec[
i][j] +=
ctx->prev_vec[
i][j];
341 ctx->prev_vec[
i][j] = vec[
i][j];
343 sel_flag[
i] = vec_len[
i] > 1;
344 sel_len[
i] = vec_len[
i] > 2 ? vec_len[
i] - 2 : 0;
347 for (j = 0; j < 16; j++) {
352 vals[0] = vals[1] = vals[2] = 0;
359 for (
i = 0;
i < 16;
i++) {
361 vals[0] = prev_mode[
i] & 7;
362 vals[1] = (prev_mode[
i] >> 3) & 7;
363 vals[2] = prev_mode[
i] >> 6;
367 }
else if (
mode == 2) {
371 for (k = 0; k < 3; k++)
374 val_shift, prev_pix);
375 prev_mode[
i] =
MKVAL(vals);
380 if (
split >= prev_split)
387 vals[0] = prev_mode[0] & 7;
388 vals[1] = (prev_mode[0] >> 3) & 7;
389 vals[2] = prev_mode[0] >> 6;
390 for (
i = 0;
i < 3;
i++) {
391 for (k = 0; k <
split; k++) {
393 vec_len[
i],
i, val_shift,
395 prev_mode[k] =
MKVAL(vals);
401 vals[0] = prev_vec1 & 7;
402 vals[1] = (prev_vec1 >> 3) & 7;
403 vals[2] = prev_vec1 >> 6;
406 prev_vec1 =
MKVAL(vals);
408 for (
i = 0;
i < 3;
i++) {
409 for (k = 0; k < 16 -
split; k++) {
411 vec_len[
i],
i, val_shift,
420 for (
i = 0;
i < 3;
i++)
421 for (j = 0; j < 16; j++)
422 memcpy(picdst[
i] + mb_x * 16 + j *
ctx->pic->linesize[
i],
423 ctx->imgbuf[
i] + j * 16, 16);
432 c->dc_cache[0][
TOP] =
c->prev_dc[0][mb_x * 2 + 1];
433 c->dc_cache[0][
LEFT] = 0;
434 c->dc_cache[1][
TOP] = 0;
435 c->dc_cache[1][
LEFT] = 0;
437 for (
i = 0;
i < 2;
i++)
438 c->prev_dc[0][mb_x * 2 +
i] = 0;
441 c->dc_cache[
i + 1][
TOP] =
c->prev_dc[
i][mb_x];
442 c->dc_cache[
i + 1][
LEFT] = 0;
443 c->prev_dc[
i][mb_x] = 0;
451 int buf_size = avpkt->
size;
457 int x, y,
i, mb_width, mb_height, blk_type;
462 "Frame should have at least %d bytes, got %d instead\n",
468 width = bytestream2_get_be16(&bc);
469 height = bytestream2_get_be16(&bc);
471 quality = bytestream2_get_byte(&bc);
483 if (quality < 1 || quality > 100) {
494 "Empty frame found but it is not a skip frame.\n");
516 if (
c->quality != quality) {
517 c->quality = quality;
518 for (
i = 0;
i < 2;
i++)
524 dst[0] =
c->pic->data[0];
525 dst[1] =
c->pic->data[1];
526 dst[2] =
c->pic->data[2];
528 memset(
c->prev_vec, 0,
sizeof(
c->prev_vec));
529 for (y = 0; y < mb_height; y++) {
530 memset(
c->dc_cache, 0,
sizeof(
c->dc_cache));
531 for (x = 0; x < mb_width; x++) {
537 "Error decoding DCT block %d,%d\n",
545 "Error decoding VQ block %d,%d\n",
560 dst[0] +=
c->pic->linesize[0] * 16;
561 dst[1] +=
c->pic->linesize[1] * 16;
562 dst[2] +=
c->pic->linesize[2] * 16;
579 for (
i = 0;
i < 3;
i++)
591 for (
i = 0;
i < 3;
i++) {
594 if (!
c->prev_dc[
i]) {
static double val(void *priv, double ch)
static char * split(char *message, char delim)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
int ff_init_vlc_from_lengths(VLC *vlc_arg, 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()
static av_always_inline int bytestream2_get_bytes_left(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 VLC_TYPE vlc_buf[16716][2]
#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.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
mode
Use these values in ebur128_init (or'ed).
FrameType
G723.1 frame types.
bitstream reader API header.
static int decode012(GetBitContext *gb)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], 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.
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 avpriv_mjpeg_bits_ac_chrominance[17]
const uint8_t avpriv_mjpeg_val_ac_chrominance[]
const uint8_t avpriv_mjpeg_val_ac_luminance[]
const uint8_t avpriv_mjpeg_bits_ac_luminance[17]
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int ff_thread_once(char *control, void(*routine)(void))
const uint8_t ff_zigzag_direct[64]
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 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 int get_coeff(GetBitContext *gb, VLC *vlc)
static av_cold void mss4_init_vlcs(void)
static const uint8_t mss4_vec_entry_vlc_syms[2][9]
static int mss4_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
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)
static int shift(int a, int b)
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.
const char * name
Name of the codec implementation.
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]
VLC_TYPE(* table)[2]
code, bits
#define av_malloc_array(a, b)
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
static const uint8_t offset[127][2]
#define INIT_VLC_STATIC_OVERLONG