static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size,

                       x264_nal_t *nals, int nnal, int skip_sei)

{

    X264Context *x4 = ctx->priv_data;

    uint8_t *p = buf;

    int i;



    /* Write the SEI as part of the first frame. */

    if (x4->sei_size > 0 && nnal > 0) {

        if (x4->sei_size > size) {


            return -1;


        memcpy(p, x4->sei, x4->sei_size);

        p += x4->sei_size;

        x4->sei_size = 0;

        // why is x4->sei not freed?




    for (i = 0; i < nnal; i++){

        /* Don't put the SEI in extradata. */

        if (skip_sei && nals[i].i_type == NAL_SEI) {

            x4->sei_size = nals[i].i_payload;

            x4->sei      = av_malloc(x4->sei_size);

            memcpy(x4->sei, nals[i].p_payload, nals[i].i_payload);

            continue;







        memcpy(p, nals[i].p_payload, nals[i].i_payload);

        p += nals[i].i_payload;




    return p - buf;

static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size,

                       x264_nal_t *nals, int nnal, int skip_sei)

{

    X264Context *x4 = ctx->priv_data;

    uint8_t *p = buf;

    int i;



    

    if (x4->sei_size > 0 && nnal > 0) {

        if (x4->sei_size > size) {


            return -1;


        memcpy(p, x4->sei, x4->sei_size);

        p += x4->sei_size;

        x4->sei_size = 0;

        




    for (i = 0; i < nnal; i++){

        

        if (skip_sei && nals[i].i_type == NAL_SEI) {

            x4->sei_size = nals[i].i_payload;

            x4->sei      = av_malloc(x4->sei_size);

            memcpy(x4->sei, nals[i].p_payload, nals[i].i_payload);

            continue;







        memcpy(p, nals[i].p_payload, nals[i].i_payload);

        p += nals[i].i_payload;




    return p - buf;

static int FUNC_0(AVCodecContext *VAR_0, uint8_t *VAR_1, int VAR_2,

                       x264_nal_t *VAR_3, int VAR_4, int VAR_5)

{

    X264Context *x4 = VAR_0->priv_data;

    uint8_t *p = VAR_1;

    int VAR_6;



    

    if (x4->sei_size > 0 && VAR_4 > 0) {

        if (x4->sei_size > VAR_2) {


            return -1;


        memcpy(p, x4->sei, x4->sei_size);

        p += x4->sei_size;

        x4->sei_size = 0;

        




    for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++){

        

        if (VAR_5 && VAR_3[VAR_6].i_type == NAL_SEI) {

            x4->sei_size = VAR_3[VAR_6].i_payload;

            x4->sei      = av_malloc(x4->sei_size);

            memcpy(x4->sei, VAR_3[VAR_6].p_payload, VAR_3[VAR_6].i_payload);

            continue;







        memcpy(p, VAR_3[VAR_6].p_payload, VAR_3[VAR_6].i_payload);

        p += VAR_3[VAR_6].i_payload;




    return p - VAR_1;

static int FUNC_0(AVCodecContext *VAR_0, uint8_t *VAR_1, int VAR_2,
x264_nal_t *VAR_3, int VAR_4, int VAR_5)
{ X264Context *x4 = VAR_0->priv_data; uint8_t *p = VAR_1; int VAR_6; if (x4->sei_size > 0 && VAR_4 > 0) { if (x4->sei_size > VAR_2) { return -1; memcpy(p, x4->sei, x4->sei_size); p += x4->sei_size; x4->sei_size = 0; for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++){ if (VAR_5 && VAR_3[VAR_6].i_type == NAL_SEI) { x4->sei_size = VAR_3[VAR_6].i_payload; x4->sei      = av_malloc(x4->sei_size); memcpy(x4->sei, VAR_3[VAR_6].p_payload, VAR_3[VAR_6].i_payload); continue; memcpy(p, VAR_3[VAR_6].p_payload, VAR_3[VAR_6].i_payload); p += VAR_3[VAR_6].i_payload; return p - VAR_1;