47 const uint8_t *val_table,
int nb_codes,
48 int use_static,
int is_ac)
51 uint16_t huff_code[256];
52 uint16_t huff_sym[256];
55 assert(nb_codes <= 256);
59 for (i = 0; i < 256; i++)
60 huff_sym[i] = i + 16 * is_ac;
63 huff_sym[0] = 16 * 256;
66 huff_code, 2, 2, huff_sym, 2, 2, use_static);
118 "mjpeg: error using external huffman table\n");
151 for (i = 0; i < 64; i++) {
169 int len,
index, i,
class, n, v, code_max;
186 for (i = 1; i <= 16; i++) {
191 if (len < n || n > 256)
195 for (i = 0; i < n; i++) {
206 class, index, code_max + 1);
207 if ((ret =
build_vlc(&s->
vlcs[
class][index], bits_table, val_table,
208 code_max + 1, 0,
class > 0)) < 0)
213 if ((ret =
build_vlc(&s->
vlcs[2][index], bits_table, val_table,
214 code_max + 1, 0, 0)) < 0)
253 if (nb_components <= 0 ||
259 "nb_components changing in interlaced picture\n");
263 if (s->
ls && !(bits <= 8 || nb_components == 1)) {
265 "JPEG-LS that is not <= 8 " 266 "bits/component or 16-bit gray");
272 for (i = 0; i < nb_components; i++) {
278 if (h_count[i] > s->
h_max)
279 s->
h_max = h_count[i];
280 if (v_count[i] > s->
v_max)
281 s->
v_max = v_count[i];
285 if (!h_count[i] || !v_count[i]) {
287 "Invalid sampling factor in component %d %d:%d\n",
288 i, h_count[i], v_count[i]);
293 i, h_count[i], v_count[i],
307 memcmp(s->
h_count, h_count,
sizeof(h_count)) ||
308 memcmp(s->
v_count, v_count,
sizeof(v_count))) {
312 memcpy(s->
h_count, h_count,
sizeof(h_count));
313 memcpy(s->
v_count, v_count,
sizeof(v_count));
343 if (!(pix_fmt_id & 0xD0D0D0D0))
344 pix_fmt_id -= (pix_fmt_id & 0xF0F0F0F0) >> 1;
345 if (!(pix_fmt_id & 0x0D0D0D0D))
346 pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1;
348 switch (pix_fmt_id) {
380 else if (s->
bits <= 8)
401 for (i = 0; i < 3; i++)
408 if (len != (8 + (3 * nb_components)))
414 int bw = (width + s->
h_max * 8 - 1) / (s->
h_max * 8);
415 int bh = (height + s->
v_max * 8 - 1) / (s->
v_max * 8);
435 "mjpeg_decode_dc: bad vlc: %d:%d (%p)\n",
436 0, dc_index, &s->
vlcs[0][dc_index]);
448 int dc_index,
int ac_index, int16_t *quant_matrix)
450 int code, i, j,
level, val;
458 val = val * quant_matrix[0] + s->
last_dc[component];
468 i += ((unsigned)code) >> 4;
476 int sign = (~cache) >> 31;
477 level = (
NEG_USR32(sign ^ cache,code) ^ sign) - sign;
487 block[j] = level * quant_matrix[j];
496 int component,
int dc_index,
497 int16_t *quant_matrix,
int Al)
506 val = (val * quant_matrix[0] << Al) + s->
last_dc[component];
514 uint8_t *last_nnz,
int ac_index,
515 int16_t *quant_matrix,
516 int ss,
int se,
int Al,
int *EOBRUN)
527 for (i = ss; ; i++) {
531 run = ((unsigned) code) >> 4;
540 int sign = (~cache) >> 31;
541 level = (
NEG_USR32(sign ^ cache,code) ^ sign) - sign;
549 block[j] = level * quant_matrix[j] << Al;
556 block[j] = level * quant_matrix[j] << Al;
585 #define REFINE_BIT(j) { \ 586 UPDATE_CACHE(re, &s->gb); \ 587 sign = block[j] >> 15; \ 588 block[j] += SHOW_UBITS(re, &s->gb, 1) * \ 589 ((quant_matrix[j] ^ sign) - sign) << Al; \ 590 LAST_SKIP_BITS(re, &s->gb, 1); \ 598 av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i); \ 603 j = s->scantable.permutated[i]; \ 606 else if (run-- == 0) \ 613 int ac_index, int16_t *quant_matrix,
614 int ss,
int se,
int Al,
int *EOBRUN)
616 int code, i = ss, j, sign, val,
run;
617 int last =
FFMIN(se, *last_nnz);
628 run = ((unsigned) code) >> 4;
635 block[j] = ((quant_matrix[j]^val) - val) << Al;
643 run = ((unsigned) code) >> 4;
664 for (; i <= last; i++) {
681 int left[3], top[3], topleft[3];
682 const int linesize = s->
linesize[0];
683 const int mask = (1 << s->
bits) - 1;
689 for (i = 0; i < 3; i++)
690 buffer[0][i] = 1 << (s->
bits + point_transform - 1);
692 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
693 const int modified_predictor = mb_y ? predictor : 1;
697 ptr += linesize >> 1;
699 for (i = 0; i < 3; i++)
700 top[i] = left[i] = topleft[i] =
buffer[0][i];
702 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
706 for (i = 0; i < 3; i++) {
712 PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
714 left[i] =
buffer[mb_x][i] =
725 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
726 ptr[4 * mb_x + 1] =
buffer[mb_x][0] - ((
buffer[mb_x][1] +
buffer[mb_x][2] - 0x200) >> 2);
727 ptr[4 * mb_x + 0] =
buffer[mb_x][1] + ptr[4 * mb_x + 1];
728 ptr[4 * mb_x + 2] =
buffer[mb_x][2] + ptr[4 * mb_x + 1];
731 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
733 ptr[4 * mb_x + 0] =
buffer[mb_x][1] + ptr[4 * mb_x + 1];
734 ptr[4 * mb_x + 2] =
buffer[mb_x][2] + ptr[4 * mb_x + 1];
737 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
738 ptr[4 * mb_x + 0] =
buffer[mb_x][2];
739 ptr[4 * mb_x + 1] =
buffer[mb_x][1];
740 ptr[4 * mb_x + 2] =
buffer[mb_x][0];
748 int point_transform,
int nb_components)
752 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
753 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
757 if (mb_x == 0 || mb_y == 0 || s->
interlaced) {
758 for (i = 0; i < nb_components; i++) {
760 int n, h, v, x, y, c, j, linesize;
769 for (j = 0; j < n; j++) {
773 (linesize * (v * mb_y + y)) +
775 if (y == 0 && mb_y == 0) {
776 if (x == 0 && mb_x == 0)
777 pred = 128 << point_transform;
781 if (x == 0 && mb_x == 0)
782 pred = ptr[-linesize];
784 PREDICT(pred, ptr[-linesize - 1],
785 ptr[-linesize], ptr[-1], predictor);
789 ptr += linesize >> 1;
799 for (i = 0; i < nb_components; i++) {
801 int n, h, v, x, y, c, j, linesize;
810 for (j = 0; j < n; j++) {
815 (linesize * (v * mb_y + y)) +
817 PREDICT(pred, ptr[-linesize - 1],
818 ptr[-linesize], ptr[-1], predictor);
837 int Al,
const uint8_t *mb_bitmask,
849 for (i = 0; i < nb_components; i++) {
852 reference_data[c] = reference ? reference->
data[c] :
NULL;
857 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
858 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
859 const int copy_mb = mb_bitmask && !
get_bits1(&mb_bitmask_gb);
869 for (i = 0; i < nb_components; i++) {
871 int n, h, v, x, y, c, j;
879 for (j = 0; j < n; j++) {
880 block_offset = ((linesize[c] * (v * mb_y + y) * 8) +
884 block_offset += linesize[c] >> 1;
885 ptr = data[c] + block_offset;
889 reference_data[c] + block_offset,
897 "error y=%d x=%d\n", mb_y, mb_x);
913 "error y=%d x=%d\n", mb_y, mb_x);
920 (v * mb_y + y) * 8, (h * mb_x + x) * 8);
938 for (i = 0; i < nb_components; i++)
950 int se,
int Ah,
int Al,
964 if (ss < 0 || ss >= 64 ||
965 se < ss || se >= 64 ||
978 int offset = linesize >> 1;
980 reference_data += offset;
983 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
984 int block_offset = mb_y * linesize * 8;
985 uint8_t *ptr = data + block_offset;
989 for (mb_x = 0; mb_x < s->
mb_width; mb_x++,
block++, last_nnz++) {
990 const int copy_mb = mb_bitmask && !
get_bits1(&mb_bitmask_gb);
996 quant_matrix, ss, se, Al, &EOBRUN);
999 quant_matrix, ss, se, Al, &EOBRUN);
1002 "error y=%d x=%d\n", mb_y, mb_x);
1010 reference_data + block_offset,
1025 int len, nb_components, i, h, v,
predictor, point_transform;
1027 const int block_size = s->
lossless ? 1 : 8;
1028 int ilv, prev_shift;
1035 "decode_sos: nb_components (%d) unsupported\n", nb_components);
1038 if (len != 6 + 2 * nb_components) {
1042 for (i = 0; i < nb_components; i++) {
1051 "decode_sos: index(%d) out of components\n", index);
1081 if (nb_components > 1) {
1085 }
else if (!s->
ls) {
1088 s->
mb_width = (s->
width + h * block_size - 1) / (h * block_size);
1097 s->
lossless ?
"lossless" :
"sequential DCT", s->
rgb ?
"RGB" :
"",
1098 predictor, point_transform, ilv, s->
bits,
1107 for (i = 0; i < nb_components; i++)
1116 point_transform, ilv)) < 0)
1121 point_transform)) < 0)
1126 nb_components)) < 0)
1140 prev_shift, point_transform,
1141 mb_bitmask, reference)) < 0)
1152 av_dlog(s->
avctx,
"AVRn interlaced picture marker found\n");
1226 int t_w, t_h, v1, v2;
1238 "mjpeg: JFIF header found (version: %x.%x) SAR=%d/%d\n",
1247 if (len -10 - (t_w * t_h * 3) > 0)
1248 len -= t_w * t_h * 3;
1268 "Pegasus lossless jpeg header found\n");
1315 "mjpeg: error, decode_app parser read over the end\n");
1329 for (i = 0; i < len - 2; i++)
1331 if (i > 0 && cbuf[i - 1] ==
'\n')
1340 if (!strcmp(cbuf,
"AVID")) {
1342 }
else if (!strcmp(cbuf,
"CS=ITU601"))
1344 else if ((len > 20 && !strncmp(cbuf,
"Intel(R) JPEG Library", 21)) ||
1345 (len > 19 && !strncmp(cbuf,
"Metasoft MJPEG Codec", 20)))
1366 buf_ptr = *pbuf_ptr;
1367 while (buf_ptr < buf_end) {
1370 if ((v == 0xff) && (v2 >= 0xc0) && (v2 <= 0xfe) && buf_ptr < buf_end) {
1380 av_dlog(
NULL,
"find_marker skipped %d bytes\n", skipped);
1381 *pbuf_ptr = buf_ptr;
1387 const uint8_t **unescaped_buf_ptr,
1388 int *unescaped_buf_size)
1398 if (start_code ==
SOS && !s->
ls) {
1399 const uint8_t *src = *buf_ptr;
1402 while (src < buf_end) {
1408 while (src < buf_end && x == 0xff)
1411 if (x >= 0xd0 && x <= 0xd7)
1418 *unescaped_buf_ptr = s->
buffer;
1419 *unescaped_buf_size = dst - s->
buffer;
1420 memset(s->
buffer + *unescaped_buf_size, 0,
1424 (buf_end - *buf_ptr) - (dst - s->
buffer));
1425 }
else if (start_code ==
SOS && s->
ls) {
1426 const uint8_t *src = *buf_ptr;
1435 while (src + t < buf_end) {
1438 while ((src + t < buf_end) && x == 0xff)
1461 *unescaped_buf_ptr = dst;
1462 *unescaped_buf_size = (bit_count + 7) >> 3;
1463 memset(s->
buffer + *unescaped_buf_size, 0,
1466 *unescaped_buf_ptr = *buf_ptr;
1467 *unescaped_buf_size = buf_end - *buf_ptr;
1478 int buf_size = avpkt->
size;
1480 const uint8_t *buf_end, *buf_ptr;
1481 const uint8_t *unescaped_buf_ptr;
1482 int unescaped_buf_size;
1488 buf_end = buf + buf_size;
1489 while (buf_ptr < buf_end) {
1493 &unescaped_buf_size);
1495 if (start_code < 0) {
1497 }
else if (unescaped_buf_size > INT_MAX / 8) {
1499 "MJPEG packet 0x%x too big (%d/%d), corrupt data?\n",
1500 start_code, unescaped_buf_size, buf_size);
1505 start_code, buf_end - buf_ptr);
1508 unescaped_buf_size * 8);
1517 if (start_code >= 0xd0 && start_code <= 0xd7)
1519 "restart marker: %d\n", start_code & 0x0f);
1521 else if (start_code >=
APP0 && start_code <=
APP15)
1524 else if (start_code ==
COM)
1528 (start_code ==
SOF48 || start_code ==
LSE)) {
1533 switch (start_code) {
1589 "Found EOI before any SOF, ignoring\n");
1602 for (i = 0; frame->
data[i]; i++) {
1603 int h = frame->
height >> ((i == 1 || i == 2) ?
1623 "Can not process SOS before SOF, skipping\n");
1648 "mjpeg: unsupported coding type (%x)\n", start_code);
1656 "marker parser used %d bytes (%d bits)\n",
1669 return buf_ptr - buf;
1687 for (i = 0; i < 3; i++) {
1688 for (j = 0; j < 4; j++)
1698 #define OFFSET(x) offsetof(MJpegDecodeContext, x) 1699 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM 1701 {
"extern_huff",
"Use external huffman table.",
1723 .priv_class = &mjpegdec_class,
int block_stride[MAX_COMPONENTS]
const struct AVCodec * codec
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
const AVPixFmtDescriptor * pix_desc
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int v_count[MAX_COMPONENTS]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
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.
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 8:8:8, 24bpp, RGBRGB...
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static void skip_bits_long(GetBitContext *s, int n)
const uint8_t avpriv_mjpeg_bits_ac_luminance[17]
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
void(* clear_block)(int16_t *block)
int h_scount[MAX_COMPONENTS]
int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
static int mjpeg_decode_com(MJpegDecodeContext *s)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
int qscale[4]
quantizer scale calculated from quant_matrixes
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static const AVClass mjpegdec_class
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer with padding, reusing the given one if large enough.
int dc_index[MAX_COMPONENTS]
const uint8_t avpriv_mjpeg_bits_dc_chrominance[17]
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_dlog(ac->avr, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> out
const uint8_t avpriv_mjpeg_bits_ac_chrominance[17]
int linesize[MAX_COMPONENTS]
linesize << interlaced
int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
MJPEG encoder and decoder.
int comp_index[MAX_COMPONENTS]
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
av_dlog(ac->avr, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
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)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int mjpeg_decode_dri(MJpegDecodeContext *s)
#define FF_DEBUG_PICT_INFO
uint16_t(* ljpeg_buffer)[4]
unsigned int ljpeg_buffer_size
int16_t quant_matrixes[4][64]
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
uint8_t * last_nnz[MAX_COMPONENTS]
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
static int get_bits_count(const GetBitContext *s)
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table)
int h_count[MAX_COMPONENTS]
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
int interlaced_frame
The content of the picture is interlaced.
static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, int Al, const uint8_t *mb_bitmask, const AVFrame *reference)
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
#define PREDICT(ret, topleft, top, left, predictor)
static void predictor(uint8_t *src, int size)
static int get_bits_left(GetBitContext *gb)
int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define UPDATE_CACHE(name, gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static const uint16_t mask[17]
int nb_blocks[MAX_COMPONENTS]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int predictor, int point_transform)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
int ff_jpegls_decode_lse(MJpegDecodeContext *s)
Decode LSE block with initialization parameters.
static int find_marker(const uint8_t **pbuf_ptr, const uint8_t *buf_end)
#define CLOSE_READER(name, gb)
static int build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table, int nb_codes, int use_static, int is_ac)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
static int decode_dc_progressive(MJpegDecodeContext *s, int16_t *block, int component, int dc_index, int16_t *quant_matrix, int Al)
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
void(* idct_put)(uint8_t *dest, int line_size, int16_t *block)
block -> idct -> clip to unsigned 8 bit -> dest.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
enum AVPictureType pict_type
Picture type of the frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define AV_PIX_FMT_GRAY16
static int decode_block(MJpegDecodeContext *s, int16_t *block, int component, int dc_index, int ac_index, int16_t *quant_matrix)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
int component_id[MAX_COMPONENTS]
static int mjpeg_decode_app(MJpegDecodeContext *s)
const uint8_t avpriv_mjpeg_bits_dc_luminance[17]
const uint8_t avpriv_mjpeg_val_dc[12]
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define LAST_SKIP_BITS(name, gb, num)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
int v_scount[MAX_COMPONENTS]
#define GET_VLC(code, name, gb, table, bits, max_depth)
If the vlc code is invalid and max_depth=1, then no bits will be removed.
uint8_t idct_permutation[64]
IDCT input permutation.
#define SHOW_UBITS(name, gb, num)
the normal 2^n-1 "JPEG" YUV ranges
if(ac->has_optimized_func)
static const float pred[4]
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static void close(AVCodecParserContext *s)
static int get_xbits(GetBitContext *s, int n)
read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
#define OPEN_READER(name, gb)
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
#define AVERROR_BUG
Bug detected, please report the issue.
static unsigned int get_bits1(GetBitContext *s)
int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv)
Describe the class of an AVClass context structure.
static void skip_bits(GetBitContext *s, int n)
static int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index)
int ac_index[MAX_COMPONENTS]
enum AVColorSpace colorspace
YUV colorspace type.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define GET_CACHE(name, gb)
const uint8_t ff_zigzag_direct[64]
uint64_t coefs_finished[MAX_COMPONENTS]
bitmask of which coefs have been completely decoded (progressive mode)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
the normal 219*2^(n-8) "MPEG" YUV ranges
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
const uint8_t avpriv_mjpeg_val_ac_luminance[]
int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, const AVFrame *reference)
static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point_transform, int nb_components)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void build_basic_mjpeg_vlc(MJpegDecodeContext *s)
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
static int decode_block_refinement(MJpegDecodeContext *s, int16_t *block, uint8_t *last_nnz, int ac_index, int16_t *quant_matrix, int ss, int se, int Al, int *EOBRUN)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static av_cold int init(AVCodecParserContext *s)
const uint8_t avpriv_mjpeg_val_ac_chrominance[]
static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, int se, int Ah, int Al, const uint8_t *mb_bitmask, const AVFrame *reference)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
#define FF_DEBUG_STARTCODE
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
int top_field_first
If the content is interlaced, is top field displayed first.
int got_picture
we found a SOF and picture is valid, too.
int16_t(*[MAX_COMPONENTS] blocks)[64]
intermediate sums (progressive mode)
VLC_TYPE(* table)[2]
code, bits
JPEG-LS extension parameters.
int key_frame
1 -> keyframe, 0-> not
int last_dc[MAX_COMPONENTS]
static const uint8_t * align_get_bits(GetBitContext *s)
static int decode_block_progressive(MJpegDecodeContext *s, int16_t *block, uint8_t *last_nnz, int ac_index, int16_t *quant_matrix, int ss, int se, int Al, int *EOBRUN)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
enum AVFieldOrder field_order
Field order.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
int ff_mjpeg_find_marker(MJpegDecodeContext *s, const uint8_t **buf_ptr, const uint8_t *buf_end, const uint8_t **unescaped_buf_ptr, int *unescaped_buf_size)
#define MKTAG(a, b, c, d)
static const AVOption options[]
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...