static int read_header(ShortenContext *s)

{

    int i, ret;

    int maxnlpc = 0;

    /* shorten signature */

    if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) {

        av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n");





    s->lpcqoffset     = 0;

    s->blocksize      = DEFAULT_BLOCK_SIZE;

    s->nmean          = -1;

    s->version        = get_bits(&s->gb, 8);

    s->internal_ftype = get_uint(s, TYPESIZE);



    s->channels = get_uint(s, CHANSIZE);

    if (!s->channels) {

        av_log(s->avctx, AV_LOG_ERROR, "No channels reported\n");



    if (s->channels > MAX_CHANNELS) {

        av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels);

        s->channels = 0;



    s->avctx->channels = s->channels;



    /* get blocksize if version > 0 */

    if (s->version > 0) {

        int skip_bytes;

        unsigned blocksize;



        blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE));

        if (!blocksize || blocksize > MAX_BLOCKSIZE) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "invalid or unsupported block size: %d\n",

                   blocksize);

            return AVERROR(EINVAL);


        s->blocksize = blocksize;



        maxnlpc  = get_uint(s, LPCQSIZE);





        s->nmean = get_uint(s, 0);



        skip_bytes = get_uint(s, NSKIPSIZE);

        if ((unsigned)skip_bytes > get_bits_left(&s->gb)/8) {

            av_log(s->avctx, AV_LOG_ERROR, "invalid skip_bytes: %d\n", skip_bytes);





        for (i = 0; i < skip_bytes; i++)

            skip_bits(&s->gb, 8);


    s->nwrap = FFMAX(NWRAP, maxnlpc);



    if ((ret = allocate_buffers(s)) < 0)

        return ret;



    if ((ret = init_offset(s)) < 0)

        return ret;



    if (s->version > 1)

        s->lpcqoffset = V2LPCQOFFSET;



    if (s->avctx->extradata_size > 0)

        goto end;



    if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) {

        av_log(s->avctx, AV_LOG_ERROR,

               "missing verbatim section at beginning of stream\n");





    s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);

    if (s->header_size >= OUT_BUFFER_SIZE ||

        s->header_size < CANONICAL_HEADER_SIZE) {

        av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n",

               s->header_size);





    for (i = 0; i < s->header_size; i++)

        s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);



    if (AV_RL32(s->header) == MKTAG('R','I','F','F')) {

        if ((ret = decode_wave_header(s->avctx, s->header, s->header_size)) < 0)

            return ret;

    } else if (AV_RL32(s->header) == MKTAG('F','O','R','M')) {

        if ((ret = decode_aiff_header(s->avctx, s->header, s->header_size)) < 0)

            return ret;

    } else {

        avpriv_report_missing_feature(s->avctx, "unsupported bit packing %"

                                      PRIX32, AV_RL32(s->header));

        return AVERROR_PATCHWELCOME;




end:

    s->cur_chan = 0;

    s->bitshift = 0;



    s->got_header = 1;



    return 0;

static int read_header(ShortenContext *s)

{

    int i, ret;

    int maxnlpc = 0;

    

    if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) {

        av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n");





    s->lpcqoffset     = 0;

    s->blocksize      = DEFAULT_BLOCK_SIZE;

    s->nmean          = -1;

    s->version        = get_bits(&s->gb, 8);

    s->internal_ftype = get_uint(s, TYPESIZE);



    s->channels = get_uint(s, CHANSIZE);

    if (!s->channels) {

        av_log(s->avctx, AV_LOG_ERROR, "No channels reported\n");



    if (s->channels > MAX_CHANNELS) {

        av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels);

        s->channels = 0;



    s->avctx->channels = s->channels;



    

    if (s->version > 0) {

        int skip_bytes;

        unsigned blocksize;



        blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE));

        if (!blocksize || blocksize > MAX_BLOCKSIZE) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "invalid or unsupported block size: %d\n",

                   blocksize);

            return AVERROR(EINVAL);


        s->blocksize = blocksize;



        maxnlpc  = get_uint(s, LPCQSIZE);





        s->nmean = get_uint(s, 0);



        skip_bytes = get_uint(s, NSKIPSIZE);

        if ((unsigned)skip_bytes > get_bits_left(&s->gb)/8) {

            av_log(s->avctx, AV_LOG_ERROR, "invalid skip_bytes: %d\n", skip_bytes);





        for (i = 0; i < skip_bytes; i++)

            skip_bits(&s->gb, 8);


    s->nwrap = FFMAX(NWRAP, maxnlpc);



    if ((ret = allocate_buffers(s)) < 0)

        return ret;



    if ((ret = init_offset(s)) < 0)

        return ret;



    if (s->version > 1)

        s->lpcqoffset = V2LPCQOFFSET;



    if (s->avctx->extradata_size > 0)

        goto end;



    if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) {

        av_log(s->avctx, AV_LOG_ERROR,

               "missing verbatim section at beginning of stream\n");





    s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);

    if (s->header_size >= OUT_BUFFER_SIZE ||

        s->header_size < CANONICAL_HEADER_SIZE) {

        av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n",

               s->header_size);





    for (i = 0; i < s->header_size; i++)

        s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);



    if (AV_RL32(s->header) == MKTAG('R','I','F','F')) {

        if ((ret = decode_wave_header(s->avctx, s->header, s->header_size)) < 0)

            return ret;

    } else if (AV_RL32(s->header) == MKTAG('F','O','R','M')) {

        if ((ret = decode_aiff_header(s->avctx, s->header, s->header_size)) < 0)

            return ret;

    } else {

        avpriv_report_missing_feature(s->avctx, "unsupported bit packing %"

                                      PRIX32, AV_RL32(s->header));

        return AVERROR_PATCHWELCOME;




end:

    s->cur_chan = 0;

    s->bitshift = 0;



    s->got_header = 1;



    return 0;

static int FUNC_0(ShortenContext *VAR_0)

{

    int VAR_1, VAR_2;

    int VAR_3 = 0;

    

    if (get_bits_long(&VAR_0->gb, 32) != AV_RB32("ajkg")) {

        av_log(VAR_0->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n");





    VAR_0->lpcqoffset     = 0;

    VAR_0->VAR_5      = DEFAULT_BLOCK_SIZE;

    VAR_0->nmean          = -1;

    VAR_0->version        = get_bits(&VAR_0->gb, 8);

    VAR_0->internal_ftype = get_uint(VAR_0, TYPESIZE);



    VAR_0->channels = get_uint(VAR_0, CHANSIZE);

    if (!VAR_0->channels) {

        av_log(VAR_0->avctx, AV_LOG_ERROR, "No channels reported\n");



    if (VAR_0->channels > MAX_CHANNELS) {

        av_log(VAR_0->avctx, AV_LOG_ERROR, "too many channels: %d\n", VAR_0->channels);

        VAR_0->channels = 0;



    VAR_0->avctx->channels = VAR_0->channels;



    

    if (VAR_0->version > 0) {

        int VAR_4;

        unsigned VAR_5;



        VAR_5 = get_uint(VAR_0, av_log2(DEFAULT_BLOCK_SIZE));

        if (!VAR_5 || VAR_5 > MAX_BLOCKSIZE) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "invalid or unsupported block size: %d\n",

                   VAR_5);

            return AVERROR(EINVAL);


        VAR_0->VAR_5 = VAR_5;



        VAR_3  = get_uint(VAR_0, LPCQSIZE);





        VAR_0->nmean = get_uint(VAR_0, 0);



        VAR_4 = get_uint(VAR_0, NSKIPSIZE);

        if ((unsigned)VAR_4 > get_bits_left(&VAR_0->gb)/8) {

            av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid VAR_4: %d\n", VAR_4);





        for (VAR_1 = 0; VAR_1 < VAR_4; VAR_1++)

            skip_bits(&VAR_0->gb, 8);


    VAR_0->nwrap = FFMAX(NWRAP, VAR_3);



    if ((VAR_2 = allocate_buffers(VAR_0)) < 0)

        return VAR_2;



    if ((VAR_2 = init_offset(VAR_0)) < 0)

        return VAR_2;



    if (VAR_0->version > 1)

        VAR_0->lpcqoffset = V2LPCQOFFSET;



    if (VAR_0->avctx->extradata_size > 0)

        goto end;



    if (get_ur_golomb_shorten(&VAR_0->gb, FNSIZE) != FN_VERBATIM) {

        av_log(VAR_0->avctx, AV_LOG_ERROR,

               "missing verbatim section at beginning of stream\n");





    VAR_0->header_size = get_ur_golomb_shorten(&VAR_0->gb, VERBATIM_CKSIZE_SIZE);

    if (VAR_0->header_size >= OUT_BUFFER_SIZE ||

        VAR_0->header_size < CANONICAL_HEADER_SIZE) {

        av_log(VAR_0->avctx, AV_LOG_ERROR, "header is wrong size: %d\n",

               VAR_0->header_size);





    for (VAR_1 = 0; VAR_1 < VAR_0->header_size; VAR_1++)

        VAR_0->header[VAR_1] = (char)get_ur_golomb_shorten(&VAR_0->gb, VERBATIM_BYTE_SIZE);



    if (AV_RL32(VAR_0->header) == MKTAG('R','I','F','F')) {

        if ((VAR_2 = decode_wave_header(VAR_0->avctx, VAR_0->header, VAR_0->header_size)) < 0)

            return VAR_2;

    } else if (AV_RL32(VAR_0->header) == MKTAG('F','O','R','M')) {

        if ((VAR_2 = decode_aiff_header(VAR_0->avctx, VAR_0->header, VAR_0->header_size)) < 0)

            return VAR_2;

    } else {

        avpriv_report_missing_feature(VAR_0->avctx, "unsupported bit packing %"

                                      PRIX32, AV_RL32(VAR_0->header));

        return AVERROR_PATCHWELCOME;




end:

    VAR_0->cur_chan = 0;

    VAR_0->bitshift = 0;



    VAR_0->got_header = 1;



    return 0;

static int FUNC_0(ShortenContext *VAR_0)
{ int VAR_1, VAR_2; int VAR_3 = 0; if (get_bits_long(&VAR_0->gb, 32) != AV_RB32("ajkg")) { av_log(VAR_0->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n"); VAR_0->lpcqoffset     = 0; VAR_0->VAR_5      = DEFAULT_BLOCK_SIZE; VAR_0->nmean          = -1; VAR_0->version        = get_bits(&VAR_0->gb, 8); VAR_0->internal_ftype = get_uint(VAR_0, TYPESIZE); VAR_0->channels = get_uint(VAR_0, CHANSIZE); if (!VAR_0->channels) { av_log(VAR_0->avctx, AV_LOG_ERROR, "No channels reported\n"); if (VAR_0->channels > MAX_CHANNELS) { av_log(VAR_0->avctx, AV_LOG_ERROR, "too many channels: %d\n", VAR_0->channels); VAR_0->channels = 0; VAR_0->avctx->channels = VAR_0->channels; if (VAR_0->version > 0) { int VAR_4; unsigned VAR_5; VAR_5 = get_uint(VAR_0, av_log2(DEFAULT_BLOCK_SIZE)); if (!VAR_5 || VAR_5 > MAX_BLOCKSIZE) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"invalid or unsupported block size: %d\n",
VAR_5); return AVERROR(EINVAL); VAR_0->VAR_5 = VAR_5; VAR_3  = get_uint(VAR_0, LPCQSIZE); VAR_0->nmean = get_uint(VAR_0, 0); VAR_4 = get_uint(VAR_0, NSKIPSIZE); if ((unsigned)VAR_4 > get_bits_left(&VAR_0->gb)/8) { av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid VAR_4: %d\n", VAR_4); for (VAR_1 = 0; VAR_1 < VAR_4; VAR_1++) skip_bits(&VAR_0->gb, 8); VAR_0->nwrap = FFMAX(NWRAP, VAR_3); if ((VAR_2 = allocate_buffers(VAR_0)) < 0)
return VAR_2; if ((VAR_2 = init_offset(VAR_0)) < 0)
return VAR_2; if (VAR_0->version > 1)
VAR_0->lpcqoffset = V2LPCQOFFSET; if (VAR_0->avctx->extradata_size > 0)
goto end; if (get_ur_golomb_shorten(&VAR_0->gb, FNSIZE) != FN_VERBATIM) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"missing verbatim section at beginning of stream\n"); VAR_0->header_size = get_ur_golomb_shorten(&VAR_0->gb, VERBATIM_CKSIZE_SIZE); if (VAR_0->header_size >= OUT_BUFFER_SIZE ||
VAR_0->header_size < CANONICAL_HEADER_SIZE) { av_log(VAR_0->avctx, AV_LOG_ERROR, "header is wrong size: %d\n",
VAR_0->header_size); for (VAR_1 = 0; VAR_1 < VAR_0->header_size; VAR_1++) VAR_0->header[VAR_1] = (char)get_ur_golomb_shorten(&VAR_0->gb, VERBATIM_BYTE_SIZE); if (AV_RL32(VAR_0->header) == MKTAG('R','I','F','F')) { if ((VAR_2 = decode_wave_header(VAR_0->avctx, VAR_0->header, VAR_0->header_size)) < 0)
return VAR_2; } else if (AV_RL32(VAR_0->header) == MKTAG('F','O','R','M')) { if ((VAR_2 = decode_aiff_header(VAR_0->avctx, VAR_0->header, VAR_0->header_size)) < 0)
return VAR_2; } else { avpriv_report_missing_feature(VAR_0->avctx, "unsupported bit packing %"
PRIX32, AV_RL32(VAR_0->header)); return AVERROR_PATCHWELCOME; end:
VAR_0->cur_chan = 0; VAR_0->bitshift = 0; VAR_0->got_header = 1; return 0;