| 29 | } FFV1ParseContext; |
| 30 | |
| 31 | static int parse(AVCodecParserContext *s, |
| 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; |
| 38 | RangeCoder c; |
| 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)); |
| 66 | ff_ffv1_parse_header(f, &c, 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 | |
| 76 | static av_cold void ffv1_close(AVCodecParserContext *s) |
| 77 | { |
nothing calls this directly
no test coverage detected