[vlc-devel] [PATCH] avcodec: encoder: avoid negative repeat_pict

Steve Lhomme robux4 at ycbcr.xyz
Mon Nov 16 10:12:28 CET 2020


A value of 1 i_nb_fields is possible for codecs outputing one field at a time.
---
 modules/codec/avcodec/encoder.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 2564e0a5183..44d1ba86ba8 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -1196,7 +1196,8 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
         /* Let libavcodec select the frame type */
         frame->pict_type = 0;
 
-        frame->repeat_pict = p_pict->i_nb_fields - 2;
+        // telecine information
+        frame->repeat_pict = __MAX(p_pict->i_nb_fields - 2, 0);
         frame->interlaced_frame = !p_pict->b_progressive;
         frame->top_field_first = !!p_pict->b_top_field_first;
 
-- 
2.26.2



More information about the vlc-devel mailing list