static int pmp_header(AVFormatContext *s)

{

    PMPContext *pmp = s->priv_data;

    AVIOContext *pb = s->pb;

    int tb_num, tb_den;

    uint32_t index_cnt;

    int audio_codec_id = AV_CODEC_ID_NONE;

    int srate, channels;

    int i;

    uint64_t pos;

    int64_t fsize = avio_size(pb);



    AVStream *vst = avformat_new_stream(s, NULL);

    if (!vst)

        return AVERROR(ENOMEM);

    vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;

    avio_skip(pb, 8);

    switch (avio_rl32(pb)) {

    case 0:

        vst->codec->codec_id = AV_CODEC_ID_MPEG4;

        break;

    case 1:

        vst->codec->codec_id = AV_CODEC_ID_H264;

        break;

    default:

        av_log(s, AV_LOG_ERROR, "Unsupported video format\n");

        break;

    }

    index_cnt = avio_rl32(pb);

    vst->codec->width  = avio_rl32(pb);

    vst->codec->height = avio_rl32(pb);



    tb_num = avio_rl32(pb);

    tb_den = avio_rl32(pb);

    avpriv_set_pts_info(vst, 32, tb_num, tb_den);

    vst->nb_frames = index_cnt;

    vst->duration = index_cnt;



    switch (avio_rl32(pb)) {

    case 0:

        audio_codec_id = AV_CODEC_ID_MP3;

        break;

    case 1:

        av_log(s, AV_LOG_ERROR, "AAC not yet correctly supported\n");

        audio_codec_id = AV_CODEC_ID_AAC;

        break;

    default:

        av_log(s, AV_LOG_ERROR, "Unsupported audio format\n");

        break;

    }

    pmp->num_streams = avio_rl16(pb) + 1;

    avio_skip(pb, 10);

    srate = avio_rl32(pb);

    channels = avio_rl32(pb) + 1;

    pos = avio_tell(pb) + 4*index_cnt;

    for (i = 0; i < index_cnt; i++) {

        uint32_t size = avio_rl32(pb);

        int flags = size & 1 ? AVINDEX_KEYFRAME : 0;

        if (url_feof(pb)) {

            av_log(s, AV_LOG_FATAL, "Encountered EOF while reading index.\n");

            return AVERROR_INVALIDDATA;

        }

        size >>= 1;

        if (size < 9 + 4*pmp->num_streams) {

            av_log(s, AV_LOG_ERROR, "Packet too small\n");

            return AVERROR_INVALIDDATA;

        }

        av_add_index_entry(vst, pos, i, size, 0, flags);

        pos += size;

        if (fsize > 0 && i == 0 && pos > fsize) {

            av_log(s, AV_LOG_ERROR, "File ends before first packet\n");

            return AVERROR_INVALIDDATA;

        }

    }

    for (i = 1; i < pmp->num_streams; i++) {

        AVStream *ast = avformat_new_stream(s, NULL);

        if (!ast)

            return AVERROR(ENOMEM);

        ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;

        ast->codec->codec_id = audio_codec_id;

        ast->codec->channels = channels;

        ast->codec->sample_rate = srate;

        avpriv_set_pts_info(ast, 32, 1, srate);

    }

    return 0;

}

static int pmp_header(AVFormatContext *s)

{

    PMPContext *pmp = s->priv_data;

    AVIOContext *pb = s->pb;

    int tb_num, tb_den;

    uint32_t index_cnt;

    int audio_codec_id = AV_CODEC_ID_NONE;

    int srate, channels;

    int i;

    uint64_t pos;

    int64_t fsize = avio_size(pb);



    AVStream *vst = avformat_new_stream(s, NULL);

    if (!vst)

        return AVERROR(ENOMEM);

    vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;

    avio_skip(pb, 8);

    switch (avio_rl32(pb)) {

    case 0:

        vst->codec->codec_id = AV_CODEC_ID_MPEG4;

        break;

    case 1:

        vst->codec->codec_id = AV_CODEC_ID_H264;

        break;

    default:

        av_log(s, AV_LOG_ERROR, "Unsupported video format\n");

        break;

    }

    index_cnt = avio_rl32(pb);

    vst->codec->width  = avio_rl32(pb);

    vst->codec->height = avio_rl32(pb);



    tb_num = avio_rl32(pb);

    tb_den = avio_rl32(pb);

    avpriv_set_pts_info(vst, 32, tb_num, tb_den);

    vst->nb_frames = index_cnt;

    vst->duration = index_cnt;



    switch (avio_rl32(pb)) {

    case 0:

        audio_codec_id = AV_CODEC_ID_MP3;

        break;

    case 1:

        av_log(s, AV_LOG_ERROR, "AAC not yet correctly supported\n");

        audio_codec_id = AV_CODEC_ID_AAC;

        break;

    default:

        av_log(s, AV_LOG_ERROR, "Unsupported audio format\n");

        break;

    }

    pmp->num_streams = avio_rl16(pb) + 1;

    avio_skip(pb, 10);

    srate = avio_rl32(pb);

    channels = avio_rl32(pb) + 1;

    pos = avio_tell(pb) + 4*index_cnt;

    for (i = 0; i < index_cnt; i++) {

        uint32_t size = avio_rl32(pb);

        int flags = size & 1 ? AVINDEX_KEYFRAME : 0;

        if (url_feof(pb)) {

            av_log(s, AV_LOG_FATAL, "Encountered EOF while reading index.\n");

            return AVERROR_INVALIDDATA;

        }

        size >>= 1;

        if (size < 9 + 4*pmp->num_streams) {

            av_log(s, AV_LOG_ERROR, "Packet too small\n");

            return AVERROR_INVALIDDATA;

        }

        av_add_index_entry(vst, pos, i, size, 0, flags);

        pos += size;

        if (fsize > 0 && i == 0 && pos > fsize) {

            av_log(s, AV_LOG_ERROR, "File ends before first packet\n");

            return AVERROR_INVALIDDATA;

        }

    }

    for (i = 1; i < pmp->num_streams; i++) {

        AVStream *ast = avformat_new_stream(s, NULL);

        if (!ast)

            return AVERROR(ENOMEM);

        ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;

        ast->codec->codec_id = audio_codec_id;

        ast->codec->channels = channels;

        ast->codec->sample_rate = srate;

        avpriv_set_pts_info(ast, 32, 1, srate);

    }

    return 0;

}

    pos = avio_tell(pb) + 4*index_cnt;
static int FUNC_0(AVFormatContext *VAR_0)

{

    PMPContext *pmp = VAR_0->priv_data;

    AVIOContext *pb = VAR_0->pb;

    int VAR_1, VAR_2;

    uint32_t index_cnt;

    int VAR_3 = AV_CODEC_ID_NONE;

    int VAR_4, VAR_5;

    int VAR_6;

    uint64_t pos;

    int64_t fsize = avio_size(pb);



    AVStream *vst = avformat_new_stream(VAR_0, NULL);

    if (!vst)

        return AVERROR(ENOMEM);

    vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;

    avio_skip(pb, 8);

    switch (avio_rl32(pb)) {

    case 0:

        vst->codec->codec_id = AV_CODEC_ID_MPEG4;

        break;

    case 1:

        vst->codec->codec_id = AV_CODEC_ID_H264;

        break;

    default:

        av_log(VAR_0, AV_LOG_ERROR, "Unsupported video format\n");

        break;

    }

    index_cnt = avio_rl32(pb);

    vst->codec->width  = avio_rl32(pb);

    vst->codec->height = avio_rl32(pb);



    VAR_1 = avio_rl32(pb);

    VAR_2 = avio_rl32(pb);

    avpriv_set_pts_info(vst, 32, VAR_1, VAR_2);

    vst->nb_frames = index_cnt;

    vst->duration = index_cnt;



    switch (avio_rl32(pb)) {

    case 0:

        VAR_3 = AV_CODEC_ID_MP3;

        break;

    case 1:

        av_log(VAR_0, AV_LOG_ERROR, "AAC not yet correctly supported\n");

        VAR_3 = AV_CODEC_ID_AAC;

        break;

    default:

        av_log(VAR_0, AV_LOG_ERROR, "Unsupported audio format\n");

        break;

    }

    pmp->num_streams = avio_rl16(pb) + 1;

    avio_skip(pb, 10);

    VAR_4 = avio_rl32(pb);

    VAR_5 = avio_rl32(pb) + 1;

    pos = avio_tell(pb) + 4*index_cnt;

    for (VAR_6 = 0; VAR_6 < index_cnt; VAR_6++) {

        uint32_t size = avio_rl32(pb);

        int flags = size & 1 ? AVINDEX_KEYFRAME : 0;

        if (url_feof(pb)) {

            av_log(VAR_0, AV_LOG_FATAL, "Encountered EOF while reading index.\n");

            return AVERROR_INVALIDDATA;

        }

        size >>= 1;

        if (size < 9 + 4*pmp->num_streams) {

            av_log(VAR_0, AV_LOG_ERROR, "Packet too small\n");

            return AVERROR_INVALIDDATA;

        }

        av_add_index_entry(vst, pos, VAR_6, size, 0, flags);

        pos += size;

        if (fsize > 0 && VAR_6 == 0 && pos > fsize) {

            av_log(VAR_0, AV_LOG_ERROR, "File ends before first packet\n");

            return AVERROR_INVALIDDATA;

        }

    }

    for (VAR_6 = 1; VAR_6 < pmp->num_streams; VAR_6++) {

        AVStream *ast = avformat_new_stream(VAR_0, NULL);

        if (!ast)

            return AVERROR(ENOMEM);

        ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;

        ast->codec->codec_id = VAR_3;

        ast->codec->VAR_5 = VAR_5;

        ast->codec->sample_rate = VAR_4;

        avpriv_set_pts_info(ast, 32, 1, VAR_4);

    }

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ PMPContext *pmp = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; int VAR_1, VAR_2; uint32_t index_cnt; int VAR_3 = AV_CODEC_ID_NONE; int VAR_4, VAR_5; int VAR_6; uint64_t pos; int64_t fsize = avio_size(pb); AVStream *vst = avformat_new_stream(VAR_0, NULL); if (!vst)
return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; avio_skip(pb, 8); switch (avio_rl32(pb)) { case 0:
vst->codec->codec_id = AV_CODEC_ID_MPEG4; break; case 1:
vst->codec->codec_id = AV_CODEC_ID_H264; break; default:
av_log(VAR_0, AV_LOG_ERROR, "Unsupported video format\n"); break; } index_cnt = avio_rl32(pb); vst->codec->width  = avio_rl32(pb); vst->codec->height = avio_rl32(pb); VAR_1 = avio_rl32(pb); VAR_2 = avio_rl32(pb); avpriv_set_pts_info(vst, 32, VAR_1, VAR_2); vst->nb_frames = index_cnt; vst->duration = index_cnt; switch (avio_rl32(pb)) { case 0:
VAR_3 = AV_CODEC_ID_MP3; break; case 1:
av_log(VAR_0, AV_LOG_ERROR, "AAC not yet correctly supported\n"); VAR_3 = AV_CODEC_ID_AAC; break; default:
av_log(VAR_0, AV_LOG_ERROR, "Unsupported audio format\n"); break; } pmp->num_streams = avio_rl16(pb) + 1; avio_skip(pb, 10); VAR_4 = avio_rl32(pb); VAR_5 = avio_rl32(pb) + 1; pos = avio_tell(pb) + 4*index_cnt; for (VAR_6 = 0; VAR_6 < index_cnt; VAR_6++) { uint32_t size = avio_rl32(pb); int flags = size & 1 ? AVINDEX_KEYFRAME : 0; if (url_feof(pb)) { av_log(VAR_0, AV_LOG_FATAL, "Encountered EOF while reading index.\n"); return AVERROR_INVALIDDATA; } size >>= 1; if (size < 9 + 4*pmp->num_streams) { av_log(VAR_0, AV_LOG_ERROR, "Packet too small\n"); return AVERROR_INVALIDDATA; } av_add_index_entry(vst, pos, VAR_6, size, 0, flags); pos += size; if (fsize > 0 && VAR_6 == 0 && pos > fsize) { av_log(VAR_0, AV_LOG_ERROR, "File ends before first packet\n"); return AVERROR_INVALIDDATA; } } for (VAR_6 = 1; VAR_6 < pmp->num_streams; VAR_6++) { AVStream *ast = avformat_new_stream(VAR_0, NULL); if (!ast)
return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id = VAR_3; ast->codec->VAR_5 = VAR_5; ast->codec->sample_rate = VAR_4; avpriv_set_pts_info(ast, 32, 1, VAR_4); } return 0; }