You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/ffv1: Add GRAYF16 support
Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@ -288,7 +288,10 @@ int ff_ffv1_parse_header(FFV1Context *f, RangeCoder *c, uint8_t *state)
|
|||||||
f->pix_fmt = AV_PIX_FMT_GRAY14;
|
f->pix_fmt = AV_PIX_FMT_GRAY14;
|
||||||
} else if (f->avctx->bits_per_raw_sample == 16) {
|
} else if (f->avctx->bits_per_raw_sample == 16) {
|
||||||
f->packed_at_lsb = 1;
|
f->packed_at_lsb = 1;
|
||||||
f->pix_fmt = AV_PIX_FMT_GRAY16;
|
if (f->flt) {
|
||||||
|
f->pix_fmt = AV_PIX_FMT_GRAYF16;
|
||||||
|
} else
|
||||||
|
f->pix_fmt = AV_PIX_FMT_GRAY16;
|
||||||
} else if (f->avctx->bits_per_raw_sample < 16) {
|
} else if (f->avctx->bits_per_raw_sample < 16) {
|
||||||
f->pix_fmt = AV_PIX_FMT_GRAY16;
|
f->pix_fmt = AV_PIX_FMT_GRAY16;
|
||||||
} else
|
} else
|
||||||
|
@ -128,16 +128,27 @@ static int decode_plane(FFV1Context *f, FFV1SliceContext *sc,
|
|||||||
int ret = decode_line(f, sc, gb, w, sample, plane_index, f->avctx->bits_per_raw_sample, ac);
|
int ret = decode_line(f, sc, gb, w, sample, plane_index, f->avctx->bits_per_raw_sample, ac);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (sc->remap)
|
|
||||||
for (x = 0; x < w; x++)
|
if (sc->remap) {
|
||||||
sample[1][x] = sc->fltmap[remap_index][sample[1][x]];
|
if (f->packed_at_lsb || f->avctx->bits_per_raw_sample == 16) {
|
||||||
if (f->packed_at_lsb) {
|
for (x = 0; x < w; x++) {
|
||||||
for (x = 0; x < w; x++) {
|
((uint16_t*)(src + stride*y))[x*pixel_stride] = sc->fltmap[remap_index][sample[1][x] & 0xFFFF];
|
||||||
((uint16_t*)(src + stride*y))[x*pixel_stride] = sample[1][x];
|
}
|
||||||
|
} else {
|
||||||
|
for (x = 0; x < w; x++) {
|
||||||
|
int v = sc->fltmap[remap_index][sample[1][x] & 0xFFFF];
|
||||||
|
((uint16_t*)(src + stride*y))[x*pixel_stride] = v << (16 - f->avctx->bits_per_raw_sample) | v >> (2 * f->avctx->bits_per_raw_sample - 16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (x = 0; x < w; x++) {
|
if (f->packed_at_lsb || f->avctx->bits_per_raw_sample == 16) {
|
||||||
((uint16_t*)(src + stride*y))[x*pixel_stride] = sample[1][x] << (16 - f->avctx->bits_per_raw_sample) | ((uint16_t **)sample)[1][x] >> (2 * f->avctx->bits_per_raw_sample - 16);
|
for (x = 0; x < w; x++) {
|
||||||
|
((uint16_t*)(src + stride*y))[x*pixel_stride] = sample[1][x];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (x = 0; x < w; x++) {
|
||||||
|
((uint16_t*)(src + stride*y))[x*pixel_stride] = sample[1][x] << (16 - f->avctx->bits_per_raw_sample) | ((uint16_t **)sample)[1][x] >> (2 * f->avctx->bits_per_raw_sample - 16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -839,6 +839,7 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx,
|
|||||||
case AV_PIX_FMT_YUVA444P16:
|
case AV_PIX_FMT_YUVA444P16:
|
||||||
case AV_PIX_FMT_YUVA422P16:
|
case AV_PIX_FMT_YUVA422P16:
|
||||||
case AV_PIX_FMT_YUVA420P16:
|
case AV_PIX_FMT_YUVA420P16:
|
||||||
|
case AV_PIX_FMT_GRAYF16:
|
||||||
case AV_PIX_FMT_YAF16:
|
case AV_PIX_FMT_YAF16:
|
||||||
if (!avctx->bits_per_raw_sample && !s->bits_per_raw_sample) {
|
if (!avctx->bits_per_raw_sample && !s->bits_per_raw_sample) {
|
||||||
s->bits_per_raw_sample = 16;
|
s->bits_per_raw_sample = 16;
|
||||||
@ -1539,6 +1540,7 @@ const FFCodec ff_ffv1_encoder = {
|
|||||||
AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14,
|
AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14,
|
||||||
AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV440P12,
|
AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV440P12,
|
||||||
AV_PIX_FMT_YAF16,
|
AV_PIX_FMT_YAF16,
|
||||||
|
AV_PIX_FMT_GRAYF16,
|
||||||
AV_PIX_FMT_GBRPF16),
|
AV_PIX_FMT_GBRPF16),
|
||||||
.color_ranges = AVCOL_RANGE_MPEG,
|
.color_ranges = AVCOL_RANGE_MPEG,
|
||||||
.p.priv_class = &ffv1_class,
|
.p.priv_class = &ffv1_class,
|
||||||
|
Reference in New Issue
Block a user