FFmpeg
Loading...
Searching...
No Matches
ffv1_parser.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "avcodec.h"
20#include "ffv1.h"
21#include "parser_internal.h"
22#include "rangecoder.h"
23
25
30
32 AVCodecContext *avctx,
33 const uint8_t **poutbuf, int *poutbuf_size,
34 const uint8_t *buf, int buf_size)
35{
36 FFV1ParseContext *p = s->priv_data;
37 FFV1Context *f = &p->f;
39 uint8_t keystate = 128;
40
41 *poutbuf = buf;
42 *poutbuf_size = buf_size;
43
44 if (!p->got_first) {
45 int ret = ff_ffv1_common_init(avctx, f);
46 p->got_first = 1;
47 if (ret < 0)
48 return buf_size;
49
50 if (avctx->extradata_size > 0 && (ret = ff_ffv1_read_extra_header(f)) < 0)
51 return buf_size;
52 }
53
54 ff_init_range_decoder(&c, buf, buf_size);
55 ff_build_rac_states(&c, 0.05 * (1LL << 32), 256 - 8);
56
57 f->avctx = avctx;
58 s->key_frame = get_rac(&c, &keystate);
59 s->pict_type = AV_PICTURE_TYPE_I;
60 s->field_order = AV_FIELD_UNKNOWN;
61 s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
62
63 if (s->key_frame) {
64 uint8_t state[CONTEXT_SIZE];
65 memset(state, 128, sizeof(state));
67 }
68
69 s->width = f->width;
70 s->height = f->height;
71 s->format = f->pix_fmt;
72
73 return buf_size;
74}
75
77{
78 FFV1ParseContext *p = s->priv_data;
79
80 p->f.avctx = NULL;
81 ff_ffv1_close(&p->f);
82}
83
86 .priv_data_size = sizeof(FFV1ParseContext),
87 .parse = parse,
89};
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
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
Libavcodec external API header.
#define f(width, name)
Definition cbs_vp8.c:236
#define s(width, name)
Definition cbs_vp9.c:198
#define NULL
Definition coverity.c:32
@ AV_FIELD_UNKNOWN
Definition defs.h:212
static struct @346255127015250356166251341105367306144006377143 state
av_cold int ff_ffv1_common_init(AVCodecContext *avctx, FFV1Context *s)
Definition ffv1.c:36
av_cold void ff_ffv1_close(FFV1Context *s)
Definition ffv1.c:268
FF Video Codec 1 (a lossless codec)
int ff_ffv1_read_extra_header(FFV1Context *f)
Definition ffv1_parse.c:70
#define CONTEXT_SIZE
Definition ffv1.h:45
int ff_ffv1_parse_header(FFV1Context *f, RangeCoder *c, uint8_t *state)
Definition ffv1_parse.c:216
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition ffv1_parser.c:31
const FFCodecParser ff_ffv1_parser
Definition ffv1_parser.c:84
static av_cold void ffv1_close(AVCodecParserContext *s)
Definition ffv1_parser.c:76
@ AV_CODEC_ID_FFV1
Definition codec_id.h:83
@ AV_PICTURE_STRUCTURE_UNKNOWN
unknown
Definition avcodec.h:2611
@ AV_PICTURE_TYPE_I
Intra.
Definition avutil.h:278
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
#define PARSER_CODEC_LIST(...)
av_cold void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size)
Definition rangecoder.c:53
void ff_build_rac_states(RangeCoder *c, int factor, int max_p)
Definition rangecoder.c:68
Range coder.
static int get_rac(RangeCoder *c, uint8_t *const state)
Definition rangecoder.h:118
main external API structure.
Definition avcodec.h:443
int extradata_size
Definition avcodec.h:527
FFV1Context f
Definition ffv1_parser.c:27
static double c[64]