Lines Matching refs:image

158 static inline int libopenjpeg_matches_pix_fmt(const opj_image_t *image, enum AVPixelFormat pix_fmt)
163 if (desc->nb_components != image->numcomps) {
170 desc->comp[3].depth >= image->comps[3].prec &&
171 1 == image->comps[3].dx &&
172 1 == image->comps[3].dy;
175 desc->comp[2].depth >= image->comps[2].prec &&
176 1 << desc->log2_chroma_w == image->comps[2].dx &&
177 1 << desc->log2_chroma_h == image->comps[2].dy;
180 desc->comp[1].depth >= image->comps[1].prec &&
181 1 << desc->log2_chroma_w == image->comps[1].dx &&
182 1 << desc->log2_chroma_h == image->comps[1].dy;
185 desc->comp[0].depth >= image->comps[0].prec &&
186 1 == image->comps[0].dx &&
187 1 == image->comps[0].dy;
195 static inline enum AVPixelFormat libopenjpeg_guess_pix_fmt(const opj_image_t *image) {
200 switch (image->color_space) {
220 if (libopenjpeg_matches_pix_fmt(image, possible_fmts[index])) {
242 static inline void libopenjpeg_copy_to_packed8(AVFrame *picture, opj_image_t *image) {
249 for (c = 0; c < image->numcomps; c++)
250 *img_ptr++ = 0x80 * image->comps[c].sgnd + image->comps[c].data[index];
254 static inline void libopenjpeg_copy_to_packed16(AVFrame *picture, opj_image_t *image) {
259 for (x = 0; x < image->numcomps; x++)
260 adjust[x] = FFMAX(FFMIN(desc->comp[x].depth - image->comps[x].prec, 8), 0) + desc->comp[x].shift;
266 for (c = 0; c < image->numcomps; c++)
267 *img_ptr++ = (1 << image->comps[c].prec - 1) * image->comps[c].sgnd +
268 (unsigned)image->comps[c].data[index] << adjust[c];
272 static inline void libopenjpeg_copyto8(AVFrame *picture, opj_image_t *image) {
277 for (index = 0; index < image->numcomps; index++) {
278 comp_data = image->comps[index].data;
279 for (y = 0; y < image->comps[index].h; y++) {
281 for (x = 0; x < image->comps[index].w; x++) {
282 *img_ptr = 0x80 * image->comps[index].sgnd + *comp_data;
290 static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) {
296 for (x = 0; x < image->numcomps; x++)
297 adjust[x] = FFMAX(FFMIN(desc->comp[x].depth - image->comps[x].prec, 8), 0) + desc->comp[x].shift;
299 for (index = 0; index < image->numcomps; index++) {
300 comp_data = image->comps[index].data;
301 for (y = 0; y < image->comps[index].h; y++) {
303 for (x = 0; x < image->comps[index].w; x++) {
304 *img_ptr = (1 << image->comps[index].prec - 1) * image->comps[index].sgnd +
332 opj_image_t *image = NULL;
387 ret = !opj_read_header(stream, dec, &image);
395 width = image->x1 - image->x0;
396 height = image->y1 - image->y0;
403 if (!libopenjpeg_matches_pix_fmt(image, avctx->pix_fmt))
407 avctx->pix_fmt = libopenjpeg_guess_pix_fmt(image);
414 for (i = 0; i < image->numcomps; i++)
415 if (image->comps[i].prec > avctx->bits_per_raw_sample)
416 avctx->bits_per_raw_sample = image->comps[i].prec;
421 ret = !opj_decode(dec, stream, image);
429 for (i = 0; i < image->numcomps; i++) {
430 if (!image->comps[i].data) {
445 libopenjpeg_copy_to_packed8(picture, image);
447 libopenjpeg_copyto8(picture, image);
452 libopenjpeg_copy_to_packed8(picture, image);
454 libopenjpeg_copyto16(picture, image);
460 libopenjpeg_copy_to_packed8(picture, image);
466 libopenjpeg_copy_to_packed16(picture, image);
481 opj_image_destroy(image);