libavcodec/cook.c:1144: error: Uninitialized Value
  The value read from samples_per_frame was never initialized.

libavcodec/cook.c:1144:17: 
1142.                 q->subpacket[s].joint_stereo = 1;
1143.                 q->subpacket[s].num_channels = 2;
1144.                 q->subpacket[s].samples_per_channel = samples_per_frame >> 1;
                      ^
1145. 
1146.                 if (q->subpacket[s].samples_per_channel > 256) {

static av_cold int cook_decode_init(AVCodecContext *avctx)
{
    COOKContext *q = avctx->priv_data;
    const uint8_t *edata_ptr = avctx->extradata;
    const uint8_t *edata_ptr_end = edata_ptr + avctx->extradata_size;
    int extradata_size = avctx->extradata_size;
    int s = 0;
    unsigned int channel_mask = 0;
    int samples_per_frame;
    int ret;
    q->avctx = avctx;
    if (extradata_size <= 0) {
        av_log(avctx, AV_LOG_ERROR, "Necessary extradata missing!\n");
        return AVERROR_INVALIDDATA;
    }
    av_log(avctx, AV_LOG_DEBUG, "codecdata_length=%d\n", avctx->extradata_size);
    if (!avctx->channels) {
        av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
        return AVERROR_INVALIDDATA;
    }
    av_lfg_init(&q->random_state, 0);
    ff_dsputil_init(&q->dsp, avctx);
    while (edata_ptr < edata_ptr_end) {
        if (extradata_size >= 8) {
            q->subpacket[s].cookversion = bytestream_get_be32(&edata_ptr);
            samples_per_frame           = bytestream_get_be16(&edata_ptr);
            q->subpacket[s].subbands = bytestream_get_be16(&edata_ptr);
            extradata_size -= 8;
        }
        if (extradata_size >= 8) {
            bytestream_get_be32(&edata_ptr);
            q->subpacket[s].js_subband_start = bytestream_get_be16(&edata_ptr);
            q->subpacket[s].js_vlc_bits = bytestream_get_be16(&edata_ptr);
            extradata_size -= 8;
        }
        q->subpacket[s].samples_per_channel = samples_per_frame / avctx->channels;
        q->subpacket[s].bits_per_subpacket = avctx->block_align * 8;
        q->subpacket[s].log2_numvector_size = 5;
        q->subpacket[s].total_subbands = q->subpacket[s].subbands;
        q->subpacket[s].num_channels = 1;
        av_log(avctx, AV_LOG_DEBUG, "subpacket[%i].cookversion=%x\n", s,
               q->subpacket[s].cookversion);
        q->subpacket[s].joint_stereo = 0;
        switch (q->subpacket[s].cookversion) {
        case MONO:
            if (avctx->channels != 1) {
                av_log_ask_for_sample(avctx, "Container channels != 1.\n");
                return AVERROR_PATCHWELCOME;
            }
            av_log(avctx, AV_LOG_DEBUG, "MONO\n");
            break;
        case STEREO:
            if (avctx->channels != 1) {
                q->subpacket[s].bits_per_subpdiv = 1;
                q->subpacket[s].num_channels = 2;
            }
            av_log(avctx, AV_LOG_DEBUG, "STEREO\n");
            break;
        case JOINT_STEREO:
            if (avctx->channels != 2) {
                av_log_ask_for_sample(avctx, "Container channels != 2.\n");
                return AVERROR_PATCHWELCOME;
            }
            av_log(avctx, AV_LOG_DEBUG, "JOINT_STEREO\n");
            if (avctx->extradata_size >= 16) {
                q->subpacket[s].total_subbands = q->subpacket[s].subbands +
                                                 q->subpacket[s].js_subband_start;
                q->subpacket[s].joint_stereo = 1;
                q->subpacket[s].num_channels = 2;
            }
            if (q->subpacket[s].samples_per_channel > 256) {
                q->subpacket[s].log2_numvector_size = 6;
            }
            if (q->subpacket[s].samples_per_channel > 512) {
                q->subpacket[s].log2_numvector_size = 7;
            }
            break;
        case MC_COOK:
            av_log(avctx, AV_LOG_DEBUG, "MULTI_CHANNEL\n");
            if (extradata_size >= 4)
                channel_mask |= q->subpacket[s].channel_mask = bytestream_get_be32(&edata_ptr);
            if (av_get_channel_layout_nb_channels(q->subpacket[s].channel_mask) > 1) {
                q->subpacket[s].total_subbands = q->subpacket[s].subbands +
                                                 q->subpacket[s].js_subband_start;
                q->subpacket[s].joint_stereo = 1;
                q->subpacket[s].num_channels = 2;
                q->subpacket[s].samples_per_channel = samples_per_frame >> 1;
                if (q->subpacket[s].samples_per_channel > 256) {
                    q->subpacket[s].log2_numvector_size = 6;
                }
                if (q->subpacket[s].samples_per_channel > 512) {
                    q->subpacket[s].log2_numvector_size = 7;
                }
            } else
                q->subpacket[s].samples_per_channel = samples_per_frame;
            break;
        default:
            av_log_ask_for_sample(avctx, "Unknown Cook version.\n");
            return AVERROR_PATCHWELCOME;
        }
        if (s > 1 && q->subpacket[s].samples_per_channel != q->samples_per_channel) {
            av_log(avctx, AV_LOG_ERROR, "different number of samples per channel!\n");
            return AVERROR_INVALIDDATA;
        } else
            q->samples_per_channel = q->subpacket[0].samples_per_channel;
        q->subpacket[s].numvector_size = (1 << q->subpacket[s].log2_numvector_size);
        if (q->subpacket[s].total_subbands > 53) {
            av_log_ask_for_sample(avctx, "total_subbands > 53\n");
            return AVERROR_PATCHWELCOME;
        }
        if ((q->subpacket[s].js_vlc_bits > 6) ||
            (q->subpacket[s].js_vlc_bits < 2 * q->subpacket[s].joint_stereo)) {
            av_log(avctx, AV_LOG_ERROR, "js_vlc_bits = %d, only >= %d and <= 6 allowed!\n",
                   q->subpacket[s].js_vlc_bits, 2 * q->subpacket[s].joint_stereo);
            return AVERROR_INVALIDDATA;
        }
        if (q->subpacket[s].subbands > 50) {
            av_log_ask_for_sample(avctx, "subbands > 50\n");
            return AVERROR_PATCHWELCOME;
        }
        q->subpacket[s].gains1.now      = q->subpacket[s].gain_1;
        q->subpacket[s].gains1.previous = q->subpacket[s].gain_2;
        q->subpacket[s].gains2.now      = q->subpacket[s].gain_3;
        q->subpacket[s].gains2.previous = q->subpacket[s].gain_4;
        q->num_subpackets++;
        s++;
        if (s > MAX_SUBPACKETS) {
            av_log_ask_for_sample(avctx, "Too many subpackets > 5\n");
            return AVERROR_PATCHWELCOME;
        }
    }
    init_pow2table();
    init_gain_table(q);
    init_cplscales_table(q);
    if ((ret = init_cook_vlc_tables(q)))
        return ret;
    if (avctx->block_align >= UINT_MAX / 2)
        return AVERROR(EINVAL);
    q->decoded_bytes_buffer =
        av_mallocz(avctx->block_align
                   + DECODE_BYTES_PAD1(avctx->block_align)
                   + FF_INPUT_BUFFER_PADDING_SIZE);
    if (q->decoded_bytes_buffer == NULL)
        return AVERROR(ENOMEM);
    if ((ret = init_cook_mlt(q)))
        return ret;
    if (1) {
        q->scalar_dequant  = scalar_dequant_float;
        q->decouple        = decouple_float;
        q->imlt_window     = imlt_window_float;
        q->interpolate     = interpolate_float;
        q->saturate_output = saturate_output_float;
    }
    if (q->samples_per_channel != 256 && q->samples_per_channel != 512 &&
        q->samples_per_channel != 1024) {
        av_log_ask_for_sample(avctx,
                              "unknown amount of samples_per_channel = %d\n",
                              q->samples_per_channel);
        return AVERROR_PATCHWELCOME;
    }
    avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
    if (channel_mask)
        avctx->channel_layout = channel_mask;
    else
        avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
    avcodec_get_frame_defaults(&q->frame);
    avctx->coded_frame = &q->frame;
#ifdef DEBUG
    dump_cook_context(q);
#endif
    return 0;
}
['static av_cold int cook_decode_init(AVCodecContext *avctx)\n{\n    COOKContext *q = avctx->priv_data;\n    const uint8_t *edata_ptr = avctx->extradata;\n    const uint8_t *edata_ptr_end = edata_ptr + avctx->extradata_size;\n    int extradata_size = avctx->extradata_size;\n    int s = 0;\n    unsigned int channel_mask = 0;\n    int samples_per_frame;\n    int ret;\n    q->avctx = avctx;\n    if (extradata_size <= 0) {\n        av_log(avctx, AV_LOG_ERROR, "Necessary extradata missing!\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    av_log(avctx, AV_LOG_DEBUG, "codecdata_length=%d\\n", avctx->extradata_size);\n    if (!avctx->channels) {\n        av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    av_lfg_init(&q->random_state, 0);\n    ff_dsputil_init(&q->dsp, avctx);\n    while (edata_ptr < edata_ptr_end) {\n        if (extradata_size >= 8) {\n            q->subpacket[s].cookversion = bytestream_get_be32(&edata_ptr);\n            samples_per_frame           = bytestream_get_be16(&edata_ptr);\n            q->subpacket[s].subbands = bytestream_get_be16(&edata_ptr);\n            extradata_size -= 8;\n        }\n        if (extradata_size >= 8) {\n            bytestream_get_be32(&edata_ptr);\n            q->subpacket[s].js_subband_start = bytestream_get_be16(&edata_ptr);\n            q->subpacket[s].js_vlc_bits = bytestream_get_be16(&edata_ptr);\n            extradata_size -= 8;\n        }\n        q->subpacket[s].samples_per_channel = samples_per_frame / avctx->channels;\n        q->subpacket[s].bits_per_subpacket = avctx->block_align * 8;\n        q->subpacket[s].log2_numvector_size = 5;\n        q->subpacket[s].total_subbands = q->subpacket[s].subbands;\n        q->subpacket[s].num_channels = 1;\n        av_log(avctx, AV_LOG_DEBUG, "subpacket[%i].cookversion=%x\\n", s,\n               q->subpacket[s].cookversion);\n        q->subpacket[s].joint_stereo = 0;\n        switch (q->subpacket[s].cookversion) {\n        case MONO:\n            if (avctx->channels != 1) {\n                av_log_ask_for_sample(avctx, "Container channels != 1.\\n");\n                return AVERROR_PATCHWELCOME;\n            }\n            av_log(avctx, AV_LOG_DEBUG, "MONO\\n");\n            break;\n        case STEREO:\n            if (avctx->channels != 1) {\n                q->subpacket[s].bits_per_subpdiv = 1;\n                q->subpacket[s].num_channels = 2;\n            }\n            av_log(avctx, AV_LOG_DEBUG, "STEREO\\n");\n            break;\n        case JOINT_STEREO:\n            if (avctx->channels != 2) {\n                av_log_ask_for_sample(avctx, "Container channels != 2.\\n");\n                return AVERROR_PATCHWELCOME;\n            }\n            av_log(avctx, AV_LOG_DEBUG, "JOINT_STEREO\\n");\n            if (avctx->extradata_size >= 16) {\n                q->subpacket[s].total_subbands = q->subpacket[s].subbands +\n                                                 q->subpacket[s].js_subband_start;\n                q->subpacket[s].joint_stereo = 1;\n                q->subpacket[s].num_channels = 2;\n            }\n            if (q->subpacket[s].samples_per_channel > 256) {\n                q->subpacket[s].log2_numvector_size = 6;\n            }\n            if (q->subpacket[s].samples_per_channel > 512) {\n                q->subpacket[s].log2_numvector_size = 7;\n            }\n            break;\n        case MC_COOK:\n            av_log(avctx, AV_LOG_DEBUG, "MULTI_CHANNEL\\n");\n            if (extradata_size >= 4)\n                channel_mask |= q->subpacket[s].channel_mask = bytestream_get_be32(&edata_ptr);\n            if (av_get_channel_layout_nb_channels(q->subpacket[s].channel_mask) > 1) {\n                q->subpacket[s].total_subbands = q->subpacket[s].subbands +\n                                                 q->subpacket[s].js_subband_start;\n                q->subpacket[s].joint_stereo = 1;\n                q->subpacket[s].num_channels = 2;\n                q->subpacket[s].samples_per_channel = samples_per_frame >> 1;\n                if (q->subpacket[s].samples_per_channel > 256) {\n                    q->subpacket[s].log2_numvector_size = 6;\n                }\n                if (q->subpacket[s].samples_per_channel > 512) {\n                    q->subpacket[s].log2_numvector_size = 7;\n                }\n            } else\n                q->subpacket[s].samples_per_channel = samples_per_frame;\n            break;\n        default:\n            av_log_ask_for_sample(avctx, "Unknown Cook version.\\n");\n            return AVERROR_PATCHWELCOME;\n        }\n        if (s > 1 && q->subpacket[s].samples_per_channel != q->samples_per_channel) {\n            av_log(avctx, AV_LOG_ERROR, "different number of samples per channel!\\n");\n            return AVERROR_INVALIDDATA;\n        } else\n            q->samples_per_channel = q->subpacket[0].samples_per_channel;\n        q->subpacket[s].numvector_size = (1 << q->subpacket[s].log2_numvector_size);\n        if (q->subpacket[s].total_subbands > 53) {\n            av_log_ask_for_sample(avctx, "total_subbands > 53\\n");\n            return AVERROR_PATCHWELCOME;\n        }\n        if ((q->subpacket[s].js_vlc_bits > 6) ||\n            (q->subpacket[s].js_vlc_bits < 2 * q->subpacket[s].joint_stereo)) {\n            av_log(avctx, AV_LOG_ERROR, "js_vlc_bits = %d, only >= %d and <= 6 allowed!\\n",\n                   q->subpacket[s].js_vlc_bits, 2 * q->subpacket[s].joint_stereo);\n            return AVERROR_INVALIDDATA;\n        }\n        if (q->subpacket[s].subbands > 50) {\n            av_log_ask_for_sample(avctx, "subbands > 50\\n");\n            return AVERROR_PATCHWELCOME;\n        }\n        q->subpacket[s].gains1.now      = q->subpacket[s].gain_1;\n        q->subpacket[s].gains1.previous = q->subpacket[s].gain_2;\n        q->subpacket[s].gains2.now      = q->subpacket[s].gain_3;\n        q->subpacket[s].gains2.previous = q->subpacket[s].gain_4;\n        q->num_subpackets++;\n        s++;\n        if (s > MAX_SUBPACKETS) {\n            av_log_ask_for_sample(avctx, "Too many subpackets > 5\\n");\n            return AVERROR_PATCHWELCOME;\n        }\n    }\n    init_pow2table();\n    init_gain_table(q);\n    init_cplscales_table(q);\n    if ((ret = init_cook_vlc_tables(q)))\n        return ret;\n    if (avctx->block_align >= UINT_MAX / 2)\n        return AVERROR(EINVAL);\n    q->decoded_bytes_buffer =\n        av_mallocz(avctx->block_align\n                   + DECODE_BYTES_PAD1(avctx->block_align)\n                   + FF_INPUT_BUFFER_PADDING_SIZE);\n    if (q->decoded_bytes_buffer == NULL)\n        return AVERROR(ENOMEM);\n    if ((ret = init_cook_mlt(q)))\n        return ret;\n    if (1) {\n        q->scalar_dequant  = scalar_dequant_float;\n        q->decouple        = decouple_float;\n        q->imlt_window     = imlt_window_float;\n        q->interpolate     = interpolate_float;\n        q->saturate_output = saturate_output_float;\n    }\n    if (q->samples_per_channel != 256 && q->samples_per_channel != 512 &&\n        q->samples_per_channel != 1024) {\n        av_log_ask_for_sample(avctx,\n                              "unknown amount of samples_per_channel = %d\\n",\n                              q->samples_per_channel);\n        return AVERROR_PATCHWELCOME;\n    }\n    avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;\n    if (channel_mask)\n        avctx->channel_layout = channel_mask;\n    else\n        avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;\n    avcodec_get_frame_defaults(&q->frame);\n    avctx->coded_frame = &q->frame;\n#ifdef DEBUG\n    dump_cook_context(q);\n#endif\n    return 0;\n}']