static int is_planar_yuv(const AVPixFmtDescriptor *desc)
{
    int i, has_plane[4] = { 0 };

    if (desc->flags & PIX_FMT_RGB)
        return 0;

    for (i = 0; i < desc->nb_components; i++)
        has_plane[desc->comp[i].plane] = 1;

    return has_plane[0] + has_plane[1] + has_plane[2] + has_plane[3] >= 3;
}

Add a code snippet to your website: www.paste.org