~ubuntu-branches/ubuntu/maverick/ffmpeg-debian/maverick

« back to all changes in this revision

Viewing changes to libavformat/oggenc.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-02-05 21:22:01 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090205212201-hjhtybuxtm90cbjy
Tags: 3:0.svn20090204-2ubuntu1
* merge from debian. Remaining changes:
  - don't build depend on libfaad-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
202
202
    return 0;
203
203
}
204
204
 
205
 
int ogg_interleave_per_granule(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
206
 
{
207
 
    AVPacketList *pktl, **next_point, *this_pktl;
 
205
static int ogg_compare_granule(AVFormatContext *s, AVPacket *next, AVPacket *pkt)
 
206
{
 
207
    AVStream *st2 = s->streams[next->stream_index];
 
208
    AVStream *st  = s->streams[pkt ->stream_index];
 
209
 
 
210
    int64_t next_granule = av_rescale_q(next->pts + next->duration,
 
211
                                        st2->time_base, AV_TIME_BASE_Q);
 
212
    int64_t cur_granule  = av_rescale_q(pkt ->pts + pkt ->duration,
 
213
                                        st ->time_base, AV_TIME_BASE_Q);
 
214
    return next_granule > cur_granule;
 
215
}
 
216
 
 
217
static int ogg_interleave_per_granule(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
 
218
{
 
219
    AVPacketList *pktl;
208
220
    int stream_count = 0;
209
221
    int streams[MAX_STREAMS] = {0};
210
222
    int interleaved = 0;
211
223
 
212
224
    if (pkt) {
213
 
        AVStream *st = s->streams[pkt->stream_index];
214
 
        this_pktl = av_mallocz(sizeof(AVPacketList));
215
 
        this_pktl->pkt = *pkt;
216
 
        if (pkt->destruct == av_destruct_packet)
217
 
            pkt->destruct = NULL; // not shared -> must keep original from being freed
218
 
        else
219
 
            av_dup_packet(&this_pktl->pkt); // shared -> must dup
220
 
        next_point = &s->packet_buffer;
221
 
        while (*next_point) {
222
 
            AVStream *st2 = s->streams[(*next_point)->pkt.stream_index];
223
 
            AVPacket *next_pkt = &(*next_point)->pkt;
224
 
            int64_t cur_granule, next_granule;
225
 
            next_granule = av_rescale_q(next_pkt->pts + next_pkt->duration,
226
 
                                        st2->time_base, AV_TIME_BASE_Q);
227
 
            cur_granule = av_rescale_q(pkt->pts + pkt->duration,
228
 
                                       st->time_base, AV_TIME_BASE_Q);
229
 
            if (next_granule > cur_granule)
230
 
                break;
231
 
            next_point= &(*next_point)->next;
232
 
        }
233
 
        this_pktl->next= *next_point;
234
 
        *next_point= this_pktl;
 
225
        ff_interleave_add_packet(s, pkt, ogg_compare_granule);
235
226
    }
236
227
 
237
228
    pktl = s->packet_buffer;