On 06/17/2012 11:03 AM, Martin Storsjö wrote:
> +static int ilbc_read_header(AVFormatContext *s)
> +{
> +    AVIOContext *pb = s->pb;
> +    AVStream *st;
> +    uint8_t header[9];
> +
> +    avio_read(pb, header, 9);
> +
> +    st = avformat_new_stream(s, NULL);
> +    if (!st)
> +        return AVERROR(ENOMEM);
> +    st->codec->codec_id = CODEC_ID_ILBC;
> +    st->codec->sample_rate = 8000;
> +    st->codec->channels = 1;
> +    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
> +    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
> +    if (!memcmp(header, mode20_header, sizeof(mode20_header) - 1)) {
> +        st->codec->block_align = 38;
> +        st->codec->bit_rate = 15200;
> +    } else if (!memcmp(header, mode30_header, sizeof(mode30_header) - 1)) {
> +        st->codec->block_align = 50;
> +        st->codec->bit_rate = 13333;
> +    } else {
> +        av_log(s, AV_LOG_ERROR, "Unrecognized iLBC file header\n");
> +        return AVERROR_INVALIDDATA;
> +    }
> +
> +    return 0;
> +}

Since you're setting only packet durations and not timestamps, you
should also set st->start_time to 0 when initializing the stream.

The rest looks good.

-Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to