Lines Matching defs:avctx

61 static av_cold int utvideo_encode_close(AVCodecContext *avctx)
63 UtvideoContext *c = avctx->priv_data;
73 static av_cold int utvideo_encode_init(AVCodecContext *avctx)
75 UtvideoContext *c = avctx->priv_data;
79 c->avctx = avctx;
81 c->slice_stride = FFALIGN(avctx->width, 32);
83 switch (avctx->pix_fmt) {
86 avctx->codec_tag = MKTAG('U', 'L', 'R', 'G');
91 avctx->codec_tag = MKTAG('U', 'L', 'R', 'A');
93 avctx->bits_per_coded_sample = 32;
96 if (avctx->width & 1 || avctx->height & 1) {
97 av_log(avctx, AV_LOG_ERROR,
102 if (avctx->colorspace == AVCOL_SPC_BT709)
103 avctx->codec_tag = MKTAG('U', 'L', 'H', '0');
105 avctx->codec_tag = MKTAG('U', 'L', 'Y', '0');
109 if (avctx->width & 1) {
110 av_log(avctx, AV_LOG_ERROR,
115 if (avctx->colorspace == AVCOL_SPC_BT709)
116 avctx->codec_tag = MKTAG('U', 'L', 'H', '2');
118 avctx->codec_tag = MKTAG('U', 'L', 'Y', '2');
123 if (avctx->colorspace == AVCOL_SPC_BT709)
124 avctx->codec_tag = MKTAG('U', 'L', 'H', '4');
126 avctx->codec_tag = MKTAG('U', 'L', 'Y', '4');
130 av_log(avctx, AV_LOG_ERROR, "Unknown pixel format: %d\n",
131 avctx->pix_fmt);
139 av_log(avctx, AV_LOG_ERROR, "Gradient prediction is not supported.\n");
147 if (avctx->slices > 256 || avctx->slices < 0) {
148 av_log(avctx, AV_LOG_ERROR,
150 avctx->slices);
155 subsampled_height = avctx->height >> av_pix_fmt_desc_get(avctx->pix_fmt)->log2_chroma_h;
156 if (avctx->slices > subsampled_height) {
157 av_log(avctx, AV_LOG_ERROR,
159 avctx->slices, subsampled_height);
164 avctx->extradata_size = 16;
166 avctx->extradata = av_mallocz(avctx->extradata_size +
169 if (!avctx->extradata) {
170 av_log(avctx, AV_LOG_ERROR, "Could not allocate extradata.\n");
175 c->slice_buffer[i] = av_malloc(c->slice_stride * (avctx->height + 2) +
178 av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 1.\n");
189 AV_WB32(avctx->extradata, MKTAG(1, 0, 0, 0xF0));
195 AV_WL32(avctx->extradata + 4, original_format);
198 AV_WL32(avctx->extradata + 8, c->frame_info_size);
205 if (!avctx->slices) {
213 c->slices = avctx->slices;
230 AV_WL32(avctx->extradata + 12, c->flags);
379 static int encode_plane(AVCodecContext *avctx, uint8_t *src,
383 UtvideoContext *c = avctx->priv_data;
390 const int cmask = ~(!plane_no && avctx->pix_fmt == AV_PIX_FMT_YUV420P);
422 av_log(avctx, AV_LOG_ERROR, "Unknown prediction mode: %d\n",
520 static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
523 UtvideoContext *c = avctx->priv_data;
530 int width = avctx->width, height = avctx->height;
534 ret = ff_alloc_packet(avctx, pkt, (256 + 4 * c->slices + width * height)
547 av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 2.\n");
552 if (avctx->pix_fmt == AV_PIX_FMT_GBRAP || avctx->pix_fmt == AV_PIX_FMT_GBRP)
557 switch (avctx->pix_fmt) {
561 ret = encode_plane(avctx, c->slice_buffer[i] + 2 * c->slice_stride,
566 av_log(avctx, AV_LOG_ERROR, "Error encoding plane %d.\n", i);
573 ret = encode_plane(avctx, pic->data[i], c->slice_buffer[0],
577 av_log(avctx, AV_LOG_ERROR, "Error encoding plane %d.\n", i);
584 ret = encode_plane(avctx, pic->data[i], c->slice_buffer[0],
588 av_log(avctx, AV_LOG_ERROR, "Error encoding plane %d.\n", i);
595 ret = encode_plane(avctx, pic->data[i], c->slice_buffer[0],
600 av_log(avctx, AV_LOG_ERROR, "Error encoding plane %d.\n", i);
606 av_log(avctx, AV_LOG_ERROR, "Unknown pixel format: %d\n",
607 avctx->pix_fmt);