| 709 | } |
| 710 | |
| 711 | int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt) |
| 712 | { |
| 713 | AVCodecInternal *avci = avctx->internal; |
| 714 | DecodeContext *dc = decode_ctx(avci); |
| 715 | int ret; |
| 716 | |
| 717 | if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec)) |
| 718 | return AVERROR(EINVAL); |
| 719 | |
| 720 | if (dc->draining_started) |
| 721 | return AVERROR_EOF; |
| 722 | |
| 723 | if (avpkt && !avpkt->size && avpkt->data) |
| 724 | return AVERROR(EINVAL); |
| 725 | |
| 726 | if (avpkt && (avpkt->data || avpkt->side_data_elems)) { |
| 727 | if (!AVPACKET_IS_EMPTY(avci->buffer_pkt)) |
| 728 | return AVERROR(EAGAIN); |
| 729 | ret = av_packet_ref(avci->buffer_pkt, avpkt); |
| 730 | if (ret < 0) |
| 731 | return ret; |
| 732 | } else |
| 733 | dc->draining_started = 1; |
| 734 | |
| 735 | if (!avci->buffer_frame->buf[0] && !dc->draining_started) { |
| 736 | ret = decode_receive_frame_internal(avctx, avci->buffer_frame, 0); |
| 737 | if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) |
| 738 | return ret; |
| 739 | } |
| 740 | |
| 741 | return 0; |
| 742 | } |
| 743 | |
| 744 | static int apply_cropping(AVCodecContext *avctx, AVFrame *frame) |
| 745 | { |