| 238 | } |
| 239 | |
| 240 | static 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 | |
| 294 | static int seq_read_close(AVFormatContext *s) |
| 295 | { |
nothing calls this directly
no test coverage detected