mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-19 20:32:15 +02:00
libobs/graphics: Read floating point image files
Certain file types (such as .tiff) can contain RGB data of floating point bit depth. This allows reading that data as-is without unnecessarily converting it to a lower bit depth.
This commit is contained in:
parent
0d8f54a4b8
commit
97e5e3efde
@ -116,9 +116,10 @@ fail:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void *ffmpeg_image_copy_data_straight(struct ffmpeg_image *info,
|
static void *ffmpeg_image_copy_data_straight(struct ffmpeg_image *info,
|
||||||
AVFrame *frame)
|
AVFrame *frame,
|
||||||
|
size_t channel_bits)
|
||||||
{
|
{
|
||||||
const size_t linesize = (size_t)info->cx * 4;
|
const size_t linesize = (size_t)info->cx * 4 * channel_bits / 8;
|
||||||
const size_t totalsize = info->cy * linesize;
|
const size_t totalsize = info->cy * linesize;
|
||||||
void *data = bmalloc(totalsize);
|
void *data = bmalloc(totalsize);
|
||||||
|
|
||||||
@ -369,12 +370,18 @@ static void *ffmpeg_image_reformat_frame(struct ffmpeg_image *info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (info->format == AV_PIX_FMT_BGR0) {
|
if (info->format == AV_PIX_FMT_BGR0) {
|
||||||
data = ffmpeg_image_copy_data_straight(info, frame);
|
data = ffmpeg_image_copy_data_straight(info, frame, 8);
|
||||||
|
|
||||||
|
} else if (info->format == AV_PIX_FMT_RGBAF16LE) {
|
||||||
|
data = ffmpeg_image_copy_data_straight(info, frame, 16);
|
||||||
|
|
||||||
|
} else if (info->format == AV_PIX_FMT_RGBAF32LE) {
|
||||||
|
data = ffmpeg_image_copy_data_straight(info, frame, 32);
|
||||||
|
|
||||||
} else if (info->format == AV_PIX_FMT_RGBA ||
|
} else if (info->format == AV_PIX_FMT_RGBA ||
|
||||||
info->format == AV_PIX_FMT_BGRA) {
|
info->format == AV_PIX_FMT_BGRA) {
|
||||||
if (alpha_mode == GS_IMAGE_ALPHA_STRAIGHT) {
|
if (alpha_mode == GS_IMAGE_ALPHA_STRAIGHT) {
|
||||||
data = ffmpeg_image_copy_data_straight(info, frame);
|
data = ffmpeg_image_copy_data_straight(info, frame, 8);
|
||||||
} else {
|
} else {
|
||||||
const size_t linesize = (size_t)info->cx * 4;
|
const size_t linesize = (size_t)info->cx * 4;
|
||||||
const size_t totalsize = info->cy * linesize;
|
const size_t totalsize = info->cy * linesize;
|
||||||
@ -611,6 +618,10 @@ static inline enum gs_color_format convert_format(enum AVPixelFormat format)
|
|||||||
return GS_BGRX;
|
return GS_BGRX;
|
||||||
case AV_PIX_FMT_RGBA64BE:
|
case AV_PIX_FMT_RGBA64BE:
|
||||||
return GS_RGBA16;
|
return GS_RGBA16;
|
||||||
|
case AV_PIX_FMT_RGBAF16LE:
|
||||||
|
return GS_RGBA16F;
|
||||||
|
case AV_PIX_FMT_RGBAF32LE:
|
||||||
|
return GS_RGBA32F;
|
||||||
default:
|
default:
|
||||||
return GS_BGRX;
|
return GS_BGRX;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user