switch(avctx->codec->id) { case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: avctx->block_align = 2 * avctx->channels; break; case CODEC_ID_PCM_S8: case CODEC_ID_PCM_U8: case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_ALAW: avctx->block_align = avctx->channels; break; default: break; }
static int pcm_encode_init(AVCodecContext *avctx){    avctx->frame_size = 1;    switch(avctx->codec->id) {    case CODEC_ID_PCM_ALAW:        if (linear_to_alaw_ref == 0) {            linear_to_alaw = av_malloc(16384);            if (!linear_to_alaw)                return -1;            build_xlaw_table(linear_to_alaw, alaw2linear, 0xd5);        }        linear_to_alaw_ref++;        break;    case CODEC_ID_PCM_MULAW:        if (linear_to_ulaw_ref == 0) {            linear_to_ulaw = av_malloc(16384);            if (!linear_to_ulaw)                return -1;            build_xlaw_table(linear_to_ulaw, ulaw2linear, 0xff);        }        linear_to_ulaw_ref++;        break;    default:        break;    }        avctx->coded_frame= avcodec_alloc_frame();    avctx->coded_frame->key_frame= 1;        return 0;}