+ if (avpkt != avci->compat_encode_packet) {
+ if (avpkt->data && user_pkt.data) {
+ if (user_pkt.size >= avpkt->size) {
+ memcpy(user_pkt.data, avpkt->data, avpkt->size);
+ av_buffer_unref(&avpkt->buf);
+ avpkt->buf = user_pkt.buf;
+ avpkt->data = user_pkt.data;
+ av_init_packet(&user_pkt);
+ } else {
+ av_log(avctx, AV_LOG_ERROR, "Provided packet is too small, needs to be %d\n", avpkt->size);
+ av_packet_unref(avpkt);
+ ret = AVERROR(EINVAL);
+ goto finish;
+ }
+ }
+
+ *got_packet = 1;
+ avpkt = avci->compat_encode_packet;
+ } else {
+ if (!avci->compat_decode_warned) {
+ av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_encode_* "
+ "API cannot return all the packets for this encoder. "
+ "Some packets will be dropped. Update your code to the "
+ "new encoding API to fix this.\n");
+ avci->compat_decode_warned = 1;
+ av_packet_unref(avpkt);
+ }
+ }
+
+ if (avci->draining)
+ break;
+ }