vlc | branch: master | Thomas Guillem <tho...@gllm.fr> | Tue Mar 27 19:47:17 2018 +0200| [47b038e6c1e21f42b2c7f06b9062d8210f111905] | committer: Thomas Guillem
avcodec: accept NV12 an input This removes a conversion when both decoder and encoder use NV12. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=47b038e6c1e21f42b2c7f06b9062d8210f111905 --- modules/codec/avcodec/encoder.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c index 8c8a442e14..09a8864985 100644 --- a/modules/codec/avcodec/encoder.c +++ b/modules/codec/avcodec/encoder.c @@ -543,12 +543,26 @@ int InitVideoEnc( vlc_object_t *p_this ) if( p_codec->pix_fmts ) { + static const enum AVPixelFormat vlc_pix_fmts[] = { + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_NV12, + AV_PIX_FMT_RGB24, + }; + bool found = false; const enum PixelFormat *p = p_codec->pix_fmts; - for( ; *p != -1; p++ ) + for( ; !found && *p != -1; p++ ) { - if( *p == p_context->pix_fmt ) break; + for( size_t i = 0; i < ARRAY_SIZE(vlc_pix_fmts); ++i ) + { + if( *p == vlc_pix_fmts[i] ) + { + found = true; + p_context->pix_fmt = *p; + break; + } + } } - if( *p == -1 ) p_context->pix_fmt = p_codec->pix_fmts[0]; + if (!found) p_context->pix_fmt = p_codec->pix_fmts[0]; GetVlcChroma( &p_enc->fmt_in.video, p_context->pix_fmt ); p_enc->fmt_in.i_codec = p_enc->fmt_in.video.i_chroma; } _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits