| 1371 | } |
| 1372 | |
| 1373 | static int write_uncoded_frame_internal(AVFormatContext *s, int stream_index, |
| 1374 | AVFrame *frame, int interleaved) |
| 1375 | { |
| 1376 | FFFormatContext *const si = ffformatcontext(s); |
| 1377 | AVPacket *pkt = si->parse_pkt; |
| 1378 | |
| 1379 | av_assert0(s->oformat); |
| 1380 | if (!ffofmt(s->oformat)->write_uncoded_frame) { |
| 1381 | av_frame_free(&frame); |
| 1382 | return AVERROR(ENOSYS); |
| 1383 | } |
| 1384 | |
| 1385 | if (!frame) { |
| 1386 | pkt = NULL; |
| 1387 | } else { |
| 1388 | size_t bufsize = sizeof(frame) + AV_INPUT_BUFFER_PADDING_SIZE; |
| 1389 | AVFrame **framep = av_mallocz(bufsize); |
| 1390 | |
| 1391 | if (!framep) |
| 1392 | goto fail; |
| 1393 | pkt->buf = av_buffer_create((void *)framep, bufsize, |
| 1394 | uncoded_frame_free, NULL, 0); |
| 1395 | if (!pkt->buf) { |
| 1396 | av_free(framep); |
| 1397 | fail: |
| 1398 | av_frame_free(&frame); |
| 1399 | return AVERROR(ENOMEM); |
| 1400 | } |
| 1401 | *framep = frame; |
| 1402 | |
| 1403 | pkt->data = (void *)framep; |
| 1404 | pkt->size = sizeof(frame); |
| 1405 | pkt->pts = |
| 1406 | pkt->dts = frame->pts; |
| 1407 | pkt->duration = frame->duration; |
| 1408 | pkt->stream_index = stream_index; |
| 1409 | pkt->flags |= AV_PKT_FLAG_UNCODED_FRAME; |
| 1410 | } |
| 1411 | |
| 1412 | return interleaved ? av_interleaved_write_frame(s, pkt) : |
| 1413 | av_write_frame(s, pkt); |
| 1414 | } |
| 1415 | |
| 1416 | int av_write_uncoded_frame(AVFormatContext *s, int stream_index, |
| 1417 | AVFrame *frame) |
no test coverage detected