enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum AVPixelFormat target)

{

    if (codec && codec->pix_fmts) {

        const enum AVPixelFormat *p = codec->pix_fmts;

        int has_alpha= av_pix_fmt_desc_get(target)->nb_components % 2 == 0;

        enum AVPixelFormat best= AV_PIX_FMT_NONE;

        if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {

            if (st->codec->codec_id == AV_CODEC_ID_MJPEG) {

                p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };

            } else if (st->codec->codec_id == AV_CODEC_ID_LJPEG) {

                p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,

                                                 AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };

            }

        }

        for (; *p != AV_PIX_FMT_NONE; p++) {

            best= avcodec_find_best_pix_fmt_of_2(best, *p, target, has_alpha, NULL);

            if (*p == target)

                break;

        }

        if (*p == AV_PIX_FMT_NONE) {

            if (target != AV_PIX_FMT_NONE)

                av_log(NULL, AV_LOG_WARNING,

                       "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",

                       av_get_pix_fmt_name(target),

                       codec->name,

                       av_get_pix_fmt_name(best));

            return best;

        }

    }

    return target;

}

enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum AVPixelFormat target)

{

    if (codec && codec->pix_fmts) {

        const enum AVPixelFormat *p = codec->pix_fmts;

        int has_alpha= av_pix_fmt_desc_get(target)->nb_components % 2 == 0;

        enum AVPixelFormat best= AV_PIX_FMT_NONE;

        if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {

            if (st->codec->codec_id == AV_CODEC_ID_MJPEG) {

                p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };

            } else if (st->codec->codec_id == AV_CODEC_ID_LJPEG) {

                p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,

                                                 AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };

            }

        }

        for (; *p != AV_PIX_FMT_NONE; p++) {

            best= avcodec_find_best_pix_fmt_of_2(best, *p, target, has_alpha, NULL);

            if (*p == target)

                break;

        }

        if (*p == AV_PIX_FMT_NONE) {

            if (target != AV_PIX_FMT_NONE)

                av_log(NULL, AV_LOG_WARNING,

                       "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",

                       av_get_pix_fmt_name(target),

                       codec->name,

                       av_get_pix_fmt_name(best));

            return best;

        }

    }

    return target;

}

enum AVPixelFormat FUNC_0(AVStream *VAR_0, AVCodec *VAR_1, enum AVPixelFormat VAR_2)

{

    if (VAR_1 && VAR_1->pix_fmts) {

        const enum AVPixelFormat *VAR_3 = VAR_1->pix_fmts;

        int VAR_4= av_pix_fmt_desc_get(VAR_2)->nb_components % 2 == 0;

        enum AVPixelFormat VAR_5= AV_PIX_FMT_NONE;

        if (VAR_0->VAR_1->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {

            if (VAR_0->VAR_1->codec_id == AV_CODEC_ID_MJPEG) {

                VAR_3 = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };

            } else if (VAR_0->VAR_1->codec_id == AV_CODEC_ID_LJPEG) {

                VAR_3 = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,

                                                 AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };

            }

        }

        for (; *VAR_3 != AV_PIX_FMT_NONE; VAR_3++) {

            VAR_5= avcodec_find_best_pix_fmt_of_2(VAR_5, *VAR_3, VAR_2, VAR_4, NULL);

            if (*VAR_3 == VAR_2)

                break;

        }

        if (*VAR_3 == AV_PIX_FMT_NONE) {

            if (VAR_2 != AV_PIX_FMT_NONE)

                av_log(NULL, AV_LOG_WARNING,

                       "Incompatible pixel format '%s' for VAR_1 '%s', auto-selecting format '%s'\n",

                       av_get_pix_fmt_name(VAR_2),

                       VAR_1->name,

                       av_get_pix_fmt_name(VAR_5));

            return VAR_5;

        }

    }

    return VAR_2;

}

enum AVPixelFormat FUNC_0(AVStream *VAR_0, AVCodec *VAR_1, enum AVPixelFormat VAR_2)
{ if (VAR_1 && VAR_1->pix_fmts) { const enum AVPixelFormat *VAR_3 = VAR_1->pix_fmts; int VAR_4= av_pix_fmt_desc_get(VAR_2)->nb_components % 2 == 0; enum AVPixelFormat VAR_5= AV_PIX_FMT_NONE; if (VAR_0->VAR_1->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) { if (VAR_0->VAR_1->codec_id == AV_CODEC_ID_MJPEG) { VAR_3 = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE }; } else if (VAR_0->VAR_1->codec_id == AV_CODEC_ID_LJPEG) { VAR_3 = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE }; } } for (; *VAR_3 != AV_PIX_FMT_NONE; VAR_3++) { VAR_5= avcodec_find_best_pix_fmt_of_2(VAR_5, *VAR_3, VAR_2, VAR_4, NULL); if (*VAR_3 == VAR_2)
break; } if (*VAR_3 == AV_PIX_FMT_NONE) { if (VAR_2 != AV_PIX_FMT_NONE)
av_log(NULL, AV_LOG_WARNING,
"Incompatible pixel format '%s' for VAR_1 '%s', auto-selecting format '%s'\n",
av_get_pix_fmt_name(VAR_2),
VAR_1->name,
av_get_pix_fmt_name(VAR_5)); return VAR_5; } } return VAR_2; }