34 #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)]
225 }
while (size && size2);
241 uint8_t tmp1[16] = { 0 }, tmp2[16], *
in = tmp1, *
out = tmp2;
246 for (i = 0; i < 16; i++)
252 for (i = 0; i <=
len; i++) {
254 tmp1[tree->
syms[i]] = 1;
256 for (i = 0; i < 16 && len < 16 - 1; i++)
261 for (i = 0; i < 16; i++)
263 for (i = 0; i <=
len; i++) {
265 for (t = 0; t < 16; t += size << 1)
266 merge(gb, out + t, in + t, size);
269 memcpy(tree->
syms, in, 16);
285 for (i = 0; i < 16; i++)
302 #define CHECK_READ_VAL(gb, b, t) \
303 if (!b->cur_dec || (b->cur_dec > b->cur_ptr)) \
305 t = get_bits(gb, b->len); \
348 v = (v ^ sign) - sign;
357 v = (v ^ sign) - sign;
392 if (dec_end - b->
cur_dec < run)
438 sign = ((int8_t) v) >> 7;
439 v = ((v & 0x7F) ^ sign) - sign;
450 sign = ((int8_t) v) >> 7;
451 v = ((v & 0x7F) ^ sign) - sign;
461 #define DC_START_BITS 11
464 int start_bits,
int has_sign)
466 int i, j,
len, len2, bsize, sign, v, v2;
467 int16_t *dst = (int16_t*)b->
cur_dec;
468 int16_t *dst_end = (int16_t*)b->
data_end;
471 v =
get_bits(gb, start_bits - has_sign);
474 v = (v ^ sign) - sign;
476 if (dst_end - dst < 1)
480 for (i = 0; i <
len; i += 8) {
481 len2 =
FFMIN(len - i, 8);
482 if (dst_end - dst < len2)
486 for (j = 0; j < len2; j++) {
490 v2 = (v2 ^ sign) - sign;
494 if (v < -32768 || v > 32767) {
500 for (j = 0; j < len2; j++)
545 const int mask = 1 << (bits - 1);
555 for (i = 0; i <
len; i++)
558 for (i = 0; i <
len; i++)
562 int16_t *dst = (int16_t*)b->
cur_dec;
565 for (i = 0; i <
len; i++)
568 for (i = 0; i <
len; i++)
600 const int32_t quant_matrices[16][64],
int q)
604 int i, t,
bits, ccoef, mode, sign;
605 int list_start = 64, list_end = 64, list_pos;
611 coef_list[list_end] = 4; mode_list[list_end++] = 0;
612 coef_list[list_end] = 24; mode_list[list_end++] = 0;
613 coef_list[list_end] = 44; mode_list[list_end++] = 0;
614 coef_list[list_end] = 1; mode_list[list_end++] = 3;
615 coef_list[list_end] = 2; mode_list[list_end++] = 3;
616 coef_list[list_end] = 3; mode_list[list_end++] = 3;
618 for (bits =
get_bits(gb, 4) - 1; bits >= 0; bits--) {
619 list_pos = list_start;
620 while (list_pos < list_end) {
621 if (!(mode_list[list_pos] | coef_list[list_pos]) || !
get_bits1(gb)) {
625 ccoef = coef_list[list_pos];
626 mode = mode_list[list_pos];
629 coef_list[list_pos] = ccoef + 4;
630 mode_list[list_pos] = 1;
633 coef_list[list_pos] = 0;
634 mode_list[list_pos++] = 0;
636 for (i = 0; i < 4; i++, ccoef++) {
638 coef_list[--list_start] = ccoef;
639 mode_list[ list_start] = 3;
646 t = (t ^ sign) - sign;
648 block[scan[ccoef]] = t;
649 coef_idx[coef_count++] = ccoef;
654 mode_list[list_pos] = 2;
655 for (i = 0; i < 3; i++) {
657 coef_list[list_end] = ccoef;
658 mode_list[list_end++] = 2;
667 t = (t ^ sign) - sign;
669 block[scan[ccoef]] = t;
670 coef_idx[coef_count++] = ccoef;
671 coef_list[list_pos] = 0;
672 mode_list[list_pos++] = 0;
687 quant = quant_matrices[quant_idx];
689 block[0] = (block[0] * quant[0]) >> 11;
690 for (i = 0; i < coef_count; i++) {
691 int idx = coef_idx[i];
692 block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11;
710 int i, sign,
mask, ccoef, mode;
711 int list_start = 64, list_end = 64, list_pos;
713 int nz_coeff_count = 0;
715 coef_list[list_end] = 4; mode_list[list_end++] = 0;
716 coef_list[list_end] = 24; mode_list[list_end++] = 0;
717 coef_list[list_end] = 44; mode_list[list_end++] = 0;
718 coef_list[list_end] = 0; mode_list[list_end++] = 2;
721 for (i = 0; i < nz_coeff_count; i++) {
724 if (block[nz_coeff[i]] < 0)
725 block[nz_coeff[i]] -=
mask;
727 block[nz_coeff[i]] +=
mask;
732 list_pos = list_start;
733 while (list_pos < list_end) {
734 if (!(coef_list[list_pos] | mode_list[list_pos]) || !
get_bits1(gb)) {
738 ccoef = coef_list[list_pos];
739 mode = mode_list[list_pos];
742 coef_list[list_pos] = ccoef + 4;
743 mode_list[list_pos] = 1;
746 coef_list[list_pos] = 0;
747 mode_list[list_pos++] = 0;
749 for (i = 0; i < 4; i++, ccoef++) {
751 coef_list[--list_start] = ccoef;
752 mode_list[ list_start] = 3;
754 nz_coeff[nz_coeff_count++] =
bink_scan[ccoef];
756 block[
bink_scan[ccoef]] = (mask ^ sign) - sign;
764 mode_list[list_pos] = 2;
765 for (i = 0; i < 3; i++) {
767 coef_list[list_end] = ccoef;
768 mode_list[list_end++] = 2;
772 nz_coeff[nz_coeff_count++] =
bink_scan[ccoef];
774 block[
bink_scan[ccoef]] = (mask ^ sign) - sign;
775 coef_list[list_pos] = 0;
776 mode_list[list_pos++] = 0;
795 for (i = 0; i < 8; i++)
796 memcpy(tmp + i*8, src + i*stride, 8);
797 for (i = 0; i < 8; i++)
798 memcpy(dst + i*stride, tmp + i*8, 8);
802 int plane_idx,
int is_key,
int is_chroma)
806 uint8_t *dst, *ref, *ref_start, *ref_end;
813 int ybias = is_key ? -15 : 0;
821 ref_start = frame->
data[plane_idx];
822 ref_end = frame->
data[plane_idx] + (bh * frame->
linesize[plane_idx] + bw) * 8;
824 for (i = 0; i < 64; i++)
825 coordmap[i] = (i & 7) + (i >> 3) * stride;
827 for (by = 0; by < bh; by++) {
834 for (bx = 0; bx < bw; bx++, dst += 8) {
855 for (j = 0; j <
run; j++)
856 dst[coordmap[*scan++]] = v;
858 for (j = 0; j <
run; j++)
866 memset(dctblock, 0,
sizeof(*dctblock) * 64);
875 ref = dst + xoff + yoff *
stride;
876 if (ref < ref_start || ref + 8*stride > ref_end) {
878 }
else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
891 ref = dst + xoff + yoff *
stride;
892 if (ref < ref_start || ref + 8 * stride > ref_end) {
894 }
else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
899 memset(dctblock, 0,
sizeof(*dctblock) * 64);
910 for (i = 0; i < 2; i++)
912 for (i = 0; i < 8; i++) {
914 for (j = 0; j < 8; j++, v >>= 1)
915 dst[i*stride + j] = col[v & 1];
921 ref = dst + xoff + yoff *
stride;
922 if (ref < ref_start || ref + 8 * stride > ref_end) {
924 }
else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
931 for (i = 0; i < 8; i++)
948 int plane_idx,
int is_chroma)
952 uint8_t *dst, *prev, *ref, *ref_start, *ref_end;
971 : frame->
data[plane_idx];
973 + (bw - 1 + c->
last->
linesize[plane_idx] * (bh - 1)) * 8;
975 for (i = 0; i < 64; i++)
976 coordmap[i] = (i & 7) + (i >> 3) * stride;
978 for (by = 0; by < bh; by++) {
1002 : frame->
data[plane_idx]) + 8*by*stride;
1003 for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
1032 for (j = 0; j <
run; j++)
1033 ublock[*scan++] = v;
1035 for (j = 0; j <
run; j++)
1043 memset(dctblock, 0,
sizeof(*dctblock) * 64);
1053 for (i = 0; i < 2; i++)
1055 for (j = 0; j < 8; j++) {
1057 for (i = 0; i < 8; i++, v >>= 1)
1058 ublock[i + j*8] = col[v & 1];
1062 for (j = 0; j < 8; j++)
1063 for (i = 0; i < 8; i++)
1079 ref = prev + xoff + yoff *
stride;
1080 if (ref < ref_start || ref > ref_end) {
1082 bx*8 + xoff, by*8 + yoff);
1100 for (j = 0; j <
run; j++)
1101 dst[coordmap[*scan++]] = v;
1103 for (j = 0; j <
run; j++)
1113 ref = prev + xoff + yoff *
stride;
1114 if (ref < ref_start || ref > ref_end) {
1116 bx*8 + xoff, by*8 + yoff);
1126 memset(dctblock, 0,
sizeof(*dctblock) * 64);
1138 ref = prev + xoff + yoff *
stride;
1140 memset(dctblock, 0,
sizeof(*dctblock) * 64);
1146 for (i = 0; i < 2; i++)
1148 for (i = 0; i < 8; i++) {
1150 for (j = 0; j < 8; j++, v >>= 1)
1151 dst[i*stride + j] = col[v & 1];
1155 for (i = 0; i < 8; i++)
1176 int plane, plane_idx, ret;
1177 int bits_count = pkt->
size << 3;
1203 for (plane = 0; plane < 3; plane++) {
1204 plane_idx = (!plane || !c->
swap_planes) ? plane : (plane ^ 3);
1240 for (j = 0; j < 8; j++) {
1241 for (i = 0; i < 8; i++) {
1244 s[j*8 + i] = cos(j * M_PI/16.0) * cos(i * M_PI/16.0) * 2.0;
1246 s[j*8 + i] = cos(j * M_PI/16.0) * sqrt(2.0);
1249 s[j*8 + i] = cos(i * M_PI/16.0) * sqrt(2.0);
1255 for (i = 0; i < 64; i++)
1258 for (j = 0; j < 16; j++) {
1259 for (i = 0; i < 64; i++) {
1260 int k = inv_bink_scan[i];
1279 static VLC_TYPE table[16 * 128][2];
1280 static int binkb_initialised = 0;
1292 if (!bink_trees[15].table) {
1293 for (i = 0; i < 16; i++) {
1295 bink_trees[i].
table = table + i*128;
1297 init_vlc(&bink_trees[i], maxbits, 16,
1320 if (!binkb_initialised) {
1322 binkb_initialised = 1;
1340 .
name =
"binkvideo",
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const uint8_t bink_tree_lens[16][16]
8-bit values for 2-colour pattern fill
This structure describes decoded (raw) audio or video data.
av_cold void ff_binkdsp_init(BinkDSPContext *c)
static const uint8_t bink_tree_bits[16][16]
#define CHECK_READ_VAL(gb, b, t)
common check before starting decoding bundle data
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static void skip_bits_long(GetBitContext *s, int n)
void(* clear_block)(int16_t *block)
void(* scale_block)(const uint8_t src[64], uint8_t *dst, int linesize)
static const uint8_t binkb_den[16]
static int read_residue(GetBitContext *gb, int16_t block[64], int masks_count)
Read 8x8 block with residue after motion compensation.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
8-bit values for 2-colour pattern fill
static const uint8_t bink_scan[64]
Bink DCT and residue 8x8 block scan order.
Tree col_high[16]
trees for decoding high nibble in "colours" data type
16x16 block types (a subset of 8x8 block types)
int len
length of number of entries to decode (in bits)
Macro definitions for various function/variable attributes.
static int32_t binkb_inter_quant[16][64]
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void(* idct_put)(uint8_t *dest, int line_size, int32_t *block)
quantizer values for interblocks with DCT
static av_cold void binkb_init_bundle(BinkContext *c, int bundle_num)
static int read_patterns(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
X components of motion value.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
motion block with DCT applied to the difference
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int binkb_get_value(BinkContext *c, int bundle_num)
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.
Tree tree
Huffman tree-related data.
BlockTypes
Bink video block types.
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.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static const int32_t bink_inter_quant[16][64]
static int get_bits_count(const GetBitContext *s)
int vlc_num
tree number (in bink_trees[])
static av_cold void init_bundles(BinkContext *c)
Allocate memory for bundles.
bitstream reader API header.
static int read_runs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
data structure used for decoding single Bink data type
static const uint8_t bink_patterns[16][64]
uint8_t * data
buffer for decoded symbols
block is copied from previous frame with some offset
static int read_dct_coeffs(GetBitContext *gb, int32_t block[64], const uint8_t *scan, const int32_t quant_matrices[16][64], int q)
Read 8x8 block of DCT coefficients.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t * data_end
buffer end
static const uint16_t mask[17]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold void free_bundles(BinkContext *c)
Free memory used by bundles.
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
int col_lastval
value of last decoded high nibble in "colours" data type
DC values for interblocks with DCT.
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
block is composed from runs of colours with custom scan order
common internal API header
block is filled with single colour
static av_cold void binkb_calc_quant(void)
Caclulate quantization tables for version b.
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_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
int width
picture width / height.
static int binkb_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, int plane_idx, int is_key, int is_chroma)
Y components of motion value.
void(* idct_add)(uint8_t *dest, int line_size, int32_t *block)
number of coefficients for residue blocks
static const uint8_t binkb_inter_seed[64]
#define INIT_VLC_USE_NEW_STATIC
if(ac->has_optimized_func)
static const uint8_t binkb_runbits[64]
static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, int plane_idx, int is_chroma)
void(* add_pixels8)(uint8_t *pixels, int16_t *block, int line_size)
data needed to decode 4-bit Huffman-coded value
uint8_t * cur_dec
pointer to the not yet decoded part of the buffer
Libavcodec external API header.
quantizer values for intrablocks with DCT
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.
#define DC_START_BITS
number of bits used to store first DC value in bundle
main external API structure.
static void close(AVCodecParserContext *s)
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 init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
static av_cold int decode_init(AVCodecContext *avctx)
static unsigned int get_bits1(GetBitContext *s)
static const int32_t bink_intra_quant[16][64]
DC values for interblocks with DCT.
Sources
IDs for different data types used in Bink video codec.
block is filled with two colours following custom pattern
static av_cold void binkb_init_bundles(BinkContext *c)
static int32_t binkb_intra_quant[16][64]
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static const uint8_t binkb_num[16]
#define GET_HUFF(gb, tree)
run lengths for special fill block
Y components of motion value.
static VLC bink_trees[16]
static void merge(GetBitContext *gb, uint8_t *dst, uint8_t *src, int size)
Merge two consequent lists of equal size depending on bits read.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Bundle bundle[BINKB_NB_SRC]
bundles for decoding all data types
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
pixel values used for different block types
X components of motion value.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
uint8_t * cur_ptr
pointer to the data that is not read from buffer yet
static const uint8_t binkb_intra_seed[64]
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int binkb_read_bundle(BinkContext *c, GetBitContext *gb, int bundle_num)
common internal api header.
static void init_lengths(BinkContext *c, int width, int bw)
Initialize length length in all bundles.
static int read_colors(GetBitContext *gb, Bundle *b, BinkContext *c)
static int read_block_types(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
static void read_tree(GetBitContext *gb, Tree *tree)
Read information about Huffman tree used to decode data.
uint8_t syms[16]
leaf value to symbol mapping
static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b, int start_bits, int has_sign)
static av_cold int init(AVCodecParserContext *s)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
DC values for intrablocks with DCT.
static int read_motion_values(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
motion block with some difference added
VLC_TYPE(* table)[2]
code, bits
static const int binkb_bundle_sizes[BINKB_NB_SRC]
int version
internal Bink file version
static const int binkb_bundle_signed[BINKB_NB_SRC]
static av_cold int decode_end(AVCodecContext *avctx)
int frame_number
Frame counter, set by libavcodec.
#define LOCAL_ALIGNED_16(t, v,...)
#define FFSWAP(type, a, b)
static void read_bundle(GetBitContext *gb, BinkContext *c, int bundle_num)
Prepare bundle for decoding data.
static const uint8_t bink_rlelens[4]
pixel values used for different block types
static int get_value(BinkContext *c, int bundle)
Retrieve next value from bundle.
This structure stores compressed data.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
DC values for intrablocks with DCT.
OldSources
IDs for different data types used in old version of Bink video codec.
op_fill_func fill_block_tab[2]