static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track)

{

    int tag = track->par->codec_tag;

    int interlaced = track->par->field_order > AV_FIELD_PROGRESSIVE;

    AVStream *st = track->st;

    int rate = av_q2d(find_fps(s, st));



    if (!tag)

        tag = MKTAG('a', 'v', 'c', 'i'); //fallback tag



    if (track->par->format == AV_PIX_FMT_YUV420P10) {

        if (track->par->width == 960 && track->par->height == 720) {

            if (!interlaced) {

                if      (rate == 24) tag = MKTAG('a','i','5','p');

                else if (rate == 25) tag = MKTAG('a','i','5','q');

                else if (rate == 30) tag = MKTAG('a','i','5','p');

                else if (rate == 50) tag = MKTAG('a','i','5','q');

                else if (rate == 60) tag = MKTAG('a','i','5','p');

            }

        } else if (track->par->width == 1440 && track->par->height == 1080) {

            if (!interlaced) {

                if      (rate == 24) tag = MKTAG('a','i','5','3');

                else if (rate == 25) tag = MKTAG('a','i','5','2');

                else if (rate == 30) tag = MKTAG('a','i','5','3');

            } else {

                if      (rate == 50) tag = MKTAG('a','i','5','5');

                else if (rate == 60) tag = MKTAG('a','i','5','6');

            }

        }

    } else if (track->par->format == AV_PIX_FMT_YUV422P10) {

        if (track->par->width == 1280 && track->par->height == 720) {

            if (!interlaced) {

                if      (rate == 24) tag = MKTAG('a','i','1','p');

                else if (rate == 25) tag = MKTAG('a','i','1','q');

                else if (rate == 30) tag = MKTAG('a','i','1','p');

                else if (rate == 50) tag = MKTAG('a','i','1','q');

                else if (rate == 60) tag = MKTAG('a','i','1','p');

            }

        } else if (track->par->width == 1920 && track->par->height == 1080) {

            if (!interlaced) {

                if      (rate == 24) tag = MKTAG('a','i','1','3');

                else if (rate == 25) tag = MKTAG('a','i','1','2');

                else if (rate == 30) tag = MKTAG('a','i','1','3');

            } else {

                if      (rate == 25) tag = MKTAG('a','i','1','5');

                else if (rate == 50) tag = MKTAG('a','i','1','5');

                else if (rate == 60) tag = MKTAG('a','i','1','6');

            }

        } else if (   track->par->width == 4096 && track->par->height == 2160

                   || track->par->width == 3840 && track->par->height == 2160

                   || track->par->width == 2048 && track->par->height == 1080) {

            tag = MKTAG('a','i','v','x');

        }

    }



    return tag;

}

static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track)

{

    int tag = track->par->codec_tag;

    int interlaced = track->par->field_order > AV_FIELD_PROGRESSIVE;

    AVStream *st = track->st;

    int rate = av_q2d(find_fps(s, st));



    if (!tag)

        tag = MKTAG('a', 'v', 'c', 'i'); 



    if (track->par->format == AV_PIX_FMT_YUV420P10) {

        if (track->par->width == 960 && track->par->height == 720) {

            if (!interlaced) {

                if      (rate == 24) tag = MKTAG('a','i','5','p');

                else if (rate == 25) tag = MKTAG('a','i','5','q');

                else if (rate == 30) tag = MKTAG('a','i','5','p');

                else if (rate == 50) tag = MKTAG('a','i','5','q');

                else if (rate == 60) tag = MKTAG('a','i','5','p');

            }

        } else if (track->par->width == 1440 && track->par->height == 1080) {

            if (!interlaced) {

                if      (rate == 24) tag = MKTAG('a','i','5','3');

                else if (rate == 25) tag = MKTAG('a','i','5','2');

                else if (rate == 30) tag = MKTAG('a','i','5','3');

            } else {

                if      (rate == 50) tag = MKTAG('a','i','5','5');

                else if (rate == 60) tag = MKTAG('a','i','5','6');

            }

        }

    } else if (track->par->format == AV_PIX_FMT_YUV422P10) {

        if (track->par->width == 1280 && track->par->height == 720) {

            if (!interlaced) {

                if      (rate == 24) tag = MKTAG('a','i','1','p');

                else if (rate == 25) tag = MKTAG('a','i','1','q');

                else if (rate == 30) tag = MKTAG('a','i','1','p');

                else if (rate == 50) tag = MKTAG('a','i','1','q');

                else if (rate == 60) tag = MKTAG('a','i','1','p');

            }

        } else if (track->par->width == 1920 && track->par->height == 1080) {

            if (!interlaced) {

                if      (rate == 24) tag = MKTAG('a','i','1','3');

                else if (rate == 25) tag = MKTAG('a','i','1','2');

                else if (rate == 30) tag = MKTAG('a','i','1','3');

            } else {

                if      (rate == 25) tag = MKTAG('a','i','1','5');

                else if (rate == 50) tag = MKTAG('a','i','1','5');

                else if (rate == 60) tag = MKTAG('a','i','1','6');

            }

        } else if (   track->par->width == 4096 && track->par->height == 2160

                   || track->par->width == 3840 && track->par->height == 2160

                   || track->par->width == 2048 && track->par->height == 1080) {

            tag = MKTAG('a','i','v','x');

        }

    }



    return tag;

}

    int rate = av_q2d(find_fps(s, st));     int rate = av_q2d(find_fps(s, st));
static int FUNC_0(AVFormatContext *VAR_0, MOVTrack *VAR_1)

{

    int VAR_2 = VAR_1->par->codec_tag;

    int VAR_3 = VAR_1->par->field_order > AV_FIELD_PROGRESSIVE;

    AVStream *st = VAR_1->st;

    int VAR_4 = av_q2d(find_fps(VAR_0, st));



    if (!VAR_2)

        VAR_2 = MKTAG('a', 'v', 'c', 'i'); 



    if (VAR_1->par->format == AV_PIX_FMT_YUV420P10) {

        if (VAR_1->par->width == 960 && VAR_1->par->height == 720) {

            if (!VAR_3) {

                if      (VAR_4 == 24) VAR_2 = MKTAG('a','i','5','p');

                else if (VAR_4 == 25) VAR_2 = MKTAG('a','i','5','q');

                else if (VAR_4 == 30) VAR_2 = MKTAG('a','i','5','p');

                else if (VAR_4 == 50) VAR_2 = MKTAG('a','i','5','q');

                else if (VAR_4 == 60) VAR_2 = MKTAG('a','i','5','p');

            }

        } else if (VAR_1->par->width == 1440 && VAR_1->par->height == 1080) {

            if (!VAR_3) {

                if      (VAR_4 == 24) VAR_2 = MKTAG('a','i','5','3');

                else if (VAR_4 == 25) VAR_2 = MKTAG('a','i','5','2');

                else if (VAR_4 == 30) VAR_2 = MKTAG('a','i','5','3');

            } else {

                if      (VAR_4 == 50) VAR_2 = MKTAG('a','i','5','5');

                else if (VAR_4 == 60) VAR_2 = MKTAG('a','i','5','6');

            }

        }

    } else if (VAR_1->par->format == AV_PIX_FMT_YUV422P10) {

        if (VAR_1->par->width == 1280 && VAR_1->par->height == 720) {

            if (!VAR_3) {

                if      (VAR_4 == 24) VAR_2 = MKTAG('a','i','1','p');

                else if (VAR_4 == 25) VAR_2 = MKTAG('a','i','1','q');

                else if (VAR_4 == 30) VAR_2 = MKTAG('a','i','1','p');

                else if (VAR_4 == 50) VAR_2 = MKTAG('a','i','1','q');

                else if (VAR_4 == 60) VAR_2 = MKTAG('a','i','1','p');

            }

        } else if (VAR_1->par->width == 1920 && VAR_1->par->height == 1080) {

            if (!VAR_3) {

                if      (VAR_4 == 24) VAR_2 = MKTAG('a','i','1','3');

                else if (VAR_4 == 25) VAR_2 = MKTAG('a','i','1','2');

                else if (VAR_4 == 30) VAR_2 = MKTAG('a','i','1','3');

            } else {

                if      (VAR_4 == 25) VAR_2 = MKTAG('a','i','1','5');

                else if (VAR_4 == 50) VAR_2 = MKTAG('a','i','1','5');

                else if (VAR_4 == 60) VAR_2 = MKTAG('a','i','1','6');

            }

        } else if (   VAR_1->par->width == 4096 && VAR_1->par->height == 2160

                   || VAR_1->par->width == 3840 && VAR_1->par->height == 2160

                   || VAR_1->par->width == 2048 && VAR_1->par->height == 1080) {

            VAR_2 = MKTAG('a','i','v','x');

        }

    }



    return VAR_2;

}

static int FUNC_0(AVFormatContext *VAR_0, MOVTrack *VAR_1)
{ int VAR_2 = VAR_1->par->codec_tag; int VAR_3 = VAR_1->par->field_order > AV_FIELD_PROGRESSIVE; AVStream *st = VAR_1->st; int VAR_4 = av_q2d(find_fps(VAR_0, st)); if (!VAR_2)
VAR_2 = MKTAG('a', 'v', 'c', 'i'); if (VAR_1->par->format == AV_PIX_FMT_YUV420P10) { if (VAR_1->par->width == 960 && VAR_1->par->height == 720) { if (!VAR_3) { if      (VAR_4 == 24) VAR_2 = MKTAG('a','i','5','p'); else if (VAR_4 == 25) VAR_2 = MKTAG('a','i','5','q'); else if (VAR_4 == 30) VAR_2 = MKTAG('a','i','5','p'); else if (VAR_4 == 50) VAR_2 = MKTAG('a','i','5','q'); else if (VAR_4 == 60) VAR_2 = MKTAG('a','i','5','p'); } } else if (VAR_1->par->width == 1440 && VAR_1->par->height == 1080) { if (!VAR_3) { if      (VAR_4 == 24) VAR_2 = MKTAG('a','i','5','3'); else if (VAR_4 == 25) VAR_2 = MKTAG('a','i','5','2'); else if (VAR_4 == 30) VAR_2 = MKTAG('a','i','5','3'); } else { if      (VAR_4 == 50) VAR_2 = MKTAG('a','i','5','5'); else if (VAR_4 == 60) VAR_2 = MKTAG('a','i','5','6'); } } } else if (VAR_1->par->format == AV_PIX_FMT_YUV422P10) { if (VAR_1->par->width == 1280 && VAR_1->par->height == 720) { if (!VAR_3) { if      (VAR_4 == 24) VAR_2 = MKTAG('a','i','1','p'); else if (VAR_4 == 25) VAR_2 = MKTAG('a','i','1','q'); else if (VAR_4 == 30) VAR_2 = MKTAG('a','i','1','p'); else if (VAR_4 == 50) VAR_2 = MKTAG('a','i','1','q'); else if (VAR_4 == 60) VAR_2 = MKTAG('a','i','1','p'); } } else if (VAR_1->par->width == 1920 && VAR_1->par->height == 1080) { if (!VAR_3) { if      (VAR_4 == 24) VAR_2 = MKTAG('a','i','1','3'); else if (VAR_4 == 25) VAR_2 = MKTAG('a','i','1','2'); else if (VAR_4 == 30) VAR_2 = MKTAG('a','i','1','3'); } else { if      (VAR_4 == 25) VAR_2 = MKTAG('a','i','1','5'); else if (VAR_4 == 50) VAR_2 = MKTAG('a','i','1','5'); else if (VAR_4 == 60) VAR_2 = MKTAG('a','i','1','6'); } } else if (   VAR_1->par->width == 4096 && VAR_1->par->height == 2160 || VAR_1->par->width == 3840 && VAR_1->par->height == 2160
|| VAR_1->par->width == 2048 && VAR_1->par->height == 1080) { VAR_2 = MKTAG('a','i','v','x'); } } return VAR_2; }