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,6 +288,9 @@ int ff_ffv1_parse_header(FFV1Context *f, RangeCoder *c, uint8_t *state)
|
||||
f->pix_fmt = AV_PIX_FMT_GRAY14;
|
||||
} else if (f->avctx->bits_per_raw_sample == 16) {
|
||||
f->packed_at_lsb = 1;
|
||||
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) {
|
||||
f->pix_fmt = AV_PIX_FMT_GRAY16;
|
||||
|
@ -128,10 +128,20 @@ 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);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (sc->remap)
|
||||
for (x = 0; x < w; x++)
|
||||
sample[1][x] = sc->fltmap[remap_index][sample[1][x]];
|
||||
if (f->packed_at_lsb) {
|
||||
|
||||
if (sc->remap) {
|
||||
if (f->packed_at_lsb || f->avctx->bits_per_raw_sample == 16) {
|
||||
for (x = 0; x < w; x++) {
|
||||
((uint16_t*)(src + stride*y))[x*pixel_stride] = sc->fltmap[remap_index][sample[1][x] & 0xFFFF];
|
||||
}
|
||||
} 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 {
|
||||
if (f->packed_at_lsb || f->avctx->bits_per_raw_sample == 16) {
|
||||
for (x = 0; x < w; x++) {
|
||||
((uint16_t*)(src + stride*y))[x*pixel_stride] = sample[1][x];
|
||||
}
|
||||
@ -142,6 +152,7 @@ static int decode_plane(FFV1Context *f, FFV1SliceContext *sc,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -839,6 +839,7 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx,
|
||||
case AV_PIX_FMT_YUVA444P16:
|
||||
case AV_PIX_FMT_YUVA422P16:
|
||||
case AV_PIX_FMT_YUVA420P16:
|
||||
case AV_PIX_FMT_GRAYF16:
|
||||
case AV_PIX_FMT_YAF16:
|
||||
if (!avctx->bits_per_raw_sample && !s->bits_per_raw_sample) {
|
||||
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_YUV440P10, AV_PIX_FMT_YUV440P12,
|
||||
AV_PIX_FMT_YAF16,
|
||||
AV_PIX_FMT_GRAYF16,
|
||||
AV_PIX_FMT_GBRPF16),
|
||||
.color_ranges = AVCOL_RANGE_MPEG,
|
||||
.p.priv_class = &ffv1_class,
|
||||
|
Reference in New Issue
Block a user