summaryrefslogtreecommitdiff
path: root/libavcodec/vp9_parser.c
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2015-02-05 16:43:27 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-02-05 21:16:26 +0100
commita83b6b077c56341300a271ef4a1aaff19af5235d (patch)
treed1102b581eafe3be0daa3889080f78bd7dfb16a4 /libavcodec/vp9_parser.c
parent15574c505b81d6e92370096eaca6764c13b5fbfc (diff)
vp9: assign PTS to visible instead of invisible frames
All the webm/vp9 files I have seen so far can have packets that contain 1 invisible and 1 visible frame. The vp9 parser separates them. Since the invisible frame is always (?) the first sub-packet, the new packet is assigned the PTS of the original packet, while the packet containing the visible frame has no PTS. This patch essentially reassigns the PTS from the invisible to the visible frame. Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vp9_parser.c')
-rw-r--r--libavcodec/vp9_parser.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/vp9_parser.c b/libavcodec/vp9_parser.c
index b188785456..220290fbf1 100644
--- a/libavcodec/vp9_parser.c
+++ b/libavcodec/vp9_parser.c
@@ -24,10 +24,13 @@
typedef struct VP9ParseContext {
int n_frames; // 1-8
int size[8];
+ int64_t pts;
} VP9ParseContext;
static void parse_frame(AVCodecParserContext *ctx, const uint8_t *buf, int size)
{
+ VP9ParseContext *s = ctx->priv_data;
+
if (buf[0] & 0x4) {
ctx->pict_type = AV_PICTURE_TYPE_P;
ctx->key_frame = 0;
@@ -35,6 +38,15 @@ static void parse_frame(AVCodecParserContext *ctx, const uint8_t *buf, int size)
ctx->pict_type = AV_PICTURE_TYPE_I;
ctx->key_frame = 1;
}
+
+ if (buf[0] & 0x2) {
+ if (ctx->pts == AV_NOPTS_VALUE)
+ ctx->pts = s->pts;
+ s->pts = AV_NOPTS_VALUE;
+ } else {
+ s->pts = ctx->pts;
+ ctx->pts = AV_NOPTS_VALUE;
+ }
}
static int parse(AVCodecParserContext *ctx,