| 489 | } |
| 490 | |
| 491 | int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame) |
| 492 | { |
| 493 | AVCodecInternal *avci = avctx->internal; |
| 494 | int ret; |
| 495 | |
| 496 | if (!avcodec_is_open(avctx) || !av_codec_is_encoder(avctx->codec)) |
| 497 | return AVERROR(EINVAL); |
| 498 | |
| 499 | if (avci->draining) |
| 500 | return AVERROR_EOF; |
| 501 | |
| 502 | if (avci->buffer_frame->buf[0]) |
| 503 | return AVERROR(EAGAIN); |
| 504 | |
| 505 | if (!frame) { |
| 506 | avci->draining = 1; |
| 507 | } else { |
| 508 | ret = encode_send_frame_internal(avctx, frame); |
| 509 | if (ret < 0) |
| 510 | return ret; |
| 511 | } |
| 512 | |
| 513 | if (!avci->buffer_pkt->data && !avci->buffer_pkt->side_data) { |
| 514 | ret = encode_receive_packet_internal(avctx, avci->buffer_pkt); |
| 515 | if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) |
| 516 | return ret; |
| 517 | } |
| 518 | |
| 519 | avctx->frame_num++; |
| 520 | |
| 521 | return 0; |
| 522 | } |
| 523 | |
| 524 | int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt) |
| 525 | { |