Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: source/patched-ffmpeg-mt/libavformat/oggenc.c

Issue 4533003: patched ffmpeg nov 2 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Ogg muxer 2 * Ogg muxer
3 * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at free dot fr> 3 * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at free dot fr>
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 page->granule = granule; 199 page->granule = granule;
200 200
201 if (page->segments_count == 255) { 201 if (page->segments_count == 255) {
202 ogg_buffer_page(s, oggstream); 202 ogg_buffer_page(s, oggstream);
203 } 203 }
204 } 204 }
205 return 0; 205 return 0;
206 } 206 }
207 207
208 static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact, 208 static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
209 int *header_len, AVMetadata *m, int fram ing_bit) 209 int *header_len, AVMetadata **m, int fra ming_bit)
210 { 210 {
211 const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT; 211 const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
212 int size; 212 int size;
213 uint8_t *p, *p0; 213 uint8_t *p, *p0;
214 unsigned int count; 214 unsigned int count;
215 215
216 size = offset + ff_vorbiscomment_length(m, vendor, &count) + framing_bit; 216 size = offset + ff_vorbiscomment_length(*m, vendor, &count) + framing_bit;
217 p = av_mallocz(size); 217 p = av_mallocz(size);
218 if (!p) 218 if (!p)
219 return NULL; 219 return NULL;
220 p0 = p; 220 p0 = p;
221 221
222 p += offset; 222 p += offset;
223 ff_vorbiscomment_write(&p, m, vendor, count); 223 ff_vorbiscomment_write(&p, m, vendor, count);
224 if (framing_bit) 224 if (framing_bit)
225 bytestream_put_byte(&p, 1); 225 bytestream_put_byte(&p, 1);
226 226
227 *header_len = size; 227 *header_len = size;
228 return p0; 228 return p0;
229 } 229 }
230 230
231 static int ogg_build_flac_headers(AVCodecContext *avctx, 231 static int ogg_build_flac_headers(AVCodecContext *avctx,
232 OGGStreamContext *oggstream, int bitexact, 232 OGGStreamContext *oggstream, int bitexact,
233 AVMetadata *m) 233 AVMetadata **m)
234 { 234 {
235 enum FLACExtradataFormat format; 235 enum FLACExtradataFormat format;
236 uint8_t *streaminfo; 236 uint8_t *streaminfo;
237 uint8_t *p; 237 uint8_t *p;
238 238
239 if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo)) 239 if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo))
240 return -1; 240 return -1;
241 241
242 // first packet: STREAMINFO 242 // first packet: STREAMINFO
243 oggstream->header_len[0] = 51; 243 oggstream->header_len[0] = 51;
(...skipping 19 matching lines...) Expand all
263 bytestream_put_byte(&p, 0x84); // last metadata block and vorbis comment 263 bytestream_put_byte(&p, 0x84); // last metadata block and vorbis comment
264 bytestream_put_be24(&p, oggstream->header_len[1] - 4); 264 bytestream_put_be24(&p, oggstream->header_len[1] - 4);
265 265
266 return 0; 266 return 0;
267 } 267 }
268 268
269 #define SPEEX_HEADER_SIZE 80 269 #define SPEEX_HEADER_SIZE 80
270 270
271 static int ogg_build_speex_headers(AVCodecContext *avctx, 271 static int ogg_build_speex_headers(AVCodecContext *avctx,
272 OGGStreamContext *oggstream, int bitexact, 272 OGGStreamContext *oggstream, int bitexact,
273 AVMetadata *m) 273 AVMetadata **m)
274 { 274 {
275 uint8_t *p; 275 uint8_t *p;
276 276
277 if (avctx->extradata_size < SPEEX_HEADER_SIZE) 277 if (avctx->extradata_size < SPEEX_HEADER_SIZE)
278 return -1; 278 return -1;
279 279
280 // first packet: Speex header 280 // first packet: Speex header
281 p = av_mallocz(SPEEX_HEADER_SIZE); 281 p = av_mallocz(SPEEX_HEADER_SIZE);
282 if (!p) 282 if (!p)
283 return AVERROR(ENOMEM); 283 return AVERROR(ENOMEM);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (serial_num == sc->serial_num) 331 if (serial_num == sc->serial_num)
332 break; 332 break;
333 } 333 }
334 } while (j < i); 334 } while (j < i);
335 oggstream->serial_num = serial_num; 335 oggstream->serial_num = serial_num;
336 336
337 st->priv_data = oggstream; 337 st->priv_data = oggstream;
338 if (st->codec->codec_id == CODEC_ID_FLAC) { 338 if (st->codec->codec_id == CODEC_ID_FLAC) {
339 int err = ogg_build_flac_headers(st->codec, oggstream, 339 int err = ogg_build_flac_headers(st->codec, oggstream,
340 st->codec->flags & CODEC_FLAG_BITEX ACT, 340 st->codec->flags & CODEC_FLAG_BITEX ACT,
341 s->metadata); 341 &s->metadata);
342 if (err) { 342 if (err) {
343 av_log(s, AV_LOG_ERROR, "Error writing FLAC headers\n"); 343 av_log(s, AV_LOG_ERROR, "Error writing FLAC headers\n");
344 av_freep(&st->priv_data); 344 av_freep(&st->priv_data);
345 return err; 345 return err;
346 } 346 }
347 } else if (st->codec->codec_id == CODEC_ID_SPEEX) { 347 } else if (st->codec->codec_id == CODEC_ID_SPEEX) {
348 int err = ogg_build_speex_headers(st->codec, oggstream, 348 int err = ogg_build_speex_headers(st->codec, oggstream,
349 st->codec->flags & CODEC_FLAG_BITE XACT, 349 st->codec->flags & CODEC_FLAG_BITE XACT,
350 s->metadata); 350 &s->metadata);
351 if (err) { 351 if (err) {
352 av_log(s, AV_LOG_ERROR, "Error writing Speex headers\n"); 352 av_log(s, AV_LOG_ERROR, "Error writing Speex headers\n");
353 av_freep(&st->priv_data); 353 av_freep(&st->priv_data);
354 return err; 354 return err;
355 } 355 }
356 } else { 356 } else {
357 uint8_t *p; 357 uint8_t *p;
358 char *cstr = st->codec->codec_id == CODEC_ID_VORBIS ? "vorbis" : "th eora"; 358 const char *cstr = st->codec->codec_id == CODEC_ID_VORBIS ? "vorbis" : "theora";
359 int header_type = st->codec->codec_id == CODEC_ID_VORBIS ? 3 : 0x81; 359 int header_type = st->codec->codec_id == CODEC_ID_VORBIS ? 3 : 0x81;
360 int framing_bit = st->codec->codec_id == CODEC_ID_VORBIS ? 1 : 0; 360 int framing_bit = st->codec->codec_id == CODEC_ID_VORBIS ? 1 : 0;
361 361
362 if (ff_split_xiph_headers(st->codec->extradata, st->codec->extradata _size, 362 if (ff_split_xiph_headers(st->codec->extradata, st->codec->extradata _size,
363 st->codec->codec_id == CODEC_ID_VORBIS ? 3 0 : 42, 363 st->codec->codec_id == CODEC_ID_VORBIS ? 3 0 : 42,
364 oggstream->header, oggstream->header_len) < 0) { 364 oggstream->header, oggstream->header_len) < 0) {
365 av_log(s, AV_LOG_ERROR, "Extradata corrupted\n"); 365 av_log(s, AV_LOG_ERROR, "Extradata corrupted\n");
366 av_freep(&st->priv_data); 366 av_freep(&st->priv_data);
367 return -1; 367 return -1;
368 } 368 }
369 369
370 p = ogg_write_vorbiscomment(7, st->codec->flags & CODEC_FLAG_BITEXAC T, 370 p = ogg_write_vorbiscomment(7, st->codec->flags & CODEC_FLAG_BITEXAC T,
371 &oggstream->header_len[1], s->metadata, 371 &oggstream->header_len[1], &s->metadata,
372 framing_bit); 372 framing_bit);
373 if (!p) 373 if (!p)
374 return AVERROR(ENOMEM); 374 return AVERROR(ENOMEM);
375 375
376 oggstream->header[1] = p; 376 oggstream->header[1] = p;
377 bytestream_put_byte(&p, header_type); 377 bytestream_put_byte(&p, header_type);
378 bytestream_put_buffer(&p, cstr, 6); 378 bytestream_put_buffer(&p, cstr, 6);
379 379
380 if (st->codec->codec_id == CODEC_ID_THEORA) { 380 if (st->codec->codec_id == CODEC_ID_THEORA) {
381 /** KFGSHIFT is the width of the less significant section of the granule position 381 /** KFGSHIFT is the width of the less significant section of the granule position
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 "ogg", 488 "ogg",
489 NULL_IF_CONFIG_SMALL("Ogg"), 489 NULL_IF_CONFIG_SMALL("Ogg"),
490 "application/ogg", 490 "application/ogg",
491 "ogg,ogv,spx", 491 "ogg,ogv,spx",
492 sizeof(OGGContext), 492 sizeof(OGGContext),
493 CODEC_ID_FLAC, 493 CODEC_ID_FLAC,
494 CODEC_ID_THEORA, 494 CODEC_ID_THEORA,
495 ogg_write_header, 495 ogg_write_header,
496 ogg_write_packet, 496 ogg_write_packet,
497 ogg_write_trailer, 497 ogg_write_trailer,
498 .metadata_conv = ff_vorbiscomment_metadata_conv,
499 }; 498 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698