Exemplo n.º 1
0
static int hwdownload_query_formats(AVFilterContext *avctx)
{
    AVFilterFormats  *infmts = NULL;
    AVFilterFormats *outfmts = NULL;
    const AVPixFmtDescriptor *desc;
    int err;

    for (desc = av_pix_fmt_desc_next(NULL); desc;
         desc = av_pix_fmt_desc_next(desc)) {
        if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
            err = ff_add_format(&infmts,  av_pix_fmt_desc_get_id(desc));
        else
            err = ff_add_format(&outfmts, av_pix_fmt_desc_get_id(desc));
        if (err) {
            ff_formats_unref(&infmts);
            ff_formats_unref(&outfmts);
            return err;
        }
    }

    if ((err = ff_formats_ref(infmts,  &avctx->inputs[0]->out_formats)) < 0 ||
        (err = ff_formats_ref(outfmts, &avctx->outputs[0]->in_formats)) < 0)
        return err;

    return 0;
}
Exemplo n.º 2
0
static int query_formats(AVFilterContext *ctx)
{
    AVFilterFormats  *formats;
    enum AVPixelFormat pix_fmt;
    int              ret;

    /** accept any input pixel format that is not hardware accelerated, not
     *  a bitstream format, and does not have vertically sub-sampled chroma */
    if (ctx->inputs[0]) {
        const AVPixFmtDescriptor *desc = NULL;
        formats = NULL;
        while ((desc = av_pix_fmt_desc_next(desc))) {
            pix_fmt = av_pix_fmt_desc_get_id(desc);
            if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
                  desc->flags & AV_PIX_FMT_FLAG_PAL     ||
                  desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) &&
                desc->nb_components && !desc->log2_chroma_h &&
                (ret = ff_add_format(&formats, pix_fmt)) < 0) {
                ff_formats_unref(&formats);
                return ret;
            }
        }
        ff_formats_ref(formats, &ctx->inputs[0]->out_formats);
        ff_formats_ref(formats, &ctx->outputs[0]->in_formats);
    }

    return 0;
}
Exemplo n.º 3
0
std::vector<std::string> getPixelFormats( const std::string& videoCodecName )
{
    std::vector<std::string> pixelFormats;

    // all video codec concerned
    if( videoCodecName == "" )
    {
        const AVPixFmtDescriptor* pixFmtDesc = NULL;

#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT( 51, 44, 0 )
        for( int pix_fmt = 0; pix_fmt < PIX_FMT_NB; ++pix_fmt )
            pixFmtDesc = &av_pix_fmt_descriptors[pix_fmt];
#else
        while( ( pixFmtDesc = av_pix_fmt_desc_next( pixFmtDesc ) ) != NULL )
#endif
        {
            if( ! pixFmtDesc->name )
                continue;
            pixelFormats.push_back( std::string( pixFmtDesc->name ) );
        }
    }
    // specific video codec
    else
    {
        const AVCodec* videoCodec = avcodec_find_encoder_by_name( videoCodecName.c_str() );
        if( videoCodec && videoCodec->pix_fmts != NULL )
        {
            size_t pix_fmt = 0;
            while( videoCodec->pix_fmts[pix_fmt] != -1 )
            {
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT( 51, 44, 0 )
                const AVPixFmtDescriptor* pix_desc = &av_pix_fmt_descriptors[ videoCodec->pix_fmts[pix_fmt] ];
#else
                const AVPixFmtDescriptor* pix_desc = av_pix_fmt_desc_get( videoCodec->pix_fmts[pix_fmt] );
#endif
                if( ! pix_desc || ! pix_desc->name )
                    continue;
                pixelFormats.push_back( std::string( pix_desc->name ) );
                ++pix_fmt;
            }
        }
    }
    return pixelFormats;
}
Exemplo n.º 4
0
AVFilterFormats *ff_all_formats(enum AVMediaType type)
{
    AVFilterFormats *ret = NULL;

    if (type == AVMEDIA_TYPE_VIDEO) {
        const AVPixFmtDescriptor *desc = NULL;
        while ((desc = av_pix_fmt_desc_next(desc))) {
            if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
                ff_add_format(&ret, av_pix_fmt_desc_get_id(desc));
        }
    } else if (type == AVMEDIA_TYPE_AUDIO) {
        enum AVSampleFormat fmt = 0;
        while (av_get_sample_fmt_name(fmt)) {
            ff_add_format(&ret, fmt);
            fmt++;
        }
    }

    return ret;
}