[vlc-commits] avcodec: accept NV12 an input
Thomas Guillem
git at videolan.org
Thu Mar 29 14:04:10 CEST 2018
vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Mar 27 19:47:17 2018 +0200| [9a6212cfbdc31a3ca8cf35ce42b21e3d7b31a5cd] | committer: Thomas Guillem
avcodec: accept NV12 an input
This removes a conversion when both decoder and encoder use NV12.
(cherry picked from commit 47b038e6c1e21f42b2c7f06b9062d8210f111905)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=9a6212cfbdc31a3ca8cf35ce42b21e3d7b31a5cd
---
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 e25d2ba0b3..74c5dc3144 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;
}
More information about the vlc-commits
mailing list