FFmpeg: Add support for 16 bits FFV1 output

This adds 16-bit/channel option for FFV1 video codec to
output render videos with high precision

Pull Request: https://projects.blender.org/blender/blender/pulls/138624
This commit is contained in:
Martin Vignali
2025-05-13 11:10:33 +02:00
committed by Pratik Borhade
parent 0cee690de3
commit 1d21d496f2
2 changed files with 15 additions and 1 deletions

View File

@@ -392,6 +392,9 @@ int MOV_codec_valid_bit_depths(int av_codec_id)
if (ELEM(av_codec_id, AV_CODEC_ID_H265, AV_CODEC_ID_AV1, AV_CODEC_ID_FFV1)) {
bit_depths |= R_IMF_CHAN_DEPTH_12;
}
if (ELEM(av_codec_id, AV_CODEC_ID_FFV1)) {
bit_depths |= R_IMF_CHAN_DEPTH_16;
}
#else
UNUSED_VARS(av_codec_id);
#endif

View File

@@ -766,6 +766,7 @@ static AVStream *alloc_video_stream(MovieWriter *context,
const bool is_10_bpp = rd->im_format.depth == R_IMF_CHAN_DEPTH_10;
const bool is_12_bpp = rd->im_format.depth == R_IMF_CHAN_DEPTH_12;
const bool is_16_bpp = rd->im_format.depth == R_IMF_CHAN_DEPTH_16;
if (is_10_bpp) {
c->pix_fmt = AV_PIX_FMT_YUV420P10LE;
}
@@ -813,6 +814,9 @@ static AVStream *alloc_video_stream(MovieWriter *context,
else if (is_12_bpp) {
c->pix_fmt = AV_PIX_FMT_GRAY12;
}
else if (is_16_bpp) {
c->pix_fmt = AV_PIX_FMT_GRAY16;
}
}
else if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
c->pix_fmt = AV_PIX_FMT_RGB32;
@@ -822,6 +826,9 @@ static AVStream *alloc_video_stream(MovieWriter *context,
else if (is_12_bpp) {
c->pix_fmt = AV_PIX_FMT_GBRAP12;
}
else if (is_16_bpp) {
c->pix_fmt = AV_PIX_FMT_GBRAP16;
}
}
else { /* RGB */
c->pix_fmt = AV_PIX_FMT_0RGB32;
@@ -831,6 +838,9 @@ static AVStream *alloc_video_stream(MovieWriter *context,
else if (is_12_bpp) {
c->pix_fmt = AV_PIX_FMT_GBRP12;
}
else if (is_16_bpp) {
c->pix_fmt = AV_PIX_FMT_GBRP16;
}
}
}
@@ -954,7 +964,8 @@ static AVStream *alloc_video_stream(MovieWriter *context,
}
else {
/* Output pixel format is different, allocate frame for conversion. */
AVPixelFormat src_format = is_10_bpp || is_12_bpp ? AV_PIX_FMT_GBRAPF32LE : AV_PIX_FMT_RGBA;
AVPixelFormat src_format = is_10_bpp || is_12_bpp || is_16_bpp ? AV_PIX_FMT_GBRAPF32LE :
AV_PIX_FMT_RGBA;
context->img_convert_frame = alloc_frame(src_format, c->width, c->height);
context->img_convert_ctx = ffmpeg_sws_get_context(
c->width, c->height, src_format, c->width, c->height, c->pix_fmt, SWS_BICUBIC);