<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    W dniu 2017-02-16 o 03:54, Pradeep Ramachandran pisze:<br>
    <blockquote
cite="mid:CAKpaXXde+cOZsGpE9tt1LeNFrxK6EiebJfLqSzsdrWmJ=vW4DA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Thu, Feb 16, 2017 at 12:11 AM,
            Mateusz Brzostek <span dir="ltr"><<a
                moz-do-not-send="true"
                href="mailto:mateusz@msystem.waw.pl" target="_blank">mateusz@msystem.waw.pl</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">This
              patch fixes issue #323 -- crash when encoding to 422. The
              'qpCb' index is -2 on Selur's sample file and options.<br>
              <br>
              Please review.<br>
              <br>
              Mateusz<br>
              <br>
              # HG changeset patch<br>
              # User Ma0 <<a moz-do-not-send="true"
                href="mailto:mateuszb@poczta.onet.pl">mateuszb@poczta.onet.pl</a>><br>
              # Date 1487183578 -3600<br>
              #      Wed Feb 15 19:32:58 2017 +0100<br>
              # Node ID 7b55d81f0677b7cbef5a490d90bd9c<wbr>bbf96127cb<br>
              # Parent  912dd749bdb53cdd1e251bc3a69e4c<wbr>41ece3b308<br>
              SAO: avoid negative indexes in 'x265_lambda2_tab' table<br>
              <br>
              diff -r 912dd749bdb5 -r 7b55d81f0677
              source/encoder/sao.cpp<br>
              --- a/source/encoder/sao.cpp    Wed Feb 15 12:04:41 2017
              +0530<br>
              +++ b/source/encoder/sao.cpp    Wed Feb 15 19:32:58 2017
              +0100<br>
              @@ -1234,7 +1234,7 @@<br>
                   if (m_param->internalCsp == X265_CSP_I420)<br>
                       qpCb = x265_clip3(m_param->rc.qpMin,
              m_param->rc.qpMax, (int)g_chromaScale[qp +
              slice->m_pps->chromaQpOffset[<wbr>0]]);<br>
                   else<br>
              -        qpCb = X265_MIN(qp +
              slice->m_pps->chromaQpOffset[<wbr>0], QP_MAX_SPEC);<br>
              +        qpCb = x265_clip3(0, QP_MAX_SPEC, qp +
              slice->m_pps->chromaQpOffset[<wbr>0]);<br>
            </blockquote>
            <div><br>
            </div>
            <div>This clip should be between m_param->rc.qpMin and
              m_param->rc.qpMax, as per what is done for the 4:2:0
              videos.</div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <br>
                   lambda[0] = (int64_t)floor(256.0 *
              x265_lambda2_tab[qp]);<br>
                   lambda[1] = (int64_t)floor(256.0 *
              x265_lambda2_tab[qpCb]); // Use Cb QP for SAO chroma<br>
              <br>
              <br>
              ______________________________<wbr>_________________<br>
              x265-devel mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
              <a moz-do-not-send="true"
                href="https://mailman.videolan.org/listinfo/x265-devel"
                rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/x265-devel</a><br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
x265-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a>
<a class="moz-txt-link-freetext" href="https://mailman.videolan.org/listinfo/x265-devel">https://mailman.videolan.org/listinfo/x265-devel</a>
</pre>
    </blockquote>
    Thanks for review.<br>
    <br>
    After new commits there are changes in sao.cpp. I've made more tests
    and <br>
    'qp + slice->m_pps->chromaQpOffset[0] +
    slice->m_chromaQpOffset[0]' is < 0 for 4:2:0 too.<br>
    There is no crash but in this case qpCb is random (in good Min and
    Max).<br>
    <br>
    In this new patch index in 'g_chromaScale' table is OK and qpCb is
    between m_param->rc.qpMin and m_param->rc.qpMax.<br>
    <br>
    Please review.<br>
    <br>
    Mateusz<br>
    <br>
    # HG changeset patch<br>
    # User Ma0 <a class="moz-txt-link-rfc2396E" href="mailto:mateuszb@poczta.onet.pl"><mateuszb@poczta.onet.pl></a><br>
    # Date 1487242844 -3600<br>
    #      Thu Feb 16 12:00:44 2017 +0100<br>
    # Node ID cac23bf21ede49cb5f98ec3393fb40bbbbda35ba<br>
    # Parent  db913efb1a5999a75569628b8a4675e1b6b9e066<br>
    SAO: avoid negative indexes in 'x265_lambda2_tab' table<br>
    <br>
    diff -r db913efb1a59 -r cac23bf21ede source/encoder/sao.cpp<br>
    --- a/source/encoder/sao.cpp    Wed Feb 01 17:01:29 2017 +0530<br>
    +++ b/source/encoder/sao.cpp    Thu Feb 16 12:00:44 2017 +0100<br>
    @@ -1230,11 +1230,11 @@<br>
     <br>
         int64_t lambda[2] = { 0 };<br>
     <br>
    -    int qpCb = qp;<br>
    +    int qpCb = qp + slice->m_pps->chromaQpOffset[0] +
    slice->m_chromaQpOffset[0];<br>
         if (m_param->internalCsp == X265_CSP_I420)<br>
    -        qpCb = x265_clip3(m_param->rc.qpMin,
    m_param->rc.qpMax, (int)g_chromaScale[qp +
    slice->m_pps->chromaQpOffset[0] +
    slice->m_chromaQpOffset[0]]);<br>
    +        qpCb = x265_clip3(m_param->rc.qpMin,
    m_param->rc.qpMax, (int)g_chromaScale[x265_clip3(QP_MIN,
    QP_MAX_MAX, qpCb)]);<br>
         else<br>
    -        qpCb = X265_MIN(qp + slice->m_pps->chromaQpOffset[0]
    + slice->m_chromaQpOffset[0], QP_MAX_SPEC);<br>
    +        qpCb = x265_clip3(m_param->rc.qpMin,
    m_param->rc.qpMax, qpCb);<br>
         lambda[0] = (int64_t)floor(256.0 * x265_lambda2_tab[qp]);<br>
         lambda[1] = (int64_t)floor(256.0 * x265_lambda2_tab[qpCb]); //
    Use Cb QP for SAO chroma<br>
      <br>
  </body>
</html>