[FFmpeg-devel] [PATCH v1] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet
Michael Niedermayer
michael at niedermayer.cc
Sat Apr 4 00:23:59 EEST 2020
On Fri, Apr 03, 2020 at 11:05:59PM +0800, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
> libavformat/mux.c | 16 ++++++++
> tests/ref/fate/binsub-movtextenc | 2 +-
> tests/ref/fate/movenc | 50 +++++++++++------------
> tests/ref/fate/sub2video | 86 ++++++++++++++++++++--------------------
> 4 files changed, 85 insertions(+), 69 deletions(-)
>
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index cc2d1e2..dc897c2 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -548,6 +548,17 @@ fail:
> return ret;
> }
>
> +static int is_intra_only(enum AVCodecID id)
> +{
> + const AVCodecDescriptor *d = avcodec_descriptor_get(id);
> + if (!d)
> + return 0;
> + if ((d->type == AVMEDIA_TYPE_VIDEO || d->type == AVMEDIA_TYPE_AUDIO) &&
> + !(d->props & AV_CODEC_PROP_INTRA_ONLY))
> + return 0;
> + return 1;
> +}
this should not be duplicated with code in utils.c
> +
> #define AV_PKT_FLAG_UNCODED_FRAME 0x2000
>
> /* Note: using sizeof(AVFrame) from outside lavu is unsafe in general, but
> @@ -664,6 +675,11 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
> frac_add(st->internal->priv_pts, (int64_t)st->time_base.den * st->time_base.num);
> break;
> }
> +
> + /* update flags */
> + if (is_intra_only(st->codecpar->codec_id))
> + pkt->flags |= AV_PKT_FLAG_KEY;
> +
it may make sense to store the AVCodecDescriptor and not search it again for
each packet. But then the "is_intra_only" itself also does not change so that
should itself be computet just once per stream
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200403/d2d62cb4/attachment.sig>
More information about the ffmpeg-devel
mailing list