FFmpeg
Loading...
Searching...
No Matches
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 "avcodec.h"
25#include "get_bits.h"
26#include "parser_internal.h"
27
29 AVCodecContext *avctx,
30 const uint8_t **out_data, int *out_size,
31 const uint8_t *data, int size)
32{
34 int res, profile, keyframe;
35
36 *out_data = data;
37 *out_size = size;
38
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);
45 if (profile > 3)
46 return size;
47
48 avctx->profile = profile;
49
50 if (get_bits1(&gb)) {
51 keyframe = 0;
52 } else {
53 keyframe = !get_bits1(&gb);
54 }
55
56 if (!keyframe) {
57 ctx->pict_type = AV_PICTURE_TYPE_P;
58 ctx->key_frame = 0;
59 } else {
60 ctx->pict_type = AV_PICTURE_TYPE_I;
61 ctx->key_frame = 1;
62 }
63
64 return size;
65}
66
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition apv_parser.c:92
Libavcodec external API header.
bitstream reader API header.
static unsigned int get_bits1(GetBitContext *s)
Definition get_bits.h:391
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition get_bits.h:544
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition get_bits.h:337
@ AV_CODEC_ID_VP9
Definition codec_id.h:217
@ AV_PICTURE_TYPE_I
Intra.
Definition avutil.h:278
@ AV_PICTURE_TYPE_P
Predicted.
Definition avutil.h:279
const char data[16]
Definition mxf.c:149
int profile
Definition mxfenc.c:2299
#define PARSER_CODEC_LIST(...)
const FFCodecParser ff_vp9_parser
Definition vp9_parser.c:67
main external API structure.
Definition avcodec.h:443
int profile
profile
Definition avcodec.h:1636
static int out_size
Definition movenc.c:56
static AVFormatContext * ctx
Definition movenc.c:49
int size
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