[FFmpeg-devel] [PATCH] avcodec/h264_parser: set missing pts for top/bottom field frames

Paul B Mahol onemda at gmail.com
Wed Sep 14 22:19:13 EEST 2016


On 9/14/16, Michael Niedermayer <michael at niedermayer.cc> wrote:
> On Wed, Sep 14, 2016 at 04:42:59PM +0200, Paul B Mahol wrote:
>> Adopted from 4eb49fdde8f84d54a763cfb5d355527b525ee2bf revert.
>>
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>>  libavcodec/h264_parser.c | 22 ++++++++++++++++++++++
>>  1 file changed, 22 insertions(+)
>>
>> diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
>> index 615884f..cf6c3d1 100644
>> --- a/libavcodec/h264_parser.c
>> +++ b/libavcodec/h264_parser.c
>> @@ -60,6 +60,7 @@ typedef struct H264ParseContext {
>>      uint8_t parse_history[6];
>>      int parse_history_count;
>>      int parse_last_mb;
>> +    int64_t reference_dts;
>>  } H264ParseContext;
>>
>>
>> @@ -598,6 +599,26 @@ static int h264_parse(AVCodecParserContext *s,
>>          s->flags &= PARSER_FLAG_COMPLETE_FRAMES;
>>      }
>>
>> +    if (s->dts_sync_point >= 0) {
>> +        int64_t den = avctx->time_base.den * avctx->pkt_timebase.num;
>> +        if (den > 0) {
>> +            int64_t num = avctx->time_base.num *
>> avctx->pkt_timebase.den;
>
> overflows, needs this:
> @@ -600,9 +600,9 @@ static int h264_parse(AVCodecParserContext *s,
>      }
>
>      if (s->dts_sync_point >= 0) {
> -        int64_t den = avctx->time_base.den * avctx->pkt_timebase.num;
> +        int64_t den = avctx->time_base.den *
> (int64_t)avctx->pkt_timebase.num;
>          if (den > 0) {
> -            int64_t num = avctx->time_base.num * avctx->pkt_timebase.den;
> +            int64_t num = avctx->time_base.num *
> (int64_t)avctx->pkt_timebase.den;
>              if (s->dts != AV_NOPTS_VALUE) {
>                  // got DTS from the stream, update reference timestamp
>                  p->reference_dts = s->dts - s->dts_ref_dts_delta * num /
> den;
>
>
> LGTM otherwise
>
> thanks

Sorry, I completely forgot to do this in same patch, got sidetracked
with av_rescale.

Applied.


More information about the ffmpeg-devel mailing list