Revision 521d434f

View differences:

libavformat/oggenc.c
206 206
}
207 207

  
208 208
static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
209
                                        int *header_len, AVMetadata *m)
209
                                        int *header_len, AVMetadata *m, int framing_bit)
210 210
{
211 211
    const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
212 212
    int size;
213 213
    uint8_t *p, *p0;
214 214
    unsigned int count;
215 215

  
216
    size = offset + ff_vorbiscomment_length(m, vendor, &count);
216
    size = offset + ff_vorbiscomment_length(m, vendor, &count) + framing_bit;
217 217
    p = av_mallocz(size);
218 218
    if (!p)
219 219
        return NULL;
......
221 221

  
222 222
    p += offset;
223 223
    ff_vorbiscomment_write(&p, m, vendor, count);
224
    if (framing_bit)
225
        bytestream_put_byte(&p, 1);
224 226

  
225 227
    *header_len = size;
226 228
    return p0;
......
254 256
    bytestream_put_buffer(&p, streaminfo, FLAC_STREAMINFO_SIZE);
255 257

  
256 258
    // second packet: VorbisComment
257
    p = ogg_write_vorbiscomment(4, bitexact, &oggstream->header_len[1], m);
259
    p = ogg_write_vorbiscomment(4, bitexact, &oggstream->header_len[1], m, 0);
258 260
    if (!p)
259 261
        return AVERROR(ENOMEM);
260 262
    oggstream->header[1] = p;
......
285 287
    AV_WL32(&oggstream->header[0][68], 0);  // set extra_headers to 0
286 288

  
287 289
    // second packet: VorbisComment
288
    p = ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m);
290
    p = ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m, 0);
289 291
    if (!p)
290 292
        return AVERROR(ENOMEM);
291 293
    oggstream->header[1] = p;
......
352 354
                return err;
353 355
            }
354 356
        } else {
357
            uint8_t *p;
358
            char *cstr = st->codec->codec_id == CODEC_ID_VORBIS ? "vorbis" : "theora";
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;
361

  
355 362
            if (ff_split_xiph_headers(st->codec->extradata, st->codec->extradata_size,
356 363
                                      st->codec->codec_id == CODEC_ID_VORBIS ? 30 : 42,
357 364
                                      oggstream->header, oggstream->header_len) < 0) {
......
359 366
                av_freep(&st->priv_data);
360 367
                return -1;
361 368
            }
369

  
370
            p = ogg_write_vorbiscomment(7, st->codec->flags & CODEC_FLAG_BITEXACT,
371
                                        &oggstream->header_len[1], s->metadata,
372
                                        framing_bit);
373
            if (!p)
374
                return AVERROR(ENOMEM);
375

  
376
            oggstream->header[1] = p;
377
            bytestream_put_byte(&p, header_type);
378
            bytestream_put_buffer(&p, cstr, 6);
379

  
362 380
            if (st->codec->codec_id == CODEC_ID_THEORA) {
363 381
                /** KFGSHIFT is the width of the less significant section of the granule position
364 382
                    The less significant section is the frame count since the last keyframe */

Also available in: Unified diff