51 #define MAX_DWT_LEVELS 5
56 #define MAX_REFERENCE_FRAMES 8
58 #define MAX_FRAMES (MAX_REFERENCE_FRAMES + MAX_DELAY + 1)
60 #define MAX_BLOCKSIZE 32
65 #define DIRAC_REF_MASK_REF1 1
66 #define DIRAC_REF_MASK_REF2 2
67 #define DIRAC_REF_MASK_GLOBAL 4
73 #define DELAYED_PIC_REF 4
75 #define ff_emulated_edge_mc ff_emulated_edge_mc_8
77 #define CALC_PADDING(size, depth) \
78 (((size + (1 << depth) - 1) >> depth) << depth)
80 #define DIVRNDUP(a, b) (((a) + (b) - 1) / (b))
240 { { 5, 3, 3, 0}, { 0, 4, 4, 1}, { 0, 5, 5, 2}, { 0, 6, 6, 3} },
241 { { 4, 2, 2, 0}, { 0, 4, 4, 2}, { 0, 5, 5, 3}, { 0, 7, 7, 5} },
242 { { 5, 3, 3, 0}, { 0, 4, 4, 1}, { 0, 5, 5, 2}, { 0, 6, 6, 3} },
243 { { 8, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0} },
244 { { 8, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0} },
245 { { 0, 4, 4, 8}, { 0, 8, 8, 12}, { 0, 13, 13, 17}, { 0, 17, 17, 21} },
246 { { 3, 1, 1, 0}, { 0, 4, 4, 2}, { 0, 6, 6, 5}, { 0, 9, 9, 7} },
250 4, 5, 6, 7, 8, 10, 11, 13,
251 16, 19, 23, 27, 32, 38, 45, 54,
252 64, 76, 91, 108, 128, 152, 181, 215,
253 256, 304, 362, 431, 512, 609, 724, 861,
254 1024, 1218, 1448, 1722, 2048, 2435, 2896, 3444,
255 4096, 4871, 5793, 6889, 8192, 9742, 11585, 13777,
256 16384, 19484, 23170, 27554, 32768, 38968, 46341, 55109,
261 1, 2, 3, 4, 4, 5, 6, 7,
262 8, 10, 12, 14, 16, 19, 23, 27,
263 32, 38, 46, 54, 64, 76, 91, 108,
264 128, 152, 181, 216, 256, 305, 362, 431,
265 512, 609, 724, 861, 1024, 1218, 1448, 1722,
266 2048, 2436, 2897, 3445, 4096, 4871, 5793, 6889,
267 8192, 9742, 11585, 13777, 16384, 19484, 23171, 27555,
272 1, 2, 2, 3, 3, 4, 4, 5,
273 6, 7, 9, 10, 12, 14, 17, 20,
274 24, 29, 34, 41, 48, 57, 68, 81,
275 96, 114, 136, 162, 192, 228, 272, 323,
276 384, 457, 543, 646, 768, 913, 1086, 1292,
277 1536, 1827, 2172, 2583, 3072, 3653, 4344, 5166,
278 6144, 7307, 8689, 10333, 12288, 14613, 17378, 20666,
285 return ((x+1)*21845 + 10922) >> 16;
291 int i, remove_idx = -1;
293 for (i = 0; framelist[i]; i++)
294 if (framelist[i]->avframe.display_picture_number == picnum) {
295 remove_pic = framelist[i];
300 for (i = remove_idx; framelist[i]; i++)
301 framelist[i] = framelist[i+1];
309 for (i = 0; i < maxframes; i++)
311 framelist[i] =
frame;
321 int i, w, h, top_padding;
324 for (i = 0; i < 3; i++) {
372 for (j = 0; j < 3; j++)
373 for (k = 1; k < 4; k++)
380 for (i = 0; i < 3; i++) {
424 #define SIGN_CTX(x) (CTX_SIGN_ZERO + ((x) > 0) - ((x) < 0))
438 sign_pred = buf[-b->
stride];
442 pred_ctx += !(buf[-1] | buf[-b->
stride] | buf[-1-b->
stride]);
446 pred_ctx += !buf[-b->
stride];
451 coeff = (coeff * qfactor + qoffset + 2) >> 2;
453 coeff = (coeff ^ -sign) + sign;
464 coeff = (coeff * qfactor + qoffset + 2) >> 2;
466 coeff = (coeff ^ -sign) + sign;
477 int left,
int right,
int top,
int bottom,
478 int blockcnt_one,
int is_arith)
480 int x,
y, zero_block;
481 int qoffset, qfactor;
518 for (y = top; y < bottom; y++) {
519 for (x = left; x < right; x++) {
539 for (x = 1; x < b->
width; x++)
543 for (y = 1; y < b->
height; y++) {
544 buf[0] += buf[-b->
stride];
546 for (x = 1; x < b->
width; x++) {
560 int cb_x, cb_y, left, right, top, bottom;
565 int blockcnt_one = (cb_width + cb_height) == 2;
576 for (cb_y = 0; cb_y < cb_height; cb_y++) {
577 bottom = (b->
height * (cb_y+1)) / cb_height;
579 for (cb_x = 0; cb_x < cb_width; cb_x++) {
580 right = (b->
width * (cb_x+1)) / cb_width;
581 codeblock(s, b, &gb, &c, left, right, top, bottom, blockcnt_one, is_arith);
615 int level, num_bands = 0;
619 for (orientation = !!level; orientation < 4; orientation++) {
621 bands[num_bands++] =
b;
637 NULL, 4-!!level,
sizeof(
SubBand));
647 int slice_x,
int slice_y,
int bits_end,
666 for (y = top; y < bottom; y++) {
667 for (x = left; x < right; x++) {
710 for (orientation = !!level; orientation < 4; orientation++) {
713 &s->
plane[0].
band[level][orientation], NULL);
719 chroma_bits = 8*slice->
bytes - 7 - length_bits - luma_bits;
723 for (orientation = !!level; orientation < 4; orientation++) {
752 for (slice_y = 0; bufsize > 0 && slice_y < s->
lowdelay.
num_y; slice_y++)
753 for (slice_x = 0; bufsize > 0 && slice_x < s->
lowdelay.
num_x; slice_x++) {
757 slices[slice_num].
bytes = bytes;
758 slices[slice_num].
slice_x = slice_x;
759 slices[slice_num].
slice_y = slice_y;
777 int i, w, h,
level, orientation;
779 for (i = 0; i < 3; i++) {
791 for (orientation = !!level; orientation < 4; orientation++) {
830 static const uint8_t default_blen[] = { 4, 12, 16, 24 };
831 static const uint8_t default_bsep[] = { 4, 8, 12, 16 };
888 for (ref = 0; ref < s->
num_refs; ref++) {
946 #define CHECKEDREAD(dst, cond, errmsg) \
947 tmp = svq3_get_ue_golomb(gb); \
949 av_log(s->avctx, AV_LOG_ERROR, errmsg); \
1007 for (i = 0; i < 4; i++) {
1020 static const uint8_t avgsplit[7] = { 0, 0, 1, 1, 1, 2, 2 };
1029 return avgsplit[sbsplit[-1] + sbsplit[-
stride] + sbsplit[-stride-1]];
1039 return block[-1].
ref & refmask;
1044 pred = (block[-1].
ref & refmask) + (block[-stride].ref & refmask) + (block[-stride-1].
ref & refmask);
1045 return (pred >> 1) & refmask;
1052 memset(block->
u.
dc, 0,
sizeof(block->
u.
dc));
1054 if (x && !(block[-1].ref & 3)) {
1055 for (i = 0; i < 3; i++)
1056 block->
u.
dc[i] += block[-1].
u.
dc[i];
1060 if (y && !(block[-stride].ref & 3)) {
1061 for (i = 0; i < 3; i++)
1062 block->
u.
dc[i] += block[-stride].
u.
dc[i];
1066 if (x && y && !(block[-1-stride].ref & 3)) {
1067 for (i = 0; i < 3; i++)
1068 block->
u.
dc[i] += block[-1-stride].
u.
dc[i];
1073 for (i = 0; i < 3; i++)
1074 block->
u.
dc[i] = (block->
u.
dc[i]+1)>>1;
1075 }
else if (n == 3) {
1076 for (i = 0; i < 3; i++)
1084 int refmask = ref+1;
1088 if (x && (block[-1].ref & mask) == refmask)
1089 pred[n++] = block[-1].
u.
mv[ref];
1091 if (y && (block[-stride].ref & mask) == refmask)
1094 if (x && y && (block[-stride-1].ref & mask) == refmask)
1095 pred[n++] = block[-stride-1].
u.
mv[ref];
1099 block->
u.
mv[ref][0] = 0;
1100 block->
u.
mv[ref][1] = 0;
1103 block->
u.
mv[ref][0] = pred[0][0];
1104 block->
u.
mv[ref][1] = pred[0][1];
1107 block->
u.
mv[ref][0] = (pred[0][0] + pred[1][0] + 1) >> 1;
1108 block->
u.
mv[ref][1] = (pred[0][1] + pred[1][1] + 1) >> 1;
1111 block->
u.
mv[ref][0] =
mid_pred(pred[0][0], pred[1][0], pred[2][0]);
1112 block->
u.
mv[ref][1] =
mid_pred(pred[0][1], pred[1][1], pred[2][1]);
1125 int m = (1<<ep) - (c[0]*x + c[1]*y);
1126 int mx = m * ((
A[0][0] * x +
A[0][1]*
y) + (1<<ez) * b[0]);
1127 int my = m * ((
A[1][0] * x +
A[1][1]*
y) + (1<<ez) * b[1]);
1129 block->
u.
mv[ref][0] = (mx + (1<<(ez+ep))) >> (ez+ep);
1130 block->
u.
mv[ref][1] = (my + (1<<(ez+ep))) >> (ez+ep);
1148 for (i = 0; i < 3; i++)
1159 if (block->
ref & (i+1)) {
1163 pred_mv(block, stride, x, y, i);
1178 for (x = 1; x <
size; x++)
1181 for (y = 1; y <
size; y++) {
1183 for (x = 0; x <
size; x++)
1210 for (y = 0; y < s->
sbheight; y++) {
1211 for (x = 0; x < s->
sbwidth; x++) {
1222 for (i = 0; i < s->
num_refs; i++) {
1226 for (i = 0; i < 3; i++)
1230 for (x = 0; x < s->
sbwidth; x++) {
1234 for (q = 0; q < blkcnt; q++)
1235 for (p = 0; p < blkcnt; p++) {
1236 int bx = 4 * x + p*step;
1237 int by = 4 * y + q*step;
1249 #define ROLLOFF(i) offset == 1 ? ((i) ? 5 : 3) : \
1250 (1 + (6*(i) + offset - 1) / (2*offset - 1))
1254 else if (i > blen-1 - 2*offset)
1260 int left,
int right,
int wy)
1263 for (x = 0; left && x < p->
xblen >> 1; x++)
1264 obmc_weight[x] = wy*8;
1265 for (; x < p->
xblen >> right; x++)
1267 for (; x < p->
xblen; x++)
1268 obmc_weight[x] = wy*8;
1274 int left,
int right,
int top,
int bottom)
1277 for (y = 0; top && y < p->
yblen >> 1; y++) {
1281 for (; y < p->
yblen >> bottom; y++) {
1286 for (; y < p->
yblen; y++) {
1298 if (top || bottom || by == 1) {
1333 int x,
int y,
int ref,
int plane)
1337 int motion_x = block->
u.
mv[ref][0];
1338 int motion_y = block->
u.
mv[ref][1];
1339 int mx, my, i, epel, nplanes = 0;
1362 src[0] = ref_hpel[(my>>1)+(mx>>2)] + y*p->
stride + x;
1366 for (i = 0; i < 4; i++)
1367 src[i] = ref_hpel[i] + y*p->
stride + x;
1391 src[!mx] = src[2 + !!mx];
1393 }
else if (!(my&3)) {
1394 src[0] = src[(my>>1) ];
1395 src[1] = src[(my>>1)+1];
1416 for (i = 0; i < nplanes; i++) {
1424 return (nplanes>>1) + epel;
1428 uint8_t *obmc_weight,
int xblen,
int yblen)
1433 for (y = 0; y < yblen; y++) {
1434 for (x = 0; x < xblen; x += 2) {
1435 dst[x ] += dc * obmc_weight[x ];
1436 dst[x+1] += dc * obmc_weight[x+1];
1444 uint16_t *mctmp,
uint8_t *obmc_weight,
1445 int plane,
int dstx,
int dsty)
1451 switch (block->
ref&3) {
1457 idx =
mc_subpel(s, block, src, dstx, dsty, (block->
ref&3)-1, plane);
1464 idx =
mc_subpel(s, block, src, dstx, dsty, 0, plane);
1466 idx =
mc_subpel(s, block, src, dstx, dsty, 1, plane);
1487 for (x = 1; x < s->
blwidth-1; x++) {
1529 for (i = 1; i < 4; i++) {
1538 ref->
hpel[plane][3], ref->
hpel[plane][0],
1554 int y, i,
comp, dsty;
1558 for (comp = 0; comp < 3; comp++) {
1566 for (comp = 0; comp < 3; comp++) {
1571 for (i = 0; i < 4; i++)
1584 for (y = 0; y < p->
height; y += 16) {
1600 for (y = 0; y < s->
blheight; y++) {
1603 uint16_t *mctmp = s->
mctmp + y*rowheight;
1616 mc_row(s, blocks, mctmp, comp, dsty);
1639 int i, j, refnum, refdist;
1654 for (i = 0; i < s->
num_refs; i++) {
1683 if (retire != picnum) {
1743 #define DATA_UNIT_HEADER_SIZE 13
1751 int ret, i, parse_code = buf[4];
1773 }
else if (parse_code ==
pc_eos) {
1781 if (sscanf(buf+14,
"Schroedinger %d.%d.%d", ver, ver+1, ver+2) == 3)
1782 if (ver[0] == 1 && ver[1] == 0 && ver[2] <= 7)
1785 }
else if (parse_code & 0x8) {
1803 tmp = parse_code & 0x03;
1809 s->
is_arith = (parse_code & 0x48) == 0x08;
1810 s->
low_delay = (parse_code & 0x88) == 0x88;
1838 int buf_size = pkt->
size;
1839 int i, data_unit_size, buf_idx = 0;
1861 if (buf[buf_idx ] ==
'B' && buf[buf_idx+1] ==
'B' &&
1862 buf[buf_idx+2] ==
'C' && buf[buf_idx+3] ==
'D')
1869 data_unit_size =
AV_RB32(buf+buf_idx+5);
1870 if (buf_idx + data_unit_size > buf_size || !data_unit_size) {
1871 if(buf_idx + data_unit_size > buf_size)
1873 "Data unit with size %d is larger than input buffer, discarding\n",
1884 buf_idx += data_unit_size;
1909 if (delayed_frame) {
#define CHECKEDREAD(dst, cond, errmsg)
void(* add_obmc)(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen)
av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
static av_cold int dirac_decode_end(AVCodecContext *avctx)
static void codeblock(DiracContext *s, SubBand *b, GetBitContext *gb, DiracArith *c, int left, int right, int top, int bottom, int blockcnt_one, int is_arith)
Decode the coeffs in the rectangle defined by left, right, top, bottom [DIRAC_STD] 13...
#define AVERROR_PATCHWELCOME
This structure describes decoded (raw) audio or video data.
dirac_weight_func weight_func
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
DiracFrame * ref_frames[MAX_REFERENCE_FRAMES+1]
static int divide3(int x)
static int dirac_decode_frame_internal(DiracContext *s)
Dirac Specification -> 13.0 Transform data syntax.
static void skip_bits_long(GetBitContext *s, int n)
static av_cold int init(AVCodecContext *avctx)
static void propagate_block_data(DiracBlock *block, int stride, int size)
Copies the current block to the other blocks covered by the current superblock split mode...
dirac_weight_func weight_dirac_pixels_tab[3]
void(* draw_edges)(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides)
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output...
void ff_dirac_init_arith_decoder(DiracArith *c, GetBitContext *gb, int length)
#define DATA_UNIT_HEADER_SIZE
Dirac Specification -> 9.6 Parse Info Header Syntax.
#define DECLARE_ALIGNED(n, t, v)
static unsigned svq3_get_ue_golomb(GetBitContext *gb)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static void global_mv(DiracContext *s, DiracBlock *block, int x, int y, int ref)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static const int qoffset_inter_tab[MAX_QUANT+1]
static int dirac_get_arith_uint(DiracArith *c, int follow_ctx, int data_ctx)
dirac_source_params source
static void coeff_unpack_arith(DiracArith *c, int qfactor, int qoffset, SubBand *b, IDWTELEM *buf, int x, int y)
static void lowdelay_subband(DiracContext *s, GetBitContext *gb, int quant, int slice_x, int slice_y, int bits_end, SubBand *b1, SubBand *b2)
static void dirac_decode_flush(AVCodecContext *avctx)
const uint8_t * coeff_data
static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame)
static int dirac_unpack_idwt_params(DiracContext *s)
Dirac Specification -> 11.3 Wavelet transform data.
#define DIRAC_REF_MASK_REF2
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
unsigned weight_log2denom
void(* put_signed_rect_clamped)(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height)
DiracFrame * delay_frames[MAX_DELAY+1]
void(* add_rect_clamped)(uint8_t *dst, const uint16_t *src, int stride, const int16_t *idwt, int idwt_stride, int width, int height)
Interface to Dirac Decoder/Encoder.
static int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffset)
static const uint8_t offset[511][2]
static av_cold int dirac_decode_init(AVCodecContext *avctx)
uint8_t quant[MAX_DWT_LEVELS][4]
const char * name
Name of the codec implementation.
static int dirac_get_se_golomb(GetBitContext *gb)
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
static void free_sequence_buffers(DiracContext *s)
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
#define ff_emulated_edge_mc
static const uint8_t epel_weights[4][4][4]
static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
Dirac Specification -> 13.5.2 Slices.
#define FFSWAP(type, a, b)
static const int qoffset_intra_tab[MAX_QUANT+1]
void(* avg_dirac_pixels_tab[3][4])(uint8_t *dst, const uint8_t *src[5], int stride, int h)
static void pred_block_dc(DiracBlock *block, int stride, int x, int y)
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
void(* dirac_hpel_filter)(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, const uint8_t *src, int stride, int width, int height)
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){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));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=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);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);ff_audio_convert_init_arm(ac);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-> dc
static const uint16_t mask[17]
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
void ff_diracdsp_init(DiracDSPContext *c)
#define DIRAC_REF_MASK_GLOBAL
static int pred_sbsplit(uint8_t *sbsplit, int stride, int x, int y)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int add_frame(DiracFrame *framelist[], int maxframes, DiracFrame *frame)
static void pred_mv(DiracBlock *block, int stride, int x, int y, int ref)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5], int x, int y, int ref, int plane)
For block x,y, determine which of the hpel planes to do bilinear interpolation from and set src[] to ...
DiracFrame * current_picture
#define MAX_DWT_LEVELS
The spec limits the number of wavelet decompositions to 4 for both level 1 (VC-2) and 128 (long-gop d...
unsigned old_delta_quant
schroedinger older than 1.0.8 doesn't store quant delta if only one codebook exists in a band ...
Libavcodec external API header.
int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, dirac_source_params *source)
static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int size)
static char * split(char *message, char delim)
static void init_planes(DiracContext *s)
static void decode_block_params(DiracContext *s, DiracArith arith[8], DiracBlock *block, int stride, int x, int y)
enum AVPictureType pict_type
Picture type of the frame.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int display_picture_number
picture number in display order
#define CALC_PADDING(size, depth)
void(* avg_pixels_tab[4])(uint8_t *dst, const uint8_t *src[5], int stride, int h)
static void block_mc(DiracContext *s, DiracBlock *block, uint16_t *mctmp, uint8_t *obmc_weight, int plane, int dstx, int dsty)
static DiracFrame * remove_frame(DiracFrame *framelist[], int picnum)
void ff_spatial_idwt_slice2(DWTContext *d, int y)
attribute_deprecated int reference
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int dirac_unpack_prediction_parameters(DiracContext *s)
Unpack the motion compensation parameters Dirac Specification -> 11.2 Picture prediction data...
struct DiracContext::@57 globalmc[2]
static void mc_row(DiracContext *s, DiracBlock *block, uint16_t *mctmp, int plane, int dsty)
static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height)
static void select_dsp_funcs(DiracContext *s, int width, int height, int xblen, int yblen)
void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
uint8_t * edge_emu_buffer_base
static void intra_dc_prediction(SubBand *b)
Dirac Specification -> 13.3 intra_dc_prediction(band)
static void decode_component(DiracContext *s, int comp)
Dirac Specification -> [DIRAC_STD] 13.4.1 core_transform_data()
static void flush(AVCodecContext *avctx)
static void init_obmc_weights(DiracContext *s, Plane *p, int by)
static const float pred[4]
void(* add_dirac_obmc[3])(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen)
SubBand band[MAX_DWT_LEVELS][4]
static const int8_t mv[256][2]
static av_always_inline void decode_subband_internal(DiracContext *s, SubBand *b, int is_arith)
Dirac Specification -> 13.4.2 Non-skipped subbands.
uint8_t * edge_emu_buffer[4]
static void decode_lowdelay(DiracContext *s)
Dirac Specification -> 13.5.1 low_delay_transform_data()
typedef void(RENAME(mix_any_func_type))
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static const uint8_t default_qmat[][4][4]
void(* dirac_weight_func)(uint8_t *block, int stride, int log2_denom, int weight, int h)
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.
DiracFrame all_frames[MAX_FRAMES]
Arithmetic decoder for Dirac.
dirac_biweight_func biweight_dirac_pixels_tab[3]
static unsigned int get_bits1(GetBitContext *s)
BYTE int const BYTE int int int height
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
static int dirac_get_arith_bit(DiracArith *c, int ctx)
rational number numerator/denominator
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
dirac_biweight_func biweight_func
int ff_spatial_idwt_init2(DWTContext *d, IDWTELEM *buffer, int width, int height, int stride, enum dwt_type type, int decomposition_count, IDWTELEM *temp)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int decode_subband_arith(AVCodecContext *avctx, void *b)
static int weight(int i, int blen, int offset)
static const int qscale_tab[MAX_QUANT+1]
static int pred_block_mode(DiracBlock *block, int stride, int x, int y, int refmask)
#define CODEC_FLAG_EMU_EDGE
Don't draw edges.
#define MAX_REFERENCE_FRAMES
The spec limits this to 3 for frame coding, but in practice can be as high as 6.
static int dirac_decode_picture_header(DiracContext *s)
Dirac Specification -> 11.1.1 Picture Header.
common internal api header.
struct DiracContext::@56 lowdelay
static int decode_subband_golomb(AVCodecContext *avctx, void *arg)
static int dirac_get_arith_int(DiracArith *c, int follow_ctx, int data_ctx)
struct DiracContext::@55 codeblock[MAX_DWT_LEVELS+1]
static void init_obmc_weight_row(Plane *p, uint8_t *obmc_weight, int stride, int left, int right, int wy)
Core video DSP helper functions.
void(* put_dirac_pixels_tab[3][4])(uint8_t *dst, const uint8_t *src[5], int stride, int h)
dirac_pixels_tab[width][subpel] width is 2 for 32, 1 for 16, 0 for 8 subpel is 0 for fpel and hpel (o...
dirac_parse_code
Dirac Specification -> Parse code values.
static int alloc_sequence_buffers(DiracContext *s)
void(* put_pixels_tab[4])(uint8_t *dst, const uint8_t *src[5], int stride, int h)
static void init_obmc_weight(Plane *p, uint8_t *obmc_weight, int stride, int left, int right, int top, int bottom)
#define AVERROR_INVALIDDATA
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
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){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));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=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);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);ff_audio_convert_init_arm(ac);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
void(* dirac_biweight_func)(uint8_t *dst, const uint8_t *src, int stride, int log2_denom, int weightd, int weights, int h)
int key_frame
1 -> keyframe, 0-> not
static const double coeff[2][5]
static const uint8_t * align_get_bits(GetBitContext *s)
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
static void add_dc(uint16_t *dst, int dc, int stride, uint8_t *obmc_weight, int xblen, int yblen)
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
uint8_t * hpel_base[3][4]
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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define DIRAC_REF_MASK_REF1
DiracBlock->ref flags, if set then the block does MC from the given ref.
static int dirac_unpack_block_motion_data(DiracContext *s)
Dirac Specification ->
uint8_t obmc_weight[3][MAX_BLOCKSIZE *MAX_BLOCKSIZE]
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...