Lines Matching refs:avpkt

35 int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
43 av_assert0(!avpkt->data);
47 avpkt->data = avctx->internal->byte_buffer;
48 if (!avpkt->data) {
52 avpkt->size = size;
57 int avcodec_default_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int flags)
61 if (avpkt->size < 0 || avpkt->size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
64 if (avpkt->data || avpkt->buf) {
65 av_log(avctx, AV_LOG_ERROR, "avpkt->{data,buf} != NULL in avcodec_default_get_encode_buffer()\n");
69 ret = av_buffer_realloc(&avpkt->buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE);
71 av_log(avctx, AV_LOG_ERROR, "Failed to allocate packet of size %d\n", avpkt->size);
74 avpkt->data = avpkt->buf->data;
79 int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
86 av_assert0(!avpkt->data && !avpkt->buf);
88 avpkt->size = size;
89 ret = avctx->get_encode_buffer(avctx, avpkt, flags);
93 if (!avpkt->data || !avpkt->buf) {
98 memset(avpkt->data + avpkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
104 av_packet_unref(avpkt);
175 static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
212 ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet);
214 ret = codec->cb.encode(avctx, avpkt, frame, &got_packet);
217 avpkt->pts = avpkt->dts = frame->pts;
225 if (avpkt->data) {
226 ret = av_packet_make_refcounted(avpkt);
233 if (avpkt->pts == AV_NOPTS_VALUE)
234 avpkt->pts = frame->pts;
235 if (!avpkt->duration)
236 avpkt->duration = ff_samples_to_time_base(avctx,
241 avpkt->dts = avpkt->pts;
243 avpkt->flags |= avci->intra_only_flag;
251 av_packet_unref(avpkt);
259 av_assert0(!avpkt->data || avpkt->buf);
264 static int encode_simple_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
268 while (!avpkt->data && !avpkt->side_data) {
269 ret = encode_simple_internal(avctx, avpkt);
277 static int encode_receive_packet_internal(AVCodecContext *avctx, AVPacket *avpkt)
285 av_assert0(!avpkt->data && !avpkt->side_data);
295 ret = ffcodec(avctx->codec)->cb.receive_packet(avctx, avpkt);
297 av_packet_unref(avpkt);
301 av_assert0(!avpkt->data || avpkt->buf);
303 ret = encode_simple_receive_packet(avctx, avpkt);
390 int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
395 av_packet_unref(avpkt);
401 av_packet_move_ref(avpkt, avci->buffer_pkt);
403 ret = encode_receive_packet_internal(avctx, avpkt);