~siretart/libav/merge.raring.libav-0.8.6

« back to all changes in this revision

Viewing changes to libavformat/oggparsespeex.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-12 22:30:00 UTC
  • mfrom: (1.4.1)
  • mto: (1.3.11 sid) (26.1.1 quantal-security)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20120112223000-s1reiy1e28hnix42
Tags: upstream-0.8~beta2
ImportĀ upstreamĀ versionĀ 0.8~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "libavcodec/get_bits.h"
29
29
#include "libavcodec/bytestream.h"
30
30
#include "avformat.h"
 
31
#include "internal.h"
31
32
#include "oggdec.h"
32
33
 
33
34
struct speex_params {
 
35
    int packet_size;
34
36
    int final_packet_duration;
35
37
    int seq;
36
38
};
58
60
        st->codec->sample_rate = AV_RL32(p + 36);
59
61
        st->codec->channels = AV_RL32(p + 48);
60
62
 
61
 
        /* We treat the whole Speex packet as a single frame everywhere Speex
62
 
           is handled in Libav.  This avoids the complexities of splitting
63
 
           and joining individual Speex frames, which are not always
64
 
           byte-aligned. */
65
 
        st->codec->frame_size = AV_RL32(p + 56);
66
 
        frames_per_packet     = AV_RL32(p + 64);
 
63
        spxp->packet_size  = AV_RL32(p + 56);
 
64
        frames_per_packet  = AV_RL32(p + 64);
67
65
        if (frames_per_packet)
68
 
            st->codec->frame_size *= frames_per_packet;
 
66
            spxp->packet_size *= frames_per_packet;
69
67
 
70
68
        st->codec->extradata_size = os->psize;
71
69
        st->codec->extradata = av_malloc(st->codec->extradata_size
72
70
                                         + FF_INPUT_BUFFER_PADDING_SIZE);
73
71
        memcpy(st->codec->extradata, p, st->codec->extradata_size);
74
72
 
75
 
        av_set_pts_info(st, 64, 1, st->codec->sample_rate);
 
73
        avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
76
74
    } else
77
75
        ff_vorbis_comment(s, &st->metadata, p, os->psize);
78
76
 
95
93
    struct ogg *ogg = s->priv_data;
96
94
    struct ogg_stream *os = ogg->streams + idx;
97
95
    struct speex_params *spxp = os->private;
98
 
    int packet_size = s->streams[idx]->codec->frame_size;
 
96
    int packet_size = spxp->packet_size;
99
97
 
100
98
    if (os->flags & OGG_FLAG_EOS && os->lastpts != AV_NOPTS_VALUE &&
101
99
        os->granule > 0) {
108
106
 
109
107
    if (!os->lastpts && os->granule > 0)
110
108
        /* first packet */
111
 
        os->pduration = os->granule - packet_size * (ogg_page_packets(os) - 1);
112
 
    else if (os->flags & OGG_FLAG_EOS && os->segp == os->nsegs &&
113
 
             spxp->final_packet_duration)
 
109
        os->lastpts = os->lastdts = os->granule - packet_size *
 
110
                                    ogg_page_packets(os);
 
111
    if (os->flags & OGG_FLAG_EOS && os->segp == os->nsegs &&
 
112
        spxp->final_packet_duration)
114
113
        /* final packet */
115
114
        os->pduration = spxp->final_packet_duration;
116
115
    else