2 * VP9 compatible video decoder
4 * Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
5 * Copyright (C) 2013 Clément Bœsch <u pkh me>
7 * This file is part of FFmpeg.
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "libavutil/intreadwrite.h"
25 #include "libavcodec/get_bits.h"
28 static int parse(AVCodecParserContext
*ctx
,
29 AVCodecContext
*avctx
,
30 const uint8_t **out_data
, int *out_size
,
31 const uint8_t *data
, int size
)
34 int res
, profile
, keyframe
;
39 if (!size
|| (res
= init_get_bits8(&gb
, data
, size
)) < 0)
40 return size
; // parsers can't return errors
41 get_bits(&gb
, 2); // frame marker
42 profile
= get_bits1(&gb
);
43 profile
|= get_bits1(&gb
) << 1;
44 if (profile
== 3) profile
+= get_bits1(&gb
);
48 avctx
->profile
= profile
;
53 keyframe
= !get_bits1(&gb
);
57 ctx
->pict_type
= AV_PICTURE_TYPE_P
;
60 ctx
->pict_type
= AV_PICTURE_TYPE_I
;
67 const AVCodecParser ff_vp9_parser
= {
68 .codec_ids
= { AV_CODEC_ID_VP9
},
69 .parser_parse
= parse
,