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

Function seq_read_packet

libavformat/tiertexseq.c:240–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240static int seq_read_packet(AVFormatContext *s, AVPacket *pkt)
241{
242 int rc;
243 SeqDemuxContext *seq = s->priv_data;
244 ByteIOContext *pb = s->pb;
245
246 if (!seq->audio_buffer_full) {
247 rc = seq_parse_frame_data(seq, pb);
248 if (rc)
249 return rc;
250
251 /* video packet */
252 if (seq->current_pal_data_size + seq->current_video_data_size != 0) {
253 if (av_new_packet(pkt, 1 + seq->current_pal_data_size + seq->current_video_data_size))
254 return AVERROR(ENOMEM);
255
256 pkt->data[0] = 0;
257 if (seq->current_pal_data_size) {
258 pkt->data[0] |= 1;
259 url_fseek(pb, seq->current_frame_offs + seq->current_pal_data_offs, SEEK_SET);
260 if (get_buffer(pb, &pkt->data[1], seq->current_pal_data_size) != seq->current_pal_data_size)
261 return AVERROR(EIO);
262 }
263 if (seq->current_video_data_size) {
264 pkt->data[0] |= 2;
265 memcpy(&pkt->data[1 + seq->current_pal_data_size],
266 seq->current_video_data_ptr,
267 seq->current_video_data_size);
268 }
269 pkt->stream_index = seq->video_stream_index;
270 pkt->pts = seq->current_frame_pts;
271
272 /* sound buffer will be processed on next read_packet() call */
273 seq->audio_buffer_full = 1;
274 return 0;
275 }
276 }
277
278 /* audio packet */
279 if (seq->current_audio_data_offs == 0) /* end of data reached */
280 return AVERROR(EIO);
281
282 url_fseek(pb, seq->current_frame_offs + seq->current_audio_data_offs, SEEK_SET);
283 rc = av_get_packet(pb, pkt, seq->current_audio_data_size);
284 if (rc < 0)
285 return rc;
286
287 pkt->stream_index = seq->audio_stream_index;
288 seq->current_frame_pts++;
289
290 seq->audio_buffer_full = 0;
291 return 0;
292}
293
294static int seq_read_close(AVFormatContext *s)
295{

Callers

nothing calls this directly

Calls 5

seq_parse_frame_dataFunction · 0.85
av_new_packetFunction · 0.85
url_fseekFunction · 0.85
get_bufferFunction · 0.85
av_get_packetFunction · 0.85

Tested by

no test coverage detected