>y_1strow += Width;
>y_2ndrow += Width;

Check this to see if it is your problem.

Appears you should be using the pitch for this and not the width. Normally width is width of video and pitch is the number of bytes per line and can be greater than width.

On 7/27/2016 11:05 PM, Ankush Wadke wrote:
Thanks for the reply Harry.
And yes it has something to do with the offset of U and V planes but it works perfectly fine for a FHD stream i.e. 1920x1080 but dosent seem to for a 3840x2160 stream. Does planer data require alignment to be considered?

On Wed, Jul 27, 2016 at 7:51 PM, Harry <[email protected] <mailto:[email protected]>> wrote:

    Green borders are a wrong offset / starting address for the UV planes.

    Harry

    Sent from my smartphone

    On 27 Jul 2016, at 11:47, Ankush Wadke <[email protected]
    <mailto:[email protected]>> wrote:

    Hi everybody,
        I am stuck with a problem to which I am not able to figure
    out what exactly is wrong.
        I am decoding a 4k video which gives me a YUV420P output
    frame. In order to convert it to UYVY I wrote a piece of code.
    which works fine for first frame, then second frame has a small
    green line and the third frame has the colors totally displaced.
    I am getting the correct frames sometimes but i am not able to
    figure out what is wrong with the other frames.
        It would be really helpful if someone would point me to
    something tat would help.

    hers the code i am using for conversion,

    void Convert_yuv420_to_yuv422(const AVFrame &videoBuffer, uint8_t
    * opBuffer, const int const &Width,  const int const &Height)
    {
    uint8_t  *buffer_uyvy_1strow = opBuffer,
                        *buffer_uyvy_2ndrow = opBuffer+(2*Width);

    uint8_t*y_1strow = videoBuffer.data[0],
    *y_2ndrow = videoBuffer.data[0]+Width;

    uint8_t * u_ptr = videoBuffer.data[1];
    uint8_t * v_ptr = videoBuffer.data[2];

    for (unsigned int i_conv_ht =0; i_conv_ht<Height;i_conv_ht+=2) {
    for (unsigned int i_conv_wt =0; i_conv_wt<Width;i_conv_wt+=2) {
    *buffer_uyvy_1strow++ = *u_ptr;
    *buffer_uyvy_1strow++ = *y_1strow++;
    *buffer_uyvy_1strow++ = *v_ptr;
    *buffer_uyvy_1strow++ = *y_1strow++;

    *buffer_uyvy_2ndrow++ = *u_ptr;
    *buffer_uyvy_2ndrow++ = *y_2ndrow++;
    *buffer_uyvy_2ndrow++ = *v_ptr;
    *buffer_uyvy_2ndrow++ = *y_2ndrow++;

    ++u_ptr;
    ++v_ptr;
    }
    y_1strow += Width;
    y_2ndrow += Width;

    buffer_uyvy_1strow += FFALIGN((2*Width),1);
    buffer_uyvy_2ndrow += FFALIGN((2*Width),1);
    }
    }

    Regards,
    Ankush

     *

     *


    _______________________________________________
    Libav-user mailing list
    [email protected] <mailto:[email protected]>
    http://ffmpeg.org/mailman/listinfo/libav-user

    _______________________________________________
    Libav-user mailing list
    [email protected] <mailto:[email protected]>
    http://ffmpeg.org/mailman/listinfo/libav-user




--
*Ankush Wadke

*
Mob: 9673898604
Email: [email protected] <mailto:[email protected]>

 *

  * in.linkedin.com/pub/ankush-wadke/36/868/981/
    <http://in.linkedin.com/pub/ankush-wadke/36/868/981/>



_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to