FFmpeg
4.0
libavcodec
vp9_parser.c
Go to the documentation of this file.
1
/*
2
* VP9 compatible video decoder
3
*
4
* Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
5
* Copyright (C) 2013 Clément Bœsch <u pkh me>
6
*
7
* This file is part of FFmpeg.
8
*
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.
13
*
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.
18
*
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
22
*/
23
24
#include "
libavutil/intreadwrite.h
"
25
#include "
libavcodec/get_bits.h
"
26
#include "
parser.h
"
27
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
)
32
{
33
GetBitContext
gb;
34
int
res,
profile
, keyframe;
35
36
*out_data =
data
;
37
*out_size =
size
;
38
39
if
((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);
45
46
if
(
get_bits1
(&gb)) {
47
keyframe = 0;
48
}
else
{
49
keyframe = !
get_bits1
(&gb);
50
}
51
52
if
(!keyframe) {
53
ctx->
pict_type
=
AV_PICTURE_TYPE_P
;
54
ctx->
key_frame
= 0;
55
}
else
{
56
ctx->
pict_type
=
AV_PICTURE_TYPE_I
;
57
ctx->
key_frame
= 1;
58
}
59
60
return
size
;
61
}
62
63
AVCodecParser
ff_vp9_parser
= {
64
.
codec_ids
= {
AV_CODEC_ID_VP9
},
65
.parser_parse =
parse
,
66
};
ff_vp9_parser
AVCodecParser ff_vp9_parser
Definition:
vp9_parser.c:63
AV_CODEC_ID_VP9
Definition:
avcodec.h:386
size
int size
Definition:
twinvq_data.h:11134
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition:
get_bits.h:269
AVCodecParser::codec_ids
int codec_ids[5]
Definition:
avcodec.h:5200
out_size
int out_size
Definition:
movenc.c:55
parse
static int parse(AVCodecParserContext *ctx, AVCodecContext *avctx, const uint8_t **out_data, int *out_size, const uint8_t *data, int size)
Definition:
vp9_parser.c:28
uint8_t
uint8_t
Definition:
audio_convert.c:194
data
const char data[16]
Definition:
mxf.c:90
get_bits.h
bitstream reader API header.
parser.h
AVCodecParserContext::pict_type
int pict_type
Definition:
avcodec.h:5040
AVCodecParser
Definition:
avcodec.h:5199
AV_PICTURE_TYPE_I
Intra.
Definition:
avutil.h:274
intreadwrite.h
ctx
AVFormatContext * ctx
Definition:
movenc.c:48
AVCodecParserContext
Definition:
avcodec.h:5032
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition:
get_bits.h:464
AVCodecContext
main external API structure.
Definition:
avcodec.h:1518
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition:
get_bits.h:321
profile
mfxU16 profile
Definition:
qsvenc.c:44
GetBitContext
Definition:
get_bits.h:56
AVCodecParserContext::key_frame
int key_frame
Set by parser to 1 for key frames and 0 for non-key frames.
Definition:
avcodec.h:5081
AV_PICTURE_TYPE_P
Predicted.
Definition:
avutil.h:275
Generated on Tue May 22 2018 07:06:43 for FFmpeg by
1.8.13