59 { 0, 1, 5, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0 },
60 { 0, 3, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0 }
69 { 0, 2, 2, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
70 { 0, 1, 5, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
74 { 0, 7, 6, 5, 8, 4, 3, 1, 2 },
75 { 0, 2, 3, 4, 5, 6, 7, 1, 8 }
78 #define MAX_ENTRIES 162
107 for (
i = 0;
i < 16;
i++) {
108 for (j = 0; j < lens[
i]; j++) {
124 for (
unsigned i = 0,
offset = 0;
i < 2;
i++) {
151 if (
val < (1 << (nbits - 1)))
152 val -= (1 << nbits) - 1;
165 int *
block,
int *dc_cache,
166 int bx,
int by, uint16_t *quant_mat)
212 block[zz_pos] =
val * quant_mat[zz_pos];
216 return pos == 64 ? 0 : -1;
220 uint8_t *dst[3],
int mb_x,
int mb_y)
225 for (j = 0; j < 2; j++) {
226 for (
i = 0;
i < 2;
i++) {
227 int xpos = mb_x * 2 +
i;
229 c->dc_cache[j][
TOP] =
c->prev_dc[0][mb_x * 2 +
i];
232 xpos, mb_y * 2 + j,
c->quant_mat[0]);
235 c->prev_dc[0][mb_x * 2 +
i] =
c->dc_cache[j][
LEFT];
240 out += 8 *
c->pic->linesize[0];
243 for (
i = 1;
i < 3;
i++) {
245 c->dc_cache[
i + 1][
TOP] =
c->prev_dc[
i][mb_x];
247 c->block,
c->dc_cache[
i + 1], mb_x, mb_y,
251 c->prev_dc[
i][mb_x] =
c->dc_cache[
i + 1][
LEFT];
254 out = dst[
i] + mb_x * 16;
257 for (j = 0; j < 16; j++) {
258 for (k = 0; k < 8; k++)
259 AV_WN16A(
out + k * 2,
c->imgbuf[
i][k + (j & ~1) * 4] * 0x101);
260 out +=
c->pic->linesize[
i];
268 int *sel_len,
int *prev)
272 for (
i = 2;
i >= 0;
i--) {
278 if (sel_len[
i] > 0) {
281 if (vec_pos[
i] >= pval)
284 vec_pos[
i] = !prev[
i];
288 vec_pos[
i] = prev[
i];
294 int vec_size,
int component,
int shift,
int *prev)
296 if (vec_pos < vec_size)
299 return prev[component];
301 return prev[component];
304 #define MKVAL(vals) ((vals)[0] | ((vals)[1] << 3) | ((vals)[2] << 6))
318 uint8_t *picdst[3],
int mb_x,
int mb_y)
322 int sel_len[3], sel_flag[3];
324 int prev_vec1 = 0, prev_split = 0;
326 int prev_pix[3] = { 0 };
327 int prev_mode[16] = { 0 };
330 const int val_shift =
ctx->quality == 100 ? 0 : 2;
332 for (
i = 0;
i < 3;
i++)
333 dst[
i] =
ctx->imgbuf[
i];
337 for (j = 0; j < vec_len[
i]; j++) {
339 vec[
i][j] +=
ctx->prev_vec[
i][j];
340 ctx->prev_vec[
i][j] = vec[
i][j];
342 sel_flag[
i] = vec_len[
i] > 1;
343 sel_len[
i] = vec_len[
i] > 2 ? vec_len[
i] - 2 : 0;
346 for (j = 0; j < 16; j++) {
351 vals[0] = vals[1] = vals[2] = 0;
358 for (
i = 0;
i < 16;
i++) {
360 vals[0] = prev_mode[
i] & 7;
361 vals[1] = (prev_mode[
i] >> 3) & 7;
362 vals[2] = prev_mode[
i] >> 6;
366 }
else if (
mode == 2) {
370 for (k = 0; k < 3; k++)
373 val_shift, prev_pix);
374 prev_mode[
i] =
MKVAL(vals);
379 if (
split >= prev_split)
386 vals[0] = prev_mode[0] & 7;
387 vals[1] = (prev_mode[0] >> 3) & 7;
388 vals[2] = prev_mode[0] >> 6;
389 for (
i = 0;
i < 3;
i++) {
390 for (k = 0; k <
split; k++) {
392 vec_len[
i],
i, val_shift,
394 prev_mode[k] =
MKVAL(vals);
400 vals[0] = prev_vec1 & 7;
401 vals[1] = (prev_vec1 >> 3) & 7;
402 vals[2] = prev_vec1 >> 6;
405 prev_vec1 =
MKVAL(vals);
407 for (
i = 0;
i < 3;
i++) {
408 for (k = 0; k < 16 -
split; k++) {
410 vec_len[
i],
i, val_shift,
419 for (
i = 0;
i < 3;
i++)
420 for (j = 0; j < 16; j++)
421 memcpy(picdst[
i] + mb_x * 16 + j *
ctx->pic->linesize[
i],
422 ctx->imgbuf[
i] + j * 16, 16);
431 c->dc_cache[0][
TOP] =
c->prev_dc[0][mb_x * 2 + 1];
432 c->dc_cache[0][
LEFT] = 0;
433 c->dc_cache[1][
TOP] = 0;
434 c->dc_cache[1][
LEFT] = 0;
436 for (
i = 0;
i < 2;
i++)
437 c->prev_dc[0][mb_x * 2 +
i] = 0;
440 c->dc_cache[
i + 1][
TOP] =
c->prev_dc[
i][mb_x];
441 c->dc_cache[
i + 1][
LEFT] = 0;
442 c->prev_dc[
i][mb_x] = 0;
450 int buf_size = avpkt->
size;
456 int x, y,
i, mb_width, mb_height, blk_type;
461 "Frame should have at least %d bytes, got %d instead\n",
467 width = bytestream2_get_be16(&bc);
468 height = bytestream2_get_be16(&bc);
470 quality = bytestream2_get_byte(&bc);
479 if (quality < 1 || quality > 100) {
490 "Empty frame found but it is not a skip frame.\n");
512 if (
c->quality != quality) {
513 c->quality = quality;
514 for (
i = 0;
i < 2;
i++)
520 dst[0] =
c->pic->data[0];
521 dst[1] =
c->pic->data[1];
522 dst[2] =
c->pic->data[2];
524 memset(
c->prev_vec, 0,
sizeof(
c->prev_vec));
525 for (y = 0; y < mb_height; y++) {
526 memset(
c->dc_cache, 0,
sizeof(
c->dc_cache));
527 for (x = 0; x < mb_width; x++) {
533 "Error decoding DCT block %d,%d\n",
541 "Error decoding VQ block %d,%d\n",
556 dst[0] +=
c->pic->linesize[0] * 16;
557 dst[1] +=
c->pic->linesize[1] * 16;
558 dst[2] +=
c->pic->linesize[2] * 16;
575 for (
i = 0;
i < 3;
i++)
587 for (
i = 0;
i < 3;
i++) {
590 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.
@ 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.
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