46 const uint8_t *val_table,
int nb_codes,
47 int use_static,
int is_ac)
49 uint8_t huff_size[256];
50 uint16_t huff_code[256];
51 uint16_t huff_sym[256];
54 assert(nb_codes <= 256);
56 memset(huff_size, 0,
sizeof(huff_size));
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);
104 #if FF_API_MJPEG_GLOBAL_OPTS
105 if (avctx->
flags & CODEC_FLAG_EXTERN_HUFF)
113 "mjpeg: error using external huffman table\n");
146 for (i = 0; i < 64; i++) {
164 int len,
index, i,
class, n,
v, code_max;
165 uint8_t bits_table[17];
166 uint8_t val_table[256];
180 for (i = 1; i <= 16; i++) {
185 if (len < n || n > 256)
189 for (i = 0; i < n; i++) {
200 class, index, code_max + 1);
202 code_max + 1, 0,
class > 0) < 0)
208 code_max + 1, 0, 0) < 0)
245 if (nb_components <= 0 ||
251 "nb_components changing in interlaced picture\n");
255 if (s->
ls && !(s->
bits <= 8 || nb_components == 1)) {
257 "only <= 8 bits/component or 16-bit gray accepted for JPEG-LS\n");
263 for (i = 0; i < nb_components; i++) {
278 "Invalid sampling factor in component %d %d:%d\n",
290 "Subsampling in JPEG-LS is not supported.\n");
332 if (!(pix_fmt_id & 0xD0D0D0D0))
333 pix_fmt_id -= (pix_fmt_id & 0xF0F0F0F0) >> 1;
334 if (!(pix_fmt_id & 0x0D0D0D0D))
335 pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1;
337 switch (pix_fmt_id) {
364 else if (s->
bits <= 8)
381 for (i = 0; i < 3; i++)
388 if (len != (8 + (3 * nb_components)))
394 int bw = (width + s->
h_max * 8 - 1) / (s->
h_max * 8);
395 int bh = (height + s->
v_max * 8 - 1) / (s->
v_max * 8);
415 "mjpeg_decode_dc: bad vlc: %d:%d (%p)\n",
416 0, dc_index, &s->
vlcs[0][dc_index]);
428 int dc_index,
int ac_index, int16_t *quant_matrix)
430 int code, i, j,
level, val;
438 val = val * quant_matrix[0] + s->
last_dc[component];
448 i += ((unsigned)code) >> 4;
456 int sign = (~cache) >> 31;
457 level = (
NEG_USR32(sign ^ cache,code) ^ sign) - sign;
467 block[j] = level * quant_matrix[j];
476 int component,
int dc_index,
477 int16_t *quant_matrix,
int Al)
486 val = (val * quant_matrix[0] << Al) + s->
last_dc[component];
494 uint8_t *last_nnz,
int ac_index,
495 int16_t *quant_matrix,
496 int ss,
int se,
int Al,
int *EOBRUN)
507 for (i = ss; ; i++) {
511 run = ((unsigned) code) >> 4;
520 int sign = (~cache) >> 31;
521 level = (
NEG_USR32(sign ^ cache,code) ^ sign) - sign;
529 block[j] = level * quant_matrix[j] << Al;
536 block[j] = level * quant_matrix[j] << Al;
565 #define REFINE_BIT(j) { \
566 UPDATE_CACHE(re, &s->gb); \
567 sign = block[j] >> 15; \
568 block[j] += SHOW_UBITS(re, &s->gb, 1) * \
569 ((quant_matrix[j] ^ sign) - sign) << Al; \
570 LAST_SKIP_BITS(re, &s->gb, 1); \
578 av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i); \
583 j = s->scantable.permutated[i]; \
586 else if (run-- == 0) \
593 int ac_index, int16_t *quant_matrix,
594 int ss,
int se,
int Al,
int *EOBRUN)
596 int code, i = ss, j, sign, val,
run;
597 int last =
FFMIN(se, *last_nnz);
608 run = ((unsigned) code) >> 4;
615 block[j] = ((quant_matrix[j]^val) - val) << Al;
623 run = ((unsigned) code) >> 4;
644 for (; i <= last; i++) {
661 int left[3], top[3], topleft[3];
662 const int linesize = s->
linesize[0];
663 const int mask = (1 << s->
bits) - 1;
669 for (i = 0; i < 3; i++)
670 buffer[0][i] = 1 << (s->
bits + point_transform - 1);
672 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
673 const int modified_predictor = mb_y ? predictor : 1;
677 ptr += linesize >> 1;
679 for (i = 0; i < 3; i++)
680 top[i] = left[i] = topleft[i] =
buffer[0][i];
682 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
686 for (i = 0; i < 3; i++) {
692 PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
694 left[i] =
buffer[mb_x][i] =
705 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
706 ptr[4 * mb_x + 1] =
buffer[mb_x][0] - ((
buffer[mb_x][1] +
buffer[mb_x][2] - 0x200) >> 2);
707 ptr[4 * mb_x + 0] =
buffer[mb_x][1] + ptr[4 * mb_x + 1];
708 ptr[4 * mb_x + 2] =
buffer[mb_x][2] + ptr[4 * mb_x + 1];
711 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
713 ptr[4 * mb_x + 0] =
buffer[mb_x][1] + ptr[4 * mb_x + 1];
714 ptr[4 * mb_x + 2] =
buffer[mb_x][2] + ptr[4 * mb_x + 1];
717 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
718 ptr[4 * mb_x + 0] =
buffer[mb_x][2];
719 ptr[4 * mb_x + 1] =
buffer[mb_x][1];
720 ptr[4 * mb_x + 2] =
buffer[mb_x][0];
728 int point_transform,
int nb_components)
732 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
733 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
737 if (mb_x == 0 || mb_y == 0 || s->
interlaced) {
738 for (i = 0; i < nb_components; i++) {
740 int n, h,
v, x, y, c, j, linesize;
749 for (j = 0; j < n; j++) {
753 (linesize * (v * mb_y + y)) +
755 if (y == 0 && mb_y == 0) {
756 if (x == 0 && mb_x == 0)
757 pred = 128 << point_transform;
761 if (x == 0 && mb_x == 0)
762 pred = ptr[-linesize];
764 PREDICT(pred, ptr[-linesize - 1],
765 ptr[-linesize], ptr[-1], predictor);
769 ptr += linesize >> 1;
779 for (i = 0; i < nb_components; i++) {
781 int n, h,
v, x, y, c, j, linesize;
790 for (j = 0; j < n; j++) {
795 (linesize * (v * mb_y + y)) +
797 PREDICT(pred, ptr[-linesize - 1],
798 ptr[-linesize], ptr[-1], predictor);
820 case 0:
copy_block8(dst, src, linesize, linesize, 8);
822 case 1:
copy_block4(dst, src, linesize, linesize, 4);
824 case 2:
copy_block2(dst, src, linesize, linesize, 2);
832 int Al,
const uint8_t *mb_bitmask,
846 "Can not flip image with CODEC_FLAG_EMU_EDGE set!\n");
850 for (i = 0; i < nb_components; i++) {
853 reference_data[c] = reference ? reference->
data[c] :
NULL;
858 int offset = (linesize[c] * (s->
v_scount[i] *
861 reference_data[c] += offset;
866 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
867 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
868 const int copy_mb = mb_bitmask && !
get_bits1(&mb_bitmask_gb);
878 for (i = 0; i < nb_components; i++) {
880 int n, h,
v, x, y, c, j;
888 for (j = 0; j < n; j++) {
889 block_offset = (((linesize[c] * (v * mb_y + y) * 8) +
893 block_offset += linesize[c] >> 1;
894 ptr = data[c] + block_offset;
905 "error y=%d x=%d\n", mb_y, mb_x);
921 "error y=%d x=%d\n", mb_y, mb_x);
947 for (i = 0; i < nb_components; i++)
959 int se,
int Ah,
int Al,
960 const uint8_t *mb_bitmask,
967 const uint8_t *reference_data = reference ? reference->
data[c] :
NULL;
973 if (ss < 0 || ss >= 64 ||
974 se < ss || se >= 64 ||
987 int offset = linesize >> 1;
989 reference_data += offset;
992 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
993 int block_offset = (mb_y * linesize * 8 >> s->
avctx->
lowres);
994 uint8_t *ptr = data + block_offset;
997 uint8_t *last_nnz = &s->
last_nnz[c][block_idx];
998 for (mb_x = 0; mb_x < s->
mb_width; mb_x++,
block++, last_nnz++) {
999 const int copy_mb = mb_bitmask && !
get_bits1(&mb_bitmask_gb);
1005 quant_matrix, ss, se, Al, &EOBRUN);
1008 quant_matrix, ss, se, Al, &EOBRUN);
1011 "error y=%d x=%d\n", mb_y, mb_x);
1033 int len, nb_components, i, h,
v, predictor, point_transform;
1035 const int block_size = s->
lossless ? 1 : 8;
1036 int ilv, prev_shift;
1043 "decode_sos: nb_components (%d) unsupported\n", nb_components);
1046 if (len != 6 + 2 * nb_components) {
1050 for (i = 0; i < nb_components; i++) {
1059 "decode_sos: index(%d) out of components\n", index);
1089 for (i = 0; i < nb_components; i++)
1092 if (nb_components > 1) {
1096 }
else if (!s->
ls) {
1099 s->
mb_width = (s->
width + h * block_size - 1) / (h * block_size);
1108 s->
lossless ?
"lossless" :
"sequential DCT", s->
rgb ?
"RGB" :
"",
1109 predictor, point_transform, ilv, s->
bits,
1138 mb_bitmask, reference) < 0)
1142 mb_bitmask, reference) < 0)
1215 int t_w, t_h, v1, v2;
1226 "mjpeg: JFIF header found (version: %x.%x) SAR=%d/%d\n",
1235 if (len -10 - (t_w * t_h * 3) > 0)
1236 len -= t_w * t_h * 3;
1256 "Pegasus lossless jpeg header found\n");
1303 "mjpeg: error, decode_app parser read over the end\n");
1317 for (i = 0; i < len - 2; i++)
1319 if (i > 0 && cbuf[i - 1] ==
'\n')
1328 if (!strcmp(cbuf,
"AVID")) {
1332 }
else if (!strcmp(cbuf,
"CS=ITU601"))
1334 else if ((len > 20 && !strncmp(cbuf,
"Intel(R) JPEG Library", 21)) ||
1335 (len > 19 && !strncmp(cbuf,
"Metasoft MJPEG Codec", 20)))
1347 static int find_marker(
const uint8_t **pbuf_ptr,
const uint8_t *buf_end)
1349 const uint8_t *buf_ptr;
1356 buf_ptr = *pbuf_ptr;
1357 while (buf_ptr < buf_end) {
1360 if ((v == 0xff) && (v2 >= 0xc0) && (v2 <= 0xfe) && buf_ptr < buf_end) {
1370 av_dlog(
NULL,
"find_marker skipped %d bytes\n", skipped);
1371 *pbuf_ptr = buf_ptr;
1376 const uint8_t **buf_ptr,
const uint8_t *buf_end,
1377 const uint8_t **unescaped_buf_ptr,
1378 int *unescaped_buf_size)
1388 "buffer too small, expanding to %d bytes\n", s->
buffer_size);
1392 if (start_code ==
SOS && !s->
ls) {
1393 const uint8_t *src = *buf_ptr;
1394 uint8_t *dst = s->
buffer;
1396 while (src < buf_end) {
1397 uint8_t x = *(src++);
1402 while (src < buf_end && x == 0xff)
1405 if (x >= 0xd0 && x <= 0xd7)
1412 *unescaped_buf_ptr = s->
buffer;
1413 *unescaped_buf_size = dst - s->
buffer;
1416 (buf_end - *buf_ptr) - (dst - s->
buffer));
1417 }
else if (start_code ==
SOS && s->
ls) {
1418 const uint8_t *src = *buf_ptr;
1419 uint8_t *dst = s->
buffer;
1427 while (src + t < buf_end) {
1428 uint8_t x = src[t++];
1430 while ((src + t < buf_end) && x == 0xff)
1443 uint8_t x = src[
b++];
1453 *unescaped_buf_ptr = dst;
1454 *unescaped_buf_size = (bit_count + 7) >> 3;
1456 *unescaped_buf_ptr = *buf_ptr;
1457 *unescaped_buf_size = buf_end - *buf_ptr;
1466 const uint8_t *buf = avpkt->
data;
1467 int buf_size = avpkt->
size;
1469 const uint8_t *buf_end, *buf_ptr;
1470 const uint8_t *unescaped_buf_ptr;
1471 int unescaped_buf_size;
1477 buf_end = buf + buf_size;
1478 while (buf_ptr < buf_end) {
1482 &unescaped_buf_size);
1484 if (start_code < 0) {
1486 }
else if (unescaped_buf_size > (1
U<<29)) {
1487 av_log(avctx,
AV_LOG_ERROR,
"MJPEG packet 0x%x too big (0x%x/0x%x), corrupt data?\n",
1488 start_code, unescaped_buf_ptr, buf_size);
1492 start_code, buf_end - buf_ptr);
1501 if (start_code >= 0xd0 && start_code <= 0xd7)
1503 "restart marker: %d\n", start_code & 0x0f);
1505 else if (start_code >=
APP0 && start_code <=
APP15)
1508 else if (start_code ==
COM)
1512 (start_code ==
SOF48 || start_code ==
LSE)) {
1517 switch (start_code) {
1572 "Found EOI before any SOF, ignoring\n");
1591 (s->
width + 15) / 16);
1594 "QP: %d\n", picture->
quality);
1602 "Can not process SOS before SOF, skipping\n");
1627 "mjpeg: unsupported coding type (%x)\n", start_code);
1638 "marker parser used %d bytes (%d bits)\n",
1652 return buf_ptr - buf;
1668 for (i = 0; i < 3; i++) {
1669 for (j = 0; j < 4; j++)
1679 #define OFFSET(x) offsetof(MJpegDecodeContext, x)
1680 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1682 {
"extern_huff",
"Use external huffman table.",
int block_stride[MAX_COMPONENTS]
const uint8_t ff_mjpeg_bits_dc_chrominance[17]
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
const uint8_t ff_mjpeg_bits_ac_chrominance[17]
int v_count[MAX_COMPONENTS]
const uint8_t ff_zigzag_direct[64]
int qstride
QP store stride.
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
const uint8_t ff_mjpeg_val_ac_chrominance[]
DCTELEM(*[MAX_COMPONENTS] blocks)[64]
intermediate sums (progressive mode)
static void skip_bits_long(GetBitContext *s, int n)
#define AV_LOG_WARNING
Something somehow does not look correct.
static void align_get_bits(GetBitContext *s)
static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block, uint8_t *last_nnz, int ac_index, int16_t *quant_matrix, int ss, int se, int Al, int *EOBRUN)
int h_scount[MAX_COMPONENTS]
int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
static int mjpeg_decode_com(MJpegDecodeContext *s)
int qscale[4]
quantizer scale calculated from quant_matrixes
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
static const AVClass mjpegdec_class
int dc_index[MAX_COMPONENTS]
int linesize[MAX_COMPONENTS]
linesize << interlaced
int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
MJPEG encoder and decoder.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
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 ...
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
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)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
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]
static void copy_block4(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
uint8_t * last_nnz[MAX_COMPONENTS]
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
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]
uint8_t idct_permutation[64]
idct input permutation.
int interlaced_frame
The content of the picture is interlaced.
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
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.
av_cold void dsputil_init(DSPContext *c, AVCodecContext *avctx)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define PREDICT(ret, topleft, top, left, predictor)
static int get_bits_left(GetBitContext *gb)
#define UPDATE_CACHE(name, gb)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static const uint16_t mask[17]
int nb_blocks[MAX_COMPONENTS]
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
void(* idct_put)(uint8_t *dest, int line_size, DCTELEM *block)
block -> idct -> clip to unsigned 8 bit -> dest.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
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)
void(* clear_block)(DCTELEM *block)
static void copy_block8(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define CODEC_FLAG_EMU_EDGE
Don't draw edges.
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)
static av_always_inline void emms_c(void)
Empty mmx state.
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, see ?_TYPE below.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int component_id[MAX_COMPONENTS]
static int mjpeg_decode_app(MJpegDecodeContext *s)
struct AVFrame AVFrame
Audio Video Frame.
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
#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.
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
#define SHOW_UBITS(name, gb, num)
static const float pred[4]
const uint8_t ff_mjpeg_bits_dc_luminance[17]
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
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).
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
#define OPEN_READER(name, gb)
static av_always_inline void mjpeg_copy_block(uint8_t *dst, const uint8_t *src, int linesize, int lowres)
static unsigned int get_bits1(GetBitContext *s)
const uint8_t ff_mjpeg_bits_ac_luminance[17]
int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Describe the class of an AVClass context structure.
struct MJpegDecodeContext MJpegDecodeContext
static void skip_bits(GetBitContext *s, int n)
static int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index)
int ac_index[MAX_COMPONENTS]
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define GET_CACHE(name, gb)
uint64_t coefs_finished[MAX_COMPONENTS]
bitmask of which coefs have been completely decoded (progressive mode)
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
const uint8_t ff_mjpeg_val_dc[12]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int8_t * qscale_table
QP table.
const uint8_t ff_mjpeg_val_ac_luminance[]
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
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)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void build_basic_mjpeg_vlc(MJpegDecodeContext *s)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
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)
#define FF_DEBUG_STARTCODE
packed RGB 8:8:8, 24bpp, RGBRGB...
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.
void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
static int decode_block_refinement(MJpegDecodeContext *s, DCTELEM *block, uint8_t *last_nnz, int ac_index, int16_t *quant_matrix, int ss, int se, int Al, int *EOBRUN)
VLC_TYPE(* table)[2]
code, bits
JPEG-LS extension parameters.
int key_frame
1 -> keyframe, 0-> not
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
int last_dc[MAX_COMPONENTS]
static int decode_dc_progressive(MJpegDecodeContext *s, DCTELEM *block, int component, int dc_index, int16_t *quant_matrix, int Al)
enum AVFieldOrder field_order
Field order.
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)
static int decode_block(MJpegDecodeContext *s, DCTELEM *block, int component, int dc_index, int ac_index, int16_t *quant_matrix)
#define MKTAG(a, b, c, d)
int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
static const AVOption options[]
void ff_free_vlc(VLC *vlc)
static void copy_block2(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)