| 7817 | } |
| 7818 | |
| 7819 | bool basisu_lowlevel_etc1s_transcoder::transcode_slice(void* pDst_blocks, uint32_t num_blocks_x, uint32_t num_blocks_y, const uint8_t* pImage_data, uint32_t image_data_size, block_format fmt, |
| 7820 | uint32_t output_block_or_pixel_stride_in_bytes, bool bc1_allow_threecolor_blocks, const bool is_video, const bool is_alpha_slice, const uint32_t level_index, const uint32_t orig_width, const uint32_t orig_height, uint32_t output_row_pitch_in_blocks_or_pixels, |
| 7821 | basisu_transcoder_state* pState, bool transcode_alpha, void *pAlpha_blocks, uint32_t output_rows_in_pixels) |
| 7822 | { |
| 7823 | // 'pDst_blocks' unused when disabling *all* hardware transcode options |
| 7824 | // (and 'bc1_allow_threecolor_blocks' when disabling DXT) |
| 7825 | BASISU_NOTE_UNUSED(pDst_blocks); |
| 7826 | BASISU_NOTE_UNUSED(bc1_allow_threecolor_blocks); |
| 7827 | BASISU_NOTE_UNUSED(transcode_alpha); |
| 7828 | BASISU_NOTE_UNUSED(pAlpha_blocks); |
| 7829 | |
| 7830 | assert(g_transcoder_initialized); |
| 7831 | if (!g_transcoder_initialized) |
| 7832 | { |
| 7833 | BASISU_DEVEL_ERROR("basisu_lowlevel_etc1s_transcoder::transcode_slice: Transcoder not globally initialized.\n"); |
| 7834 | return false; |
| 7835 | } |
| 7836 | |
| 7837 | if (!pState) |
| 7838 | pState = &m_def_state; |
| 7839 | |
| 7840 | const uint32_t total_blocks = num_blocks_x * num_blocks_y; |
| 7841 | |
| 7842 | if (!output_row_pitch_in_blocks_or_pixels) |
| 7843 | { |
| 7844 | if (basis_block_format_is_uncompressed(fmt)) |
| 7845 | output_row_pitch_in_blocks_or_pixels = orig_width; |
| 7846 | else |
| 7847 | { |
| 7848 | if (fmt == block_format::cFXT1_RGB) |
| 7849 | output_row_pitch_in_blocks_or_pixels = (orig_width + 7) / 8; |
| 7850 | else |
| 7851 | output_row_pitch_in_blocks_or_pixels = num_blocks_x; |
| 7852 | } |
| 7853 | } |
| 7854 | |
| 7855 | if (basis_block_format_is_uncompressed(fmt)) |
| 7856 | { |
| 7857 | if (!output_rows_in_pixels) |
| 7858 | output_rows_in_pixels = orig_height; |
| 7859 | } |
| 7860 | |
| 7861 | basisu::vector<uint32_t>* pPrev_frame_indices = nullptr; |
| 7862 | if (is_video) |
| 7863 | { |
| 7864 | // TODO: Add check to make sure the caller hasn't tried skipping past p-frames |
| 7865 | //const bool alpha_flag = (slice_desc.m_flags & cSliceDescFlagsHasAlpha) != 0; |
| 7866 | //const uint32_t level_index = slice_desc.m_level_index; |
| 7867 | |
| 7868 | if (level_index >= basisu_transcoder_state::cMaxPrevFrameLevels) |
| 7869 | { |
| 7870 | BASISU_DEVEL_ERROR("basisu_lowlevel_etc1s_transcoder::transcode_slice: unsupported level_index\n"); |
| 7871 | return false; |
| 7872 | } |
| 7873 | |
| 7874 | pPrev_frame_indices = &pState->m_prev_frame_indices[is_alpha_slice][level_index]; |
| 7875 | if (pPrev_frame_indices->size() < total_blocks) |
| 7876 | pPrev_frame_indices->resize(total_blocks); |
no test coverage detected