x264_nal_t avpacket
static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, const x264_nal_t *nals, int nnal) { X264Context *x4 = ctx->priv_data; uint8_t *p; int i, size = x4->sei_size, ret; if (!nnal) return 0; for (i = 0; i < nnal; i++) size += nals[i].i_payload; if ((ret = ff_alloc_packet2(ctx, pkt, size, 0)) < 0) return ret; p = pkt->data; /* Write the SEI as part of the first frame. */ if (x4->sei_size > 0 && nnal > 0) { if (x4->sei_size > size) { av_log(ctx, AV_LOG_ERROR, "Error: nal buffer is too small\n"); return -1; } memcpy(p, x4->sei, x4->sei_size); p += x4->sei_size; x4->sei_size = 0; av_freep(&x4->sei); } for (i = 0; i < nnal; i++){ memcpy(p, nals[i].p_payload, nals[i].i_payload); p += nals[i].i_payload; } return 1; }