MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / dpx_parse

Function dpx_parse

libavcodec/dpx_parser.c:41–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39} DPXParseContext;
40
41static int dpx_parse(AVCodecParserContext *s, AVCodecContext *avctx,
42 const uint8_t **poutbuf, int *poutbuf_size,
43 const uint8_t *buf, int buf_size)
44{
45 DPXParseContext *d = s->priv_data;
46 uint32_t state = d->pc.state;
47 int next = END_NOT_FOUND;
48 int i = 0;
49
50 s->pict_type = AV_PICTURE_TYPE_I;
51
52 *poutbuf_size = 0;
53 if (buf_size == 0)
54 next = 0;
55
56 if (!d->pc.frame_start_found) {
57 for (; i < buf_size; i++) {
58 state = (state << 8) | buf[i];
59 if (state == MKBETAG('S','D','P','X') ||
60 state == MKTAG('S','D','P','X')) {
61 d->pc.frame_start_found = 1;
62 d->is_be = state == MKBETAG('S','D','P','X');
63 d->index = 0;
64 break;
65 }
66 }
67 d->pc.state = state;
68 } else {
69 if (d->remaining_size) {
70 i = FFMIN(d->remaining_size, buf_size);
71 d->remaining_size -= i;
72 if (d->remaining_size)
73 goto flush;
74 }
75 }
76
77 for (; d->pc.frame_start_found && i < buf_size; i++) {
78 d->pc.state = (d->pc.state << 8) | buf[i];
79 d->index++;
80 if (d->index == 17) {
81 d->fsize = d->is_be ? d->pc.state : av_bswap32(d->pc.state);
82 if (d->fsize <= 1664) {
83 d->pc.frame_start_found = 0;
84 goto flush;
85 }
86 if (d->fsize > buf_size - i + 19)
87 d->remaining_size = d->fsize - buf_size + i - 19;
88 else
89 i += d->fsize - 19;
90
91 break;
92 } else if (d->index > 17) {
93 if (d->pc.state == MKBETAG('S','D','P','X') ||
94 d->pc.state == MKTAG('S','D','P','X')) {
95 next = i - 3;
96 break;
97 }
98 }

Callers

nothing calls this directly

Calls 2

ff_combine_frameFunction · 0.85
av_bswap32Function · 0.50

Tested by

no test coverage detected