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

Function av_parser_parse2

libavcodec/parser.c:143–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143int av_parser_parse2(AVCodecParserContext *s,
144 AVCodecContext *avctx,
145 uint8_t **poutbuf, int *poutbuf_size,
146 const uint8_t *buf, int buf_size,
147 int64_t pts, int64_t dts,
148 int64_t pos)
149{
150 int index, i;
151 uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE];
152
153 if (buf_size == 0) {
154 /* padding is always necessary even if EOF, so we add it here */
155 memset(dummy_buf, 0, sizeof(dummy_buf));
156 buf = dummy_buf;
157 } else if (s->cur_offset + buf_size !=
158 s->cur_frame_end[s->cur_frame_start_index]) { /* skip remainder packets */
159 /* add a new packet descriptor */
160 i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
161 s->cur_frame_start_index = i;
162 s->cur_frame_offset[i] = s->cur_offset;
163 s->cur_frame_end[i] = s->cur_offset + buf_size;
164 s->cur_frame_pts[i] = pts;
165 s->cur_frame_dts[i] = dts;
166 s->cur_frame_pos[i] = pos;
167 }
168
169 if (s->fetch_timestamp){
170 s->fetch_timestamp=0;
171 s->last_pts = s->pts;
172 s->last_dts = s->dts;
173 s->last_pos = s->pos;
174 ff_fetch_timestamp(s, 0, 0);
175 }
176
177 /* WARNING: the returned index can be negative */
178 index = s->parser->parser_parse(s, avctx, (const uint8_t **)poutbuf, poutbuf_size, buf, buf_size);
179//av_log(NULL, AV_LOG_DEBUG, "parser: in:%"PRId64", %"PRId64", out:%"PRId64", %"PRId64", in:%d out:%d id:%d\n", pts, dts, s->last_pts, s->last_dts, buf_size, *poutbuf_size, avctx->codec_id);
180 /* update the file pointer */
181 if (*poutbuf_size) {
182 /* fill the data for the current frame */
183 s->frame_offset = s->next_frame_offset;
184
185 /* offset of the next frame */
186 s->next_frame_offset = s->cur_offset + index;
187 s->fetch_timestamp=1;
188 }
189 if (index < 0)
190 index = 0;
191 s->cur_offset += index;
192 return index;
193}
194
195/**
196 *

Callers 2

av_read_frame_internalFunction · 0.85
av_parser_parseFunction · 0.85

Calls 1

ff_fetch_timestampFunction · 0.85

Tested by

no test coverage detected