From e1a794b2728afc479891917171b969cfdaf5262d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5ns=20Rullg=C3=A5rd?= Date: Sun, 11 Nov 2007 21:56:18 +0000 Subject: [PATCH] set PKT_FLAG_KEY for Theora and OGM streams Originally committed as revision 11002 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/oggdec.c | 3 +++ libavformat/oggdec.h | 1 + libavformat/oggparseogm.c | 3 +++ libavformat/oggparsetheora.c | 3 +++ 4 files changed, 10 insertions(+) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 03377d9cfa..211208dd25 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -377,6 +377,7 @@ ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize) } if (os->header > -1 && os->seq > os->header){ + os->pflags = 0; if (os->codec && os->codec->packet) os->codec->packet (s, idx); if (str) @@ -525,6 +526,8 @@ ogg_read_packet (AVFormatContext * s, AVPacket * pkt) os->lastgp = -1; } + pkt->flags = os->pflags; + return psize; } diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h index da79c0a6e8..964c044f65 100644 --- a/libavformat/oggdec.h +++ b/libavformat/oggdec.h @@ -42,6 +42,7 @@ typedef struct ogg_stream { unsigned int bufpos; unsigned int pstart; unsigned int psize; + unsigned int pflags; uint32_t serial; uint32_t seq; uint64_t granule, lastgp; diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c index edafd65289..bbf9cb8c8d 100644 --- a/libavformat/oggparseogm.c +++ b/libavformat/oggparseogm.c @@ -134,6 +134,9 @@ ogm_packet(AVFormatContext *s, int idx) uint8_t *p = os->buf + os->pstart; int lb; + if(*p & 8) + os->pflags |= PKT_FLAG_KEY; + lb = ((*p & 2) << 1) | ((*p >> 6) & 3); os->pstart += lb + 1; os->psize -= lb + 1; diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c index 617d1ded51..b976dcb701 100644 --- a/libavformat/oggparsetheora.c +++ b/libavformat/oggparsetheora.c @@ -124,6 +124,9 @@ theora_gptopts(AVFormatContext *ctx, int idx, uint64_t gp) uint64_t iframe = gp >> thp->gpshift; uint64_t pframe = gp & thp->gpmask; + if(!pframe) + os->pflags |= PKT_FLAG_KEY; + return iframe + pframe; }