FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vp9_parser.c
Date: 2021-09-23 20:34:37
Exec Total Coverage
Lines: 20 21 95.2%
Branches: 10 12 83.3%

Line Branch Exec Source
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 2479 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 2479 *out_data = data;
37 2479 *out_size = size;
38
39
3/4
✓ Branch 0 taken 2236 times.
✓ Branch 1 taken 243 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2236 times.
2479 if (!size || (res = init_get_bits8(&gb, data, size)) < 0)
40 243 return size; // parsers can't return errors
41 2236 get_bits(&gb, 2); // frame marker
42 2236 profile = get_bits1(&gb);
43 2236 profile |= get_bits1(&gb) << 1;
44
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 2126 times.
2236 if (profile == 3) profile += get_bits1(&gb);
45
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2236 times.
2236 if (profile > 3)
46 return size;
47
48 2236 avctx->profile = profile;
49
50
2/2
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 2205 times.
2236 if (get_bits1(&gb)) {
51 31 keyframe = 0;
52 } else {
53 2205 keyframe = !get_bits1(&gb);
54 }
55
56
2/2
✓ Branch 0 taken 1993 times.
✓ Branch 1 taken 243 times.
2236 if (!keyframe) {
57 1993 ctx->pict_type = AV_PICTURE_TYPE_P;
58 1993 ctx->key_frame = 0;
59 } else {
60 243 ctx->pict_type = AV_PICTURE_TYPE_I;
61 243 ctx->key_frame = 1;
62 }
63
64 2236 return size;
65 }
66
67 const AVCodecParser ff_vp9_parser = {
68 .codec_ids = { AV_CODEC_ID_VP9 },
69 .parser_parse = parse,
70 };
71