[vlc-commits] [Git][videolan/vlc][master] 2 commits: avcodec: don't assume ticks_per_frame can be 0

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jan 17 10:29:35 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
2f5c8604 by Steve Lhomme at 2025-01-17T10:16:21+00:00
avcodec: don't assume ticks_per_frame can be 0

The documentation says it's either 1 or 2.
I verified this is the case in FFmpeg 7.1. Only h264dec, mpeg12dec, mpegvideo_parser, vc1 set it.

- - - - -
47b878be by Steve Lhomme at 2025-01-17T10:16:21+00:00
avcodec: use AV_CODEC_PROP_FIELDS to tell the number of ticks

codecs sending 2 fields set the flag, otherwise it's one field.

ticks_per_frame is deprecated and will be removed in the next major API bump.

- - - - -


1 changed file:

- modules/codec/avcodec/video.c


Changes:

=====================================
modules/codec/avcodec/video.c
=====================================
@@ -354,8 +354,7 @@ static int lavc_GetVideoFormat(decoder_t *dec, video_format_t *restrict fmt,
     else if (ctx->time_base.num > 0 && ctx->time_base.den > 0)
     {
         fmt->i_frame_rate = ctx->time_base.den;
-        fmt->i_frame_rate_base = ctx->time_base.num
-                                 * __MAX(ctx->ticks_per_frame, 1);
+        fmt->i_frame_rate_base = ctx->time_base.num;
     }
 
     get_video_color_settings(ctx, fmt);
@@ -377,12 +376,10 @@ static int lavc_UpdateVideoFormat(decoder_t *dec, AVCodecContext *ctx,
 
     /* always have date in fields/ticks units */
     if(p_sys->pts.i_divider_num)
-        date_Change(&p_sys->pts, fmt_out.i_frame_rate *
-                                 __MAX(ctx->ticks_per_frame, 1),
+        date_Change(&p_sys->pts, fmt_out.i_frame_rate,
                                  fmt_out.i_frame_rate_base);
     else
-        date_Init(&p_sys->pts, fmt_out.i_frame_rate *
-                               __MAX(ctx->ticks_per_frame, 1),
+        date_Init(&p_sys->pts, fmt_out.i_frame_rate,
                                fmt_out.i_frame_rate_base);
 
     fmt_out.p_palette = dec->fmt_out.video.p_palette;
@@ -1052,9 +1049,11 @@ static vlc_tick_t interpolate_next_pts( decoder_t *p_dec, AVFrame *frame )
         date_Get( &p_sys->pts ) == VLC_TICK_INVALID )
         return VLC_TICK_INVALID;
 
+#if LIBAVCODEC_VERSION_CHECK( 60, 12, 100 )
+    int i_tick = p_context->codec_descriptor->props & AV_CODEC_PROP_FIELDS ? 2 : 1;
+#else
     int i_tick = p_context->ticks_per_frame;
-    if( i_tick <= 0 )
-        i_tick = 1;
+#endif
 
     /* interpolate the next PTS */
     return date_Increment( &p_sys->pts, i_tick + frame->repeat_pict );



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5a32d3bfc004476754bd09ae3180a1aed86fcfc0...47b878be880242637aea7a0ea2fa0aa4d6794cde

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5a32d3bfc004476754bd09ae3180a1aed86fcfc0...47b878be880242637aea7a0ea2fa0aa4d6794cde
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list