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

Function encode_yuv422p10

libavcodec/bitpacked_enc.c:34–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32};
33
34static int encode_yuv422p10(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame)
35{
36 const int buf_size = avctx->height * avctx->width * avctx->bits_per_coded_sample / 8;
37 int ret;
38 uint8_t *dst;
39 const uint16_t *y;
40 const uint16_t *u;
41 const uint16_t *v;
42 PutBitContext pb;
43
44 ret = ff_get_encode_buffer(avctx, pkt, buf_size, 0);
45 if (ret < 0) {
46 av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
47 return ret;
48 }
49 dst = pkt->data;
50
51 init_put_bits(&pb, dst, buf_size);
52
53 for (int i = 0; i < avctx->height; i++) {
54 y = (uint16_t*)(frame->data[0] + i * frame->linesize[0]);
55 u = (uint16_t*)(frame->data[1] + i * frame->linesize[1]);
56 v = (uint16_t*)(frame->data[2] + i * frame->linesize[2]);
57
58 for (int j = 0; j < avctx->width; j += 2) {
59 /* u, y0, v, y1 */
60 put_bits(&pb, 10, av_clip_uintp2(*u++, 10));
61 put_bits(&pb, 10, av_clip_uintp2(*y++, 10));
62 put_bits(&pb, 10, av_clip_uintp2(*v++, 10));
63 put_bits(&pb, 10, av_clip_uintp2(*y++, 10));
64 }
65 }
66 flush_put_bits(&pb);
67
68 return 0;
69}
70
71
72static av_cold int encode_init(AVCodecContext *avctx)

Callers

nothing calls this directly

Calls 5

ff_get_encode_bufferFunction · 0.85
av_logFunction · 0.85
init_put_bitsFunction · 0.85
flush_put_bitsFunction · 0.85
put_bitsFunction · 0.70

Tested by

no test coverage detected