From patchwork Sat Jun 5 15:01:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 28093 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2030131iof; Sat, 5 Jun 2021 08:02:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTPPau8KECGoyvOYeZthzoxPm0gbKHKcDKAgr+vsiAkF92U5kC/QqK2xy2VoGGVUf5+Lgv X-Received: by 2002:a17:907:779a:: with SMTP id ky26mr9447046ejc.293.1622905340268; Sat, 05 Jun 2021 08:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622905340; cv=none; d=google.com; s=arc-20160816; b=N1JFgXoOQ4B26NFgmwXkma1F5JTb3u1JSNuHtF0bKBJabH4K0OFt68nDH2WNQJSO3t AQt+CHYM1sbhXGSsqu+ArMelKIm/0k73ttt+d6Vf6IcePkLA/HhQ5PLtXfqRR+OJYcpT QQB8W4hTRWkmVg4jHehiVjOmmyDsYbCj45u3FkTW3DyzZKYerdryKFIftsrfa13ebxl1 BcZjtpC50AlL30l3Ldpsw2+wwRyM53TrHjU7NNshIG9qSg8ifdt733kHSX6jZZNnAgxF rJRbmS18Xsq/eWwDLNhZc9c+CjggpRXyMUpzvpAboZQhRv5yDAnbR2z4nX9URyfNR7bv qliA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=8gG/vy7/xMHefDdaJCFaRBb8e1Bv4mSdok31WqLQuEU=; b=wgot7XgaemKuNVvbC3XzEmRp6mhhTxVdgDRwsXo54WMPYUuAA3T/7Q9C9z1y91YXvN VA4vs3DqjcV2VmCRRz1l1wM6PMUf9XeXSZCzhwBMPrt+H2U60ImgpMK21/oNbptbD8xw I4264z0w6hUxR2AsT0StErr2VMoH0Eb95/XeNKbYunuetwpTxm5/OCABN0iGp1OiegXU n+4BT7iFEsvHjVJEfcSAqHPHnc2CgEv8t97RdHAhyLLSJGQpuJSAwrAZk9oz0RHUQaV4 vUPkW0Se+NivU8WuzS66uqiWkg1zWdH7VJumpF3d3Zxrq7Iro9VXhEzZM3EG5zNhPw98 sVUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=QnKdvO1l; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i11si9323261edb.418.2021.06.05.08.02.19; Sat, 05 Jun 2021 08:02:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=QnKdvO1l; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8726E68A538; Sat, 5 Jun 2021 18:02:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C15E68A4FA for ; Sat, 5 Jun 2021 18:02:11 +0300 (EEST) Received: by mail-qk1-f179.google.com with SMTP id j184so12364519qkd.6 for ; Sat, 05 Jun 2021 08:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=41seoTm+FLwxjRuHmqFRN9oFuHBNUZWGMZ25Pv6+pIM=; b=QnKdvO1l3X0SKWMSHQvdOwPtmyERb/UsHtSiavUVWrqmJrc3/umcXcfl030P8cer42 IhFR/rOHHHG0dm5HUpnN2Nn49y0b7jR9nG74GyORkXuJl6qzQASjzl+GtjAgumkaqZN/ rhi3h3S+1SHyf5LJORioInuw0TAGPtUkBlNmwj1ArOdgVuAfqI4dxwJ4IX0t0bRYfzdj mOKLhwgj7pqxyaVVCr9a7Z/yPqFOep6Epj6ncVEq8Z/aAARo4RPew6rItYAzSKy1sTFh 9BJ4MQA8dPrD3XpJejGgIUQUGTy0nBpE1ZMYmjdFKzQH67sSzWDQQK3aiFbq282woPb/ KlOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=41seoTm+FLwxjRuHmqFRN9oFuHBNUZWGMZ25Pv6+pIM=; b=qCBJN5ONmQyC7tDlPjJMheMInYfVpfcarSHC1tAltj50c0A983nvxRSTaPcgAUwWpA 15xL1axVW5V65uEpHDr4QzXOzulRnDBamM5yql02kIJpm2zuIrGq1Ja9w6jWH7RV3WKl sE/wVrkIATb6wRlIcqYbKkroTCoJHLG+8Lolw8xj+EpK4CYlr9En/wU495JiUl8NRSor tecdNWB7J+Xchu3xJ2hbmlksLr2fTUrzkB5NEbStmPXncyeIe0ZmbPXaYIbDmVJeDUnd Qy2I9tcBOryyeiLU96JWtObXjgk3ciVDMXLQdpY72cCcWWtdjiHiALTW/cQ7/wOHhhGT 1FiA== X-Gm-Message-State: AOAM533+bsGsCz6Y6bRu/H/Dy2I4PvzFwJYElz0z5MXOSDef1Ha6PyXN RRhoCIjiD2LZefQgo16Ia+/8fCeQ+dM= X-Received: by 2002:a05:620a:1021:: with SMTP id a1mr8974592qkk.399.1622905329200; Sat, 05 Jun 2021 08:02:09 -0700 (PDT) Received: from localhost.localdomain ([191.83.217.13]) by smtp.gmail.com with ESMTPSA id w4sm4706044qtv.79.2021.06.05.08.02.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Jun 2021 08:02:08 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Jun 2021 12:01:47 -0300 Message-Id: <20210605150149.2334-1-jamrial@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/utils: make ff_update_cur_dts() an avpriv function X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +lw92UaMf9eV libavdevice needs it. Signed-off-by: James Almer --- libavformat/aadec.c | 4 ++-- libavformat/brstm.c | 2 +- libavformat/idcin.c | 2 +- libavformat/internal.h | 2 +- libavformat/matroskadec.c | 2 +- libavformat/mca.c | 2 +- libavformat/mp3dec.c | 2 +- libavformat/mpc8.c | 2 +- libavformat/mxfdec.c | 4 ++-- libavformat/utils.c | 8 ++++---- libavformat/vpk.c | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libavformat/aadec.c b/libavformat/aadec.c index 9fe24d5d53..70df0439bd 100644 --- a/libavformat/aadec.c +++ b/libavformat/aadec.c @@ -238,7 +238,7 @@ static int aa_read_header(AVFormatContext *s) st->duration = (largest_size - CHAPTER_HEADER_SIZE * s->nb_chapters) * TIMEPREC; - ff_update_cur_dts(s, st, 0); + avpriv_update_cur_dts(s, st, 0); avio_seek(pb, start, SEEK_SET); c->current_chapter_size = 0; c->seek_offset = 0; @@ -365,7 +365,7 @@ static int aa_read_seek(AVFormatContext *s, c->seek_offset = (MP3_FRAME_SIZE - chapter_pos % MP3_FRAME_SIZE) % MP3_FRAME_SIZE; } - ff_update_cur_dts(s, s->streams[0], ch->start + (chapter_pos + c->seek_offset) * TIMEPREC); + avpriv_update_cur_dts(s, s->streams[0], ch->start + (chapter_pos + c->seek_offset) * TIMEPREC); return 1; } diff --git a/libavformat/brstm.c b/libavformat/brstm.c index f1f0f86ed5..601f73dd33 100644 --- a/libavformat/brstm.c +++ b/libavformat/brstm.c @@ -477,7 +477,7 @@ static int read_seek(AVFormatContext *s, int stream_index, return ret; b->current_block = timestamp; - ff_update_cur_dts(s, st, timestamp * b->samples_per_block); + avpriv_update_cur_dts(s, st, timestamp * b->samples_per_block); return 0; } diff --git a/libavformat/idcin.c b/libavformat/idcin.c index 0c38d880f4..b7402107da 100644 --- a/libavformat/idcin.c +++ b/libavformat/idcin.c @@ -358,7 +358,7 @@ static int idcin_read_seek(AVFormatContext *s, int stream_index, int64_t ret = avio_seek(s->pb, idcin->first_pkt_pos, SEEK_SET); if (ret < 0) return ret; - ff_update_cur_dts(s, s->streams[idcin->video_stream_index], 0); + avpriv_update_cur_dts(s, s->streams[idcin->video_stream_index], 0); idcin->next_chunk_is_video = 1; idcin->current_audio_chunk = 0; return 0; diff --git a/libavformat/internal.h b/libavformat/internal.h index 970fccf6c2..9882454d59 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -635,7 +635,7 @@ int ff_seek_frame_binary(AVFormatContext *s, int stream_index, * @param timestamp new dts expressed in time_base of param ref_st * @param ref_st reference stream giving time_base of param timestamp */ -void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); +void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); int ff_find_last_ts(AVFormatContext *s, int stream_index, int64_t *ts, int64_t *pos, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 73e1ddb68d..356a02339c 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3859,7 +3859,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, } matroska->skip_to_keyframe = 1; matroska->done = 0; - ff_update_cur_dts(s, st, st->internal->index_entries[index].timestamp); + avpriv_update_cur_dts(s, st, st->internal->index_entries[index].timestamp); return 0; err: // slightly hackish but allows proper fallback to diff --git a/libavformat/mca.c b/libavformat/mca.c index 0fd5ce8aaf..ca0f76d6bf 100644 --- a/libavformat/mca.c +++ b/libavformat/mca.c @@ -213,7 +213,7 @@ static int read_seek(AVFormatContext *s, int stream_index, return ret; m->current_block = timestamp; - ff_update_cur_dts(s, st, timestamp * m->samples_per_block); + avpriv_update_cur_dts(s, st, timestamp * m->samples_per_block); return 0; } diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index b12cd31148..c6949e6095 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -589,7 +589,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, ie1.timestamp = frame_duration * av_rescale(best_pos - s->internal->data_offset, mp3->frames, mp3->header_filesize); } - ff_update_cur_dts(s, st, ie->timestamp); + avpriv_update_cur_dts(s, st, ie->timestamp); return 0; } diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index ff6f43231c..5498ce940d 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -320,7 +320,7 @@ static int mpc8_read_seek(AVFormatContext *s, int stream_index, int64_t timestam if(index < 0) return -1; if (avio_seek(s->pb, st->internal->index_entries[index].pos, SEEK_SET) < 0) return -1; - ff_update_cur_dts(s, st, st->internal->index_entries[index].timestamp); + avpriv_update_cur_dts(s, st, st->internal->index_entries[index].timestamp); return 0; } diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 3bf480a3a6..e489e59e5d 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -3815,7 +3815,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti if (seekpos < 0) return seekpos; - ff_update_cur_dts(s, st, sample_time); + avpriv_update_cur_dts(s, st, sample_time); mxf->current_klv_data = (KLVPacket){{0}}; } else { MXFPartition *partition; @@ -3868,7 +3868,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, source_track->edit_rate, &sample_time, &seekpos, &partition, 1)) < 0) return ret; - ff_update_cur_dts(s, st, sample_time); + avpriv_update_cur_dts(s, st, sample_time); if (source_track->wrapping == ClipWrapped) { KLVPacket klv = partition->first_essence_klv; if (seekpos < klv.next_klv - klv.length || seekpos >= klv.next_klv) { diff --git a/libavformat/utils.c b/libavformat/utils.c index fe8eaa6cb3..13c0ade5ba 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1848,7 +1848,7 @@ void ff_read_frame_flush(AVFormatContext *s) } } -void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) +void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) { int i; @@ -2156,7 +2156,7 @@ int ff_seek_frame_binary(AVFormatContext *s, int stream_index, return ret; ff_read_frame_flush(s); - ff_update_cur_dts(s, st, ts); + avpriv_update_cur_dts(s, st, ts); return 0; } @@ -2350,7 +2350,7 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index, ie = &st->internal->index_entries[st->internal->nb_index_entries - 1]; if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0) return ret; - ff_update_cur_dts(s, st, ie->timestamp); + avpriv_update_cur_dts(s, st, ie->timestamp); } else { if ((ret = avio_seek(s->pb, s->internal->data_offset, SEEK_SET)) < 0) return ret; @@ -2388,7 +2388,7 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index, ie = &st->internal->index_entries[index]; if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0) return ret; - ff_update_cur_dts(s, st, ie->timestamp); + avpriv_update_cur_dts(s, st, ie->timestamp); return 0; } diff --git a/libavformat/vpk.c b/libavformat/vpk.c index 9eb3eb5362..d542a0806d 100644 --- a/libavformat/vpk.c +++ b/libavformat/vpk.c @@ -130,7 +130,7 @@ static int vpk_read_seek(AVFormatContext *s, int stream_index, return ret; vpk->current_block = timestamp; - ff_update_cur_dts(s, st, timestamp * samples_per_block); + avpriv_update_cur_dts(s, st, timestamp * samples_per_block); return 0; } From patchwork Sat Jun 5 15:01:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 28094 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2030249iof; Sat, 5 Jun 2021 08:02:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOXJ7eWDIxCruN4d5K1VKTBnXNN8cOPnG6F//RG+aUxP/r7ihavaCQivY8jmsW7RrFqeou X-Received: by 2002:a17:907:2bf9:: with SMTP id gv57mr9588233ejc.189.1622905349855; Sat, 05 Jun 2021 08:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622905349; cv=none; d=google.com; s=arc-20160816; b=lGAROdHJJlmY0JroC0MWZEKvivb+e47Dq47JvUpA6ru2erHZC0d46+YaNerdfI9ZlH EX+hst9tqRv3MvyE/+TIoENISLoeAN4UZVm3IV4dMiGqhcr9I/3rlocBjQzgoIaSPK3D UpouZ/a8Pnf8++pdIJFTZZb/uHd95NYdJf6XH4JYbhpjIDhhf5Kcj/yvjQvXkPqnBXKz zMAzeK4yWeiYIJbJ4Ks2B86bCxVLM7KvRZ+4zD7+0SNNo5d2uZehUqrE5bPLm+D9dGSl m8C0zYOOx7TM1LKL1Cyki3BIT2lB2LAgoLV0D/FZMZixHXa0DjYbbSRfRE6NdtjHQgwv YKzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=X/rJSFYW4Pbvbb61n1f96n2NNuvUC4ZD7OHtmu+YIQY=; b=eweas2UoEww9JK2T4UsA0QeF+z7G9vUzcXihSSgveqVYfSCwNLTdmKH+di52egjLhe 6tzJ6DfUqps/zz/+i2j/s824EEYM1uJgccM1yrHvBHTMrpJt8LNqwuBYoo8qJoi9XaiG EjFqdrVi8NLep1CE4Fw/7C/sDqI91Pqo8lL5IbzFSSBbrGA9P5l712CueCYeQNl5dayQ keK4N0uve/4NJiuP25rxec6qXHa+opgn94yGycMbJFvSJUswgFnW+aZOfg/frbJqWJqT O5UXaEWwXHAug+vcazweLuHHszETmyq7dIb7XOhW3nQWIV24Mng6EzZWI9dRE+cHr2Gk LnvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=eCyrkuVK; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b13si8600703ede.412.2021.06.05.08.02.29; Sat, 05 Jun 2021 08:02:29 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=eCyrkuVK; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 77D9468A548; Sat, 5 Jun 2021 18:02:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D96FE68A506 for ; Sat, 5 Jun 2021 18:02:11 +0300 (EEST) Received: by mail-qk1-f177.google.com with SMTP id r17so12329223qkp.10 for ; Sat, 05 Jun 2021 08:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xqVrh3HrNze3OVzv5u3QhvYfmBscGQn2qZn4OEiaBeY=; b=eCyrkuVKmYrRuvCu63tweUueeVQiqEhL4rYq0niAHiIQ3E35IPJlGTOVwjSCdjkEIK zsAWrzMdJ5lPn5nSXj2wRTGJ06L+TJcs+nF0HTjwp1UGJ06FnErqYd4zkabNZ/+6+HIk IvQ5CZ/7jUXt/p9WyxD6t0r4AnTYODCqS/PrGtyZotQY7UgBeqSwrm6u5/rq6IMXCJj3 z7U7TVjV1ir9F8dQo1AOSfYg/Zdgf5FaEafeVYOpJBVEKEmr40NWg+gClARja/qnUDO4 KGOPjlf0R4LOoP82ePxuJDLRRmgvJMCeDl7JfKyAQSf5gj9Hi34vNO6eF3yUaWjCf+Ej 0uQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xqVrh3HrNze3OVzv5u3QhvYfmBscGQn2qZn4OEiaBeY=; b=I3JdzQDyABhZrFlGHrAJYjAfYJLodnjGUOEuc2PZi3QLURt/5jP8+lea/4cRNCdHZj 9YE2e5ndVGV+Q7Jju5O6atndIy5XKxShtqTlhjB/0d92aOd6qaVeHyX6TmoiZWGB/dFx yamNJ27IGpm04FYab0EoAHNMpX34d4oPEVB3kqUuOxxbGbnvjM1oeEmVX3trkYQwzZR/ BsBBkuPGwTn4RzdkwDAxD0/lf29ks0Ma2PZzPz7luNhBbB8ujMJRc2kM8OyIB1fFgXN9 5mONq8AFiRzS2AKZVo/6cB7Dzcw8H2Eo6VG0pYqA3/AzIZi9uwGl0q60CYTNJHLfnYX/ SBNQ== X-Gm-Message-State: AOAM530J94Lw8NLfkLoqB7b8frSVGF2BxQRP7cHTf5Z1cD3w6zqTBPa2 gn9oK6z0/hE2jgP44QGdG2m9pQejsBY= X-Received: by 2002:a05:620a:1368:: with SMTP id d8mr9361273qkl.283.1622905330356; Sat, 05 Jun 2021 08:02:10 -0700 (PDT) Received: from localhost.localdomain ([191.83.217.13]) by smtp.gmail.com with ESMTPSA id w4sm4706044qtv.79.2021.06.05.08.02.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Jun 2021 08:02:10 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Jun 2021 12:01:48 -0300 Message-Id: <20210605150149.2334-2-jamrial@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210605150149.2334-1-jamrial@gmail.com> References: <20210605150149.2334-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avdevice/libcdio: fix AVStream.cur_dts usage X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: vTwDNrbdPu9G It should not be accessed from outside of libavformat. Signed-off-by: James Almer --- Untested. I'm removing the cur_dts usage from read_packet() because i don't want to add another avpriv function just to read it, and cdio_paranoia_read() should return NULL when there's no more data, so it's probably superfluous. libavdevice/libcdio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavdevice/libcdio.c b/libavdevice/libcdio.c index f1a1468554..dba02d4130 100644 --- a/libavdevice/libcdio.c +++ b/libavdevice/libcdio.c @@ -118,9 +118,6 @@ static int read_packet(AVFormatContext *ctx, AVPacket *pkt) uint16_t *buf; char *err = NULL; - if (ctx->streams[0]->cur_dts > s->last_sector) - return AVERROR_EOF; - buf = cdio_paranoia_read(s->paranoia, NULL); if (!buf) return AVERROR_EOF; @@ -157,7 +154,7 @@ static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, AVStream *st = ctx->streams[0]; cdio_paranoia_seek(s->paranoia, timestamp, SEEK_SET); - st->cur_dts = timestamp; + avpriv_update_cur_dts(ctx, st, timestamp); return 0; } From patchwork Sat Jun 5 15:01:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 28092 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2035077iof; Sat, 5 Jun 2021 08:08:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw23Oh7uPETLUgE2bvM9uzbjv67DPucJxVCetTpEyBtW+lj8tkgjPIhIyHOEiuWCfcvWRp1 X-Received: by 2002:aa7:d284:: with SMTP id w4mr10900924edq.347.1622905725314; Sat, 05 Jun 2021 08:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622905725; cv=none; d=google.com; s=arc-20160816; b=XscYbnNqmYu0uIjI3eFlTLNVdidYfhjISK7tRqTKcD7AFQL0caFexVr20+YAgkwvlZ 3/8XgUhFoX4MHdGOuHJv0iNBFQInbTGx4FZAT84tE+H3al0A5gQgdPQPLEbAyTg/9r6W 4wI80QUzROHbz2CnFJdjxM8YZRRI5ihmCqnMEHd5fcv9yAEKCbOUKRcjji8YwO96nklE wzy5G7QohQsEugqkWXJGhPHOwalYaqm2Q7gpgALVN+V58U4DIZw34AKrbx3deziwEg6K 2SzO/Epb32VjxumoidvxdJssT63Zk3pAhnJgfc2+MbJcnxfVw9K+qbqDAo41NuhEhxEI 73wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=d/Uikk6s4sgHTJpmsndQYjTv8qWYtIj2Y2qFvvyNq58=; b=0rNuYLSoqHnIfRW1XzjbPgUtUtT/eDDa6rqkj6A8LEuHJ0krKiUDO8/Xu/BBopiajN tNwoZpL1oRcZxCEcZ+d1fBef6Slmzcp9B+vOcmW1Fhf31bALqsjuQ2uUcy6yLUa6vm5N biqC1MrMxy6Wz8dvQBUxajai0eMALfhNGKdkQvJIhuqu7mUXk9Gw3YwJUAT/MHcFCFwE lrGXE05ROAGjNKgRCrv8fpTUQTL9efqSSMJvc6+qaHS5EFIv4560CB9kbfxWEJ6JL39h LXzVIk3ZRgIX3KhK3QV/NzZ0dGYbZvVM+F9iq9JpwdK0KdUeF55ddFVHdz9yF8xGaa2k wEeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=u8++PKQD; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j5si7777414eds.204.2021.06.05.08.08.44; Sat, 05 Jun 2021 08:08:45 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=u8++PKQD; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5312568A581; Sat, 5 Jun 2021 18:08:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 66E0868A571 for ; Sat, 5 Jun 2021 18:08:35 +0300 (EEST) Received: by mail-qv1-f48.google.com with SMTP id x2so5870680qvo.8 for ; Sat, 05 Jun 2021 08:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=CmJAHuj6crFE1jg/SiBZkajfm+cq3z6Mc1HeIThdZ/Q=; b=u8++PKQDRnZ4CgHZ3UPuhi0FeQeJaQCNW0WaWfDoZaERPAOmvuRSLzGS07MbqrbzpX E6GogjddaXwjcgGiCPrRcuQM6j4DohoemQc7UZMX2scMWjfUgjL4XTSg9Oes5PgXTaRm lNbAgWbEwBH/Dg5lUQyxBhKyvZQRQrafYrvArsBiEqslvMzX7wtxNpl/JQUU61lP4aaw hgf1N2R0uZAPPHtIKygMInsdsyZwM6a1L+nR4pKkXgKh0uT5Li85kTOS5vXZEESpQs4i VLSIhN9ilnQWvuCB1QhAC/RBkWvQCft0Ur/sZjMcS2t2e6kCJVaonaBGZ4IIcUgoS5rf R/HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CmJAHuj6crFE1jg/SiBZkajfm+cq3z6Mc1HeIThdZ/Q=; b=eP5DH82gmWdz+EqPEx9qhs9HbcVcDxLvIxDL2YwcKYZIVVzPSf2dNaLJv6uCyCxeZg hn/iKNK0QeTuknaw651NUeGQeYkQEBXN1S5Vd4bnWHgXfNKcbPJZMQD4/AP/Bc3lHJHZ o0r1nqZuA2rs/d/IKJEUH1NjIbVZidtGuliN9Q+mK9LKKXnjoYM3+zvvp0FFb3H4xaAa bXcefZ46bdk2b7c/FuQdgz5UoPyu7nlHGMIuRy7obtmV02oXrgzZa/o6H8b6w3psj5NH jG36qN3pxE3pBWbS6m0RFZpXBvHWda63zDsUylse3O/BQ7IWoSCR7h88poLzsyECRz3d /jKQ== X-Gm-Message-State: AOAM532T5mew3Q61QjInluQXIdgGHEME6F5sLfqhhvcAZW4HWdhrstay i38OBfV2INKzLQd8c5bAp+K31dGfOQc= X-Received: by 2002:a0c:d610:: with SMTP id c16mr10054552qvj.13.1622905331609; Sat, 05 Jun 2021 08:02:11 -0700 (PDT) Received: from localhost.localdomain ([191.83.217.13]) by smtp.gmail.com with ESMTPSA id w4sm4706044qtv.79.2021.06.05.08.02.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Jun 2021 08:02:11 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Jun 2021 12:01:49 -0300 Message-Id: <20210605150149.2334-3-jamrial@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210605150149.2334-1-jamrial@gmail.com> References: <20210605150149.2334-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avformat: move AVStream.{first, cur}_dts to AVStreamInternal X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: CBbw/Ll1HfJE They are private fields, no reason to have them exposed in a public header. Signed-off-by: James Almer --- libavformat/avformat.h | 11 ---- libavformat/concatdec.c | 4 +- libavformat/fifo.c | 2 +- libavformat/hdsenc.c | 6 +-- libavformat/internal.h | 12 +++++ libavformat/mux.c | 18 +++---- libavformat/mxfdec.c | 2 +- libavformat/pcm.c | 2 +- libavformat/rdt.c | 4 +- libavformat/sbgdec.c | 6 +-- libavformat/smoothstreamingenc.c | 6 +-- libavformat/tedcaptionsdec.c | 2 +- libavformat/utils.c | 91 +++++++++++++++++--------------- libavformat/vqf.c | 2 +- libavformat/wavdec.c | 4 +- 15 files changed, 89 insertions(+), 83 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index a28ac372da..094683f12a 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -992,17 +992,6 @@ typedef struct AVStream { int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ - // Timestamp generation support: - /** - * Timestamp corresponding to the last dts sync point. - * - * Initialized when AVCodecParserContext.dts_sync_point >= 0 and - * a DTS is received from the underlying container. Otherwise set to - * AV_NOPTS_VALUE by default. - */ - int64_t first_dts; - int64_t cur_dts; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 65fbe0a854..6d77398f48 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -638,8 +638,8 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt) } } - if (cat->cur_file->duration == AV_NOPTS_VALUE && st->cur_dts != AV_NOPTS_VALUE) { - int64_t next_dts = av_rescale_q(st->cur_dts, st->time_base, AV_TIME_BASE_Q); + if (cat->cur_file->duration == AV_NOPTS_VALUE && st->internal->cur_dts != AV_NOPTS_VALUE) { + int64_t next_dts = av_rescale_q(st->internal->cur_dts, st->time_base, AV_TIME_BASE_Q); if (cat->cur_file->next_dts == AV_NOPTS_VALUE || next_dts > cat->cur_file->next_dts) { cat->cur_file->next_dts = next_dts; } diff --git a/libavformat/fifo.c b/libavformat/fifo.c index 50656f78b7..a9b59b6589 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -139,7 +139,7 @@ static int fifo_thread_write_header(FifoThreadContext *ctx) } for (i = 0;i < avf2->nb_streams; i++) - avf2->streams[i]->cur_dts = 0; + avf2->streams[i]->internal->cur_dts = 0; ret = avformat_write_header(avf2, &format_options); if (!ret) diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c index 202855392e..1793fb69d5 100644 --- a/libavformat/hdsenc.c +++ b/libavformat/hdsenc.c @@ -504,11 +504,11 @@ static int hds_write_packet(AVFormatContext *s, AVPacket *pkt) int64_t end_dts = os->fragment_index * (int64_t)c->min_frag_duration; int ret; - if (st->first_dts == AV_NOPTS_VALUE) - st->first_dts = pkt->dts; + if (st->internal->first_dts == AV_NOPTS_VALUE) + st->internal->first_dts = pkt->dts; if ((!os->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && - av_compare_ts(pkt->dts - st->first_dts, st->time_base, + av_compare_ts(pkt->dts - st->internal->first_dts, st->time_base, end_dts, AV_TIME_BASE_Q) >= 0 && pkt->flags & AV_PKT_FLAG_KEY && os->packets_written) { diff --git a/libavformat/internal.h b/libavformat/internal.h index 9882454d59..2da2030074 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -389,9 +389,21 @@ struct AVStreamInternal { * 0 means unknown */ int stream_identifier; + + // Timestamp generation support: + /** + * Timestamp corresponding to the last dts sync point. + * + * Initialized when AVCodecParserContext.dts_sync_point >= 0 and + * a DTS is received from the underlying container. Otherwise set to + * AV_NOPTS_VALUE by default. + */ + int64_t first_dts; + int64_t cur_dts; }; void avpriv_stream_set_need_parsing(AVStream *st, enum AVStreamParseType type); +int64_t avpriv_stream_get_cur_dts(AVStream *st); #ifdef __GNUC__ #define dynarray_add(tab, nb_ptr, elem)\ diff --git a/libavformat/mux.c b/libavformat/mux.c index eab58aa225..d719e16283 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -525,7 +525,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * if (s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "compute_muxer_pkt_fields: pts:%s dts:%s cur_dts:%s b:%d size:%d st:%d\n", - av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), delay, pkt->size, pkt->stream_index); + av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->internal->cur_dts), delay, pkt->size, pkt->stream_index); if (pkt->pts == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE && delay == 0) pkt->pts = pkt->dts; @@ -553,14 +553,14 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * pkt->dts = st->internal->pts_buffer[0]; } - if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && + if (st->internal->cur_dts && st->internal->cur_dts != AV_NOPTS_VALUE && ((!(s->oformat->flags & AVFMT_TS_NONSTRICT) && st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE && st->codecpar->codec_type != AVMEDIA_TYPE_DATA && - st->cur_dts >= pkt->dts) || st->cur_dts > pkt->dts)) { + st->internal->cur_dts >= pkt->dts) || st->internal->cur_dts > pkt->dts)) { av_log(s, AV_LOG_ERROR, "Application provided invalid, non monotonically increasing dts to muxer in stream %d: %s >= %s\n", - st->index, av_ts2str(st->cur_dts), av_ts2str(pkt->dts)); + st->index, av_ts2str(st->internal->cur_dts), av_ts2str(pkt->dts)); return AVERROR(EINVAL); } if (pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts < pkt->dts) { @@ -575,7 +575,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * av_log(s, AV_LOG_DEBUG, "av_write_frame: pts2:%s dts2:%s\n", av_ts2str(pkt->pts), av_ts2str(pkt->dts)); - st->cur_dts = pkt->dts; + st->internal->cur_dts = pkt->dts; st->internal->priv_pts->val = pkt->dts; /* update pts */ @@ -763,13 +763,13 @@ static int prepare_input_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt) /* check that the dts are increasing (or at least non-decreasing, * if the format allows it */ - if (st->cur_dts != AV_NOPTS_VALUE && - ((!(s->oformat->flags & AVFMT_TS_NONSTRICT) && st->cur_dts >= pkt->dts) || - st->cur_dts > pkt->dts)) { + if (st->internal->cur_dts != AV_NOPTS_VALUE && + ((!(s->oformat->flags & AVFMT_TS_NONSTRICT) && st->internal->cur_dts >= pkt->dts) || + st->internal->cur_dts > pkt->dts)) { av_log(s, AV_LOG_ERROR, "Application provided invalid, non monotonically increasing " "dts to muxer in stream %d: %" PRId64 " >= %" PRId64 "\n", - st->index, st->cur_dts, pkt->dts); + st->index, st->internal->cur_dts, pkt->dts); return AVERROR(EINVAL); } diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index e489e59e5d..979bdedb6c 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1766,7 +1766,7 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf, MXFIndexTable *index_ta * 6: 5 5 * * We do this by bucket sorting x by x+TemporalOffset[x] into mxf->ptses, - * then settings mxf->first_dts = -max(TemporalOffset[x]). + * then settings mxf->internal->first_dts = -max(TemporalOffset[x]). * The latter makes DTS <= PTS. */ for (i = x = 0; i < index_table->nb_segments; i++) { diff --git a/libavformat/pcm.c b/libavformat/pcm.c index 1effc0b6f8..0e5443a826 100644 --- a/libavformat/pcm.c +++ b/libavformat/pcm.c @@ -79,7 +79,7 @@ int ff_pcm_read_seek(AVFormatContext *s, pos *= block_align; /* recompute exact position */ - st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num); + st->internal->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num); if ((ret = avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET)) < 0) return ret; return 0; diff --git a/libavformat/rdt.c b/libavformat/rdt.c index e5824f6a48..da55503ea6 100644 --- a/libavformat/rdt.c +++ b/libavformat/rdt.c @@ -415,7 +415,7 @@ rdt_parse_sdp_line (AVFormatContext *s, int st_index, if (av_strstart(p, "OpaqueData:buffer;", &p)) { rdt->mlti_data = rdt_parse_b64buf(&rdt->mlti_data_size, p); } else if (av_strstart(p, "StartTime:integer;", &p)) - stream->first_dts = atoi(p); + stream->internal->first_dts = atoi(p); else if (av_strstart(p, "ASMRuleBook:string;", &p)) { int n, first = -1; @@ -465,7 +465,7 @@ add_dstream(AVFormatContext *s, AVStream *orig_st) return NULL; st->id = orig_st->id; st->codecpar->codec_type = orig_st->codecpar->codec_type; - st->first_dts = orig_st->first_dts; + st->internal->first_dts = orig_st->internal->first_dts; return st; } diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c index 7b9ada569e..dafdc4a1cc 100644 --- a/libavformat/sbgdec.c +++ b/libavformat/sbgdec.c @@ -1444,7 +1444,7 @@ static av_cold int sbg_read_header(AVFormatContext *avf) st->duration = script.end_ts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE : av_rescale(script.end_ts - script.start_ts, sbg->sample_rate, AV_TIME_BASE); - st->cur_dts = st->start_time; + st->internal->cur_dts = st->start_time; r = encode_intervals(&script, st->codecpar, &inter); if (r < 0) goto fail; @@ -1465,7 +1465,7 @@ static int sbg_read_packet(AVFormatContext *avf, AVPacket *packet) int64_t ts, end_ts; int ret; - ts = avf->streams[0]->cur_dts; + ts = avf->streams[0]->internal->cur_dts; end_ts = ts + avf->streams[0]->codecpar->frame_size; if (avf->streams[0]->duration != AV_NOPTS_VALUE) end_ts = FFMIN(avf->streams[0]->start_time + avf->streams[0]->duration, @@ -1488,7 +1488,7 @@ static int sbg_read_seek2(AVFormatContext *avf, int stream_index, return AVERROR(EINVAL); if (stream_index < 0) ts = av_rescale_q(ts, AV_TIME_BASE_Q, avf->streams[0]->time_base); - avf->streams[0]->cur_dts = ts; + avf->streams[0]->internal->cur_dts = ts; return 0; } diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index a18fbd07d9..65ef942367 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -586,11 +586,11 @@ static int ism_write_packet(AVFormatContext *s, AVPacket *pkt) int64_t end_dts = (c->nb_fragments + 1) * (int64_t) c->min_frag_duration; int ret; - if (st->first_dts == AV_NOPTS_VALUE) - st->first_dts = pkt->dts; + if (st->internal->first_dts == AV_NOPTS_VALUE) + st->internal->first_dts = pkt->dts; if ((!c->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && - av_compare_ts(pkt->dts - st->first_dts, st->time_base, + av_compare_ts(pkt->dts - st->internal->first_dts, st->time_base, end_dts, AV_TIME_BASE_Q) >= 0 && pkt->flags & AV_PKT_FLAG_KEY && os->packets_written) { diff --git a/libavformat/tedcaptionsdec.c b/libavformat/tedcaptionsdec.c index 6e87ef66e9..8bebaba5c0 100644 --- a/libavformat/tedcaptionsdec.c +++ b/libavformat/tedcaptionsdec.c @@ -302,7 +302,7 @@ static av_cold int tedcaptions_read_header(AVFormatContext *avf) st->internal->probe_packets = 0; st->start_time = 0; st->duration = last->pts + last->duration; - st->cur_dts = 0; + st->internal->cur_dts = 0; return 0; } diff --git a/libavformat/utils.c b/libavformat/utils.c index 13c0ade5ba..a5d944358e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -131,6 +131,11 @@ void avpriv_stream_set_need_parsing(AVStream *st, enum AVStreamParseType type) st->internal->need_parsing = type; } +int64_t avpriv_stream_get_cur_dts(AVStream *st) +{ + return st->internal->cur_dts; +} + void av_format_inject_global_side_data(AVFormatContext *s) { int i; @@ -842,12 +847,12 @@ FF_ENABLE_DEPRECATION_WARNINGS if (update_wrap_reference(s, st, pkt->stream_index, pkt) && st->internal->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) { // correct first time stamps to negative values - if (!is_relative(st->first_dts)) - st->first_dts = wrap_timestamp(st, st->first_dts); + if (!is_relative(st->internal->first_dts)) + st->internal->first_dts = wrap_timestamp(st, st->internal->first_dts); if (!is_relative(st->start_time)) st->start_time = wrap_timestamp(st, st->start_time); - if (!is_relative(st->cur_dts)) - st->cur_dts = wrap_timestamp(st, st->cur_dts); + if (!is_relative(st->internal->cur_dts)) + st->internal->cur_dts = wrap_timestamp(st, st->internal->cur_dts); } pkt->dts = wrap_timestamp(st, pkt->dts); @@ -1071,17 +1076,17 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, uint64_t shift; - if (st->first_dts != AV_NOPTS_VALUE || + if (st->internal->first_dts != AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE || - st->cur_dts == AV_NOPTS_VALUE || - st->cur_dts < INT_MIN + RELATIVE_TS_BASE || - dts < INT_MIN + (st->cur_dts - RELATIVE_TS_BASE) || + st->internal->cur_dts == AV_NOPTS_VALUE || + st->internal->cur_dts < INT_MIN + RELATIVE_TS_BASE || + dts < INT_MIN + (st->internal->cur_dts - RELATIVE_TS_BASE) || is_relative(dts)) return; - st->first_dts = dts - (st->cur_dts - RELATIVE_TS_BASE); - st->cur_dts = dts; - shift = (uint64_t)st->first_dts - RELATIVE_TS_BASE; + st->internal->first_dts = dts - (st->internal->cur_dts - RELATIVE_TS_BASE); + st->internal->cur_dts = dts; + shift = (uint64_t)st->internal->first_dts - RELATIVE_TS_BASE; if (is_relative(pts)) pts += shift; @@ -1121,11 +1126,11 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, PacketList *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue; int64_t cur_dts = RELATIVE_TS_BASE; - if (st->first_dts != AV_NOPTS_VALUE) { + if (st->internal->first_dts != AV_NOPTS_VALUE) { if (st->internal->update_initial_durations_done) return; st->internal->update_initial_durations_done = 1; - cur_dts = st->first_dts; + cur_dts = st->internal->first_dts; for (; pktl; pktl = get_next_pkt(s, st, pktl)) { if (pktl->pkt.stream_index == stream_index) { if (pktl->pkt.pts != pktl->pkt.dts || @@ -1135,18 +1140,18 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, cur_dts -= duration; } } - if (pktl && pktl->pkt.dts != st->first_dts) { + if (pktl && pktl->pkt.dts != st->internal->first_dts) { av_log(s, AV_LOG_DEBUG, "first_dts %s not matching first dts %s (pts %s, duration %"PRId64") in the queue\n", - av_ts2str(st->first_dts), av_ts2str(pktl->pkt.dts), av_ts2str(pktl->pkt.pts), pktl->pkt.duration); + av_ts2str(st->internal->first_dts), av_ts2str(pktl->pkt.dts), av_ts2str(pktl->pkt.pts), pktl->pkt.duration); return; } if (!pktl) { - av_log(s, AV_LOG_DEBUG, "first_dts %s but no packet with dts in the queue\n", av_ts2str(st->first_dts)); + av_log(s, AV_LOG_DEBUG, "first_dts %s but no packet with dts in the queue\n", av_ts2str(st->internal->first_dts)); return; } pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue; - st->first_dts = cur_dts; - } else if (st->cur_dts != RELATIVE_TS_BASE) + st->internal->first_dts = cur_dts; + } else if (st->internal->cur_dts != RELATIVE_TS_BASE) return; for (; pktl; pktl = get_next_pkt(s, st, pktl)) { @@ -1155,7 +1160,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, if ((pktl->pkt.pts == pktl->pkt.dts || pktl->pkt.pts == AV_NOPTS_VALUE) && (pktl->pkt.dts == AV_NOPTS_VALUE || - pktl->pkt.dts == st->first_dts || + pktl->pkt.dts == st->internal->first_dts || pktl->pkt.dts == RELATIVE_TS_BASE) && !pktl->pkt.duration) { pktl->pkt.dts = cur_dts; @@ -1167,7 +1172,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, cur_dts = pktl->pkt.dts + pktl->pkt.duration; } if (!pktl) - st->cur_dts = cur_dts; + st->internal->cur_dts = cur_dts; } static void compute_pkt_fields(AVFormatContext *s, AVStream *st, @@ -1226,7 +1231,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, if (pkt->pts != AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE && st->pts_wrap_bits < 63 && pkt->dts > INT64_MIN + (1LL << st->pts_wrap_bits) && pkt->dts - (1LL << (st->pts_wrap_bits - 1)) > pkt->pts) { - if (is_relative(st->cur_dts) || pkt->dts - (1LL<<(st->pts_wrap_bits - 1)) > st->cur_dts) { + if (is_relative(st->internal->cur_dts) || pkt->dts - (1LL<<(st->pts_wrap_bits - 1)) > st->internal->cur_dts) { pkt->dts -= 1LL << st->pts_wrap_bits; } else pkt->pts += 1LL << st->pts_wrap_bits; @@ -1279,7 +1284,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, if (s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%"PRId64" delay:%d onein_oneout:%d\n", - presentation_delayed, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), + presentation_delayed, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->internal->cur_dts), pkt->stream_index, pc, pkt->duration, delay, onein_oneout); /* Interpolate PTS and DTS if they are not present. We skip H264 @@ -1293,18 +1298,18 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, pkt->dts = st->internal->last_IP_pts; update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt); if (pkt->dts == AV_NOPTS_VALUE) - pkt->dts = st->cur_dts; + pkt->dts = st->internal->cur_dts; /* This is tricky: the dts must be incremented by the duration * of the frame we are displaying, i.e. the last I- or P-frame. */ if (st->internal->last_IP_duration == 0 && (uint64_t)pkt->duration <= INT32_MAX) st->internal->last_IP_duration = pkt->duration; if (pkt->dts != AV_NOPTS_VALUE) - st->cur_dts = av_sat_add64(pkt->dts, st->internal->last_IP_duration); + st->internal->cur_dts = av_sat_add64(pkt->dts, st->internal->last_IP_duration); if (pkt->dts != AV_NOPTS_VALUE && pkt->pts == AV_NOPTS_VALUE && st->internal->last_IP_duration > 0 && - ((uint64_t)st->cur_dts - (uint64_t)next_dts + 1) <= 2 && + ((uint64_t)st->internal->cur_dts - (uint64_t)next_dts + 1) <= 2 && next_dts != next_pts && next_pts != AV_NOPTS_VALUE) pkt->pts = next_dts; @@ -1324,10 +1329,10 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, update_initial_timestamps(s, pkt->stream_index, pkt->pts, pkt->pts, pkt); if (pkt->pts == AV_NOPTS_VALUE) - pkt->pts = st->cur_dts; + pkt->pts = st->internal->cur_dts; pkt->dts = pkt->pts; if (pkt->pts != AV_NOPTS_VALUE && duration.num >= 0) - st->cur_dts = av_add_stable(st->time_base, pkt->pts, duration, 1); + st->internal->cur_dts = av_add_stable(st->time_base, pkt->pts, duration, 1); } } @@ -1343,12 +1348,12 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, if (!onein_oneout) // This should happen on the first packet update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt); - if (pkt->dts > st->cur_dts) - st->cur_dts = pkt->dts; + if (pkt->dts > st->internal->cur_dts) + st->internal->cur_dts = pkt->dts; if (s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s st:%d (%d)\n", - presentation_delayed, delay, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), st->index, st->id); + presentation_delayed, delay, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->internal->cur_dts), st->index, st->id); /* update flags */ if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA || ff_is_intra_only(st->codecpar->codec_id)) @@ -1830,11 +1835,11 @@ void ff_read_frame_flush(AVFormatContext *s) } st->internal->last_IP_pts = AV_NOPTS_VALUE; st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; - if (st->first_dts == AV_NOPTS_VALUE) - st->cur_dts = RELATIVE_TS_BASE; + if (st->internal->first_dts == AV_NOPTS_VALUE) + st->internal->cur_dts = RELATIVE_TS_BASE; else /* We set the current DTS to an unspecified origin. */ - st->cur_dts = AV_NOPTS_VALUE; + st->internal->cur_dts = AV_NOPTS_VALUE; st->internal->probe_packets = s->max_probe_packets; @@ -1855,7 +1860,7 @@ void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timesta for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; - st->cur_dts = + st->internal->cur_dts = av_rescale(timestamp, st->time_base.den * (int64_t) ref_st->time_base.num, st->time_base.num * (int64_t) ref_st->time_base.den); @@ -2736,7 +2741,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) for (i = 0; i < ic->nb_streams; i++) { st = ic->streams[i]; if (st->start_time == AV_NOPTS_VALUE && - st->first_dts == AV_NOPTS_VALUE && + st->internal->first_dts == AV_NOPTS_VALUE && st->codecpar->codec_type != AVMEDIA_TYPE_UNKNOWN) av_log(ic, AV_LOG_WARNING, "start time for stream %d is not set in estimate_timings_from_pts\n", i); @@ -2777,7 +2782,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) st = ic->streams[pkt->stream_index]; if (pkt->pts != AV_NOPTS_VALUE && (st->start_time != AV_NOPTS_VALUE || - st->first_dts != AV_NOPTS_VALUE)) { + st->internal->first_dts != AV_NOPTS_VALUE)) { if (pkt->duration == 0) { ff_compute_frame_duration(ic, &num, &den, st, st->internal->parser, pkt); if (den && num) { @@ -2792,7 +2797,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) if (st->start_time != AV_NOPTS_VALUE) duration -= st->start_time; else - duration -= st->first_dts; + duration -= st->internal->first_dts; if (duration > 0) { if (st->duration == AV_NOPTS_VALUE || st->internal->info->last_duration<= 0 || (st->duration < duration && FFABS(duration - st->internal->info->last_duration) < 60LL*st->time_base.den / st->time_base.num)) @@ -2829,7 +2834,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) switch (st->codecpar->codec_type) { case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_AUDIO: - if (st->start_time != AV_NOPTS_VALUE || st->first_dts != AV_NOPTS_VALUE) { + if (st->start_time != AV_NOPTS_VALUE || st->internal->first_dts != AV_NOPTS_VALUE) { av_log(ic, AV_LOG_WARNING, "stream %d : no PTS found at end of file, duration not set\n", i); } else av_log(ic, AV_LOG_WARNING, "stream %d : no TS found at start of file, duration not set\n", i); @@ -2844,7 +2849,7 @@ skip_duration_calc: int j; st = ic->streams[i]; - st->cur_dts = st->first_dts; + st->internal->cur_dts = st->internal->first_dts; st->internal->last_IP_pts = AV_NOPTS_VALUE; st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; for (j = 0; j < MAX_REORDER_DELAY + 1; j++) @@ -3699,7 +3704,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) st->internal->extract_extradata.bsf) && extract_extradata_check(st)) break; - if (st->first_dts == AV_NOPTS_VALUE && + if (st->internal->first_dts == AV_NOPTS_VALUE && !(ic->iformat->flags & AVFMT_NOTIMESTAMPS) && st->internal->codec_info_nb_frames < ((st->disposition & AV_DISPOSITION_ATTACHED_PIC) ? 1 : ic->max_ts_probe) && (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || @@ -4414,15 +4419,15 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c) * but durations get some timestamps, formats with some unknown * timestamps have their first few packets buffered and the * timestamps corrected before they are returned to the user */ - st->cur_dts = RELATIVE_TS_BASE; + st->internal->cur_dts = RELATIVE_TS_BASE; } else { - st->cur_dts = AV_NOPTS_VALUE; + st->internal->cur_dts = AV_NOPTS_VALUE; } st->index = s->nb_streams; st->start_time = AV_NOPTS_VALUE; st->duration = AV_NOPTS_VALUE; - st->first_dts = AV_NOPTS_VALUE; + st->internal->first_dts = AV_NOPTS_VALUE; st->internal->probe_packets = s->max_probe_packets; st->internal->pts_wrap_reference = AV_NOPTS_VALUE; st->internal->pts_wrap_behavior = AV_PTS_WRAP_IGNORE; diff --git a/libavformat/vqf.c b/libavformat/vqf.c index 431ba1a0c9..08dba858b4 100644 --- a/libavformat/vqf.c +++ b/libavformat/vqf.c @@ -277,7 +277,7 @@ static int vqf_read_seek(AVFormatContext *s, AV_ROUND_DOWN : AV_ROUND_UP); pos *= c->frame_bit_len; - st->cur_dts = av_rescale(pos, st->time_base.den, + st->internal->cur_dts = av_rescale(pos, st->time_base.den, st->codecpar->bit_rate * (int64_t)st->time_base.num); if ((ret = avio_seek(s->pb, ((pos-7) >> 3) + s->internal->data_offset, SEEK_SET)) < 0) diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 6bce9ba688..d2fb81ca7f 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -702,8 +702,8 @@ static int wav_read_packet(AVFormatContext *s, AVPacket *pkt) int64_t audio_dts, video_dts; AVStream *vst = wav->vst; smv_retry: - audio_dts = (int32_t)st->cur_dts; - video_dts = (int32_t)vst->cur_dts; + audio_dts = (int32_t)st->internal->cur_dts; + video_dts = (int32_t)vst->internal->cur_dts; if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) { /*We always return a video frame first to get the pixel format first*/