MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / libx265_encode_frame

Function libx265_encode_frame

libavcodec/libx265.c:721–953  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719}
720
721static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
722 const AVFrame *pic, int *got_packet)
723{
724 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
725 libx265Context *ctx = avctx->priv_data;
726 x265_picture x265pic;
727 x265_picture x265pic_out[FF_X265_MAX_LAYERS] = { 0 };
728#if (X265_BUILD >= 210) && (X265_BUILD < 213)
729 x265_picture *x265pic_lyrptr_out[FF_X265_MAX_LAYERS];
730#endif
731 x265_nal *nal;
732 x265_sei *sei;
733 uint8_t *dst;
734 int payload = 0;
735 int nnal;
736 int ret;
737 int i;
738
739 ctx->api->picture_init(ctx->params, &x265pic);
740
741 sei = &x265pic.userSEI;
742 sei->numPayloads = 0;
743
744 if (pic) {
745 AVFrameSideData *sd;
746 ReorderedData *rd;
747 int rd_idx;
748
749 for (i = 0; i < desc->nb_components; i++) {
750 x265pic.planes[i] = pic->data[i];
751 x265pic.stride[i] = pic->linesize[i];
752 }
753
754 x265pic.pts = pic->pts;
755 x265pic.bitDepth = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth;
756
757 x265pic.sliceType = pic->pict_type == AV_PICTURE_TYPE_I ?
758 (ctx->forced_idr ? X265_TYPE_IDR : X265_TYPE_I) :
759 pic->pict_type == AV_PICTURE_TYPE_P ? X265_TYPE_P :
760 pic->pict_type == AV_PICTURE_TYPE_B ? X265_TYPE_B :
761 X265_TYPE_AUTO;
762
763 ret = libx265_encode_set_roi(ctx, pic, &x265pic);
764 if (ret < 0)
765 return ret;
766
767 rd_idx = rd_get(ctx);
768 if (rd_idx < 0) {
769 free_picture(ctx, &x265pic);
770 return rd_idx;
771 }
772 rd = &ctx->rd[rd_idx];
773
774 rd->duration = pic->duration;
775 if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
776 rd->frame_opaque = pic->opaque;
777 ret = av_buffer_replace(&rd->frame_opaque_ref, pic->opaque_ref);
778 if (ret < 0) {

Callers

nothing calls this directly

Calls 15

av_pix_fmt_desc_getFunction · 0.85
libx265_encode_set_roiFunction · 0.85
rd_getFunction · 0.85
av_buffer_replaceFunction · 0.85
rd_releaseFunction · 0.85
ff_alloc_a53_seiFunction · 0.85
av_logFunction · 0.85
av_fast_reallocFunction · 0.85
av_memdupFunction · 0.85
av_frame_get_side_dataFunction · 0.85
ff_dovi_rpu_generateFunction · 0.85
av_freepFunction · 0.85

Tested by

no test coverage detected