Go to the documentation of this file.
33 for (v = 0;
i < 128; v++) {
45 for (
i = 1;
i < 128;
i++)
56 int context_count = 1;
58 for (
i = 0;
i < 5;
i++) {
63 if (context_count > 32768
U) {
67 return (context_count + 1) / 2;
78 memset(state2, 128,
sizeof(state2));
94 f->combined_version =
f->version << 16;
96 c.bytestream_end -= 4;
98 if (
f->micro_version < 0 ||
f->micro_version > 65535)
100 f->combined_version +=
f->micro_version;
105 for (
int i = 1;
i < 256;
i++)
110 for (
int i = 1;
i < 256;
i++)
120 f->bayer = (
f->colorspace == 2);
123 if (
f->bayer_order != 0) {
128 f->plane_count = 1 + (
f->chroma_planes ||
f->version<4) +
f->transparency +
f->bayer;
132 if (
f->chroma_h_shift > 4
U ||
f->chroma_v_shift > 4
U) {
134 f->chroma_h_shift,
f->chroma_v_shift);
138 if (
f->num_h_slices > (
unsigned)
f->width || !
f->num_h_slices ||
139 f->num_v_slices > (
unsigned)
f->height || !
f->num_v_slices
153 f->quant_table_count = 0;
157 for (
int i = 0;
i <
f->quant_table_count;
i++) {
159 if (
f->context_count[
i] < 0) {
167 for (
int i = 0;
i <
f->quant_table_count;
i++)
169 for (
int j = 0; j <
f->context_count[
i]; j++)
171 int pred = j ?
f->initial_states[
i][j - 1][k] : 128;
172 f->initial_states[
i][j][k] =
177 if (
f->version > 2) {
180 f->crcref = 0x7a8c4079;
181 if (
f->combined_version >= 0x30003)
183 if (
f->combined_version >= 0x40004)
187 if (
f->version > 2) {
190 f->avctx->extradata,
f->avctx->extradata_size);
191 if (v !=
f->crcref ||
f->avctx->extradata_size < 4) {
195 crc =
AV_RB32(
f->avctx->extradata +
f->avctx->extradata_size - 4);
200 "global: ver:%d.%d, coder:%d, colorspace: %d bpr:%d chroma:%d(%d:%d), alpha:%d slices:%dx%d qtabs:%d ec:%d intra:%d CRC:0x%08X\n",
201 f->version,
f->micro_version,
204 f->avctx->bits_per_raw_sample,
205 f->chroma_planes,
f->chroma_h_shift,
f->chroma_v_shift,
207 f->num_h_slices,
f->num_v_slices,
208 f->quant_table_count,
218 if (
f->version < 2) {
219 int chroma_planes, chroma_h_shift, chroma_v_shift, transparency, colorspace, bits_per_raw_sample;
229 for (
int i = 1;
i < 256;
i++) {
231 if (st < 1 || st > 255) {
235 f->state_transition[
i] = st;
240 for (
int i = 1;
i < 256;
i++)
250 if (colorspace == 0 &&
f->avctx->skip_alpha)
253 if (
f->plane_count) {
254 if (colorspace !=
f->colorspace ||
255 bits_per_raw_sample !=
f->avctx->bits_per_raw_sample ||
256 chroma_planes !=
f->chroma_planes ||
257 chroma_h_shift !=
f->chroma_h_shift ||
258 chroma_v_shift !=
f->chroma_v_shift ||
259 transparency !=
f->transparency) {
265 if (chroma_h_shift > 4
U || chroma_v_shift > 4
U) {
267 chroma_h_shift, chroma_v_shift);
271 f->colorspace = colorspace;
272 f->avctx->bits_per_raw_sample = bits_per_raw_sample;
273 f->chroma_planes = chroma_planes;
274 f->chroma_h_shift = chroma_h_shift;
275 f->chroma_v_shift = chroma_v_shift;
276 f->transparency = transparency;
278 f->plane_count = 2 +
f->transparency;
281 if (
f->colorspace == 0) {
282 if (!
f->transparency && !
f->chroma_planes) {
283 if (
f->avctx->bits_per_raw_sample <= 8)
285 else if (
f->avctx->bits_per_raw_sample == 9) {
286 f->packed_at_lsb = 1;
288 }
else if (
f->avctx->bits_per_raw_sample == 10) {
289 f->packed_at_lsb = 1;
291 }
else if (
f->avctx->bits_per_raw_sample == 12) {
292 f->packed_at_lsb = 1;
294 }
else if (
f->avctx->bits_per_raw_sample == 14) {
295 f->packed_at_lsb = 1;
297 }
else if (
f->avctx->bits_per_raw_sample == 16) {
298 f->packed_at_lsb = 1;
303 }
else if (
f->avctx->bits_per_raw_sample < 16) {
307 }
else if (
f->transparency && !
f->chroma_planes) {
308 if (
f->avctx->bits_per_raw_sample <= 8 && !
f->flt) {
310 }
else if (
f->avctx->bits_per_raw_sample == 16 &&
f->flt) {
314 }
else if (
f->avctx->bits_per_raw_sample<=8 && !
f->transparency) {
315 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
323 }
else if (
f->avctx->bits_per_raw_sample <= 8 &&
f->transparency) {
324 switch(16*
f->chroma_h_shift +
f->chroma_v_shift) {
329 }
else if (
f->avctx->bits_per_raw_sample == 9 && !
f->transparency) {
330 f->packed_at_lsb = 1;
331 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
336 }
else if (
f->avctx->bits_per_raw_sample == 9 &&
f->transparency) {
337 f->packed_at_lsb = 1;
338 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
343 }
else if (
f->avctx->bits_per_raw_sample == 10 && !
f->transparency) {
344 f->packed_at_lsb = 1;
345 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
351 }
else if (
f->avctx->bits_per_raw_sample == 10 &&
f->transparency) {
352 f->packed_at_lsb = 1;
353 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
358 }
else if (
f->avctx->bits_per_raw_sample == 12 && !
f->transparency) {
359 f->packed_at_lsb = 1;
360 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
366 }
else if (
f->avctx->bits_per_raw_sample == 12 &&
f->transparency) {
367 f->packed_at_lsb = 1;
368 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
372 }
else if (
f->avctx->bits_per_raw_sample == 14 && !
f->transparency) {
373 f->packed_at_lsb = 1;
374 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
379 }
else if (
f->avctx->bits_per_raw_sample == 16 && !
f->transparency){
380 f->packed_at_lsb = 1;
381 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
386 }
else if (
f->avctx->bits_per_raw_sample == 16 &&
f->transparency){
387 f->packed_at_lsb = 1;
388 switch(16 *
f->chroma_h_shift +
f->chroma_v_shift) {
394 }
else if (
f->colorspace == 1) {
395 if (
f->chroma_h_shift ||
f->chroma_v_shift) {
397 "chroma subsampling not supported in this colorspace\n");
400 if (
f->avctx->bits_per_raw_sample <= 8 && !
f->transparency)
402 else if (
f->avctx->bits_per_raw_sample <= 8 &&
f->transparency)
404 else if (
f->avctx->bits_per_raw_sample == 9 && !
f->transparency)
406 else if (
f->avctx->bits_per_raw_sample == 10 && !
f->transparency)
408 else if (
f->avctx->bits_per_raw_sample == 10 &&
f->transparency)
410 else if (
f->avctx->bits_per_raw_sample == 12 && !
f->transparency)
412 else if (
f->avctx->bits_per_raw_sample == 12 &&
f->transparency)
414 else if (
f->avctx->bits_per_raw_sample == 14 && !
f->transparency)
416 else if (
f->avctx->bits_per_raw_sample == 14 &&
f->transparency)
418 else if (
f->avctx->bits_per_raw_sample == 16 && !
f->transparency) {
424 }
else if (
f->avctx->bits_per_raw_sample == 16 &&
f->transparency) {
430 }
else if (
f->avctx->bits_per_raw_sample == 32 && !
f->transparency) {
435 }
else if (
f->avctx->bits_per_raw_sample == 32 &&
f->transparency) {
441 }
else if (
f->colorspace == 2) {
442 if (
f->avctx->bits_per_raw_sample == 16) {
#define AV_PIX_FMT_YUVA422P16
int ff_ffv1_parse_header(FFV1Context *f, RangeCoder *c, uint8_t *state)
#define AV_PIX_FMT_GBRAP16
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
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
int ff_ffv1_read_extra_header(FFV1Context *f)
int ff_ffv1_read_quant_tables(RangeCoder *c, int16_t quant_table[MAX_CONTEXT_INPUTS][256])
#define AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
#define AC_RANGE_CUSTOM_TAB
#define AV_PIX_FMT_YUVA422P10
#define FF_DEBUG_PICT_INFO
#define AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_GRAYF16
#define AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_YUV444P10
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP14
#define AV_PIX_FMT_GBRAP12
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_GRAY14
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define AV_PIX_FMT_GRAY10
static const int16_t quant_table[64]
#define AV_PIX_FMT_GBRP16
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_PIX_FMT_YUV440P10
int ff_ffv1_get_symbol(RangeCoder *c, uint8_t *state, int is_signed)
#define AV_PIX_FMT_YUV422P10
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
#define AV_PIX_FMT_GBRPF16
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
av_cold void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size)
#define i(width, name, range_min, range_max)
#define AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_YUV422P12
void ff_build_rac_states(RangeCoder *c, int factor, int max_p)
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
#define AV_PIX_FMT_YUV444P12
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_GBRP12
static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale)
static int get_rac(RangeCoder *c, uint8_t *const state)
#define AV_PIX_FMT_YUV444P9
#define MAX_CONTEXT_INPUTS
static const float pred[4]
#define AV_PIX_FMT_0RGB32
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
int ff_ffv1_allocate_initial_states(FFV1Context *f)
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF16
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_BAYER_RGGB16
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14