<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#CCCCCC" text="#000000">
    Greetings all,<br>
    <br>
       This must be asked a million times, but I am trying to take rgb24
    and convert it to yuv420 for use with x264.  My code is failing on
    the sws_scale call with a bad access, inside
    ff_yuv2plane1_8_avx.loop_a, which suggests to me that I haven't
    given it the input data structures in the right way. I'm starting
    with packed data, that is, rgb pixel values every 24 bits, but it
    looks like the sws_scale call is generalized to assume that input
    and output data is planar, and that (I imagine) if the input (or
    output) is supposed to be non-planar, that it should be stored/can
    be found in the first plane of the relevant data structures<br>
    <br>
      Since x264 seems to provide for a data structure that fits this
    purpose (the img struct inside of a pic_t, properly initialized),
    I've used it as my dst and dstStride locations<br>
    <br>
       My code looks like this.<br>
    <br>
    //the compiler complained that it couldn't locate these when I tried
    to call them directly in the getCachedContext call.  This is the
    result of a few rounds of debugging<br>
        enum AVPixelFormat src_pix_fmt = AV_PIX_FMT_RGB24, dst_pix_fmt =
    AV_PIX_FMT_YUV420P;<br>
    <br>
    <br>
        scale_context = sws_getCachedContext(scale_context,<br>
                         frame_width,<br>
                         frame_height,<br>
                         src_pix_fmt,<br>
                         frame_width,<br>
                         frame_height,<br>
                         dst_pix_fmt,<br>
                         SWS_BICUBIC,<br>
                         NULL,<br>
                         NULL,<br>
                         NULL<br>
                         );<br>
    <br>
    //where frame_width, frame_height is the size in pixels of my input
    frame (right?)<br>
    <br>
    ...snip...<br>
    <br>
          sws_scale(scale_context,<br>
                &frame,<br>
                &rowstride,<br>
                0,<br>
                x264_params->i_height,<br>
                pic_in.img.plane,<br>
                pic_in.img.i_stride<br>
                );<br>
    <br>
    <br>
    where frame is a pointer to my packed data, so I pass in a reference
    to the pointer (so that, assuming that the input pixel format
    specifier assumes packed data, and that the packed data is in the
    [0] offset of the pointer provided to the function....) right?, <br>
    rowstride is 3 * frame_width stored in a local, same problem, the
    function call is expecting a pointer or reference to de-reference,
    but since this is packed data there is only one stride, right?<br>
    <br>
    pic_in is a struct from the x264 library, with a convenient sub
    structure img, which seems to be purpose built for this kind of
    function (or vice versa), where i_stride is an array of strides,
    plane an array of planes, i_height was a convenient place for me to
    retrieve this value.<br>
    <br>
    I have a feeling I'm abusing lots of things, I was trying to avoid
    doing this and using x264 support for encoding rgb directly, but
    apparently it was too bleeding edge and decoding it was becoming a
    problem.  I thought the plan b wouldn't be too hard to implement but
    I just don't seem to be understanding how to setup and use this
    code.<br>
    <br>
    I'm starting from a codebase that did compile and run, attempting to
    encode the rgb directly.  I couldn't find a decoder that was able to
    decode what I was producing, it seemed to be related to the
    colorspace I was trying to decode to, so it became more apparent
    that I needed to do a conversion.<br>
    <br>
    I would appreciate any pointers anyone may have.  I'm not afraid of
    reading, I just haven't been able to leverage the things I've found
    so far.<br>
    <pre class="moz-signature" cols="72">-- 
Joshua Kordani
LSA Autonomy</pre>
  </body>
</html>