50 #define MAX_REFERENCE_FRAMES 8 52 #define MAX_FRAMES (MAX_REFERENCE_FRAMES + MAX_DELAY + 1) 54 #define MAX_BLOCKSIZE 32 59 #define DIRAC_REF_MASK_REF1 1 60 #define DIRAC_REF_MASK_REF2 2 61 #define DIRAC_REF_MASK_GLOBAL 4 67 #define DELAYED_PIC_REF 4 69 #define CALC_PADDING(size, depth) \ 70 (((size + (1 << depth) - 1) >> depth) << depth) 72 #define DIVRNDUP(a, b) (((a) + (b) - 1) / (b)) 106 typedef struct Plane {
253 return (
int)((x+1
U)*21845 + 10922) >> 16;
259 int i, remove_idx = -1;
261 for (i = 0; framelist[i]; i++)
262 if (framelist[i]->avframe->display_picture_number == picnum) {
263 remove_pic = framelist[i];
268 for (i = remove_idx; framelist[i]; i++)
269 framelist[i] = framelist[i+1];
277 for (i = 0; i < maxframes; i++)
279 framelist[i] =
frame;
289 int i,
w,
h, top_padding;
292 for (i = 0; i < 3; i++) {
362 for (j = 0; j < 3; j++)
363 for (k = 1; k < 4; k++)
370 for (i = 0; i < 3; i++) {
446 const unsigned sign =
FFSIGN(coeff);
448 coeff = sign*((sign * coeff * qfactor + qoffset) >> 2);
452 #define SIGN_CTX(x) (CTX_SIGN_ZERO + ((x) > 0) - ((x) < 0)) 454 #define UNPACK_ARITH(n, type) \ 455 static inline void coeff_unpack_arith_##n(DiracArith *c, int qfactor, int qoffset, \ 456 SubBand *b, type *buf, int x, int y) \ 458 int sign, sign_pred = 0, pred_ctx = CTX_ZPZN_F1; \ 460 const int mstride = -(b->stride >> (1+b->pshift)); \ 462 const type *pbuf = (type *)b->parent->ibuf; \ 463 const int stride = b->parent->stride >> (1+b->parent->pshift); \ 464 pred_ctx += !!pbuf[stride * (y>>1) + (x>>1)] << 1; \ 466 if (b->orientation == subband_hl) \ 467 sign_pred = buf[mstride]; \ 469 pred_ctx += !(buf[-1] | buf[mstride] | buf[-1 + mstride]); \ 470 if (b->orientation == subband_lh) \ 471 sign_pred = buf[-1]; \ 473 pred_ctx += !buf[mstride]; \ 475 coeff = dirac_get_arith_uint(c, pred_ctx, CTX_COEFF_DATA); \ 477 coeff = (coeff * qfactor + qoffset) >> 2; \ 478 sign = dirac_get_arith_bit(c, SIGN_CTX(sign_pred)); \ 479 coeff = (coeff ^ -sign) + sign; \ 493 int left,
int right,
int top,
int bottom,
494 int blockcnt_one,
int is_arith)
496 int x,
y, zero_block;
497 int qoffset, qfactor;
511 if (s->codeblock_mode && !(s->old_delta_quant && blockcnt_one)) {
517 if (quant > INT_MAX - b->quant || b->quant + quant < 0) {
537 buf = b->ibuf + top * b->stride;
539 for (y = top; y < bottom; y++) {
540 for (x = left; x < right; x++) {
542 coeff_unpack_arith_10(c, qfactor, qoffset, b, (
int32_t*)(buf)+x, x, y);
544 coeff_unpack_arith_8(c, qfactor, qoffset, b, (int16_t*)(buf)+x, x, y);
550 for (y = top; y < bottom; y++) {
551 for (x = left; x < right; x++) {
568 #define INTRA_DC_PRED(n, type) \ 569 static inline void intra_dc_prediction_##n(SubBand *b) \ 571 type *buf = (type*)b->ibuf; \ 574 for (x = 1; x < b->width; x++) \ 575 buf[x] += buf[x-1]; \ 576 buf += (b->stride >> (1+b->pshift)); \ 578 for (y = 1; y < b->height; y++) { \ 579 buf[0] += buf[-(b->stride >> (1+b->pshift))]; \ 581 for (x = 1; x < b->width; x++) { \ 582 int pred = buf[x - 1] + buf[x - (b->stride >> (1+b->pshift))] + buf[x - (b->stride >> (1+b->pshift))-1]; \ 583 buf[x] += divide3(pred); \ 585 buf += (b->stride >> (1+b->pshift)); \ 598 int cb_x, cb_y, left, right, top, bottom;
601 int cb_width = s->codeblock[b->level + (b->orientation !=
subband_ll)].
width;
602 int cb_height = s->codeblock[b->level + (b->orientation !=
subband_ll)].
height;
603 int blockcnt_one = (cb_width + cb_height) == 2;
614 for (cb_y = 0; cb_y < cb_height; cb_y++) {
615 bottom = (b->height * (cb_y+1LL)) / cb_height;
617 for (cb_x = 0; cb_x < cb_width; cb_x++) {
618 right = (b->width * (cb_x+1LL)) / cb_width;
619 codeblock(s, b, &gb, &c, left, right, top, bottom, blockcnt_one, is_arith);
625 if (b->orientation ==
subband_ll && s->num_refs == 0) {
627 intra_dc_prediction_10(b);
629 intra_dc_prediction_8(b);
658 int level, num_bands = 0;
662 for (orientation = !!level; orientation < 4; orientation++) {
664 bands[num_bands++] =
b;
687 #define PARSE_VALUES(type, x, gb, ebits, buf1, buf2) \ 688 type *buf = (type *)buf1; \ 689 buf[x] = coeff_unpack_golomb(gb, qfactor, qoffset); \ 690 if (get_bits_count(gb) >= ebits) \ 693 buf = (type *)buf2; \ 694 buf[x] = coeff_unpack_golomb(gb, qfactor, qoffset); \ 695 if (get_bits_count(gb) >= ebits) \ 700 int slice_x,
int slice_y,
int bits_end,
704 int right = b1->
width *(slice_x+1) / s->
num_x;
708 int qfactor, qoffset;
726 for (y = top; y < bottom; y++) {
727 for (x = left; x < right; x++) {
736 for (y = top; y < bottom; y++) {
737 for (x = left; x < right; x++) {
766 for (orientation = !!level; orientation < 4; orientation++) {
775 chroma_bits = 8*slice->
bytes - 7 - length_bits - luma_bits;
779 for (orientation = !!level; orientation < 4; orientation++) {
835 for (orientation = !!level; orientation < 4; orientation++) {
843 for (i = 0; i < 3; i++) {
844 int coef_num, coef_par, off = 0;
858 length, tmp_buf, coef_num);
861 length, tmp_buf, coef_num);
863 if (coef_num > coef_par) {
864 const int start_b = coef_par * (1 << (s->
pshift + 1));
865 const int end_b = coef_num * (1 << (s->
pshift + 1));
866 memset(&tmp_buf[start_b], 0, end_b - start_b);
871 for (orientation = !!level; orientation < 4; orientation++) {
898 for (i = 0; i < s->
num_x; i++)
910 int slice_x, slice_y, bufsize;
911 int64_t coef_buf_size, bytes = 0;
931 coef_buf_size = (coef_buf_size << (1 + s->
pshift)) + 512;
952 for (slice_y = 0; bufsize > 0 && slice_y < s->
num_y; slice_y++) {
953 for (slice_x = 0; bufsize > 0 && slice_x < s->
num_x; slice_x++) {
955 for (i = 0; i < 3; i++) {
956 if (bytes <= bufsize/8)
959 if (bytes >= INT_MAX || bytes*8 > bufsize) {
964 slices[slice_num].
bytes = bytes;
965 slices[slice_num].
slice_x = slice_x;
966 slices[slice_num].
slice_y = slice_y;
971 if (bufsize/8 >= bytes)
985 for (slice_y = 0; bufsize > 0 && slice_y < s->
num_y; slice_y++) {
986 for (slice_x = 0; bufsize > 0 && slice_x < s->
num_x; slice_x++) {
989 slices[slice_num].
bytes = bytes;
990 slices[slice_num].
slice_x = slice_x;
991 slices[slice_num].
slice_y = slice_y;
996 if (bufsize/8 >= bytes)
1008 intra_dc_prediction_10(&s->
plane[0].
band[0][0]);
1009 intra_dc_prediction_10(&s->
plane[1].
band[0][0]);
1010 intra_dc_prediction_10(&s->
plane[2].
band[0][0]);
1012 intra_dc_prediction_8(&s->
plane[0].
band[0][0]);
1013 intra_dc_prediction_8(&s->
plane[1].
band[0][0]);
1014 intra_dc_prediction_8(&s->
plane[2].
band[0][0]);
1025 for (i = 0; i < 3; i++) {
1037 for (orientation = !!level; orientation < 4; orientation++) {
1048 if (orientation & 1)
1050 if (orientation > 1)
1077 static const uint8_t default_blen[] = { 4, 12, 16, 24 };
1111 "invalid x/y block length (%d/%d) for x/y chroma shift (%d/%d)\n",
1142 for (ref = 0; ref < s->
num_refs; ref++) {
1209 #define CHECKEDREAD(dst, cond, errmsg) \ 1210 tmp = get_interleaved_ue_golomb(gb); \ 1212 av_log(s->avctx, AV_LOG_ERROR, errmsg); \ 1213 return AVERROR_INVALIDDATA; \ 1272 for (i = !!level; i < 4; i++) {
1283 for (i = 0; i < 4; i++) {
1296 static const uint8_t avgsplit[7] = { 0, 0, 1, 1, 1, 2, 2 };
1305 return avgsplit[sbsplit[-1] + sbsplit[-
stride] + sbsplit[-stride-1]];
1315 return block[-1].
ref & refmask;
1320 pred = (block[-1].
ref & refmask) + (block[-stride].
ref & refmask) + (block[-stride-1].
ref & refmask);
1321 return (pred >> 1) & refmask;
1328 memset(block->
u.
dc, 0,
sizeof(block->
u.
dc));
1330 if (x && !(block[-1].
ref & 3)) {
1331 for (i = 0; i < 3; i++)
1332 block->
u.
dc[i] += block[-1].
u.
dc[i];
1336 if (y && !(block[-stride].
ref & 3)) {
1337 for (i = 0; i < 3; i++)
1338 block->
u.
dc[i] += block[-stride].
u.
dc[i];
1342 if (x && y && !(block[-1-stride].ref & 3)) {
1343 for (i = 0; i < 3; i++)
1344 block->
u.
dc[i] += block[-1-stride].
u.
dc[i];
1349 for (i = 0; i < 3; i++)
1350 block->
u.
dc[i] = (block->
u.
dc[i]+1)>>1;
1351 }
else if (n == 3) {
1352 for (i = 0; i < 3; i++)
1360 int refmask = ref+1;
1364 if (x && (block[-1].ref & mask) == refmask)
1365 pred[n++] = block[-1].
u.
mv[
ref];
1367 if (y && (block[-stride].ref & mask) == refmask)
1370 if (x && y && (block[-stride-1].ref & mask) == refmask)
1371 pred[n++] = block[-stride-1].
u.
mv[
ref];
1379 block->
u.
mv[
ref][0] = pred[0][0];
1380 block->
u.
mv[
ref][1] = pred[0][1];
1383 block->
u.
mv[
ref][0] = (pred[0][0] + pred[1][0] + 1) >> 1;
1384 block->
u.
mv[
ref][1] = (pred[0][1] + pred[1][1] + 1) >> 1;
1387 block->
u.
mv[
ref][0] =
mid_pred(pred[0][0], pred[1][0], pred[2][0]);
1388 block->
u.
mv[
ref][1] =
mid_pred(pred[0][1], pred[1][1], pred[2][1]);
1401 int m = (1<<ep) - (c[0]*x + c[1]*y);
1402 int64_t mx = m * (int64_t)((
A[0][0] * x +
A[0][1]*y) + (1<<ez) * b[0]);
1403 int64_t my = m * (int64_t)((
A[1][0] * x +
A[1][1]*y) + (1<<ez) * b[1]);
1405 block->
u.
mv[
ref][0] = (mx + (1<<(ez+ep))) >> (ez+ep);
1406 block->
u.
mv[
ref][1] = (my + (1<<(ez+ep))) >> (ez+ep);
1424 for (i = 0; i < 3; i++)
1435 if (block->
ref & (i+1)) {
1439 pred_mv(block, stride, x, y, i);
1454 for (x = 1; x <
size; x++)
1457 for (y = 1; y <
size; y++) {
1459 for (x = 0; x <
size; x++)
1486 for (y = 0; y < s->
sbheight; y++) {
1487 for (x = 0; x < s->
sbwidth; x++) {
1498 for (i = 0; i < s->
num_refs; i++) {
1502 for (i = 0; i < 3; i++)
1506 for (x = 0; x < s->
sbwidth; x++) {
1510 for (q = 0; q < blkcnt; q++)
1511 for (p = 0; p < blkcnt; p++) {
1512 int bx = 4 * x + p*step;
1513 int by = 4 * y + q*step;
1525 #define ROLLOFF(i) offset == 1 ? ((i) ? 5 : 3) : \ 1526 (1 + (6*(i) + offset - 1) / (2*offset - 1)) 1530 else if (i > blen-1 - 2*offset)
1536 int left,
int right,
int wy)
1539 for (x = 0; left && x < p->
xblen >> 1; x++)
1540 obmc_weight[x] = wy*8;
1541 for (; x < p->
xblen >> right; x++)
1543 for (; x < p->
xblen; x++)
1544 obmc_weight[x] = wy*8;
1550 int left,
int right,
int top,
int bottom)
1553 for (y = 0; top && y < p->
yblen >> 1; y++) {
1557 for (; y < p->
yblen >> bottom; y++) {
1562 for (; y < p->
yblen; y++) {
1574 if (top || bottom || by == 1) {
1613 int motion_x = block->
u.
mv[
ref][0];
1614 int motion_y = block->
u.
mv[
ref][1];
1615 int mx, my, i, epel, nplanes = 0;
1638 src[0] = ref_hpel[(my>>1)+(mx>>2)] + y*p->
stride +
x;
1642 for (i = 0; i < 4; i++)
1643 src[i] = ref_hpel[i] + y*p->
stride + x;
1667 src[!mx] = src[2 + !!mx];
1669 }
else if (!(my&3)) {
1670 src[0] = src[(my>>1) ];
1671 src[1] = src[(my>>1)+1];
1692 for (i = 0; i < nplanes; i++) {
1700 return (nplanes>>1) + epel;
1704 uint8_t *obmc_weight,
int xblen,
int yblen)
1709 for (y = 0; y < yblen; y++) {
1710 for (x = 0; x < xblen; x += 2) {
1711 dst[
x ] += dc * obmc_weight[
x ];
1712 dst[x+1] += dc * obmc_weight[x+1];
1720 uint16_t *mctmp,
uint8_t *obmc_weight,
1721 int plane,
int dstx,
int dsty)
1727 switch (block->
ref&3) {
1733 idx =
mc_subpel(s, block, src, dstx, dsty, (block->
ref&3)-1, plane);
1740 idx =
mc_subpel(s, block, src, dstx, dsty, 0, plane);
1742 idx =
mc_subpel(s, block, src, dstx, dsty, 1, plane);
1763 for (x = 1; x < s->
blwidth-1; x++) {
1805 for (i = 1; i < 4; i++) {
1817 ref->
hpel[plane][3], ref->
hpel[plane][0],
1835 int y, i,
comp, dsty;
1841 for (comp = 0; comp < 3; comp++) {
1852 for (comp = 0; comp < 3; comp++) {
1857 for (i = 0; i < 4; i++)
1871 for (y = 0; y < p->
height; y += 16) {
1884 for (i = 0; i < s->
num_refs; i++) {
1893 for (y = 0; y < s->
blheight; y++) {
1896 uint16_t *mctmp = s->
mctmp + y*rowheight;
1909 mc_row(s, blocks, mctmp, comp, dsty);
1930 int chroma_x_shift, chroma_y_shift;
1942 for (i = 0; f->
data[i]; i++) {
1959 unsigned retire, picnum;
1961 int64_t refdist, refnum;
1976 for (i = 0; i < s->
num_refs; i++) {
1978 refdist = INT64_MAX;
2013 if (retire != picnum) {
2076 #define DATA_UNIT_HEADER_SIZE 13 2092 parse_code = buf[4];
2152 if (sscanf(buf+14,
"Schroedinger %d.%d.%d", ver, ver+1, ver+2) == 3)
2153 if (ver[0] == 1 && ver[1] == 0 && ver[2] <= 7)
2156 }
else if (parse_code & 0x8) {
2174 tmp = parse_code & 0x03;
2180 s->
is_arith = (parse_code & 0x48) == 0x08;
2181 s->
low_delay = (parse_code & 0x88) == 0x88;
2186 pic->
reference = (parse_code & 0x0C) == 0x0C;
2227 int buf_size = pkt->
size;
2230 unsigned data_unit_size;
2251 if (buf[buf_idx ] ==
'B' && buf[buf_idx+1] ==
'B' &&
2252 buf[buf_idx+2] ==
'C' && buf[buf_idx+3] ==
'D')
2259 data_unit_size =
AV_RB32(buf+buf_idx+5);
2260 if (data_unit_size > buf_size - buf_idx || !data_unit_size) {
2261 if(data_unit_size > buf_size - buf_idx)
2263 "Data unit with size %d is larger than input buffer, discarding\n",
2275 buf_idx += data_unit_size;
2299 if (delayed_frame) {
#define CHECKEDREAD(dst, cond, errmsg)
int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, int bytes, uint8_t *_dst, int coeffs)
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
#define UNPACK_ARITH(n, type)
const char const char void * val
const int32_t ff_dirac_qscale_tab[116]
#define PARSE_VALUES(type, x, gb, ebits, buf1, buf2)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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 av_realloc_f(p, o, n)
This structure describes decoded (raw) audio or video data.
dirac_weight_func weight_func
static void flush(AVCodecContext *avctx)
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.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
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...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
dirac_weight_func weight_dirac_pixels_tab[3]
#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)
static int subband_coeffs(DiracContext *s, int x, int y, int p, SliceCoeffs c[MAX_DWT_LEVELS])
#define DATA_UNIT_HEADER_SIZE
Dirac Specification -> 9.6 Parse Info Header Syntax.
void(* add_rect_clamped)(uint8_t *dst, const uint16_t *src, int stride, const int16_t *idwt, int idwt_stride, int width, int height)
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 int dirac_get_arith_uint(DiracArith *c, int follow_ctx, int data_ctx)
static int alloc_buffers(DiracContext *s, int stride)
int ff_dirac_golomb_read_16bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, int bytes, uint8_t *_dst, int coeffs)
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
static int decode_hq_slice(DiracContext *s, DiracSlice *slice, uint8_t *tmp_buf)
VC-2 Specification -> 13.5.3 hq_slice(sx,sy)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
int av_dirac_parse_sequence_header(AVDiracSeqHeader **pdsh, const uint8_t *buf, size_t buf_size, void *log_ctx)
Parse a Dirac sequence header.
unsigned weight_log2denom
void(* draw_edges)(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides)
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
void(* emulated_edge_mc)(uint8_t *dst, const uint8_t *src, ptrdiff_t dst_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
DiracFrame * delay_frames[MAX_DELAY+1]
av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, AVCodecContext *avctx)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Interface to Dirac Decoder/Encoder.
static int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffset)
static av_cold int dirac_decode_init(AVCodecContext *avctx)
uint8_t quant[MAX_DWT_LEVELS][4]
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static int dirac_get_se_golomb(GetBitContext *gb)
#define u(width, name, range_min, range_max)
DiracSlice * slice_params_buf
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
static AVOnce dirac_arith_init
static void free_sequence_buffers(DiracContext *s)
static int get_bits_count(const GetBitContext *s)
struct DiracContext::@57 highquality
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
bitstream reader API header.
static const uint8_t epel_weights[4][4][4]
static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
Dirac Specification -> 13.5.2 Slices.
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 ref_frames(Vp3DecodeContext *dst, Vp3DecodeContext *src)
av_cold int ff_dirac_golomb_reader_init(DiracGolombLUT **lut_ctx)
static int get_bits_left(GetBitContext *gb)
const int32_t ff_dirac_qoffset_intra_tab[120]
av_cold void ff_diracdsp_init(DiracDSPContext *c)
struct DiracContext::@58 globalmc[2]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
static const uint16_t mask[17]
void(* add_obmc)(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen)
#define DIRAC_REF_MASK_GLOBAL
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static int pred_sbsplit(uint8_t *sbsplit, int stride, int x, int y)
int av_pix_fmt_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.
#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.
const uint8_t ff_dirac_default_qmat[7][4][4]
static int interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height)
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 ...
const char * name
Name of the codec implementation.
DiracFrame * current_picture
int64_t max_pixels
The number of pixels per image to maximally accept.
#define DIRAC_MAX_QUANT_INDEX
unsigned old_delta_quant
schroedinger older than 1.0.8 doesn't store quant delta if only one codebook exists in a band ...
static const uint8_t offset[127][2]
static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int size)
static char * split(char *message, char delim)
#define INTRA_DC_PRED(n, type)
Dirac Specification -> 13.3 intra_dc_prediction(band)
static void init_planes(DiracContext *s)
static void decode_block_params(DiracContext *s, DiracArith arith[8], DiracBlock *block, int stride, int x, int y)
SubBand band[DWT_LEVELS][4]
enum AVPictureType pict_type
Picture type of the frame.
int display_picture_number
picture number in display order
#define CALC_PADDING(size, depth)
static int decode_hq_slice_row(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
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)
int width
picture width / height.
static int dirac_unpack_prediction_parameters(DiracContext *s)
Unpack the motion compensation parameters Dirac Specification -> 11.2 Picture prediction data...
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
av_cold void ff_dirac_golomb_reader_end(DiracGolombLUT **lut_ctx)
MpegvideoEncDSPContext mpvencdsp
static void mc_row(DiracContext *s, DiracBlock *block, uint16_t *mctmp, int plane, int dsty)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static void select_dsp_funcs(DiracContext *s, int width, int height, int xblen, int yblen)
uint8_t * edge_emu_buffer_base
static void decode_component(DiracContext *s, int comp)
Dirac Specification -> [DIRAC_STD] 13.4.1 core_transform_data()
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
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)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
static const int8_t mv[256][2]
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
static int get_buffer_with_edge(AVCodecContext *avctx, AVFrame *f, int flags)
static av_always_inline void decode_subband_internal(DiracContext *s, SubBand *b, int is_arith)
Dirac Specification -> 13.4.2 Non-skipped subbands.
Libavcodec external API header.
void(* dirac_biweight_func)(uint8_t *dst, const uint8_t *src, int stride, int log2_denom, int weightd, int weights, int h)
uint8_t * edge_emu_buffer[4]
typedef void(RENAME(mix_any_func_type))
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
const int ff_dirac_qoffset_inter_tab[122]
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
DiracFrame all_frames[MAX_FRAMES]
static const float bands[]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Arithmetic decoder for Dirac.
dirac_biweight_func biweight_dirac_pixels_tab[3]
#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...
static unsigned int get_bits1(GetBitContext *s)
static int decode_lowdelay(DiracContext *s)
Dirac Specification -> 13.5.1 low_delay_transform_data()
static int dirac_get_arith_bit(DiracArith *c, int ctx)
enum AVColorSpace colorspace
YUV colorspace type.
Rational number (pair of numerator and denominator).
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
dirac_biweight_func biweight_func
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)
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)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int pred_block_mode(DiracBlock *block, int stride, int x, int y, int refmask)
void(* dirac_weight_func)(uint8_t *block, int stride, int log2_denom, int weight, int h)
DiracGolombLUT * reader_ctx
#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 ref[MAX_W *MAX_W]
static void decode_subband(DiracContext *s, GetBitContext *gb, int quant, int slice_x, int slice_y, int bits_end, SubBand *b1, SubBand *b2)
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)
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
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...
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)
void(* dequant_subband[4])(uint8_t *src, uint8_t *dst, ptrdiff_t stride, const int qf, const int qs, int tot_v, int tot_h)
static int ff_thread_once(char *control, void(*routine)(void))
int key_frame
1 -> keyframe, 0-> not
static const double coeff[2][5]
static const uint8_t * align_get_bits(GetBitContext *s)
static void add_dc(uint16_t *dst, int dc, int stride, uint8_t *obmc_weight, int xblen, int yblen)
#define av_malloc_array(a, b)
uint8_t * hpel_base[3][4]
#define FFSWAP(type, a, b)
static unsigned get_interleaved_ue_golomb(GetBitContext *gb)
void(* dirac_hpel_filter)(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, const uint8_t *src, int stride, int width, int height)
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.
This structure stores compressed data.
void(* put_signed_rect_clamped[3])(uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#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]
int ff_spatial_idwt_init(DWTContext *d, DWTPlane *p, enum dwt_type type, int decomposition_count, int bit_depth)
av_cold void ff_dirac_init_arith_tables(void)
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().