Unified · Split
| @@ -115,6 +115,7 @@ typedef struct { · 114 unmodified lines | |||
| 115 | 115 | ||
| 116 | int width, height; ///< image width and height | 116 | int width, height; ///< image width and height |
| 117 | uint8_t cbps[4]; ///< bits per sample in particular components | 117 | uint8_t cbps[4]; ///< bits per sample in particular components |
| 118 | uint8_t comp_remap[4]; | ||
| 118 | int chroma_shift[2]; | 119 | int chroma_shift[2]; |
| 119 | uint8_t planar; | 120 | uint8_t planar; |
| 120 | int ncomponents; | 121 | int ncomponents; |
| @@ -512,17 +513,18 @@ static int init_tiles(Jpeg2000EncoderContext *s) · 391 unmodified lines | |||
| 512 | Jpeg2000Tile *tile = s->tile + tileno; \ | 513 | Jpeg2000Tile *tile = s->tile + tileno; \ |
| 513 | if (s->planar){ \ | 514 | if (s->planar){ \ |
| 514 | for (compno = 0; compno < s->ncomponents; compno++){ \ | 515 | for (compno = 0; compno < s->ncomponents; compno++){ \ |
| 516 | int icompno = s->comp_remap[compno]; \ | ||
| 515 | Jpeg2000Component *comp = tile->comp + compno; \ | 517 | Jpeg2000Component *comp = tile->comp + compno; \ |
| 516 | int *dst = comp->i_data; \ | 518 | int *dst = comp->i_data; \ |
| 517 | int cbps = s->cbps[compno]; \ | 519 | int cbps = s->cbps[compno]; \ |
| 518 | line = (const PIXEL*)s->picture->data[compno] \ | 520 | line = (const PIXEL*)s->picture->data[icompno] \ |
| 519 | + comp->coord[1][0] * (s->picture->linesize[compno] / sizeof(PIXEL)) \ | 521 | + comp->coord[1][0] * (s->picture->linesize[icompno] / sizeof(PIXEL)) \ |
| 520 | + comp->coord[0][0]; \ | 522 | + comp->coord[0][0]; \ |
| 521 | for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){ \ | 523 | for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){ \ |
| 522 | const PIXEL *ptr = line; \ | 524 | const PIXEL *ptr = line; \ |
| 523 | for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++) \ | 525 | for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++) \ |
| 524 | *dst++ = *ptr++ - (1 << (cbps - 1)); \ | 526 | *dst++ = *ptr++ - (1 << (cbps - 1)); \ |
| 525 | line += s->picture->linesize[compno] / sizeof(PIXEL); \ | 527 | line += s->picture->linesize[icompno] / sizeof(PIXEL); \ |
| 526 | } \ | 528 | } \ |
| 527 | } \ | 529 | } \ |
| 528 | } else{ \ | 530 | } else{ \ |
| @@ -1763,6 +1765,7 @@ static av_cold int j2kenc_init(AVCodecContext *avctx) · 1234 unmodified lines | |||
| 1763 | s->ncomponents = desc->nb_components; | 1765 | s->ncomponents = desc->nb_components; |
| 1764 | for (i = 0; i < 3; i++) { | 1766 | for (i = 0; i < 3; i++) { |
| 1765 | s->cbps[i] = desc->comp[i].depth; | 1767 | s->cbps[i] = desc->comp[i].depth; |
| 1768 | s->comp_remap[i] = i; //default | ||
| 1766 | } | 1769 | } |
| 1767 | 1770 | ||
| 1768 | if ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) && s->ncomponents > 1) { | 1771 | if ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) && s->ncomponents > 1) { |
| @@ -1771,6 +1774,11 @@ static av_cold int j2kenc_init(AVCodecContext *avctx) · 2 unmodified lines | |||
| 1771 | s->chroma_shift, s->chroma_shift + 1); | 1774 | s->chroma_shift, s->chroma_shift + 1); |
| 1772 | if (ret) | 1775 | if (ret) |
| 1773 | return ret; | 1776 | return ret; |
| 1777 | if (desc->flags & AV_PIX_FMT_FLAG_RGB) { | ||
| 1778 | s->comp_remap[0] = 2; | ||
| 1779 | s->comp_remap[1] = 0; | ||
| 1780 | s->comp_remap[2] = 1; | ||
| 1781 | } | ||
| 1774 | } | 1782 | } |
| 1775 | 1783 | ||
| 1776 | ff_thread_once(&init_static_once, init_luts); | 1784 | ff_thread_once(&init_static_once, init_luts); |