static int mxf_compute_sample_count(MXFContext *mxf, int stream_index, uint64_t *sample_count)

{

    int i, total = 0, size = 0;

    AVStream *st = mxf->fc->streams[stream_index];

    MXFTrack *track = st->priv_data;

    AVRational time_base = av_inv_q(track->edit_rate);

    AVRational sample_rate = av_inv_q(st->time_base);

    const MXFSamplesPerFrame *spf = NULL;



    if ((sample_rate.num / sample_rate.den) == 48000)

        spf = ff_mxf_get_samples_per_frame(mxf->fc, time_base);

    if (!spf) {

        int remainder = (sample_rate.num * time_base.num) % (time_base.den * sample_rate.den);

        *sample_count = av_q2d(av_mul_q((AVRational){mxf->current_edit_unit, 1},

                                        av_mul_q(sample_rate, time_base)));

        if (remainder)

            av_log(mxf->fc, AV_LOG_WARNING,

                   "seeking detected on stream #%d with time base (%d/%d) and sample rate (%d/%d), audio pts won't be accurate.\n",

                   stream_index, time_base.num, time_base.den, sample_rate.num, sample_rate.den);

        return 0;

    }



    while (spf->samples_per_frame[size]) {

        total += spf->samples_per_frame[size];

        size++;

    }



    av_assert2(size);



    *sample_count = (mxf->current_edit_unit / size) * total;

    for (i = 0; i < mxf->current_edit_unit % size; i++) {

        *sample_count += spf->samples_per_frame[i];

    }



    return 0;

}

static int mxf_compute_sample_count(MXFContext *mxf, int stream_index, uint64_t *sample_count)

{

    int i, total = 0, size = 0;

    AVStream *st = mxf->fc->streams[stream_index];

    MXFTrack *track = st->priv_data;

    AVRational time_base = av_inv_q(track->edit_rate);

    AVRational sample_rate = av_inv_q(st->time_base);

    const MXFSamplesPerFrame *spf = NULL;



    if ((sample_rate.num / sample_rate.den) == 48000)

        spf = ff_mxf_get_samples_per_frame(mxf->fc, time_base);

    if (!spf) {

        int remainder = (sample_rate.num * time_base.num) % (time_base.den * sample_rate.den);

        *sample_count = av_q2d(av_mul_q((AVRational){mxf->current_edit_unit, 1},

                                        av_mul_q(sample_rate, time_base)));

        if (remainder)

            av_log(mxf->fc, AV_LOG_WARNING,

                   "seeking detected on stream #%d with time base (%d/%d) and sample rate (%d/%d), audio pts won't be accurate.\n",

                   stream_index, time_base.num, time_base.den, sample_rate.num, sample_rate.den);

        return 0;

    }



    while (spf->samples_per_frame[size]) {

        total += spf->samples_per_frame[size];

        size++;

    }



    av_assert2(size);



    *sample_count = (mxf->current_edit_unit / size) * total;

    for (i = 0; i < mxf->current_edit_unit % size; i++) {

        *sample_count += spf->samples_per_frame[i];

    }



    return 0;

}

    *sample_count = (mxf->current_edit_unit / size) * total;
static int FUNC_0(MXFContext *VAR_0, int VAR_1, uint64_t *VAR_2)

{

    int VAR_3, VAR_4 = 0, VAR_5 = 0;

    AVStream *st = VAR_0->fc->streams[VAR_1];

    MXFTrack *track = st->priv_data;

    AVRational time_base = av_inv_q(track->edit_rate);

    AVRational sample_rate = av_inv_q(st->time_base);

    const MXFSamplesPerFrame *VAR_6 = NULL;



    if ((sample_rate.num / sample_rate.den) == 48000)

        VAR_6 = ff_mxf_get_samples_per_frame(VAR_0->fc, time_base);

    if (!VAR_6) {

        int VAR_7 = (sample_rate.num * time_base.num) % (time_base.den * sample_rate.den);

        *VAR_2 = av_q2d(av_mul_q((AVRational){VAR_0->current_edit_unit, 1},

                                        av_mul_q(sample_rate, time_base)));

        if (VAR_7)

            av_log(VAR_0->fc, AV_LOG_WARNING,

                   "seeking detected on stream #%d with time base (%d/%d) and sample rate (%d/%d), audio pts won't be accurate.\n",

                   VAR_1, time_base.num, time_base.den, sample_rate.num, sample_rate.den);

        return 0;

    }



    while (VAR_6->samples_per_frame[VAR_5]) {

        VAR_4 += VAR_6->samples_per_frame[VAR_5];

        VAR_5++;

    }



    av_assert2(VAR_5);



    *VAR_2 = (VAR_0->current_edit_unit / VAR_5) * VAR_4;

    for (VAR_3 = 0; VAR_3 < VAR_0->current_edit_unit % VAR_5; VAR_3++) {

        *VAR_2 += VAR_6->samples_per_frame[VAR_3];

    }



    return 0;

}

static int FUNC_0(MXFContext *VAR_0, int VAR_1, uint64_t *VAR_2)
{ int VAR_3, VAR_4 = 0, VAR_5 = 0; AVStream *st = VAR_0->fc->streams[VAR_1]; MXFTrack *track = st->priv_data; AVRational time_base = av_inv_q(track->edit_rate); AVRational sample_rate = av_inv_q(st->time_base); const MXFSamplesPerFrame *VAR_6 = NULL; if ((sample_rate.num / sample_rate.den) == 48000)
VAR_6 = ff_mxf_get_samples_per_frame(VAR_0->fc, time_base); if (!VAR_6) { int VAR_7 = (sample_rate.num * time_base.num) % (time_base.den * sample_rate.den); *VAR_2 = av_q2d(av_mul_q((AVRational){VAR_0->current_edit_unit, 1}, av_mul_q(sample_rate, time_base))); if (VAR_7)
av_log(VAR_0->fc, AV_LOG_WARNING,
"seeking detected on stream #%d with time base (%d/%d) and sample rate (%d/%d), audio pts won't be accurate.\n",
VAR_1, time_base.num, time_base.den, sample_rate.num, sample_rate.den); return 0; } while (VAR_6->samples_per_frame[VAR_5]) { VAR_4 += VAR_6->samples_per_frame[VAR_5]; VAR_5++; } av_assert2(VAR_5); *VAR_2 = (VAR_0->current_edit_unit / VAR_5) * VAR_4; for (VAR_3 = 0; VAR_3 < VAR_0->current_edit_unit % VAR_5; VAR_3++) { *VAR_2 += VAR_6->samples_per_frame[VAR_3]; } return 0; }