int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,

                             int has_alpha)

{

    const PixFmtInfo *pf, *ps;

    const AVPixFmtDescriptor *src_desc = &av_pix_fmt_descriptors[src_pix_fmt];

    const AVPixFmtDescriptor *dst_desc = &av_pix_fmt_descriptors[dst_pix_fmt];

    int loss;



    ps = &pix_fmt_info[src_pix_fmt];



    /* compute loss */

    loss = 0;

    pf = &pix_fmt_info[dst_pix_fmt];

    if (pf->depth < ps->depth ||

        ((dst_pix_fmt == PIX_FMT_RGB555BE || dst_pix_fmt == PIX_FMT_RGB555LE ||

          dst_pix_fmt == PIX_FMT_BGR555BE || dst_pix_fmt == PIX_FMT_BGR555LE) &&

         (src_pix_fmt == PIX_FMT_RGB565BE || src_pix_fmt == PIX_FMT_RGB565LE ||

          src_pix_fmt == PIX_FMT_BGR565BE || src_pix_fmt == PIX_FMT_BGR565LE)))

        loss |= FF_LOSS_DEPTH;

    if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w ||

        dst_desc->log2_chroma_h > src_desc->log2_chroma_h)

        loss |= FF_LOSS_RESOLUTION;

    switch(pf->color_type) {

    case FF_COLOR_RGB:

        if (ps->color_type != FF_COLOR_RGB &&

            ps->color_type != FF_COLOR_GRAY)

            loss |= FF_LOSS_COLORSPACE;

        break;

    case FF_COLOR_GRAY:

        if (ps->color_type != FF_COLOR_GRAY)

            loss |= FF_LOSS_COLORSPACE;

        break;

    case FF_COLOR_YUV:

        if (ps->color_type != FF_COLOR_YUV)

            loss |= FF_LOSS_COLORSPACE;

        break;

    case FF_COLOR_YUV_JPEG:

        if (ps->color_type != FF_COLOR_YUV_JPEG &&

            ps->color_type != FF_COLOR_YUV &&

            ps->color_type != FF_COLOR_GRAY)

            loss |= FF_LOSS_COLORSPACE;

        break;

    default:

        /* fail safe test */

        if (ps->color_type != pf->color_type)

            loss |= FF_LOSS_COLORSPACE;

        break;

    }

    if (pf->color_type == FF_COLOR_GRAY &&

        ps->color_type != FF_COLOR_GRAY)

        loss |= FF_LOSS_CHROMA;

    if (!pf->is_alpha && (ps->is_alpha && has_alpha))

        loss |= FF_LOSS_ALPHA;

    if (pf->pixel_type == FF_PIXEL_PALETTE &&

        (ps->pixel_type != FF_PIXEL_PALETTE && ps->color_type != FF_COLOR_GRAY))

        loss |= FF_LOSS_COLORQUANT;

    return loss;

}

int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,

                             int has_alpha)

{

    const PixFmtInfo *pf, *ps;

    const AVPixFmtDescriptor *src_desc = &av_pix_fmt_descriptors[src_pix_fmt];

    const AVPixFmtDescriptor *dst_desc = &av_pix_fmt_descriptors[dst_pix_fmt];

    int loss;



    ps = &pix_fmt_info[src_pix_fmt];



    

    loss = 0;

    pf = &pix_fmt_info[dst_pix_fmt];

    if (pf->depth < ps->depth ||

        ((dst_pix_fmt == PIX_FMT_RGB555BE || dst_pix_fmt == PIX_FMT_RGB555LE ||

          dst_pix_fmt == PIX_FMT_BGR555BE || dst_pix_fmt == PIX_FMT_BGR555LE) &&

         (src_pix_fmt == PIX_FMT_RGB565BE || src_pix_fmt == PIX_FMT_RGB565LE ||

          src_pix_fmt == PIX_FMT_BGR565BE || src_pix_fmt == PIX_FMT_BGR565LE)))

        loss |= FF_LOSS_DEPTH;

    if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w ||

        dst_desc->log2_chroma_h > src_desc->log2_chroma_h)

        loss |= FF_LOSS_RESOLUTION;

    switch(pf->color_type) {

    case FF_COLOR_RGB:

        if (ps->color_type != FF_COLOR_RGB &&

            ps->color_type != FF_COLOR_GRAY)

            loss |= FF_LOSS_COLORSPACE;

        break;

    case FF_COLOR_GRAY:

        if (ps->color_type != FF_COLOR_GRAY)

            loss |= FF_LOSS_COLORSPACE;

        break;

    case FF_COLOR_YUV:

        if (ps->color_type != FF_COLOR_YUV)

            loss |= FF_LOSS_COLORSPACE;

        break;

    case FF_COLOR_YUV_JPEG:

        if (ps->color_type != FF_COLOR_YUV_JPEG &&

            ps->color_type != FF_COLOR_YUV &&

            ps->color_type != FF_COLOR_GRAY)

            loss |= FF_LOSS_COLORSPACE;

        break;

    default:

        

        if (ps->color_type != pf->color_type)

            loss |= FF_LOSS_COLORSPACE;

        break;

    }

    if (pf->color_type == FF_COLOR_GRAY &&

        ps->color_type != FF_COLOR_GRAY)

        loss |= FF_LOSS_CHROMA;

    if (!pf->is_alpha && (ps->is_alpha && has_alpha))

        loss |= FF_LOSS_ALPHA;

    if (pf->pixel_type == FF_PIXEL_PALETTE &&

        (ps->pixel_type != FF_PIXEL_PALETTE && ps->color_type != FF_COLOR_GRAY))

        loss |= FF_LOSS_COLORQUANT;

    return loss;

}

int FUNC_0(enum PixelFormat VAR_0, enum PixelFormat VAR_1,

                             int VAR_2)

{

    const PixFmtInfo *VAR_3, *ps;

    const AVPixFmtDescriptor *VAR_4 = &av_pix_fmt_descriptors[VAR_1];

    const AVPixFmtDescriptor *VAR_5 = &av_pix_fmt_descriptors[VAR_0];

    int VAR_6;



    ps = &pix_fmt_info[VAR_1];



    

    VAR_6 = 0;

    VAR_3 = &pix_fmt_info[VAR_0];

    if (VAR_3->depth < ps->depth ||

        ((VAR_0 == PIX_FMT_RGB555BE || VAR_0 == PIX_FMT_RGB555LE ||

          VAR_0 == PIX_FMT_BGR555BE || VAR_0 == PIX_FMT_BGR555LE) &&

         (VAR_1 == PIX_FMT_RGB565BE || VAR_1 == PIX_FMT_RGB565LE ||

          VAR_1 == PIX_FMT_BGR565BE || VAR_1 == PIX_FMT_BGR565LE)))

        VAR_6 |= FF_LOSS_DEPTH;

    if (VAR_5->log2_chroma_w > VAR_4->log2_chroma_w ||

        VAR_5->log2_chroma_h > VAR_4->log2_chroma_h)

        VAR_6 |= FF_LOSS_RESOLUTION;

    switch(VAR_3->color_type) {

    case FF_COLOR_RGB:

        if (ps->color_type != FF_COLOR_RGB &&

            ps->color_type != FF_COLOR_GRAY)

            VAR_6 |= FF_LOSS_COLORSPACE;

        break;

    case FF_COLOR_GRAY:

        if (ps->color_type != FF_COLOR_GRAY)

            VAR_6 |= FF_LOSS_COLORSPACE;

        break;

    case FF_COLOR_YUV:

        if (ps->color_type != FF_COLOR_YUV)

            VAR_6 |= FF_LOSS_COLORSPACE;

        break;

    case FF_COLOR_YUV_JPEG:

        if (ps->color_type != FF_COLOR_YUV_JPEG &&

            ps->color_type != FF_COLOR_YUV &&

            ps->color_type != FF_COLOR_GRAY)

            VAR_6 |= FF_LOSS_COLORSPACE;

        break;

    default:

        

        if (ps->color_type != VAR_3->color_type)

            VAR_6 |= FF_LOSS_COLORSPACE;

        break;

    }

    if (VAR_3->color_type == FF_COLOR_GRAY &&

        ps->color_type != FF_COLOR_GRAY)

        VAR_6 |= FF_LOSS_CHROMA;

    if (!VAR_3->is_alpha && (ps->is_alpha && VAR_2))

        VAR_6 |= FF_LOSS_ALPHA;

    if (VAR_3->pixel_type == FF_PIXEL_PALETTE &&

        (ps->pixel_type != FF_PIXEL_PALETTE && ps->color_type != FF_COLOR_GRAY))

        VAR_6 |= FF_LOSS_COLORQUANT;

    return VAR_6;

}

int FUNC_0(enum PixelFormat VAR_0, enum PixelFormat VAR_1,
int VAR_2)
{ const PixFmtInfo *VAR_3, *ps; const AVPixFmtDescriptor *VAR_4 = &av_pix_fmt_descriptors[VAR_1]; const AVPixFmtDescriptor *VAR_5 = &av_pix_fmt_descriptors[VAR_0]; int VAR_6; ps = &pix_fmt_info[VAR_1]; VAR_6 = 0; VAR_3 = &pix_fmt_info[VAR_0]; if (VAR_3->depth < ps->depth ||
((VAR_0 == PIX_FMT_RGB555BE || VAR_0 == PIX_FMT_RGB555LE ||
VAR_0 == PIX_FMT_BGR555BE || VAR_0 == PIX_FMT_BGR555LE) &&
(VAR_1 == PIX_FMT_RGB565BE || VAR_1 == PIX_FMT_RGB565LE ||
VAR_1 == PIX_FMT_BGR565BE || VAR_1 == PIX_FMT_BGR565LE)))
VAR_6 |= FF_LOSS_DEPTH; if (VAR_5->log2_chroma_w > VAR_4->log2_chroma_w ||
VAR_5->log2_chroma_h > VAR_4->log2_chroma_h)
VAR_6 |= FF_LOSS_RESOLUTION; switch(VAR_3->color_type) { case FF_COLOR_RGB:
if (ps->color_type != FF_COLOR_RGB &&
ps->color_type != FF_COLOR_GRAY)
VAR_6 |= FF_LOSS_COLORSPACE; break; case FF_COLOR_GRAY:
if (ps->color_type != FF_COLOR_GRAY)
VAR_6 |= FF_LOSS_COLORSPACE; break; case FF_COLOR_YUV:
if (ps->color_type != FF_COLOR_YUV)
VAR_6 |= FF_LOSS_COLORSPACE; break; case FF_COLOR_YUV_JPEG:
if (ps->color_type != FF_COLOR_YUV_JPEG &&
ps->color_type != FF_COLOR_YUV &&
ps->color_type != FF_COLOR_GRAY)
VAR_6 |= FF_LOSS_COLORSPACE; break; default:
if (ps->color_type != VAR_3->color_type)
VAR_6 |= FF_LOSS_COLORSPACE; break; } if (VAR_3->color_type == FF_COLOR_GRAY &&
ps->color_type != FF_COLOR_GRAY)
VAR_6 |= FF_LOSS_CHROMA; if (!VAR_3->is_alpha && (ps->is_alpha && VAR_2))
VAR_6 |= FF_LOSS_ALPHA; if (VAR_3->pixel_type == FF_PIXEL_PALETTE &&
(ps->pixel_type != FF_PIXEL_PALETTE && ps->color_type != FF_COLOR_GRAY))
VAR_6 |= FF_LOSS_COLORQUANT; return VAR_6; }