}
}
+av_cold void ff_v210enc_init(V210EncContext *s)
+{
+ s->pack_line_8 = v210_planar_pack_8_c;
+ s->pack_line_10 = v210_planar_pack_10_c;
+ s->sample_factor_8 = 1;
+ s->sample_factor_10 = 1;
+
+ if (ARCH_X86)
+ ff_v210enc_init_x86(s);
+}
+
static av_cold int encode_init(AVCodecContext *avctx)
{
V210EncContext *s = avctx->priv_data;
return AVERROR(EINVAL);
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
- s->pack_line_8 = v210_planar_pack_8_c;
- s->pack_line_10 = v210_planar_pack_10_c;
-
- if (ARCH_X86)
- ff_v210enc_init_x86(s);
+ ff_v210enc_init(s);
return 0;
}
const uint16_t *y = (const uint16_t *)pic->data[0];
const uint16_t *u = (const uint16_t *)pic->data[1];
const uint16_t *v = (const uint16_t *)pic->data[2];
+
+ const int sample_size = 6 * s->sample_factor_10;
+ const int sample_w = avctx->width / sample_size;
+
for (h = 0; h < avctx->height; h++) {
uint32_t val;
- w = (avctx->width / 6) * 6;
+ w = sample_w * sample_size;
s->pack_line_10(y, u, v, dst, w);
y += w;
u += w >> 1;
v += w >> 1;
- dst += (w / 6) * 16;
+ dst += sample_w * 16 * s->sample_factor_10;
+
+ for (; w < avctx->width - 5; w += 6) {
+ WRITE_PIXELS(u, y, v);
+ WRITE_PIXELS(y, u, y);
+ WRITE_PIXELS(v, y, u);
+ WRITE_PIXELS(y, v, y);
+ }
if (w < avctx->width - 1) {
WRITE_PIXELS(u, y, v);
const uint8_t *y = pic->data[0];
const uint8_t *u = pic->data[1];
const uint8_t *v = pic->data[2];
+
+ const int sample_size = 12 * s->sample_factor_8;
+ const int sample_w = avctx->width / sample_size;
+
for (h = 0; h < avctx->height; h++) {
uint32_t val;
- w = (avctx->width / 12) * 12;
+ w = sample_w * sample_size;
s->pack_line_8(y, u, v, dst, w);
y += w;
u += w >> 1;
v += w >> 1;
- dst += (w / 12) * 32;
+ dst += sample_w * 32 * s->sample_factor_8;
for (; w < avctx->width - 5; w += 6) {
WRITE_PIXELS8(u, y, v);
return 0;
}
-static av_cold int encode_close(AVCodecContext *avctx)
-{
- av_freep(&avctx->coded_frame);
-
- return 0;
-}
-
AVCodec ff_v210_encoder = {
.name = "v210",
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"),
.priv_data_size = sizeof(V210EncContext),
.init = encode_init,
.encode2 = encode_frame,
- .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE },
};