static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)

{

    AVStream *st;

    MOVStreamContext *sc;

    int ret;



    if (c->fc->nb_streams < 1)

        return 0;

    st = c->fc->streams[c->fc->nb_streams - 1];

    sc = st->priv_data;



    avio_r8(pb); /* version */

    avio_rb24(pb); /* flags */

    sc->stsd_count = avio_rb32(pb); /* entries */



    /* Prepare space for hosting multiple extradata. */

    sc->extradata = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata));

    if (!sc->extradata)

        return AVERROR(ENOMEM);



    sc->extradata_size = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata_size));

    if (!sc->extradata_size)

        return AVERROR(ENOMEM);



    ret = ff_mov_read_stsd_entries(c, pb, sc->stsd_count);

    if (ret < 0)

        return ret;



    /* Restore back the primary extradata. */

    av_freep(&st->codecpar->extradata);

    st->codecpar->extradata_size = sc->extradata_size[0];

    if (sc->extradata_size[0]) {

        st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE);

        if (!st->codecpar->extradata)

            return AVERROR(ENOMEM);

        memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]);

    }



    return 0;

}

static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)

{

    AVStream *st;

    MOVStreamContext *sc;

    int ret;



    if (c->fc->nb_streams < 1)

        return 0;

    st = c->fc->streams[c->fc->nb_streams - 1];

    sc = st->priv_data;



    avio_r8(pb); 

    avio_rb24(pb); 

    sc->stsd_count = avio_rb32(pb); 



    

    sc->extradata = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata));

    if (!sc->extradata)

        return AVERROR(ENOMEM);



    sc->extradata_size = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata_size));

    if (!sc->extradata_size)

        return AVERROR(ENOMEM);



    ret = ff_mov_read_stsd_entries(c, pb, sc->stsd_count);

    if (ret < 0)

        return ret;



    

    av_freep(&st->codecpar->extradata);

    st->codecpar->extradata_size = sc->extradata_size[0];

    if (sc->extradata_size[0]) {

        st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE);

        if (!st->codecpar->extradata)

            return AVERROR(ENOMEM);

        memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]);

    }



    return 0;

}

static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)

{

    AVStream *st;

    MOVStreamContext *sc;

    int VAR_3;



    if (VAR_0->fc->nb_streams < 1)

        return 0;

    st = VAR_0->fc->streams[VAR_0->fc->nb_streams - 1];

    sc = st->priv_data;



    avio_r8(VAR_1); 

    avio_rb24(VAR_1); 

    sc->stsd_count = avio_rb32(VAR_1); 



    

    sc->extradata = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata));

    if (!sc->extradata)

        return AVERROR(ENOMEM);



    sc->extradata_size = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata_size));

    if (!sc->extradata_size)

        return AVERROR(ENOMEM);



    VAR_3 = ff_mov_read_stsd_entries(VAR_0, VAR_1, sc->stsd_count);

    if (VAR_3 < 0)

        return VAR_3;



    

    av_freep(&st->codecpar->extradata);

    st->codecpar->extradata_size = sc->extradata_size[0];

    if (sc->extradata_size[0]) {

        st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE);

        if (!st->codecpar->extradata)

            return AVERROR(ENOMEM);

        memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]);

    }



    return 0;

}

static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)
{ AVStream *st; MOVStreamContext *sc; int VAR_3; if (VAR_0->fc->nb_streams < 1)
return 0; st = VAR_0->fc->streams[VAR_0->fc->nb_streams - 1]; sc = st->priv_data; avio_r8(VAR_1); avio_rb24(VAR_1); sc->stsd_count = avio_rb32(VAR_1); sc->extradata = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata)); if (!sc->extradata)
return AVERROR(ENOMEM); sc->extradata_size = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata_size)); if (!sc->extradata_size)
return AVERROR(ENOMEM); VAR_3 = ff_mov_read_stsd_entries(VAR_0, VAR_1, sc->stsd_count); if (VAR_3 < 0)
return VAR_3; av_freep(&st->codecpar->extradata); st->codecpar->extradata_size = sc->extradata_size[0]; if (sc->extradata_size[0]) { st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE); if (!st->codecpar->extradata)
return AVERROR(ENOMEM); memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]); } return 0; }