static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)

{

    int i;

    m->style_entries = AV_RB16(tsmb);

    tsmb += 2;

    // A single style record is of length 12 bytes.

    if (m->tracksize + m->size_var + 2 + m->style_entries * 12 > avpkt->size)

        return -1;



    m->box_flags |= STYL_BOX;

    for(i = 0; i < m->style_entries; i++) {

        m->s_temp = av_malloc(sizeof(*m->s_temp));

        if (!m->s_temp) {

            mov_text_cleanup(m);

            return AVERROR(ENOMEM);

        }

        m->s_temp->style_start = AV_RB16(tsmb);

        tsmb += 2;

        m->s_temp->style_end = AV_RB16(tsmb);

        tsmb += 2;

        m->s_temp->style_fontID = AV_RB16(tsmb);

        tsmb += 2;

        m->s_temp->style_flag = AV_RB8(tsmb);

        tsmb++;

        m->s_temp->fontsize = AV_RB8(tsmb);

        av_dynarray_add(&m->s, &m->count_s, m->s_temp);

        if(!m->s) {

            mov_text_cleanup(m);

            return AVERROR(ENOMEM);

        }

        tsmb++;

        // text-color-rgba

        tsmb += 4;

    }

    return 0;

}

static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)

{

    int i;

    m->style_entries = AV_RB16(tsmb);

    tsmb += 2;

    

    if (m->tracksize + m->size_var + 2 + m->style_entries * 12 > avpkt->size)

        return -1;



    m->box_flags |= STYL_BOX;

    for(i = 0; i < m->style_entries; i++) {

        m->s_temp = av_malloc(sizeof(*m->s_temp));

        if (!m->s_temp) {

            mov_text_cleanup(m);

            return AVERROR(ENOMEM);

        }

        m->s_temp->style_start = AV_RB16(tsmb);

        tsmb += 2;

        m->s_temp->style_end = AV_RB16(tsmb);

        tsmb += 2;

        m->s_temp->style_fontID = AV_RB16(tsmb);

        tsmb += 2;

        m->s_temp->style_flag = AV_RB8(tsmb);

        tsmb++;

        m->s_temp->fontsize = AV_RB8(tsmb);

        av_dynarray_add(&m->s, &m->count_s, m->s_temp);

        if(!m->s) {

            mov_text_cleanup(m);

            return AVERROR(ENOMEM);

        }

        tsmb++;

        

        tsmb += 4;

    }

    return 0;

}

    m->style_entries = AV_RB16(tsmb);     if (m->tracksize + m->size_var + 2 + m->style_entries * 12 > avpkt->size)
static int FUNC_0(const uint8_t *VAR_0, MovTextContext *VAR_1, AVPacket *VAR_2)

{

    int VAR_3;

    VAR_1->style_entries = AV_RB16(VAR_0);

    VAR_0 += 2;

    

    if (VAR_1->tracksize + VAR_1->size_var + 2 + VAR_1->style_entries * 12 > VAR_2->size)

        return -1;



    VAR_1->box_flags |= STYL_BOX;

    for(VAR_3 = 0; VAR_3 < VAR_1->style_entries; VAR_3++) {

        VAR_1->s_temp = av_malloc(sizeof(*VAR_1->s_temp));

        if (!VAR_1->s_temp) {

            mov_text_cleanup(VAR_1);

            return AVERROR(ENOMEM);

        }

        VAR_1->s_temp->style_start = AV_RB16(VAR_0);

        VAR_0 += 2;

        VAR_1->s_temp->style_end = AV_RB16(VAR_0);

        VAR_0 += 2;

        VAR_1->s_temp->style_fontID = AV_RB16(VAR_0);

        VAR_0 += 2;

        VAR_1->s_temp->style_flag = AV_RB8(VAR_0);

        VAR_0++;

        VAR_1->s_temp->fontsize = AV_RB8(VAR_0);

        av_dynarray_add(&VAR_1->s, &VAR_1->count_s, VAR_1->s_temp);

        if(!VAR_1->s) {

            mov_text_cleanup(VAR_1);

            return AVERROR(ENOMEM);

        }

        VAR_0++;

        

        VAR_0 += 4;

    }

    return 0;

}

static int FUNC_0(const uint8_t *VAR_0, MovTextContext *VAR_1, AVPacket *VAR_2)
{ int VAR_3; VAR_1->style_entries = AV_RB16(VAR_0); VAR_0 += 2; if (VAR_1->tracksize + VAR_1->size_var + 2 + VAR_1->style_entries * 12 > VAR_2->size)
return -1; VAR_1->box_flags |= STYL_BOX; for(VAR_3 = 0; VAR_3 < VAR_1->style_entries; VAR_3++) { VAR_1->s_temp = av_malloc(sizeof(*VAR_1->s_temp)); if (!VAR_1->s_temp) { mov_text_cleanup(VAR_1); return AVERROR(ENOMEM); } VAR_1->s_temp->style_start = AV_RB16(VAR_0); VAR_0 += 2; VAR_1->s_temp->style_end = AV_RB16(VAR_0); VAR_0 += 2; VAR_1->s_temp->style_fontID = AV_RB16(VAR_0); VAR_0 += 2; VAR_1->s_temp->style_flag = AV_RB8(VAR_0); VAR_0++; VAR_1->s_temp->fontsize = AV_RB8(VAR_0); av_dynarray_add(&VAR_1->s, &VAR_1->count_s, VAR_1->s_temp); if(!VAR_1->s) { mov_text_cleanup(VAR_1); return AVERROR(ENOMEM); } VAR_0++; VAR_0 += 4; } return 0; }