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

Function encode_frame

libavcodec/v210enc.c:69–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
70 const AVFrame *pic, int *got_packet)
71{
72 int aligned_width = ((avctx->width + 47) / 48) * 48;
73 int stride = aligned_width * 8 / 3;
74 AVFrameSideData *side_data;
75 int ret;
76 uint8_t *dst;
77
78 ret = ff_get_encode_buffer(avctx, pkt, avctx->height * stride, 0);
79 if (ret < 0) {
80 av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
81 return ret;
82 }
83 dst = pkt->data;
84
85 if (pic->format == AV_PIX_FMT_YUV422P10)
86 v210_enc_10(avctx, dst, pic);
87 else if(pic->format == AV_PIX_FMT_YUV422P)
88 v210_enc_8(avctx, dst, pic);
89
90 side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_A53_CC);
91 if (side_data && side_data->size) {
92 uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_A53_CC, side_data->size);
93 if (!buf)
94 return AVERROR(ENOMEM);
95 memcpy(buf, side_data->data, side_data->size);
96 }
97
98 side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_AFD);
99 if (side_data && side_data->size) {
100 uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_AFD, side_data->size);
101 if (!buf)
102 return AVERROR(ENOMEM);
103 memcpy(buf, side_data->data, side_data->size);
104 }
105
106 *got_packet = 1;
107 return 0;
108}
109
110const FFCodec ff_v210_encoder = {
111 .p.name = "v210",

Callers

nothing calls this directly

Calls 4

ff_get_encode_bufferFunction · 0.85
av_logFunction · 0.85
av_frame_get_side_dataFunction · 0.85
av_packet_new_side_dataFunction · 0.85

Tested by

no test coverage detected