From 928a0caa3e5db2d4748bce6b23507757f9867d14 Mon Sep 17 00:00:00 2001 From: Rich Geldreich Date: Mon, 27 Dec 2021 02:18:33 -0500 Subject: [PATCH] Fixing asserts on 1x1 jpeg's when chroma filtering is enabled. --- encoder/jpgd.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/encoder/jpgd.cpp b/encoder/jpgd.cpp index 4608344..563fa74 100644 --- a/encoder/jpgd.cpp +++ b/encoder/jpgd.cpp @@ -2085,7 +2085,7 @@ namespace jpgd { if (setjmp(m_jmp_state)) return JPGD_FAILED; - const bool chroma_y_filtering = (m_flags & cFlagLinearChromaFiltering) && ((m_scan_type == JPGD_YH2V2) || (m_scan_type == JPGD_YH1V2)); + const bool chroma_y_filtering = (m_flags & cFlagLinearChromaFiltering) && ((m_scan_type == JPGD_YH2V2) || (m_scan_type == JPGD_YH1V2)) && (m_image_x_size >= 2) && (m_image_y_size >= 2); if (chroma_y_filtering) { std::swap(m_pSample_buf, m_pSample_buf_prev); @@ -2114,7 +2114,7 @@ namespace jpgd { if (m_total_lines_left == 0) return JPGD_DONE; - const bool chroma_y_filtering = (m_flags & cFlagLinearChromaFiltering) && ((m_scan_type == JPGD_YH2V2) || (m_scan_type == JPGD_YH1V2)); + const bool chroma_y_filtering = (m_flags & cFlagLinearChromaFiltering) && ((m_scan_type == JPGD_YH2V2) || (m_scan_type == JPGD_YH1V2)) && (m_image_x_size >= 2) && (m_image_y_size >= 2); bool get_another_mcu_row = false; bool got_mcu_early = false; @@ -2144,7 +2144,7 @@ namespace jpgd { { case JPGD_YH2V2: { - if (m_flags & cFlagLinearChromaFiltering) + if ((m_flags & cFlagLinearChromaFiltering) && (m_image_x_size >= 2) && (m_image_y_size >= 2)) { if (m_num_buffered_scanlines == 1) { @@ -2173,7 +2173,7 @@ namespace jpgd { } case JPGD_YH2V1: { - if (m_flags & cFlagLinearChromaFiltering) + if ((m_flags & cFlagLinearChromaFiltering) && (m_image_x_size >= 2) && (m_image_y_size >= 2)) H2V1ConvertFiltered(); else H2V1Convert();