78 #define NMSEDEC_BITS 7 79 #define NMSEDEC_FRACBITS (NMSEDEC_BITS-1) 80 #define WMSEDEC_SHIFT 13 81 #define LAMBDA_SCALE (100000000LL << (WMSEDEC_SHIFT - 13))
92 {{10000, 19650, 41770, 84030, 169000, 338400, 676900, 1353000, 2706000, 5409000},
93 {20220, 39890, 83550, 170400, 342700, 686300, 1373000, 2746000, 5490000},
94 {20220, 39890, 83550, 170400, 342700, 686300, 1373000, 2746000, 5490000},
95 {20800, 38650, 83070, 171800, 347100, 695900, 1393000, 2786000, 5572000}},
97 {{10000, 15000, 27500, 53750, 106800, 213400, 426700, 853300, 1707000, 3413000},
98 {10380, 15920, 29190, 57030, 113300, 226400, 452500, 904800, 1809000},
99 {10380, 15920, 29190, 57030, 113300, 226400, 452500, 904800, 1809000},
100 { 7186, 9218, 15860, 30430, 60190, 120100, 240000, 479700, 959300}}
132 int layer_rates[100];
150 static void nspaces(FILE *fd,
int n)
152 while(n--) putc(
' ', fd);
158 for (i = 0; i < comp->y1 - comp->y0; i++)
159 ff_jpeg2000_printv(comp->
i_data + i * (comp->x1 - comp->x0), comp->x1 - comp->x0);
164 int tileno, compno, reslevelno, bandno, precno;
165 fprintf(fd,
"XSiz = %d, YSiz = %d, tile_width = %d, tile_height = %d\n" 166 "numXtiles = %d, numYtiles = %d, ncomponents = %d\n" 173 fprintf(fd,
"tile %d:\n", tileno);
174 for(compno = 0; compno < s->
ncomponents; compno++){
177 fprintf(fd,
"component %d:\n", compno);
179 fprintf(fd,
"x0 = %d, x1 = %d, y0 = %d, y1 = %d\n",
180 comp->x0, comp->x1, comp->y0, comp->y1);
181 for(reslevelno = 0; reslevelno < s->nreslevels; reslevelno++){
184 fprintf(fd,
"reslevel %d:\n", reslevelno);
186 fprintf(fd,
"x0 = %d, x1 = %d, y0 = %d, y1 = %d, nbands = %d\n",
187 reslevel->x0, reslevel->x1, reslevel->y0,
188 reslevel->y1, reslevel->
nbands);
189 for(bandno = 0; bandno < reslevel->
nbands; bandno++){
192 fprintf(fd,
"band %d:\n", bandno);
194 fprintf(fd,
"x0 = %d, x1 = %d, y0 = %d, y1 = %d," 195 "codeblock_width = %d, codeblock_height = %d cblknx = %d cblkny = %d\n",
198 band->codeblock_width, band->codeblock_height,
199 band->cblknx, band->cblkny);
203 fprintf(fd,
"prec %d:\n", precno);
205 fprintf(fd,
"xi0 = %d, xi1 = %d, yi0 = %d, yi1 = %d\n",
206 prec->xi0, prec->xi1, prec->yi0, prec->yi1);
252 int sp = -1, curval = 0;
266 if (node->
val >= threshold) {
307 bytestream_put_be16(&s->
buf, 0);
308 bytestream_put_be32(&s->
buf, s->
width);
310 bytestream_put_be32(&s->
buf, 0);
311 bytestream_put_be32(&s->
buf, 0);
315 bytestream_put_be32(&s->
buf, 0);
316 bytestream_put_be32(&s->
buf, 0);
320 bytestream_put_byte(&s->
buf, s->
cbps[i] - 1);
336 bytestream_put_be16(&s->
buf, 12);
341 bytestream_put_byte(&s->
buf, scod);
343 bytestream_put_byte(&s->
buf, s->
prog);
346 bytestream_put_byte(&s->
buf, 0);
348 bytestream_put_byte(&s->
buf, 0);
354 bytestream_put_byte(&s->
buf, 0);
374 bytestream_put_be16(&s->
buf, size);
377 for (i = 0; i < codsty->
nreslevels * 3 - 2; i++)
378 bytestream_put_byte(&s->
buf, qntsty->
expn[i] << 3);
380 for (i = 0; i < codsty->
nreslevels * 3 - 2; i++)
381 bytestream_put_be16(&s->
buf, (qntsty->
expn[i] << 11) | qntsty->
mant[i]);
396 bytestream_put_be16(&s->
buf, size);
397 bytestream_put_be16(&s->
buf, 1);
412 bytestream_put_be16(&s->
buf, 10);
413 bytestream_put_be16(&s->
buf, tileno);
416 bytestream_put_be32(&s->
buf, 0);
418 bytestream_put_byte(&s->
buf, 0);
419 bytestream_put_byte(&s->
buf, 1);
430 for (compno = 0; compno < s->
ncomponents; compno++) {
434 for (layno = 0; layno < s->
nlayers; layno++) {
455 int tileno, tilex, tiley, compno;
465 for (tileno = 0, tiley = 0; tiley < s->
numYtiles; tiley++)
466 for (tilex = 0; tilex < s->
numXtiles; tilex++, tileno++){
477 for (compno = 0; compno < s->
ncomponents; compno++){
486 for (i = 0; i < 2; i++)
487 for (j = 0; j < 2; j++)
505 #define COPY_FRAME(D, PIXEL) \ 506 static void copy_frame_ ##D(Jpeg2000EncoderContext *s) \ 508 int tileno, compno, i, y, x; \ 510 for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ \ 511 Jpeg2000Tile *tile = s->tile + tileno; \ 513 for (compno = 0; compno < s->ncomponents; compno++){ \ 514 Jpeg2000Component *comp = tile->comp + compno; \ 515 int *dst = comp->i_data; \ 516 int cbps = s->cbps[compno]; \ 517 line = (PIXEL*)s->picture->data[compno] \ 518 + comp->coord[1][0] * (s->picture->linesize[compno] / sizeof(PIXEL)) \ 519 + comp->coord[0][0]; \ 520 for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){ \ 522 for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++) \ 523 *dst++ = *ptr++ - (1 << (cbps - 1)); \ 524 line += s->picture->linesize[compno] / sizeof(PIXEL); \ 528 line = (PIXEL*)s->picture->data[0] + tile->comp[0].coord[1][0] * (s->picture->linesize[0] / sizeof(PIXEL)) \ 529 + tile->comp[0].coord[0][0] * s->ncomponents; \ 532 for (y = tile->comp[0].coord[1][0]; y < tile->comp[0].coord[1][1]; y++){ \ 534 for (x = tile->comp[0].coord[0][0]; x < tile->comp[0].coord[0][1]; x++, i++){ \ 535 for (compno = 0; compno < s->ncomponents; compno++){ \ 536 int cbps = s->cbps[compno]; \ 537 tile->comp[compno].i_data[i] = *ptr++ - (1 << (cbps - 1)); \ 540 line += s->picture->linesize[0] / sizeof(PIXEL); \ 551 int compno, reslevelno, bandno;
555 for (compno = 0; compno < s->ncomponents; compno++){
557 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++){
559 nbands = reslevelno ? 3 : 1;
560 for (bandno = 0; bandno < nbands; bandno++, gbandno++){
564 int bandpos = bandno + (reslevelno>0),
567 mant = (11 - log < 0 ? ss >> log - 11 :
ss << 11 - log) & 0x7ff;
568 expn = s->cbps[compno] - log + 13;
570 expn = ((bandno&2)>>1) + (reslevelno>0) + s->cbps[compno];
572 qntsty->
expn[gbandno] = expn;
573 qntsty->
mant[gbandno] = mant;
590 (1 << 13) - (a * a << 11), 0);
614 for (y0 = 0; y0 <
height; y0 += 4)
615 for (x = 0; x <
width; x++)
616 for (y = y0; y < height && y < y0+4; y++){
636 for (y0 = 0; y0 <
height; y0 += 4)
637 for (x = 0; x <
width; x++)
638 for (y = y0; y < height && y < y0+4; y++)
650 for (y0 = 0; y0 <
height; y0 += 4)
651 for (x = 0; x <
width; x++){
652 if (y0 + 3 < height && !(
660 for (rlen = 0; rlen < 4; rlen++)
668 for (y = y0 + rlen; y < y0 + 4; y++){
684 for (y = y0; y < y0 + 4 && y <
height; y++){
705 int pass_t = 2, passno, x, y,
max=0, nmsedec, bpno;
710 for (y = 0; y <
height; y++){
711 for (x = 0; x <
width; x++){
731 for (passno = 0; bpno >= 0; passno++){
735 case 0:
encode_sigpass(t1, width, height, bandpos, &nmsedec, bpno);
739 case 2:
encode_clnpass(t1, width, height, bandpos, &nmsedec, bpno);
746 wmsedec += (int64_t)nmsedec << (2*bpno);
776 put_num(s, 0xff80 | (n-37), 16);
781 int precno,
uint8_t *expn,
int numgbits,
int packetno,
784 int bandno, empty = 1;
792 bytestream_put_be16(&s->
buf, 4);
793 bytestream_put_be16(&s->
buf, packetno);
798 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
807 for (pos = 0; pos < nb_cblks; pos++) {
813 for (i = 0; i < nlayers; i++) {
828 for (bandno = 0; bandno < rlevel->
nbands; bandno++){
835 for (pos = 0; pos < nb_cblks; pos++) {
855 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
866 for (xi = 0; xi < cblknw; xi++, pos++){
913 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
919 for (xi = 0; xi < cblknw; xi++){
938 int compno, reslevelno, layno,
ret;
944 int tile_coord[2][2];
957 for (layno = 0; layno < nlayers; layno++) {
958 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++){
959 for (compno = 0; compno < s->
ncomponents; compno++){
963 if ((ret =
encode_packet(s, reslevel, layno, precno, qntsty->
expn + (reslevelno ? 3*reslevelno-2 : 0),
964 qntsty->
nguardbits, packetno++, nlayers)) < 0)
972 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++){
973 for (layno = 0; layno < nlayers; layno++) {
974 for (compno = 0; compno < s->
ncomponents; compno++){
978 if ((ret =
encode_packet(s, reslevel, layno, precno, qntsty->
expn + (reslevelno ? 3*reslevelno-2 : 0),
979 qntsty->
nguardbits, packetno++, nlayers)) < 0)
987 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
991 for (compno = 0; compno < s->
ncomponents; compno++) {
993 if (reslevelno < codsty->nreslevels) {
1003 for (y = tile_coord[1][0]; y < tile_coord[1][1]; y = (y/step_y + 1)*step_y) {
1004 for (x = tile_coord[0][0]; x < tile_coord[0][1]; x = (x/step_x + 1)*step_x) {
1005 for (compno = 0; compno < s->
ncomponents; compno++) {
1010 unsigned prcx, prcy;
1016 if (!(y % ((uint64_t)1 << (reslevel->
log2_prec_height + reducedresno + log_subsampling[1])) == 0 ||
1017 (y == tile_coord[1][0] && (try0 << reducedresno) % (1
U << (reducedresno + reslevel->
log2_prec_height)))))
1020 if (!(x % ((uint64_t)1 << (reslevel->
log2_prec_width + reducedresno + log_subsampling[0])) == 0 ||
1021 (x == tile_coord[0][0] && (trx0 << reducedresno) % (1
U << (reducedresno + reslevel->
log2_prec_width)))))
1036 for (layno = 0; layno < nlayers; layno++) {
1037 if ((ret =
encode_packet(s, reslevel, layno, precno, qntsty->
expn + (reslevelno ? 3*reslevelno-2 : 0),
1038 qntsty->
nguardbits, packetno++, nlayers)) < 0)
1049 for (compno = 0; compno < s->
ncomponents; compno++) {
1052 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
1059 if (step_x >= 31 || step_y >= 31){
1066 for (y = tile_coord[1][0]; y < tile_coord[1][1]; y = (y/step_y + 1)*step_y) {
1067 for (x = tile_coord[0][0]; x < tile_coord[0][1]; x = (x/step_x + 1)*step_x) {
1068 for (compno = 0; compno < s->
ncomponents; compno++) {
1072 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
1073 unsigned prcx, prcy;
1082 if (!(y % ((uint64_t)1 << (reslevel->
log2_prec_height + reducedresno + log_subsampling[1])) == 0 ||
1083 (y == tile_coord[1][0] && (try0 << reducedresno) % (1
U << (reducedresno + reslevel->
log2_prec_height)))))
1086 if (!(x % ((uint64_t)1 << (reslevel->
log2_prec_width + reducedresno + log_subsampling[0])) == 0 ||
1087 (x == tile_coord[0][0] && (trx0 << reducedresno) % (1
U << (reducedresno + reslevel->
log2_prec_width)))))
1103 for (layno = 0; layno < nlayers; layno++) {
1104 if ((ret =
encode_packet(s, reslevel, layno, precno, qntsty->
expn + (reslevelno ? 3*reslevelno-2 : 0),
1105 qntsty->
nguardbits, packetno++, nlayers)) < 0)
1114 for (compno = 0; compno < s->
ncomponents; compno++) {
1120 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
1126 if (step_x >= 31 || step_y >= 31){
1133 for (y = tile_coord[1][0]; y < tile_coord[1][1]; y = (y/step_y + 1)*step_y) {
1134 for (x = tile_coord[0][0]; x < tile_coord[0][1]; x = (x/step_x + 1)*step_x) {
1135 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
1136 unsigned prcx, prcy;
1145 if (!(y % ((uint64_t)1 << (reslevel->
log2_prec_height + reducedresno + log_subsampling[1])) == 0 ||
1146 (y == tile_coord[1][0] && (try0 << reducedresno) % (1
U << (reducedresno + reslevel->
log2_prec_height)))))
1149 if (!(x % ((uint64_t)1 << (reslevel->
log2_prec_width + reducedresno + log_subsampling[0])) == 0 ||
1150 (x == tile_coord[0][0] && (trx0 << reducedresno) % (1
U << (reducedresno + reslevel->
log2_prec_width)))))
1166 for (layno = 0; layno < nlayers; layno++) {
1167 if ((ret =
encode_packet(s, reslevel, layno, precno, qntsty->
expn + (reslevelno ? 3*reslevelno-2 : 0),
1168 qntsty->
nguardbits, packetno++, nlayers)) < 0)
1184 int compno, resno, bandno, precno, cblkno;
1187 for (compno = 0; compno < s->
ncomponents; compno++) {
1194 for (bandno = 0; bandno < reslevel->
nbands ; bandno++){
1212 for (passno = cblk->
ninclpasses; passno < cblk->npasses; passno++) {
1232 if (thresh - (dd / dr) < DBL_EPSILON)
1267 int precno, compno, reslevelno, bandno, cblkno,
lev, passno, layno;
1269 double min = DBL_MAX;
1276 for (compno = 0; compno < s->
ncomponents; compno++){
1279 for (reslevelno = 0, lev = codsty->
nreslevels-1; reslevelno < codsty->nreslevels; reslevelno++, lev--){
1283 for (bandno = 0; bandno < reslevel->
nbands ; bandno++){
1289 for (passno = 0; passno < cblk->
npasses; passno++) {
1294 tile_disto += pass->
disto;
1319 for (layno = 0; layno < s->
nlayers; layno++) {
1322 double stable_thresh = 0.0;
1323 double good_thresh = 0.0;
1327 for (i = 0; i < 128; i++) {
1330 thresh = (lo + hi) / 2;
1333 memset(stream_pos, 0, s->
buf - stream_pos);
1336 s->
buf = stream_pos;
1340 stable_thresh = thresh;
1341 s->
buf = stream_pos;
1344 if (good_thresh >= 0.0)
1345 good_thresh = stable_thresh == 0.0 ? thresh : stable_thresh;
1346 makelayer(s, layno, good_thresh, tile, 1);
1352 int passno, res = 0;
1353 for (passno = 0; passno < cblk->
npasses; passno++){
1362 if (((dd * dwt_norm) >>
WMSEDEC_SHIFT) * dwt_norm >= dr * lambda)
1370 int precno, compno, reslevelno, bandno, cblkno,
lev;
1373 for (compno = 0; compno < s->
ncomponents; compno++){
1376 for (reslevelno = 0, lev = codsty->
nreslevels-1; reslevelno < codsty->nreslevels; reslevelno++, lev--){
1380 for (bandno = 0; bandno < reslevel->
nbands ; bandno++){
1381 int bandpos = bandno + (reslevelno > 0);
1404 int compno, reslevelno, bandno,
ret;
1407 for (compno = 0; compno < s->
ncomponents; compno++){
1417 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++){
1420 for (bandno = 0; bandno < reslevel->
nbands ; bandno++){
1423 int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos;
1427 band->
coord[1][1]) - band->
coord[1][0] + yy0;
1432 bandpos = bandno + (reslevelno > 0);
1435 if (reslevelno == 0 || bandno == 1)
1441 band->
coord[0][1]) - band->
coord[0][0] + xx0;
1446 for (y = yy0; y < yy1; y++){
1448 for (x = xx0; x < xx1; x++){
1453 for (y = yy0; y < yy1; y++){
1455 for (x = xx0; x < xx1; x++){
1469 bandpos, codsty->
nreslevels - reslevelno - 1);
1502 for (compno = 0; compno < s->
ncomponents; compno++){
1518 for (compno = 0; compno < s->
ncomponents; compno++)
1529 const AVFrame *pict,
int *got_packet)
1533 uint8_t *chunkstart, *jp2cstart, *jp2hstart;
1556 bytestream_put_be32(&s->
buf, 0x0000000C);
1557 bytestream_put_be32(&s->
buf, 0x6A502020);
1558 bytestream_put_be32(&s->
buf, 0x0D0A870A);
1560 chunkstart = s->
buf;
1561 bytestream_put_be32(&s->
buf, 0);
1564 bytestream_put_be32(&s->
buf, 0);
1569 bytestream_put_be32(&s->
buf, 0);
1572 chunkstart = s->
buf;
1573 bytestream_put_be32(&s->
buf, 0);
1575 bytestream_put_be32(&s->
buf, avctx->
height);
1576 bytestream_put_be32(&s->
buf, avctx->
width);
1578 bytestream_put_byte(&s->
buf, s->
cbps[0]);
1579 bytestream_put_byte(&s->
buf, 7);
1580 bytestream_put_byte(&s->
buf, 0);
1581 bytestream_put_byte(&s->
buf, 0);
1584 chunkstart = s->
buf;
1585 bytestream_put_be32(&s->
buf, 0);
1587 bytestream_put_byte(&s->
buf, 1);
1588 bytestream_put_byte(&s->
buf, 0);
1589 bytestream_put_byte(&s->
buf, 0);
1591 bytestream_put_be32(&s->
buf, 16);
1593 bytestream_put_be32(&s->
buf, 17);
1595 bytestream_put_be32(&s->
buf, 18);
1601 chunkstart = s->
buf;
1602 bytestream_put_be32(&s->
buf, 0);
1605 bytestream_put_byte(&s->
buf, 3);
1606 bytestream_put_be24(&s->
buf, 0x070707);
1608 bytestream_put_be24(&s->
buf, HAVE_BIGENDIAN ?
AV_RB24(palette + 1) :
AV_RL24(palette));
1612 chunkstart = s->
buf;
1613 bytestream_put_be32(&s->
buf, 0);
1615 for (i = 0; i < 3; i++) {
1616 bytestream_put_be16(&s->
buf, 0);
1617 bytestream_put_byte(&s->
buf, 1);
1618 bytestream_put_byte(&s->
buf, i);
1625 bytestream_put_be32(&s->
buf, 0);
1636 if ((ret =
put_qcd(s, 0)) < 0)
1638 if ((ret =
put_com(s, 0)) < 0)
1643 if (!(psotptr =
put_sot(s, tileno)))
1650 bytestream_put_be32(&psotptr, s->
buf - psotptr + 6);
1671 char *saveptr =
NULL;
1682 if (rate = strtol(token,
NULL, 10)) {
1693 if (rate = strtol(token,
NULL, 10)) {
1694 if (nlayers >= 100) {
1704 for (i = 1; i < nlayers; i++) {
1724 av_log(s,
AV_LOG_WARNING,
"Layer rates invalid. Encoding with 1 layer based on quality metric.\n");
1730 #if FF_API_PRIVATE_OPT 1769 for (i = 0; i < 3; i++) {
1812 #define OFFSET(x) offsetof(Jpeg2000EncoderContext, x) 1813 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM #define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static int getcut(Jpeg2000Cblk *cblk, int64_t lambda, int dwt_norm)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_cold ff_jpeg2000_init_tier1_luts(void)
void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
This structure describes decoded (raw) audio or video data.
Jpeg2000TgtNode * cblkincl
static void cleanup(Jpeg2000EncoderContext *s)
#define JPEG2000_T1_SIG_NB
AVCodec ff_jpeg2000_encoder
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
packed RGB 8:8:8, 24bpp, RGBRGB...
#define JPEG2000_PGOD_PCRL
static av_cold int init(AVCodecContext *avctx)
#define JPEG2000_PGOD_RLCP
#define avpriv_request_sample(...)
Jpeg2000QuantStyle qntsty
static int lut_nmsedec_ref[1<< NMSEDEC_BITS]
static av_cold int j2kenc_init(AVCodecContext *avctx)
const char * av_default_item_name(void *ptr)
Return the context name.
static int put_com(Jpeg2000EncoderContext *s, int compno)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
uint16_t mant[JPEG2000_MAX_DECLEVELS *3]
void ff_mqc_initenc(MqcState *mqc, uint8_t *bp)
initialize the encoder
static void tag_tree_code(Jpeg2000EncoderContext *s, Jpeg2000TgtNode *node, int threshold)
code the value stored in node
static __device__ float ceil(float a)
static void tag_tree_update(Jpeg2000TgtNode *node)
update the value in node
static void update_size(uint8_t *size, const uint8_t *end)
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
static int getnmsedec_ref(int x, int bpno)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define JPEG2000_CSTY_SOP
static int lut_nmsedec_ref0[1<< NMSEDEC_BITS]
8 bits with AV_PIX_FMT_RGB32 palette
static void compute_rates(Jpeg2000EncoderContext *s)
static const AVClass j2k_class
Jpeg2000TgtNode * zerobits
static void j2k_flush(Jpeg2000EncoderContext *s)
flush the bitstream
static int init_tiles(Jpeg2000EncoderContext *s)
compute the sizes of tiles, resolution levels, bands, etc.
#define AV_INPUT_BUFFER_MIN_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
uint8_t log2_prec_widths[JPEG2000_MAX_RESLEVELS]
#define JPEG2000_CSTY_EPH
static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, int layno, int precno, uint8_t *expn, int numgbits, int packetno, int nlayers)
static const uint16_t mask[17]
void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1, int x, int y, int negative)
static int put_cod(Jpeg2000EncoderContext *s)
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. ...
#define JPEG2000_PGOD_CPRL
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
uint8_t log2_prec_heights[JPEG2000_MAX_RESLEVELS]
int flags
AV_CODEC_FLAG_*.
#define JPEG2000_MAX_PASSES
static void put_num(Jpeg2000EncoderContext *s, int num, int n)
put n least significant bits of a number num
const char * name
Name of the codec implementation.
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_RL24
static int ff_jpeg2000_ceildiv(int a, int64_t b)
int flags
A combination of AV_PKT_FLAG values.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static int put_siz(Jpeg2000EncoderContext *s)
static int lut_nmsedec_sig0[1<< NMSEDEC_BITS]
#define ss(width, name, subs,...)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static int put_qcd(Jpeg2000EncoderContext *s, int compno)
#define AV_PIX_FMT_GRAY16
static int getnmsedec_sig(int x, int bpno)
struct Jpeg2000TgtNode * parent
#define xi(width, name, var, range_min, range_max, subs,...)
static void encode_sigpass(Jpeg2000T1Context *t1, int width, int height, int bandno, int *nmsedec, int bpno)
int width
picture width / height.
JPEG 2000 structures and defines common to encoder and decoder.
static int j2kenc_destroy(AVCodecContext *avctx)
static int ff_jpeg2000_getsigctxno(int flag, int bandno)
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
static void makelayers(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile)
uint8_t cbps[4]
bits per sample in particular components
int ff_dwt_encode(DWTContext *s, void *t)
static int encode_tile(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int tileno)
#define JPEG2000_PGOD_RPCL
static int ff_jpeg2000_ceildivpow2(int a, int b)
static const float pred[4]
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 COPY_FRAME(D, PIXEL)
Libavcodec external API header.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
static void encode_refpass(Jpeg2000T1Context *t1, int width, int height, int *nmsedec, int bpno)
attribute_deprecated int prediction_method
Jpeg2000CodingStyle codsty
main external API structure.
void av_cold ff_mqc_init_context_tables(void)
MQ-coder Initialize context tables (QE, NLPS, NMPS)
static void init_luts(void)
static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, Jpeg2000Tile *tile, int width, int height, int bandpos, int lev)
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
static const AVOption options[]
int height
image width and height
Jpeg2000ResLevel * reslevel
static enum AVPixelFormat pix_fmts[]
void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
static int encode_packets(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int tileno, int nlayers)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
uint8_t expn[JPEG2000_MAX_DECLEVELS *3]
static void reinit(Jpeg2000EncoderContext *s)
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok()...
static uint8_t * put_sot(Jpeg2000EncoderContext *s, int tileno)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
common internal and external API header
#define bit(string, value)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
uint16_t log2_cblk_height
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h, int val)
int ff_jpeg2000_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy, AVCodecContext *avctx)
static void putnumpasses(Jpeg2000EncoderContext *s, int n)
#define JPEG2000_PGOD_LRCP
int ff_mqc_flush_to(MqcState *mqc, uint8_t *dst, int *dst_len)
#define FF_ENABLE_DEPRECATION_WARNINGS
static LevelCodes lev[4+3+3]
static void truncpasses(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile)
static void makelayer(Jpeg2000EncoderContext *s, int layno, double thresh, Jpeg2000Tile *tile, int final)
static void encode_clnpass(Jpeg2000T1Context *t1, int width, int height, int bandno, int *nmsedec, int bpno)
static int lut_nmsedec_sig[1<< NMSEDEC_BITS]
static int ff_jpeg2000_getrefctxno(int flag)
#define av_malloc_array(a, b)
static void init_quantization(Jpeg2000EncoderContext *s)
static int parse_layer_rates(Jpeg2000EncoderContext *s)
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 const int dwt_norms[2][4][10]
AVPixelFormat
Pixel format.
static double val(void *priv, double ch)
This structure stores compressed data.
uint8_t compression_rate_enc
Is compression done using compression ratio?
#define WMSEDEC_SHIFT
must be >= 13
void * av_mallocz_array(size_t nmemb, size_t size)
static int ff_jpeg2000_getsgnctxno(int flag, int *xorbit)
void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d)
code bit d with context cx