void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
{
- *h_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_w;
- *v_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_h;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
+ *h_shift = desc->log2_chroma_w;
+ *v_shift = desc->log2_chroma_h;
}
int ff_is_hwaccel_pix_fmt(enum AVPixelFormat pix_fmt)
{
- return av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_HWACCEL;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
+ return desc->flags & PIX_FMT_HWACCEL;
}
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
static int get_pix_fmt_depth(int *min, int *max, enum AVPixelFormat pix_fmt)
{
- const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int i;
- if (!desc->nb_components) {
+ if (!desc || !desc->nb_components) {
*min = *max = 0;
return AVERROR(EINVAL);
}
int has_alpha)
{
const PixFmtInfo *pf, *ps;
- const AVPixFmtDescriptor *src_desc;
- const AVPixFmtDescriptor *dst_desc;
+ 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_min_depth, src_max_depth, dst_min_depth, dst_max_depth;
int ret, loss;
if (dst_pix_fmt >= AV_PIX_FMT_NB || dst_pix_fmt <= AV_PIX_FMT_NONE)
return ~0;
- src_desc = &av_pix_fmt_descriptors[src_pix_fmt];
- dst_desc = &av_pix_fmt_descriptors[dst_pix_fmt];
ps = &pix_fmt_info[src_pix_fmt];
/* compute loss */
static int avg_bits_per_pixel(enum AVPixelFormat pix_fmt)
{
const PixFmtInfo *info = &pix_fmt_info[pix_fmt];
- const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
return info->padded_size ?
info->padded_size : av_get_bits_per_pixel(desc);
loss_order1 = loss1 & loss_mask_order[i];
loss_order2 = loss2 & loss_mask_order[i];
- if (loss_order1 == 0 && loss_order2 == 0){ /* use format with smallest depth */
+ if (loss_order1 == 0 && loss_order2 == 0 && dst_pix_fmt2 != AV_PIX_FMT_NONE && dst_pix_fmt1 != AV_PIX_FMT_NONE){ /* use format with smallest depth */
dst_pix_fmt = avg_bits_per_pixel(dst_pix_fmt2) < avg_bits_per_pixel(dst_pix_fmt1) ? dst_pix_fmt2 : dst_pix_fmt1;
} else if (loss_order1 == 0 || loss_order2 == 0) { /* use format with no loss */
dst_pix_fmt = loss_order2 ? dst_pix_fmt1 : dst_pix_fmt2;
static inline int is_yuv_planar(enum AVPixelFormat fmt)
{
const PixFmtInfo *info = &pix_fmt_info[fmt];
- const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[fmt];
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
int i;
int planes[4] = { 0 };
int av_picture_crop(AVPicture *dst, const AVPicture *src,
enum AVPixelFormat pix_fmt, int top_band, int left_band)
{
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int y_shift;
int x_shift;
if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
return -1;
- y_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_h;
- x_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_w;
+ y_shift = desc->log2_chroma_h;
+ x_shift = desc->log2_chroma_w;
if (is_yuv_planar(pix_fmt)) {
dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;
enum AVPixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright,
int *color)
{
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
uint8_t *optr;
int y_shift;
int x_shift;
!is_yuv_planar(pix_fmt)) return -1;
for (i = 0; i < 3; i++) {
- x_shift = i ? av_pix_fmt_descriptors[pix_fmt].log2_chroma_w : 0;
- y_shift = i ? av_pix_fmt_descriptors[pix_fmt].log2_chroma_h : 0;
+ x_shift = i ? desc->log2_chroma_w : 0;
+ y_shift = i ? desc->log2_chroma_h : 0;
if (padtop || padleft) {
memset(dst->data[i], color[i],