Commit f39fd206 authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

windowscodecs: Remove get_pixel_format_bpp().

parent 80ae60ca
...@@ -125,6 +125,7 @@ typedef struct dds_info { ...@@ -125,6 +125,7 @@ typedef struct dds_info {
WICDdsDimension dimension; WICDdsDimension dimension;
WICDdsAlphaMode alpha_mode; WICDdsAlphaMode alpha_mode;
const GUID *pixel_format; const GUID *pixel_format;
UINT pixel_format_bpp;
} dds_info; } dds_info;
typedef struct dds_frame_info { typedef struct dds_frame_info {
...@@ -470,11 +471,18 @@ static void get_dds_info(dds_info* info, DDS_HEADER *header, DDS_HEADER_DXT10 *h ...@@ -470,11 +471,18 @@ static void get_dds_info(dds_info* info, DDS_HEADER *header, DDS_HEADER_DXT10 *h
info->dimension = get_dimension(NULL, header_dxt10); info->dimension = get_dimension(NULL, header_dxt10);
info->alpha_mode = header_dxt10->miscFlags2 & 0x00000008; info->alpha_mode = header_dxt10->miscFlags2 & 0x00000008;
info->data_offset = sizeof(DWORD) + sizeof(*header) + sizeof(*header_dxt10); info->data_offset = sizeof(DWORD) + sizeof(*header) + sizeof(*header_dxt10);
if (is_compressed(info->format)) {
info->pixel_format_bpp = 32;
} else {
info->pixel_format_bpp = 0;
FIXME("Pixel format bpp is incorrect for uncompressed DDS image with extended header\n");
}
} else { } else {
info->format = format_info->dxgi_format; info->format = format_info->dxgi_format;
info->dimension = get_dimension(header, NULL); info->dimension = get_dimension(header, NULL);
info->alpha_mode = get_alpha_mode_from_fourcc(header->ddspf.fourCC); info->alpha_mode = get_alpha_mode_from_fourcc(header->ddspf.fourCC);
info->data_offset = sizeof(DWORD) + sizeof(*header); info->data_offset = sizeof(DWORD) + sizeof(*header);
info->pixel_format_bpp = format_info->wic_format_bpp;
} }
info->pixel_format = (info->alpha_mode == WICDdsAlphaModePremultiplied) ? info->pixel_format = (info->alpha_mode == WICDdsAlphaModePremultiplied) ?
&GUID_WICPixelFormat32bppPBGRA : &GUID_WICPixelFormat32bppBGRA; &GUID_WICPixelFormat32bppPBGRA : &GUID_WICPixelFormat32bppBGRA;
...@@ -502,27 +510,6 @@ static void get_dds_info(dds_info* info, DDS_HEADER *header, DDS_HEADER_DXT10 *h ...@@ -502,27 +510,6 @@ static void get_dds_info(dds_info* info, DDS_HEADER *header, DDS_HEADER_DXT10 *h
if (info->dimension == WICDdsTextureCube) info->frame_count *= 6; if (info->dimension == WICDdsTextureCube) info->frame_count *= 6;
} }
static UINT get_pixel_format_bpp(const GUID *pixel_format)
{
HRESULT hr;
UINT bpp = 0;
IWICComponentInfo *info = NULL;
IWICPixelFormatInfo* format_info = NULL;
hr = CreateComponentInfo(pixel_format, &info);
if (hr != S_OK) goto end;
hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo, (void **)&format_info);
if (hr != S_OK) goto end;
IWICPixelFormatInfo_GetBitsPerPixel(format_info, &bpp);
end:
if (format_info) IWICPixelFormatInfo_Release(format_info);
if (info) IWICComponentInfo_Release(info);
return bpp;
}
static void decode_block(const BYTE *block_data, UINT block_count, DXGI_FORMAT format, static void decode_block(const BYTE *block_data, UINT block_count, DXGI_FORMAT format,
UINT width, UINT height, DWORD *buffer) UINT width, UINT height, DWORD *buffer)
{ {
...@@ -766,6 +753,8 @@ static HRESULT WINAPI DdsFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, ...@@ -766,6 +753,8 @@ static HRESULT WINAPI DdsFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
if (!pbBuffer) return E_INVALIDARG; if (!pbBuffer) return E_INVALIDARG;
bpp = This->info.pixel_format_bpp; bpp = This->info.pixel_format_bpp;
if (!bpp) return WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT;
frame_stride = This->info.width * bpp / 8; frame_stride = This->info.width * bpp / 8;
frame_size = frame_stride * This->info.height; frame_size = frame_stride * This->info.height;
if (!prc) { if (!prc) {
...@@ -1326,7 +1315,7 @@ static HRESULT WINAPI DdsDecoder_Dds_GetFrame(IWICDdsDecoder *iface, ...@@ -1326,7 +1315,7 @@ static HRESULT WINAPI DdsDecoder_Dds_GetFrame(IWICDdsDecoder *iface,
frame_decode->info.width_in_blocks = frame_width_in_blocks; frame_decode->info.width_in_blocks = frame_width_in_blocks;
frame_decode->info.height_in_blocks = frame_height_in_blocks; frame_decode->info.height_in_blocks = frame_height_in_blocks;
frame_decode->info.pixel_format = This->info.pixel_format; frame_decode->info.pixel_format = This->info.pixel_format;
frame_decode->info.pixel_format_bpp = get_pixel_format_bpp(This->info.pixel_format); frame_decode->info.pixel_format_bpp = This->info.pixel_format_bpp;
frame_decode->block_data = HeapAlloc(GetProcessHeap(), 0, frame_size); frame_decode->block_data = HeapAlloc(GetProcessHeap(), 0, frame_size);
frame_decode->pixel_data = NULL; frame_decode->pixel_data = NULL;
hr = IStream_Seek(This->stream, seek, SEEK_SET, NULL); hr = IStream_Seek(This->stream, seek, SEEK_SET, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment