Go to the documentation of this file.
48 #define BITSTREAM_READER_LE
59 #define VP8X_FLAG_ANIMATION 0x02
60 #define VP8X_FLAG_XMP_METADATA 0x04
61 #define VP8X_FLAG_EXIF_METADATA 0x08
62 #define VP8X_FLAG_ALPHA 0x10
63 #define VP8X_FLAG_ICC 0x20
65 #define MAX_PALETTE_SIZE 256
66 #define MAX_CACHE_BITS 11
67 #define NUM_CODE_LENGTH_CODES 19
68 #define HUFFMAN_CODES_PER_META_CODE 5
69 #define NUM_LITERAL_CODES 256
70 #define NUM_LENGTH_CODES 24
71 #define NUM_DISTANCE_CODES 40
72 #define NUM_SHORT_DISTANCES 120
73 #define MAX_HUFFMAN_CODE_LENGTH 15
82 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
86 { 0, 1 }, { 1, 0 }, { 1, 1 }, { -1, 1 }, { 0, 2 }, { 2, 0 }, { 1, 2 }, { -1, 2 },
87 { 2, 1 }, { -2, 1 }, { 2, 2 }, { -2, 2 }, { 0, 3 }, { 3, 0 }, { 1, 3 }, { -1, 3 },
88 { 3, 1 }, { -3, 1 }, { 2, 3 }, { -2, 3 }, { 3, 2 }, { -3, 2 }, { 0, 4 }, { 4, 0 },
89 { 1, 4 }, { -1, 4 }, { 4, 1 }, { -4, 1 }, { 3, 3 }, { -3, 3 }, { 2, 4 }, { -2, 4 },
90 { 4, 2 }, { -4, 2 }, { 0, 5 }, { 3, 4 }, { -3, 4 }, { 4, 3 }, { -4, 3 }, { 5, 0 },
91 { 1, 5 }, { -1, 5 }, { 5, 1 }, { -5, 1 }, { 2, 5 }, { -2, 5 }, { 5, 2 }, { -5, 2 },
92 { 4, 4 }, { -4, 4 }, { 3, 5 }, { -3, 5 }, { 5, 3 }, { -5, 3 }, { 0, 6 }, { 6, 0 },
93 { 1, 6 }, { -1, 6 }, { 6, 1 }, { -6, 1 }, { 2, 6 }, { -2, 6 }, { 6, 2 }, { -6, 2 },
94 { 4, 5 }, { -4, 5 }, { 5, 4 }, { -5, 4 }, { 3, 6 }, { -3, 6 }, { 6, 3 }, { -6, 3 },
95 { 0, 7 }, { 7, 0 }, { 1, 7 }, { -1, 7 }, { 5, 5 }, { -5, 5 }, { 7, 1 }, { -7, 1 },
96 { 4, 6 }, { -4, 6 }, { 6, 4 }, { -6, 4 }, { 2, 7 }, { -2, 7 }, { 7, 2 }, { -7, 2 },
97 { 3, 7 }, { -3, 7 }, { 7, 3 }, { -7, 3 }, { 5, 6 }, { -5, 6 }, { 6, 5 }, { -6, 5 },
98 { 8, 0 }, { 4, 7 }, { -4, 7 }, { 7, 4 }, { -7, 4 }, { 8, 1 }, { 8, 2 }, { 6, 6 },
99 { -6, 6 }, { 8, 3 }, { 5, 7 }, { -5, 7 }, { 7, 5 }, { -7, 5 }, { 8, 4 }, { 6, 7 },
100 { -6, 7 }, { 7, 6 }, { -7, 6 }, { 8, 5 }, { 7, 7 }, { -7, 7 }, { 8, 6 }, { 8, 7 }
223 #define GET_PIXEL(frame, x, y) \
224 ((frame)->data[0] + (y) * frame->linesize[0] + 4 * (x))
226 #define GET_PIXEL_COMP(frame, x, y, c) \
227 (*((frame)->data[0] + (y) * frame->linesize[0] + 4 * (x) + c))
236 if (
img->huffman_groups) {
237 for (
i = 0;
i <
img->nb_huffman_groups;
i++) {
243 memset(
img, 0,
sizeof(*
img));
249 if (
r->nb_symbols == 1)
250 return r->simple_symbols[0];
259 uint8_t lens[], uint16_t syms[],
260 int alphabet_size,
void *logctx)
262 unsigned nb_codes = 0;
268 unsigned cnt = len_counts[
len];
269 len_counts[
len] = nb_codes;
273 for (
int sym = 0; sym < alphabet_size; ++sym) {
274 if (code_lengths[sym]) {
275 unsigned idx = len_counts[code_lengths[sym]]++;
277 lens[idx] = code_lengths[sym];
289 r->simple_symbols[0] = syms[0];
320 HuffReader code_len_hc = { { 0 }, 0, 0, { 0 } };
321 uint8_t *code_lengths;
326 int symbol, max_symbol, prev_code_len,
ret;
331 for (
int i = 0;
i < num_codes;
i++) {
340 if (max_symbol > alphabet_size) {
342 max_symbol, alphabet_size);
346 max_symbol = alphabet_size;
350 reordered_code_length_code_lengths,
351 reordered_code_length_syms,
356 code_lengths =
av_malloc_array(alphabet_size, 2 *
sizeof(uint8_t) +
sizeof(uint16_t));
364 memset(len_counts, 0,
sizeof(len_counts));
365 while (symbol < alphabet_size) {
371 if (code_len < 16
U) {
373 code_lengths[symbol++] = code_len;
374 len_counts[code_len]++;
376 prev_code_len = code_len;
378 int repeat = 0, length = 0;
388 length = prev_code_len;
389 len_counts[length] += repeat;
402 if (symbol + repeat > alphabet_size) {
404 "invalid symbol %d + repeat %d > alphabet size %d\n",
405 symbol, repeat, alphabet_size);
410 code_lengths[symbol++] = length;
415 code_lengths + symbol,
416 (uint16_t*)(code_lengths + 2 * symbol),
428 #define PARSE_BLOCK_SIZE(w, h) do { \
429 block_bits = get_bits(&s->gb, 3) + 2; \
430 blocks_w = FFALIGN((w), 1 << block_bits) >> block_bits; \
431 blocks_h = FFALIGN((h), 1 << block_bits) >> block_bits; \
451 for (y = 0; y <
img->frame->height; y++) {
452 for (x = 0; x <
img->frame->width; x++) {
455 int p = p0 << 8 | p1;
459 s->nb_huffman_groups =
max + 1;
499 int width_bits, index_size,
ret, x;
506 else if (index_size <= 4)
508 else if (index_size <= 16)
519 img->size_reduction = width_bits;
521 s->reduced_width = (
s->width + ((1 << width_bits) - 1)) >> width_bits;
524 ct =
img->frame->data[0] + 4;
525 for (x = 4; x <
img->frame->width * 4; x++, ct++)
542 group = g0 << 8 | g1;
550 uint32_t cache_idx = (0x1E35A7BD *
c) >> (32 -
img->color_cache_bits);
551 img->color_cache[cache_idx] =
c;
561 img = &
s->image[role];
571 img->frame->width =
w;
572 img->frame->height =
h;
583 if (
img->color_cache_bits < 1 ||
img->color_cache_bits > 11) {
585 img->color_cache_bits);
589 sizeof(*
img->color_cache));
590 if (!
img->color_cache)
593 img->color_cache_bits = 0;
596 img->nb_huffman_groups = 1;
601 img->nb_huffman_groups =
s->nb_huffman_groups;
605 sizeof(*
img->huffman_groups));
606 if (!
img->huffman_groups)
609 for (
i = 0;
i <
img->nb_huffman_groups;
i++) {
613 if (!j &&
img->color_cache_bits > 0)
614 alphabet_size += 1 <<
img->color_cache_bits;
631 while (y < img->
frame->height) {
646 if (
img->color_cache_bits)
655 int prefix_code, length,
distance, ref_x, ref_y;
659 if (prefix_code < 4) {
660 length = prefix_code + 1;
667 if (prefix_code > 39
U) {
669 "distance prefix code too large: %d\n", prefix_code);
672 if (prefix_code < 4) {
705 ref_x =
FFMAX(0, ref_x);
706 ref_y =
FFMAX(0, ref_y);
708 if (ref_y == y && ref_x >= x)
714 for (
i = 0;
i < length;
i++) {
719 if (
img->color_cache_bits)
727 if (ref_x ==
width) {
731 if (y ==
img->frame->height || ref_y ==
img->frame->height)
739 if (!
img->color_cache_bits) {
743 if (cache_idx >= 1 <<
img->color_cache_bits) {
745 "color cache index out-of-bounds\n");
762 const uint8_t *p_t,
const uint8_t *p_tr)
769 const uint8_t *p_t,
const uint8_t *p_tr)
776 const uint8_t *p_t,
const uint8_t *p_tr)
783 const uint8_t *p_t,
const uint8_t *p_tr)
790 const uint8_t *p_t,
const uint8_t *p_tr)
797 const uint8_t *p_t,
const uint8_t *p_tr)
799 p[0] = p_t[0] + (p_l[0] + p_tr[0] >> 1) >> 1;
800 p[1] = p_t[1] + (p_l[1] + p_tr[1] >> 1) >> 1;
801 p[2] = p_t[2] + (p_l[2] + p_tr[2] >> 1) >> 1;
802 p[3] = p_t[3] + (p_l[3] + p_tr[3] >> 1) >> 1;
807 const uint8_t *p_t,
const uint8_t *p_tr)
809 p[0] = p_l[0] + p_tl[0] >> 1;
810 p[1] = p_l[1] + p_tl[1] >> 1;
811 p[2] = p_l[2] + p_tl[2] >> 1;
812 p[3] = p_l[3] + p_tl[3] >> 1;
817 const uint8_t *p_t,
const uint8_t *p_tr)
819 p[0] = p_l[0] + p_t[0] >> 1;
820 p[1] = p_l[1] + p_t[1] >> 1;
821 p[2] = p_l[2] + p_t[2] >> 1;
822 p[3] = p_l[3] + p_t[3] >> 1;
827 const uint8_t *p_t,
const uint8_t *p_tr)
829 p[0] = p_tl[0] + p_t[0] >> 1;
830 p[1] = p_tl[1] + p_t[1] >> 1;
831 p[2] = p_tl[2] + p_t[2] >> 1;
832 p[3] = p_tl[3] + p_t[3] >> 1;
837 const uint8_t *p_t,
const uint8_t *p_tr)
839 p[0] = p_t[0] + p_tr[0] >> 1;
840 p[1] = p_t[1] + p_tr[1] >> 1;
841 p[2] = p_t[2] + p_tr[2] >> 1;
842 p[3] = p_t[3] + p_tr[3] >> 1;
847 const uint8_t *p_t,
const uint8_t *p_tr)
849 p[0] = (p_l[0] + p_tl[0] >> 1) + (p_t[0] + p_tr[0] >> 1) >> 1;
850 p[1] = (p_l[1] + p_tl[1] >> 1) + (p_t[1] + p_tr[1] >> 1) >> 1;
851 p[2] = (p_l[2] + p_tl[2] >> 1) + (p_t[2] + p_tr[2] >> 1) >> 1;
852 p[3] = (p_l[3] + p_tl[3] >> 1) + (p_t[3] + p_tr[3] >> 1) >> 1;
857 const uint8_t *p_t,
const uint8_t *p_tr)
860 (
FFABS(p_l[1] - p_tl[1]) -
FFABS(p_t[1] - p_tl[1])) +
861 (
FFABS(p_l[2] - p_tl[2]) -
FFABS(p_t[2] - p_tl[2])) +
862 (
FFABS(p_l[3] - p_tl[3]) -
FFABS(p_t[3] - p_tl[3]));
871 const uint8_t *p_t,
const uint8_t *p_tr)
887 const uint8_t *p_t,
const uint8_t *p_tr)
896 const uint8_t *p_tl,
const uint8_t *p_t,
897 const uint8_t *p_tr);
908 uint8_t *dec, *p_l, *p_tl, *p_t, *p_tr;
915 if (x ==
frame->width - 1)
934 for (y = 0; y <
img->frame->height; y++) {
935 for (x = 0; x <
s->reduced_width; x++) {
950 "invalid predictor mode: %d\n", m);
974 for (y = 0; y <
img->frame->height; y++) {
975 for (x = 0; x <
s->reduced_width; x++) {
994 for (y = 0; y <
img->frame->height; y++) {
995 for (x = 0; x <
s->reduced_width; x++) {
1023 for (y = 0; y <
img->frame->height; y++) {
1025 memcpy(
line,
p,
img->frame->linesize[0]);
1029 for (x = 0; x <
img->frame->width; x++) {
1040 s->reduced_width =
s->width;
1044 if (
img->frame->height *
img->frame->width > 300) {
1045 uint8_t palette[256 * 4];
1050 memset(palette +
size, 0, 256 * 4 -
size);
1051 for (y = 0; y <
img->frame->height; y++) {
1052 for (x = 0; x <
img->frame->width; x++) {
1059 for (y = 0; y <
img->frame->height; y++) {
1060 for (x = 0; x <
img->frame->width; x++) {
1079 if (
s->width &&
s->width !=
w) {
1084 if (
s->height &&
s->height !=
h) {
1092 int *got_frame,
const uint8_t *data_start,
1093 unsigned int data_size,
int is_alpha_chunk)
1098 if (!is_alpha_chunk)
1105 if (!is_alpha_chunk) {
1127 if (!
s->width || !
s->height)
1134 s->nb_transforms = 0;
1135 s->reduced_width =
s->width;
1143 goto free_and_return;
1159 goto free_and_return;
1168 goto free_and_return;
1171 for (
i =
s->nb_transforms - 1;
i >= 0;
i--) {
1172 switch (
s->transforms[
i]) {
1187 goto free_and_return;
1208 ls =
frame->linesize[3];
1211 dec =
frame->data[3] + 1;
1212 for (x = 1; x <
frame->width; x++, dec++)
1216 dec =
frame->data[3] + ls;
1217 for (y = 1; y <
frame->height; y++, dec += ls)
1218 *dec += *(dec - ls);
1223 for (y = 1; y <
frame->height; y++) {
1224 dec =
frame->data[3] + y * ls + 1;
1225 for (x = 1; x <
frame->width; x++, dec++)
1230 for (y = 1; y <
frame->height; y++) {
1231 dec =
frame->data[3] + y * ls + 1;
1232 for (x = 1; x <
frame->width; x++, dec++)
1233 *dec += *(dec - ls);
1237 for (y = 1; y <
frame->height; y++) {
1238 dec =
frame->data[3] + y * ls + 1;
1239 for (x = 1; x <
frame->width; x++, dec++)
1240 dec[0] +=
av_clip_uint8(*(dec - 1) + *(dec - ls) - *(dec - ls - 1));
1247 const uint8_t *data_start,
1248 unsigned int data_size)
1257 for (y = 0; y <
s->height; y++)
1262 int alpha_got_frame = 0;
1265 if (!
s->alpha_frame)
1269 data_start, data_size, 1);
1274 if (!alpha_got_frame) {
1280 for (y = 0; y <
s->height; y++) {
1282 pp =
p->data[3] +
p->linesize[3] * y;
1283 for (x = 0; x <
s->width; x++) {
1293 if (
s->alpha_filter)
1300 int *got_frame, uint8_t *data_start,
1301 unsigned int data_size)
1306 if (!
s->initialized) {
1309 s->v.actually_webp = 1;
1313 if (data_size > INT_MAX) {
1319 s->pkt->data = data_start;
1320 s->pkt->size = data_size;
1333 s->alpha_data_size);
1346 uint32_t chunk_type, chunk_size;
1362 if (bytestream2_get_le32(&gb) !=
MKTAG(
'R',
'I',
'F',
'F')) {
1367 chunk_size = bytestream2_get_le32(&gb);
1371 if (bytestream2_get_le32(&gb) !=
MKTAG(
'W',
'E',
'B',
'P')) {
1377 chunk_type = bytestream2_get_le32(&gb);
1378 chunk_size = bytestream2_get_le32(&gb);
1379 if (chunk_size == UINT32_MAX)
1381 chunk_size += chunk_size & 1;
1389 switch (chunk_type) {
1390 case MKTAG(
'V',
'P',
'8',
' '):
1400 case MKTAG(
'V',
'P',
'8',
'L'):
1407 #if FF_API_CODEC_PROPS
1415 case MKTAG(
'V',
'P',
'8',
'X'):
1416 if (
s->width ||
s->height || *got_frame) {
1420 vp8x_flags = bytestream2_get_byte(&gb);
1422 s->width = bytestream2_get_le24(&gb) + 1;
1423 s->height = bytestream2_get_le24(&gb) + 1;
1428 case MKTAG(
'A',
'L',
'P',
'H'): {
1429 int alpha_header, filter_m, compression;
1433 "ALPHA chunk present, but alpha bit not set in the "
1436 if (chunk_size == 0) {
1440 alpha_header = bytestream2_get_byte(&gb);
1442 s->alpha_data_size = chunk_size - 1;
1445 filter_m = (alpha_header >> 2) & 0x03;
1446 compression = alpha_header & 0x03;
1450 "skipping unsupported ALPHA chunk\n");
1453 s->alpha_compression = compression;
1454 s->alpha_filter = filter_m;
1459 case MKTAG(
'E',
'X',
'I',
'F'): {
1469 "EXIF chunk present, but Exif bit not set in the "
1478 memcpy(exif_buf->
data, gb.
buffer, chunk_size);
1488 case MKTAG(
'I',
'C',
'C',
'P'): {
1498 "ICCP chunk present, but ICC Profile bit not set in the "
1514 case MKTAG(
'A',
'N',
'I',
'M'):
1515 case MKTAG(
'A',
'N',
'M',
'F'):
1520 case MKTAG(
'X',
'M',
'P',
' '): {
1528 "XMP chunk present, but XMP bit not set in the "
1539 buffer[chunk_size] =
'\0';
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define FF_ENABLE_DEPRECATION_WARNINGS
av_cold int ff_vp8_decode_free(AVCodecContext *avctx)
#define AV_LOG_WARNING
Something somehow does not look correct.
static void inv_predict_12(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
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()
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define NUM_SHORT_DISTANCES
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, uint8_t *data_start, unsigned int data_size)
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
@ PRED_MODE_AVG_T_AVG_L_TR
@ ALPHA_FILTER_HORIZONTAL
uint16_t simple_symbols[2]
static av_always_inline int bytestream2_tell(const GetByteContext *g)
uint8_t * data
The data buffer.
static int8_t ff_u8_to_s8(uint8_t a)
static const uint8_t block_bits[]
static void inv_predict_4(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static void inv_predict_2(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
This structure describes decoded (raw) audio or video data.
#define GET_PIXEL_COMP(frame, x, y, c)
@ PRED_MODE_ADD_SUBTRACT_FULL
@ COLOR_INDEXING_TRANSFORM
static int parse_transform_color(WebPContext *s)
#define AV_LOG_VERBOSE
Detailed information.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
enum TransformType transforms[4]
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, const uint8_t *data_start, unsigned int data_size, int is_alpha_chunk)
static void skip_bits(GetBitContext *s, int n)
enum AlphaCompression alpha_compression
static void inv_predict_10(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void inv_predict_8(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
AVCodec p
The public AVCodec.
static void update_canvas_size(AVCodecContext *avctx, int w, int h)
void(* inv_predict_func)(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
#define VP8X_FLAG_EXIF_METADATA
static void inv_predict_3(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
const FFCodec ff_webp_decoder
static av_always_inline uint8_t color_transform_delta(uint8_t color_pred, uint8_t color)
static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role, int w, int h)
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int read_huffman_code_normal(WebPContext *s, HuffReader *hc, int alphabet_size)
#define FF_CODEC_CAP_USES_PROGRESSFRAMES
The decoder might make use of the ProgressFrame API.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define FF_CODEC_PROPERTY_LOSSLESS
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
static void inverse_prediction(AVFrame *frame, enum PredictionMode m, int x, int y)
#define FF_CODEC_DECODE_CB(func)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static const int8_t transform[32][32]
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
#define HUFFMAN_CODES_PER_META_CODE
static const uint8_t code_length_code_order[NUM_CODE_LENGTH_CODES]
static av_always_inline void color_cache_put(ImageContext *img, uint32_t c)
#define NUM_DISTANCE_CODES
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void inv_predict_11(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
#define NUM_CODE_LENGTH_CODES
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define GET_PIXEL(frame, x, y)
static av_cold int webp_decode_close(AVCodecContext *avctx)
#define CODEC_LONG_NAME(str)
HuffReader * huffman_groups
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int ff_vp8_decode_init(AVCodecContext *avctx)
static int apply_subtract_green_transform(WebPContext *s)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
static av_always_inline uint8_t clamp_add_subtract_half(int a, int b, int c)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static const inv_predict_func inverse_predict[14]
@ AV_EXIF_TIFF_HEADER
The TIFF header starts with 0x49492a00, or 0x4d4d002a.
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
static int parse_transform_color_indexing(WebPContext *s)
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
static av_cold int webp_decode_init(AVCodecContext *avctx)
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static const uint16_t alphabet_sizes[HUFFMAN_CODES_PER_META_CODE]
#define NUM_LITERAL_CODES
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static void alpha_inverse_prediction(AVFrame *frame, enum AlphaFilter m)
@ IMAGE_ROLE_COLOR_INDEXING
int(* init)(AVBSFContext *ctx)
static void inv_predict_0(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
int ff_decode_exif_attach_buffer(AVCodecContext *avctx, AVFrame *frame, AVBufferRef **pbuf, enum AVExifHeaderMode header_mode)
Attach the data buffer to the frame.
#define i(width, name, range_min, range_max)
int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, size_t size, AVFrameSideData **psd)
Wrapper around av_frame_new_side_data, which rejects side data overridden by the demuxer.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
static int decode_entropy_image(WebPContext *s)
static int apply_color_transform(WebPContext *s)
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
static int parse_transform_predictor(WebPContext *s)
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
@ PRED_MODE_AVG_AVG_L_TL_AVG_T_TR
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
static void inv_predict_5(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
#define av_malloc_array(a, b)
static const int8_t lz77_distance_offsets[NUM_SHORT_DISTANCES][2]
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static int apply_predictor_transform(WebPContext *s)
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static void inv_predict_7(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
void * av_calloc(size_t nmemb, size_t size)
static int huff_reader_get_symbol(HuffReader *r, GetBitContext *gb)
#define VP8X_FLAG_XMP_METADATA
#define FF_CODEC_CAP_ICC_PROFILES
Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE).
static void inv_predict_13(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
void ff_vlc_free(VLC *vlc)
ImageContext image[IMAGE_ROLE_NB]
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int ff_vp8_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
static void inv_predict_6(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
#define AV_INPUT_BUFFER_PADDING_SIZE
static int vp8_lossy_decode_alpha(AVCodecContext *avctx, AVFrame *p, const uint8_t *data_start, unsigned int data_size)
main external API structure.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
static int webp_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
static void image_ctx_free(ImageContext *img)
#define FF_DISABLE_DEPRECATION_WARNINGS
static int apply_color_indexing_transform(WebPContext *s)
A reference to a data buffer.
const uint8_t * alpha_data
Structure to hold side data for an AVFrame.
#define VLC_INIT_OUTPUT_LE
#define MAX_HUFFMAN_CODE_LENGTH
#define PARSE_BLOCK_SIZE(w, h)
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int width
picture width / height.
static float distance(float x, float y, int band)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
attribute_deprecated unsigned properties
Properties of the stream that gets decoded.
static void read_huffman_code_simple(WebPContext *s, HuffReader *hc)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
static int huff_reader_build_canonical(HuffReader *r, const uint8_t *code_lengths, uint16_t len_counts[MAX_HUFFMAN_CODE_LENGTH+1], uint8_t lens[], uint16_t syms[], int alphabet_size, void *logctx)
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...
static HuffReader * get_huffman_group(WebPContext *s, ImageContext *img, int x, int y)
#define xi(width, name, var, range_min, range_max, subs,...)
#define AV_FRAME_FLAG_LOSSLESS
A decoder can use this flag to mark frames which were originally encoded losslessly.
static void inv_predict_9(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
static void inv_predict_1(uint8_t *p, const uint8_t *p_l, const uint8_t *p_tl, const uint8_t *p_t, const uint8_t *p_tr)
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line
enum AlphaFilter alpha_filter
#define av_fourcc2str(fourcc)
@ PRED_MODE_ADD_SUBTRACT_HALF
@ IMAGE_ROLE_COLOR_TRANSFORM