[vlc-devel] [PATCH 2/3] demux: h26x: fix frame rate

Zhao Zhili quinkblack at foxmail.com
Fri Mar 23 18:38:24 CET 2018


> On 23 Mar 2018, at 11:47 PM, Francois Cartegnie <fcvlcdev at free.fr> wrote:
> 
> Le 23/03/2018 à 14:30, Zhao Zhili a écrit :
>> Hi,
>> 
>> Any advice on these patches?
> 
> You're mixing both date/rate based timestamps increments,
> and original timestamps, defeating the purpose of using date_t, which is
> designed to avoid roundings errors.
> 

The i_frame_length in demuxer

h26x:
            const mtime_t i_frame_dts = p_block_out->i_dts;
            const mtime_t i_frame_length = p_block_out->i_length;
            es_out_Send( p_demux->out, p_sys->p_es, p_block_out );

is already mixed up in h264 packetizer:

    if( p_pic->i_length == 0 )
    {
        if( p_sps->vui.i_time_scale )
        {
            p_pic->i_length = CLOCK_FREQ * i_num_clock_ts *
                              p_sps->vui.i_num_units_in_tick / p_sps->vui.i_time_scale;
        }
        else
        {
            date_t next = p_sys->dts;
            date_Increment( &next, i_num_clock_ts );
            p_pic->i_length = date_Get( &next ) - date_Get( &p_sys->dts );
        }
    }


And the calculation of i_nb_fields can be rounded from 1.99... to 1

                    i_nb_fields = i_frame_length * 2 * p_sys->frame_rate_num /
                                  ( p_sys->frame_rate_den * CLOCK_FREQ );

So for the timestamp issue I'm not sure which part need to be fixed.

>> 
>> On 2018年03月20日 17:17, Zhao Zhili wrote:
>>> The packetizer doesn't try to get the real frame rate once a default
>>> value is set.
>>> ---
>>>   modules/demux/mpeg/h26x.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/modules/demux/mpeg/h26x.c b/modules/demux/mpeg/h26x.c
>>> index 053040b..0e04d80 100644
>>> --- a/modules/demux/mpeg/h26x.c
>>> +++ b/modules/demux/mpeg/h26x.c
>>> @@ -354,8 +354,8 @@ static int GenericOpen( demux_t *p_demux, const
>>> char *psz_module,
>>>         /* Load the mpegvideo packetizer */
>>>       es_format_Init( &fmt, VIDEO_ES, i_codec );
>>> -    fmt.video.i_frame_rate = p_sys->dts.i_divider_num;
>>> -    fmt.video.i_frame_rate_base = p_sys->dts.i_divider_den;
>>> +    fmt.video.i_frame_rate = p_sys->frame_rate_num;
>>> +    fmt.video.i_frame_rate_base = p_sys->frame_rate_den;
>>>       p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt,
>>> psz_module );
>>>       if( !p_sys->p_packetizer )
>>>       {
>> 
>> 
>> 
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> 
> 
> -- 
> Francois Cartegnie
> VideoLAN - VLC Developer
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list