static int pcm_dvd_decode_frame(AVCodecContext *avctx, void *data,

                                int *got_frame_ptr, AVPacket *avpkt)

{

    AVFrame *frame     = data;

    const uint8_t *src = avpkt->data;

    int buf_size       = avpkt->size;

    PCMDVDContext *s   = avctx->priv_data;

    int retval;

    int blocks;

    void *dst;



    if (buf_size < 3) {

        av_log(avctx, AV_LOG_ERROR, "PCM packet too small\n");

        return AVERROR_INVALIDDATA;




    if ((retval = pcm_dvd_parse_header(avctx, src)))

        return retval;






    src      += 3;

    buf_size -= 3;



    blocks = (buf_size + s->extra_sample_count) / s->block_size;



    /* get output buffer */

    frame->nb_samples = blocks * s->samples_per_block;

    if ((retval = ff_get_buffer(avctx, frame, 0)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return retval;


    dst = frame->data[0];



    /* consume leftover samples from last packet */

    if (s->extra_sample_count) {

        int missing_samples = s->block_size - s->extra_sample_count;

        if (buf_size >= missing_samples) {

            memcpy(s->extra_samples + s->extra_sample_count, src,

                   missing_samples);

            dst = pcm_dvd_decode_samples(avctx, s->extra_samples, dst, 1);

            src += missing_samples;

            buf_size -= missing_samples;


            blocks--;

        } else {

            /* new packet still doesn't have enough samples */

            memcpy(s->extra_samples + s->extra_sample_count, src, buf_size);

            s->extra_sample_count += buf_size;

            return avpkt->size;





    /* decode remaining complete samples */

    if (blocks) {

        pcm_dvd_decode_samples(avctx, src, dst, blocks);

        buf_size -= blocks * s->block_size;




    /* store leftover samples */

    if (buf_size) {

        src += blocks * s->block_size;

        memcpy(s->extra_samples, src, buf_size);

        s->extra_sample_count = buf_size;




    *got_frame_ptr = 1;



    return avpkt->size;

static int pcm_dvd_decode_frame(AVCodecContext *avctx, void *data,

                                int *got_frame_ptr, AVPacket *avpkt)

{

    AVFrame *frame     = data;

    const uint8_t *src = avpkt->data;

    int buf_size       = avpkt->size;

    PCMDVDContext *s   = avctx->priv_data;

    int retval;

    int blocks;

    void *dst;



    if (buf_size < 3) {

        av_log(avctx, AV_LOG_ERROR, "PCM packet too small\n");

        return AVERROR_INVALIDDATA;




    if ((retval = pcm_dvd_parse_header(avctx, src)))

        return retval;






    src      += 3;

    buf_size -= 3;



    blocks = (buf_size + s->extra_sample_count) / s->block_size;



    

    frame->nb_samples = blocks * s->samples_per_block;

    if ((retval = ff_get_buffer(avctx, frame, 0)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return retval;


    dst = frame->data[0];



    

    if (s->extra_sample_count) {

        int missing_samples = s->block_size - s->extra_sample_count;

        if (buf_size >= missing_samples) {

            memcpy(s->extra_samples + s->extra_sample_count, src,

                   missing_samples);

            dst = pcm_dvd_decode_samples(avctx, s->extra_samples, dst, 1);

            src += missing_samples;

            buf_size -= missing_samples;


            blocks--;

        } else {

            

            memcpy(s->extra_samples + s->extra_sample_count, src, buf_size);

            s->extra_sample_count += buf_size;

            return avpkt->size;





    

    if (blocks) {

        pcm_dvd_decode_samples(avctx, src, dst, blocks);

        buf_size -= blocks * s->block_size;




    

    if (buf_size) {

        src += blocks * s->block_size;

        memcpy(s->extra_samples, src, buf_size);

        s->extra_sample_count = buf_size;




    *got_frame_ptr = 1;



    return avpkt->size;

static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,

                                int *VAR_2, AVPacket *VAR_3)

{

    AVFrame *frame     = VAR_1;

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    int VAR_5       = VAR_3->size;

    PCMDVDContext *s   = VAR_0->priv_data;

    int VAR_6;

    int VAR_7;

    void *VAR_8;



    if (VAR_5 < 3) {

        av_log(VAR_0, AV_LOG_ERROR, "PCM packet too small\n");

        return AVERROR_INVALIDDATA;




    if ((VAR_6 = pcm_dvd_parse_header(VAR_0, VAR_4)))

        return VAR_6;






    VAR_4      += 3;

    VAR_5 -= 3;



    VAR_7 = (VAR_5 + s->extra_sample_count) / s->block_size;



    

    frame->nb_samples = VAR_7 * s->samples_per_block;

    if ((VAR_6 = ff_get_buffer(VAR_0, frame, 0)) < 0) {

        av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");

        return VAR_6;


    VAR_8 = frame->VAR_1[0];



    

    if (s->extra_sample_count) {

        int VAR_9 = s->block_size - s->extra_sample_count;

        if (VAR_5 >= VAR_9) {

            memcpy(s->extra_samples + s->extra_sample_count, VAR_4,

                   VAR_9);

            VAR_8 = pcm_dvd_decode_samples(VAR_0, s->extra_samples, VAR_8, 1);

            VAR_4 += VAR_9;

            VAR_5 -= VAR_9;


            VAR_7--;

        } else {

            

            memcpy(s->extra_samples + s->extra_sample_count, VAR_4, VAR_5);

            s->extra_sample_count += VAR_5;

            return VAR_3->size;





    

    if (VAR_7) {

        pcm_dvd_decode_samples(VAR_0, VAR_4, VAR_8, VAR_7);

        VAR_5 -= VAR_7 * s->block_size;




    

    if (VAR_5) {

        VAR_4 += VAR_7 * s->block_size;

        memcpy(s->extra_samples, VAR_4, VAR_5);

        s->extra_sample_count = VAR_5;




    *VAR_2 = 1;



    return VAR_3->size;

static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{ AVFrame *frame     = VAR_1; const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5       = VAR_3->size; PCMDVDContext *s   = VAR_0->priv_data; int VAR_6; int VAR_7; void *VAR_8; if (VAR_5 < 3) { av_log(VAR_0, AV_LOG_ERROR, "PCM packet too small\n"); return AVERROR_INVALIDDATA; if ((VAR_6 = pcm_dvd_parse_header(VAR_0, VAR_4)))
return VAR_6; VAR_4      += 3; VAR_5 -= 3; VAR_7 = (VAR_5 + s->extra_sample_count) / s->block_size; frame->nb_samples = VAR_7 * s->samples_per_block; if ((VAR_6 = ff_get_buffer(VAR_0, frame, 0)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return VAR_6; VAR_8 = frame->VAR_1[0]; if (s->extra_sample_count) { int VAR_9 = s->block_size - s->extra_sample_count; if (VAR_5 >= VAR_9) { memcpy(s->extra_samples + s->extra_sample_count, VAR_4,
VAR_9); VAR_8 = pcm_dvd_decode_samples(VAR_0, s->extra_samples, VAR_8, 1); VAR_4 += VAR_9; VAR_5 -= VAR_9; VAR_7--; } else { memcpy(s->extra_samples + s->extra_sample_count, VAR_4, VAR_5); s->extra_sample_count += VAR_5; return VAR_3->size; if (VAR_7) { pcm_dvd_decode_samples(VAR_0, VAR_4, VAR_8, VAR_7); VAR_5 -= VAR_7 * s->block_size; if (VAR_5) { VAR_4 += VAR_7 * s->block_size; memcpy(s->extra_samples, VAR_4, VAR_5); s->extra_sample_count = VAR_5; *VAR_2 = 1; return VAR_3->size;