History

In ogg muxer, use random serial number of each ogg streams

Originally committed as revision 23302 to svn://svn.ffmpeg.org/ffmpeg/trunk

Baptiste Coudurier committed 16 years ago

Commit ce2a9bc1 parent a2403981 file · +18 −1Browse files

Unified · Split

libavformat/oggenc.c+18−1
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 */
2121
2222 #include "libavutil/crc.h"
23+#include "libavutil/random_seed.h"
2324 #include "libavcodec/xiph.h"
2425 #include "libavcodec/bytestream.h"
2526 #include "libavcodec/flac.h"
@@ -50,6 +51,7 @@ typedef struct { · 24 unmodified lines
5051 int eos;
5152 unsigned page_count; ///< number of page buffered
5253 OGGPage page; ///< current page
54+ unsigned serial_num; ///< serial number
5355 } OGGStreamContext;
5456
5557 typedef struct OGGPageList {
@@ -80,7 +82,7 @@ static void ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags) · 24 unmodified lines
8082 put_byte(s->pb, 0);
8183 put_byte(s->pb, page->flags | extra_flags);
8284 put_le64(s->pb, page->granule);
83− put_le32(s->pb, page->stream_index);
85+ put_le32(s->pb, oggstream->serial_num);
8486 put_le32(s->pb, oggstream->page_counter++);
8587 crc_offset = url_ftell(s->pb);
8688 put_le32(s->pb, 0); // crc
@@ -280,8 +282,11 @@ static int ogg_write_header(AVFormatContext *s) · 193 unmodified lines
280282 {
281283 OGGStreamContext *oggstream;
282284 int i, j;
285+
283286 for (i = 0; i < s->nb_streams; i++) {
284287 AVStream *st = s->streams[i];
288+ unsigned serial_num = i;
289+
285290 if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
286291 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
287292 else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
@@ -300,6 +305,18 @@ static int ogg_write_header(AVFormatContext *s) · 12 unmodified lines
300305 }
301306 oggstream = av_mallocz(sizeof(*oggstream));
302307 oggstream->page.stream_index = i;
308+
309+ if (!(st->codec->flags & CODEC_FLAG_BITEXACT))
310+ do {
311+ serial_num = av_get_random_seed();
312+ for (j = 0; j < i; j++) {
313+ OGGStreamContext *sc = s->streams[j]->priv_data;
314+ if (serial_num == sc->serial_num)
315+ break;
316+ }
317+ } while (j < i);
318+ oggstream->serial_num = serial_num;
319+
303320 st->priv_data = oggstream;
304321 if (st->codec->codec_id == CODEC_ID_FLAC) {
305322 int err = ogg_build_flac_headers(st->codec, oggstream,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t