static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, unsigned *lossp, unsigned consider) { const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt); const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt); int src_color, dst_color; int src_min_depth, src_max_depth, dst_min_depth, dst_max_depth; int ret, loss, i, nb_components; int score = INT_MAX - 1; if (dst_pix_fmt >= AV_PIX_FMT_NB || dst_pix_fmt <= AV_PIX_FMT_NONE) return ~0; /* compute loss */ *lossp = loss = 0; if (dst_pix_fmt == src_pix_fmt) return INT_MAX; if ((ret = get_pix_fmt_depth(&src_min_depth, &src_max_depth, src_pix_fmt)) < 0) return ret; if ((ret = get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) < 0) return ret; src_color = get_color_type(src_desc); dst_color = get_color_type(dst_desc); nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components); for (i = 0; i < nb_components; i++) if (src_desc->comp[i].depth_minus1 > dst_desc->comp[i].depth_minus1 && (consider & FF_LOSS_DEPTH)) { loss |= FF_LOSS_DEPTH; score -= 65536 >> dst_desc->comp[i].depth_minus1; }
void set_shift(byte gray_bits, byte alpha_bits = 0) const { TRACE_IO_TRANSFORM("png_set_shift: gray_bits=%d, alpha_bits=%d\n", gray_bits, alpha_bits); if (get_color_type() != color_type_gray || get_color_type() != color_type_gray_alpha) { throw error("set_shift: expected Gray or Gray+Alpha" " color type"); } color_info bits; bits.gray = gray_bits; bits.alpha = alpha_bits; png_set_shift(m_png, & bits); }
void set_shift(byte red_bits, byte green_bits, byte blue_bits, byte alpha_bits = 0) const { TRACE_IO_TRANSFORM("png_set_shift: red_bits=%d, green_bits=%d," " blue_bits=%d, alpha_bits=%d\n", red_bits, green_bits, blue_bits, alpha_bits); if (get_color_type() != color_type_rgb || get_color_type() != color_type_rgb_alpha) { throw error("set_shift: expected RGB or RGBA color type"); } color_info bits; bits.red = red_bits; bits.green = green_bits; bits.blue = blue_bits; bits.alpha = alpha_bits; png_set_shift(m_png, & bits); }