Go to the documentation of this file.
27 #define BITSTREAM_READER_LE
37 #define BINK_FLAG_ALPHA 0x00100000
38 #define BINK_FLAG_GRAY 0x00020000
61 4, 8, 8, 5, 5, 11, 11, 4, 4, 7
65 0, 0, 0, 1, 1, 0, 1, 0, 0, 0
96 #define GET_HUFF(gb, tree) (tree).syms[get_vlc2(gb, bink_trees[(tree).vlc_num].table,\
97 bink_trees[(tree).vlc_num].bits, 1)]
183 bw = (
c->avctx->width + 7) >> 3;
184 bh = (
c->avctx->height + 7) >> 3;
189 if (!
c->bundle[
i].data)
191 c->bundle[
i].data_end =
c->bundle[
i].data + blocks * 64;
230 }
while (
size && size2);
246 uint8_t tmp1[16] = { 0 }, tmp2[16], *
in = tmp1, *
out = tmp2;
251 for (
i = 0;
i < 16;
i++)
257 for (
i = 0;
i <=
len;
i++) {
259 tmp1[tree->
syms[
i]] = 1;
261 for (
i = 0;
i < 16 &&
len < 16 - 1;
i++)
266 for (
i = 0;
i < 16;
i++)
268 for (
i = 0;
i <=
len;
i++) {
270 for (t = 0; t < 16; t +=
size << 1)
274 memcpy(tree->
syms,
in, 16);
290 for (
i = 0;
i < 16;
i++)
296 c->bundle[bundle_num].cur_dec =
297 c->bundle[bundle_num].cur_ptr =
c->bundle[bundle_num].data;
307 #define CHECK_READ_VAL(gb, b, t) \
308 if (!b->cur_dec || (b->cur_dec > b->cur_ptr)) \
310 t = get_bits(gb, b->len); \
322 dec_end =
b->cur_dec + t;
323 if (dec_end >
b->data_end) {
329 memset(
b->cur_dec, v, t);
332 while (
b->cur_dec < dec_end)
344 dec_end =
b->cur_dec + t;
345 if (dec_end >
b->data_end) {
353 v = (v ^ sign) - sign;
355 memset(
b->cur_dec, v, t);
358 while (
b->cur_dec < dec_end) {
362 v = (v ^ sign) - sign;
380 if (
c->version ==
'k') {
387 dec_end =
b->cur_dec + t;
388 if (dec_end >
b->data_end) {
394 memset(
b->cur_dec, v, t);
397 while (
b->cur_dec < dec_end) {
405 if (dec_end -
b->cur_dec <
run)
407 memset(
b->cur_dec, last,
run);
421 dec_end =
b->cur_dec + t;
422 if (dec_end >
b->data_end) {
426 while (
b->cur_dec < dec_end) {
441 dec_end =
b->cur_dec + t;
442 if (dec_end >
b->data_end) {
447 c->col_lastval =
GET_HUFF(gb,
c->col_high[
c->col_lastval]);
449 v = (
c->col_lastval << 4) | v;
450 if (
c->version <
'i') {
451 sign = ((int8_t) v) >> 7;
452 v = ((v & 0x7F) ^ sign) - sign;
455 memset(
b->cur_dec, v, t);
458 while (
b->cur_dec < dec_end) {
459 c->col_lastval =
GET_HUFF(gb,
c->col_high[
c->col_lastval]);
461 v = (
c->col_lastval << 4) | v;
462 if (
c->version <
'i') {
463 sign = ((int8_t) v) >> 7;
464 v = ((v & 0x7F) ^ sign) - sign;
474 #define DC_START_BITS 11
477 int start_bits,
int has_sign)
479 int i, j,
len, len2, bsize, sign, v, v2;
480 int16_t *dst = (int16_t*)
b->cur_dec;
481 int16_t *dst_end = (int16_t*)
b->data_end;
484 v =
get_bits(gb, start_bits - has_sign);
487 v = (v ^ sign) - sign;
489 if (dst_end - dst < 1)
493 for (
i = 0;
i <
len;
i += 8) {
495 if (dst_end - dst < len2)
499 for (j = 0; j < len2; j++) {
503 v2 = (v2 ^ sign) - sign;
507 if (v < -32768 || v > 32767) {
513 for (j = 0; j < len2; j++)
533 return *
c->bundle[bundle].cur_ptr++;
535 return (int8_t)*
c->bundle[bundle].cur_ptr++;
536 ret = *(int16_t*)
c->bundle[bundle].cur_ptr;
537 c->bundle[bundle].cur_ptr += 2;
543 c->bundle[bundle_num].cur_dec =
544 c->bundle[bundle_num].cur_ptr =
c->bundle[bundle_num].data;
545 c->bundle[bundle_num].len = 13;
564 if (
b->data_end -
b->cur_dec <
len * (1 + (
bits > 8)))
575 int16_t *dst = (int16_t*)
b->cur_dec;
595 int val = *
c->bundle[bundle_num].cur_ptr++;
598 ret = *(int16_t*)
c->bundle[bundle_num].cur_ptr;
599 c->bundle[bundle_num].cur_ptr += 2;
613 const uint8_t *scan,
int *coef_count_,
614 int coef_idx[64],
int q)
619 int list_start = 64, list_end = 64, list_pos;
623 coef_list[list_end] = 4; mode_list[list_end++] = 0;
624 coef_list[list_end] = 24; mode_list[list_end++] = 0;
625 coef_list[list_end] = 44; mode_list[list_end++] = 0;
626 coef_list[list_end] = 1; mode_list[list_end++] = 3;
627 coef_list[list_end] = 2; mode_list[list_end++] = 3;
628 coef_list[list_end] = 3; mode_list[list_end++] = 3;
631 list_pos = list_start;
632 while (list_pos < list_end) {
633 if (!(mode_list[list_pos] | coef_list[list_pos]) || !
get_bits1(gb)) {
637 ccoef = coef_list[list_pos];
638 mode = mode_list[list_pos];
641 coef_list[list_pos] = ccoef + 4;
642 mode_list[list_pos] = 1;
645 coef_list[list_pos] = 0;
646 mode_list[list_pos++] = 0;
648 for (
i = 0;
i < 4;
i++, ccoef++) {
650 coef_list[--list_start] = ccoef;
651 mode_list[ list_start] = 3;
658 t = (t ^ sign) - sign;
660 block[scan[ccoef]] = t;
661 coef_idx[coef_count++] = ccoef;
666 mode_list[list_pos] = 2;
667 for (
i = 0;
i < 3;
i++) {
669 coef_list[list_end] = ccoef;
670 mode_list[list_end++] = 2;
679 t = (t ^ sign) - sign;
681 block[scan[ccoef]] = t;
682 coef_idx[coef_count++] = ccoef;
683 coef_list[list_pos] = 0;
684 mode_list[list_pos++] = 0;
694 if (quant_idx > 15
U) {
700 *coef_count_ = coef_count;
706 int coef_count,
int coef_idx[64],
711 for (
i = 0;
i < coef_count;
i++) {
712 int idx = coef_idx[
i];
730 int list_start = 64, list_end = 64, list_pos;
732 int nz_coeff_count = 0;
734 coef_list[list_end] = 4; mode_list[list_end++] = 0;
735 coef_list[list_end] = 24; mode_list[list_end++] = 0;
736 coef_list[list_end] = 44; mode_list[list_end++] = 0;
737 coef_list[list_end] = 0; mode_list[list_end++] = 2;
740 for (
i = 0;
i < nz_coeff_count;
i++) {
743 if (
block[nz_coeff[
i]] < 0)
751 list_pos = list_start;
752 while (list_pos < list_end) {
753 if (!(coef_list[list_pos] | mode_list[list_pos]) || !
get_bits1(gb)) {
757 ccoef = coef_list[list_pos];
758 mode = mode_list[list_pos];
761 coef_list[list_pos] = ccoef + 4;
762 mode_list[list_pos] = 1;
765 coef_list[list_pos] = 0;
766 mode_list[list_pos++] = 0;
768 for (
i = 0;
i < 4;
i++, ccoef++) {
770 coef_list[--list_start] = ccoef;
771 mode_list[ list_start] = 3;
773 nz_coeff[nz_coeff_count++] =
bink_scan[ccoef];
783 mode_list[list_pos] = 2;
784 for (
i = 0;
i < 3;
i++) {
786 coef_list[list_end] = ccoef;
787 mode_list[list_end++] = 2;
791 nz_coeff[nz_coeff_count++] =
bink_scan[ccoef];
794 coef_list[list_pos] = 0;
795 mode_list[list_pos++] = 0;
814 for (
i = 0;
i < 8;
i++)
816 for (
i = 0;
i < 8;
i++)
821 int plane_idx,
int is_key,
int is_chroma)
832 int ybias = is_key ? -15 : 0;
833 int qp, quant_idx, coef_count, coef_idx[64];
836 int bw = is_chroma ? (
c->avctx->width + 15) >> 4 : (
c->avctx->width + 7) >> 3;
837 int bh = is_chroma ? (
c->avctx->height + 15) >> 4 : (
c->avctx->height + 7) >> 3;
840 ref_start =
frame->data[plane_idx];
841 ref_end =
frame->data[plane_idx] + (bh *
frame->linesize[plane_idx] + bw) * 8;
843 for (
i = 0;
i < 64;
i++)
844 coordmap[
i] = (
i & 7) + (
i >> 3) *
stride;
846 for (by = 0; by < bh; by++) {
853 for (bx = 0; bx < bw; bx++, dst += 8) {
874 for (j = 0; j <
run; j++)
875 dst[coordmap[*scan++]] = v;
877 for (j = 0; j <
run; j++)
885 memset(dctblock, 0,
sizeof(*dctblock) * 64);
891 c->binkdsp.idct_put(dst,
stride, dctblock);
897 if (ref < ref_start || ref + 8*stride > ref_end) {
899 }
else if (
ref + 8*stride < dst || ref >= dst + 8*
stride) {
900 c->hdsp.put_pixels_tab[1][0](dst,
ref,
stride, 8);
904 c->bdsp.clear_block(
block);
913 if (ref < ref_start || ref + 8 * stride > ref_end) {
915 }
else if (
ref + 8*stride < dst || ref >= dst + 8*
stride) {
916 c->hdsp.put_pixels_tab[1][0](dst,
ref,
stride, 8);
920 memset(dctblock, 0,
sizeof(*dctblock) * 64);
926 c->binkdsp.idct_add(dst,
stride, dctblock);
930 c->bdsp.fill_block_tab[1](dst, v,
stride, 8);
933 for (
i = 0;
i < 2;
i++)
935 for (
i = 0;
i < 8;
i++) {
937 for (j = 0; j < 8; j++, v >>= 1)
938 dst[
i*
stride + j] = col[v & 1];
945 if (ref < ref_start || ref + 8 * stride > ref_end) {
947 }
else if (
ref + 8*stride < dst || ref >= dst + 8*
stride) {
948 c->hdsp.put_pixels_tab[1][0](dst,
ref,
stride, 8);
954 for (
i = 0;
i < 8;
i++)
978 if (ref < ref_start || ref > ref_end) {
983 c->hdsp.put_pixels_tab[1][0](dst,
ref,
stride, 8);
989 int plane_idx,
int is_chroma)
993 uint8_t *dst, *prev, *ref_start, *ref_end;
999 int coordmap[64], quant_idx, coef_count, coef_idx[64];
1002 int bw = is_chroma ? (
c->avctx->width + 15) >> 4 : (
c->avctx->width + 7) >> 3;
1003 int bh = is_chroma ? (
c->avctx->height + 15) >> 4 : (
c->avctx->height + 7) >> 3;
1004 int width =
c->avctx->width >> is_chroma;
1005 int height =
c->avctx->height >> is_chroma;
1010 dst =
frame->data[plane_idx];
1021 ref_start =
c->last->data[plane_idx] ?
c->last->data[plane_idx]
1022 :
frame->data[plane_idx];
1024 + (bw - 1 +
c->last->linesize[plane_idx] * (bh - 1)) * 8;
1026 for (
i = 0;
i < 64;
i++)
1027 coordmap[
i] = (
i & 7) + (
i >> 3) *
stride;
1029 for (by = 0; by < bh; by++) {
1050 prev = (
c->last->data[plane_idx] ?
c->last->data[plane_idx]
1052 for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
1063 c->hdsp.put_pixels_tab[1][0](dst, prev,
stride, 8);
1081 for (j = 0; j <
run; j++)
1082 ublock[*scan++] = v;
1084 for (j = 0; j <
run; j++)
1092 memset(dctblock, 0,
sizeof(*dctblock) * 64);
1097 c->binkdsp.idct_put(ublock, 8, dctblock);
1101 c->bdsp.fill_block_tab[0](dst, v,
stride, 16);
1104 for (
i = 0;
i < 2;
i++)
1106 for (j = 0; j < 8; j++) {
1108 for (
i = 0; i < 8; i++, v >>= 1)
1109 ublock[
i + j*8] = col[v & 1];
1113 for (j = 0; j < 8; j++)
1114 for (
i = 0;
i < 8;
i++)
1122 c->binkdsp.scale_block(ublock, dst,
stride);
1129 ref_start, ref_end);
1146 for (j = 0; j <
run; j++)
1147 dst[coordmap[*scan++]] = v;
1149 for (j = 0; j <
run; j++)
1158 ref_start, ref_end);
1161 c->bdsp.clear_block(
block);
1167 memset(dctblock, 0,
sizeof(*dctblock) * 64);
1172 c->binkdsp.idct_put(dst,
stride, dctblock);
1176 c->bdsp.fill_block_tab[1](dst, v,
stride, 8);
1180 ref_start, ref_end);
1183 memset(dctblock, 0,
sizeof(*dctblock) * 64);
1188 c->binkdsp.idct_add(dst,
stride, dctblock);
1191 for (
i = 0;
i < 2;
i++)
1193 for (
i = 0;
i < 8;
i++) {
1195 for (j = 0; j < 8; j++, v >>= 1)
1196 dst[
i*
stride + j] = col[v & 1];
1200 for (
i = 0;
i < 8;
i++)
1224 int bits_count =
pkt->
size << 3;
1226 if (
c->version >
'b') {
1238 if (
c->version >=
'i')
1243 if (
c->version >=
'i')
1251 if (
c->version >
'b') {
1256 c->frame_num == 1, !!
plane)) < 0)
1264 if (
c->version >
'b') {
1282 static const int s[64]={
1283 1073741824,1489322693,1402911301,1262586814,1073741824, 843633538, 581104888, 296244703,
1284 1489322693,2065749918,1945893874,1751258219,1489322693,1170153332, 806015634, 410903207,
1285 1402911301,1945893874,1832991949,1649649171,1402911301,1102260336, 759250125, 387062357,
1286 1262586814,1751258219,1649649171,1484645031,1262586814, 992008094, 683307060, 348346918,
1287 1073741824,1489322693,1402911301,1262586814,1073741824, 843633538, 581104888, 296244703,
1288 843633538,1170153332,1102260336, 992008094, 843633538, 662838617, 456571181, 232757969,
1289 581104888, 806015634, 759250125, 683307060, 581104888, 456571181, 314491699, 160326478,
1290 296244703, 410903207, 387062357, 348346918, 296244703, 232757969, 160326478, 81733730,
1294 for (
i = 0;
i < 64;
i++)
1297 for (j = 0; j < 16; j++) {
1298 for (
i = 0;
i < 64;
i++) {
1299 int k = inv_bink_scan[
i];
1312 static int binkb_initialised = 0;
1323 c->swap_planes =
c->version >=
'h';
1325 for (
i = 0;
i < 16;
i++) {
1355 if (
c->version ==
'b') {
1356 if (!binkb_initialised) {
1358 binkb_initialised = 1;
1383 .
name =
"binkvideo",
Tree tree
Huffman tree-related data.
av_cold void ff_binkdsp_init(BinkDSPContext *c)
static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, int plane_idx, int is_key, int is_chroma)
static av_cold int init_bundles(BinkContext *c)
Allocate memory for bundles.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
uint8_t * cur_dec
pointer to the not yet decoded part of the buffer
static void put_pixels8x8_overlapped(uint8_t *dst, uint8_t *src, int stride)
Copy 8x8 block from source to destination, where src and dst may be overlapped.
@ BINKB_SRC_Y_OFF
Y components of motion value.
static av_cold int init(AVCodecContext *avctx)
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
static void init_lengths(BinkContext *c, int width, int bw)
Initialize length in all bundles.
@ INTER_BLOCK
motion block with DCT applied to the difference
#define FFSWAP(type, a, b)
#define u(width, name, range_min, range_max)
static const uint8_t bink_scan[64]
Bink DCT and residue 8x8 block scan order.
static void flush(AVCodecContext *avctx)
#define DC_START_BITS
number of bits used to store first DC value in bundle
Tree col_high[16]
trees for decoding high nibble in "colours" data type
static int get_bits_count(const GetBitContext *s)
static int read_patterns(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static void merge(GetBitContext *gb, uint8_t *dst, uint8_t *src, int size)
Merge two consequent lists of equal size depending on bits read.
@ INTRA_BLOCK
intra DCT block
static av_cold int end(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
@ AVCOL_RANGE_JPEG
the normal 2^n-1 "JPEG" YUV ranges
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
static const uint16_t table[]
int vlc_num
tree number (in bink_trees[])
static void read_bundle(GetBitContext *gb, BinkContext *c, int bundle_num)
Prepare bundle for decoding data.
static const uint8_t binkb_inter_seed[64]
@ BINK_SRC_BLOCK_TYPES
8x8 block types
@ BINKB_SRC_INTER_DC
DC values for interblocks with DCT.
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
@ BINK_SRC_X_OFF
X components of motion value.
static const uint8_t binkb_den[16]
static int read_block_types(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static int32_t binkb_intra_quant[16][64]
static const uint8_t binkb_num[16]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void read_tree(GetBitContext *gb, Tree *tree)
Read information about Huffman tree used to decode data.
int col_lastval
value of last decoded high nibble in "colours" data type
static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, int plane_idx, int is_chroma)
OldSources
IDs for different data types used in old version of Bink video codec.
int flags
AV_CODEC_FLAG_*.
static int bink_put_pixels(BinkContext *c, uint8_t *dst, uint8_t *prev, int stride, uint8_t *ref_start, uint8_t *ref_end)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static VLC bink_trees[16]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int binkb_read_bundle(BinkContext *c, GetBitContext *gb, int bundle_num)
static const uint8_t binkb_intra_seed[64]
static const uint16_t mask[17]
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ FILL_BLOCK
block is filled with single colour
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
@ BINKB_SRC_INTRA_DC
DC values for intrablocks with DCT.
static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b, int start_bits, int has_sign)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
static int binkb_get_value(BinkContext *c, int bundle_num)
@ BINK_SRC_Y_OFF
Y components of motion value.
@ BINK_SRC_RUN
run lengths for special fill block
@ RUN_BLOCK
block is composed from runs of colours with custom scan order
enum AVColorRange color_range
MPEG vs JPEG YUV range.
@ PATTERN_BLOCK
block is filled with two colours following custom pattern
static int read_runs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
static unsigned int get_bits1(GetBitContext *s)
#define INIT_VLC_USE_NEW_STATIC
@ BINK_SRC_PATTERN
8-bit values for 2-colour pattern fill
uint8_t * data
buffer for decoded symbols
int len
length of number of entries to decode (in bits)
BlockTypes
Bink video block types.
static int get_value(BinkContext *c, int bundle)
Retrieve next value from bundle.
@ RESIDUE_BLOCK
motion block with some difference added
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
data structure used for decoding single Bink data type
static const int binkb_bundle_sizes[BINKB_NB_SRC]
static int read_dct_coeffs(BinkContext *c, GetBitContext *gb, int32_t block[64], const uint8_t *scan, int *coef_count_, int coef_idx[64], int q)
Read 8x8 block of DCT coefficients.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static const int binkb_bundle_signed[BINKB_NB_SRC]
static av_cold int decode_end(AVCodecContext *avctx)
@ BINKB_SRC_COLORS
pixel values used for different block types
static av_cold void binkb_calc_quant(void)
Calculate quantization tables for version b.
@ BINKB_SRC_INTER_COEFS
number of coefficients for residue blocks
const char const char void * val
uint8_t * data_end
buffer end
int version
internal Bink file version
@ MOTION_BLOCK
block is copied from previous frame with some offset
data needed to decode 4-bit Huffman-coded value
@ BINK_SRC_INTRA_DC
DC values for intrablocks with DCT.
@ BINKB_SRC_X_OFF
X components of motion value.
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-> in
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
@ BINK_SRC_COLORS
pixel values used for different block types
static const uint8_t bink_rlelens[4]
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
static const uint8_t binkb_runbits[64]
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
@ BINKB_SRC_INTRA_Q
quantizer values for intrablocks with DCT
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Bundle bundle[BINKB_NB_SRC]
bundles for decoding all data types
@ AVCOL_RANGE_MPEG
the normal 219*2^(n-8) "MPEG" YUV ranges
static const int32_t bink_intra_quant[16][64]
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
uint8_t syms[16]
leaf value to symbol mapping
static av_cold void free_bundles(BinkContext *c)
Free memory used by bundles.
static const int32_t bink_inter_quant[16][64]
static int32_t binkb_inter_quant[16][64]
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
static int read_colors(GetBitContext *gb, Bundle *b, BinkContext *c)
main external API structure.
@ SKIP_BLOCK
skipped block
static av_cold void binkb_init_bundle(BinkContext *c, int bundle_num)
static void unquantize_dct_coeffs(int32_t block[64], const uint32_t quant[64], int coef_count, int coef_idx[64], const uint8_t *scan)
@ RAW_BLOCK
uncoded 8x8 block
#define CHECK_READ_VAL(gb, b, t)
common check before starting decoding bundle data
@ BINKB_SRC_INTER_Q
quantizer values for interblocks with DCT
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
static int ref[MAX_W *MAX_W]
uint8_t * cur_ptr
pointer to the data that is not read from buffer yet
static av_cold void binkb_init_bundles(BinkContext *c)
@ BINK_SRC_SUB_BLOCK_TYPES
16x16 block types (a subset of 8x8 block types)
static int read_residue(GetBitContext *gb, int16_t block[64], int masks_count)
Read 8x8 block with residue after motion compensation.
@ BINK_SRC_INTER_DC
DC values for interblocks with DCT.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
#define LOCAL_ALIGNED_16(t, v,...)
This structure stores compressed data.
static const uint8_t bink_patterns[16][64]
@ SCALED_BLOCK
block has size 16x16
static const uint8_t bink_tree_lens[16][16]
int width
picture width / height.
#define flags(name, subs,...)
The exact code depends on how similar the blocks are and how related they are to the block
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define LOCAL_ALIGNED_32(t, v,...)
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...
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
@ BINKB_SRC_PATTERN
8-bit values for 2-colour pattern fill
static int read_motion_values(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
Sources
IDs for different data types used in Bink video codec.
VLC_TYPE(* table)[2]
code, bits
static const uint8_t bink_tree_bits[16][16]
@ BINKB_SRC_BLOCK_TYPES
8x8 block types
#define GET_HUFF(gb, tree)
static av_cold int decode_init(AVCodecContext *avctx)