static int dirac_header(AVFormatContext *s, int idx)
{
    struct ogg *ogg = s->priv_data;
    struct ogg_stream *os = ogg->streams + idx;
    AVStream *st = s->streams[idx];
    dirac_source_params source;
    GetBitContext gb;
    int ret;

    // already parsed the header
    if (st->codec->codec_id == AV_CODEC_ID_DIRAC)
        return 0;

    ret = init_get_bits8(&gb, os->buf + os->pstart + 13, (os->psize - 13));
    if (ret < 0)
        return ret;

    ret = avpriv_dirac_parse_sequence_header(st->codec, &gb, &source);
    if (ret < 0)
        return ret;

    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
    st->codec->codec_id = AV_CODEC_ID_DIRAC;
    // dirac in ogg always stores timestamps as though the video were interlaced
    avpriv_set_pts_info(st, 64, st->codec->framerate.den, 2*st->codec->framerate.num);
    return 1;
}