Statistics
| Branch: | Revision:

ffmpeg / libavformat / nutenc.c @ 14b3f996

History | View | Annotate | Download (18 KB)

1
/*
2
 * nut muxer
3
 * Copyright (c) 2004-2007 Michael Niedermayer
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21

    
22
#include "nut.h"
23
#include "tree.h"
24

    
25
#define TRACE
26

    
27
static void build_frame_code(AVFormatContext *s){
28
    NUTContext *nut = s->priv_data;
29
    int key_frame, index, pred, stream_id;
30
    int start=1;
31
    int end= 254;
32
    int keyframe_0_esc= s->nb_streams > 2;
33
    int pred_table[10];
34
    FrameCode *ft;
35

    
36
    ft= &nut->frame_code[start];
37
    ft->flags= FLAG_CODED;
38
    ft->size_mul=1;
39
    ft->pts_delta=1;
40
    start++;
41

    
42
    if(keyframe_0_esc){
43
        /* keyframe = 0 escape */
44
        FrameCode *ft= &nut->frame_code[start];
45
        ft->flags= FLAG_STREAM_ID | FLAG_SIZE_MSB | FLAG_CODED_PTS;
46
        ft->size_mul=1;
47
        start++;
48
    }
49

    
50
    for(stream_id= 0; stream_id<s->nb_streams; stream_id++){
51
        int start2= start + (end-start)*stream_id / s->nb_streams;
52
        int end2  = start + (end-start)*(stream_id+1) / s->nb_streams;
53
        AVCodecContext *codec = s->streams[stream_id]->codec;
54
        int is_audio= codec->codec_type == CODEC_TYPE_AUDIO;
55
        int intra_only= /*codec->intra_only || */is_audio;
56
        int pred_count;
57

    
58
        for(key_frame=0; key_frame<2; key_frame++){
59
            if(intra_only && keyframe_0_esc && key_frame==0)
60
                continue;
61

    
62
            {
63
                FrameCode *ft= &nut->frame_code[start2];
64
                ft->flags= FLAG_KEY*key_frame;
65
                ft->flags|= FLAG_SIZE_MSB | FLAG_CODED_PTS;
66
                ft->stream_id= stream_id;
67
                ft->size_mul=1;
68
                start2++;
69
            }
70
        }
71

    
72
        key_frame= intra_only;
73
#if 1
74
        if(is_audio){
75
            int frame_bytes= codec->frame_size*(int64_t)codec->bit_rate / (8*codec->sample_rate);
76
            int pts;
77
            for(pts=0; pts<2; pts++){
78
                for(pred=0; pred<2; pred++){
79
                    FrameCode *ft= &nut->frame_code[start2];
80
                    ft->flags= FLAG_KEY*key_frame;
81
                    ft->stream_id= stream_id;
82
                    ft->size_mul=frame_bytes + 2;
83
                    ft->size_lsb=frame_bytes + pred;
84
                    ft->pts_delta=pts;
85
                    start2++;
86
                }
87
            }
88
        }else{
89
            FrameCode *ft= &nut->frame_code[start2];
90
            ft->flags= FLAG_KEY | FLAG_SIZE_MSB;
91
            ft->stream_id= stream_id;
92
            ft->size_mul=1;
93
            ft->pts_delta=1;
94
            start2++;
95
        }
96
#endif
97

    
98
        if(codec->has_b_frames){
99
            pred_count=5;
100
            pred_table[0]=-2;
101
            pred_table[1]=-1;
102
            pred_table[2]=1;
103
            pred_table[3]=3;
104
            pred_table[4]=4;
105
        }else if(codec->codec_id == CODEC_ID_VORBIS){
106
            pred_count=3;
107
            pred_table[0]=2;
108
            pred_table[1]=9;
109
            pred_table[2]=16;
110
        }else{
111
            pred_count=1;
112
            pred_table[0]=1;
113
        }
114

    
115
        for(pred=0; pred<pred_count; pred++){
116
            int start3= start2 + (end2-start2)*pred / pred_count;
117
            int end3  = start2 + (end2-start2)*(pred+1) / pred_count;
118

    
119
            for(index=start3; index<end3; index++){
120
                FrameCode *ft= &nut->frame_code[index];
121
                ft->flags= FLAG_KEY*key_frame;
122
                ft->flags|= FLAG_SIZE_MSB;
123
                ft->stream_id= stream_id;
124
//FIXME use single byte size and pred from last
125
                ft->size_mul= end3-start3;
126
                ft->size_lsb= index - start3;
127
                ft->pts_delta= pred_table[pred];
128
            }
129
        }
130
    }
131
    memmove(&nut->frame_code['N'+1], &nut->frame_code['N'], sizeof(FrameCode)*(255-'N'));
132
    nut->frame_code[  0].flags=
133
    nut->frame_code[255].flags=
134
    nut->frame_code['N'].flags= FLAG_INVALID;
135
}
136

    
137
/**
138
 * Gets the length in bytes which is needed to store val as v.
139
 */
140
static int get_length(uint64_t val){
141
    int i=1;
142

    
143
    while(val>>=7)
144
        i++;
145

    
146
    return i;
147
}
148

    
149
static void put_v(ByteIOContext *bc, uint64_t val){
150
    int i= get_length(val);
151

    
152
    while(--i>0)
153
        put_byte(bc, 128 | (val>>(7*i)));
154

    
155
    put_byte(bc, val&127);
156
}
157

    
158
static void put_t(NUTContext *nut, StreamContext *nus, ByteIOContext *bc, uint64_t val){
159
    val *= nut->time_base_count;
160
    val += nus->time_base - nut->time_base;
161
    put_v(bc, val);
162
}
163

    
164
/**
165
 * stores a string as vb.
166
 */
167
static void put_str(ByteIOContext *bc, const char *string){
168
    int len= strlen(string);
169

    
170
    put_v(bc, len);
171
    put_buffer(bc, string, len);
172
}
173

    
174
static void put_s(ByteIOContext *bc, int64_t val){
175
    put_v(bc, 2*FFABS(val) - (val>0));
176
}
177

    
178
#ifdef TRACE
179
static inline void put_v_trace(ByteIOContext *bc, uint64_t v, char *file, char *func, int line){
180
    av_log(NULL, AV_LOG_DEBUG, "put_v %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
181

    
182
    put_v(bc, v);
183
}
184

    
185
static inline void put_s_trace(ByteIOContext *bc, int64_t v, char *file, char *func, int line){
186
    av_log(NULL, AV_LOG_DEBUG, "put_s %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
187

    
188
    put_s(bc, v);
189
}
190
#define put_v(bc, v)  put_v_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__)
191
#define put_s(bc, v)  put_s_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__)
192
#endif
193

    
194
//FIXME remove calculate_checksum
195
static void put_packet(NUTContext *nut, ByteIOContext *bc, ByteIOContext *dyn_bc, int calculate_checksum, uint64_t startcode){
196
    uint8_t *dyn_buf=NULL;
197
    int dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf);
198
    int forw_ptr= dyn_size + 4*calculate_checksum;
199

    
200
    if(forw_ptr > 4096)
201
        init_checksum(bc, av_crc04C11DB7_update, 0);
202
    put_be64(bc, startcode);
203
    put_v(bc, forw_ptr);
204
    if(forw_ptr > 4096)
205
        put_le32(bc, get_checksum(bc));
206

    
207
    if(calculate_checksum)
208
        init_checksum(bc, av_crc04C11DB7_update, 0);
209
    put_buffer(bc, dyn_buf, dyn_size);
210
    if(calculate_checksum)
211
        put_le32(bc, get_checksum(bc));
212

    
213
    av_free(dyn_buf);
214
}
215

    
216
static void write_mainheader(NUTContext *nut, ByteIOContext *bc){
217
    int i, j, tmp_pts, tmp_flags, tmp_stream, tmp_mul, tmp_size, tmp_fields;
218

    
219
    put_v(bc, 2); /* version */
220
    put_v(bc, nut->avf->nb_streams);
221
    put_v(bc, MAX_DISTANCE);
222
    put_v(bc, nut->time_base_count);
223

    
224
    for(i=0; i<nut->time_base_count; i++){
225
        put_v(bc, nut->time_base[i].num);
226
        put_v(bc, nut->time_base[i].den);
227
    }
228

    
229
    tmp_pts=0;
230
    tmp_mul=1;
231
    tmp_stream=0;
232
    for(i=0; i<256;){
233
        tmp_fields=0;
234
        tmp_size=0;
235
//        tmp_res=0;
236
        if(tmp_pts    != nut->frame_code[i].pts_delta) tmp_fields=1;
237
        if(tmp_mul    != nut->frame_code[i].size_mul ) tmp_fields=2;
238
        if(tmp_stream != nut->frame_code[i].stream_id) tmp_fields=3;
239
        if(tmp_size   != nut->frame_code[i].size_lsb ) tmp_fields=4;
240
//        if(tmp_res    != nut->frame_code[i].res            ) tmp_fields=5;
241

    
242
        tmp_pts   = nut->frame_code[i].pts_delta;
243
        tmp_flags = nut->frame_code[i].flags;
244
        tmp_stream= nut->frame_code[i].stream_id;
245
        tmp_mul   = nut->frame_code[i].size_mul;
246
        tmp_size  = nut->frame_code[i].size_lsb;
247
//        tmp_res   = nut->frame_code[i].res;
248

    
249
        for(j=0; i<256; j++,i++){
250
            if(i == 'N'){
251
                j--;
252
                continue;
253
            }
254
            if(nut->frame_code[i].pts_delta != tmp_pts   ) break;
255
            if(nut->frame_code[i].flags     != tmp_flags ) break;
256
            if(nut->frame_code[i].stream_id != tmp_stream) break;
257
            if(nut->frame_code[i].size_mul  != tmp_mul   ) break;
258
            if(nut->frame_code[i].size_lsb  != tmp_size+j) break;
259
//            if(nut->frame_code[i].res       != tmp_res   ) break;
260
        }
261
        if(j != tmp_mul - tmp_size) tmp_fields=6;
262

    
263
        put_v(bc, tmp_flags);
264
        put_v(bc, tmp_fields);
265
        if(tmp_fields>0) put_s(bc, tmp_pts);
266
        if(tmp_fields>1) put_v(bc, tmp_mul);
267
        if(tmp_fields>2) put_v(bc, tmp_stream);
268
        if(tmp_fields>3) put_v(bc, tmp_size);
269
        if(tmp_fields>4) put_v(bc, 0 /*tmp_res*/);
270
        if(tmp_fields>5) put_v(bc, j);
271
    }
272
}
273

    
274
static int write_streamheader(NUTContext *nut, ByteIOContext *bc, AVCodecContext *codec, int i){
275
    put_v(bc, i);
276
    switch(codec->codec_type){
277
    case CODEC_TYPE_VIDEO: put_v(bc, 0); break;
278
    case CODEC_TYPE_AUDIO: put_v(bc, 1); break;
279
//    case CODEC_TYPE_TEXT : put_v(bc, 2); break;
280
    default              : put_v(bc, 3); break;
281
    }
282
    put_v(bc, 4);
283
    if (codec->codec_tag){
284
        put_le32(bc, codec->codec_tag);
285
    }else
286
        return -1;
287

    
288
    put_v(bc, nut->stream[i].time_base - nut->time_base);
289
    put_v(bc, nut->stream[i].msb_pts_shift);
290
    put_v(bc, nut->stream[i].max_pts_distance);
291
    put_v(bc, codec->has_b_frames);
292
    put_byte(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
293

    
294
    put_v(bc, codec->extradata_size);
295
    put_buffer(bc, codec->extradata, codec->extradata_size);
296

    
297
    switch(codec->codec_type){
298
    case CODEC_TYPE_AUDIO:
299
        put_v(bc, codec->sample_rate);
300
        put_v(bc, 1);
301
        put_v(bc, codec->channels);
302
        break;
303
    case CODEC_TYPE_VIDEO:
304
        put_v(bc, codec->width);
305
        put_v(bc, codec->height);
306
        put_v(bc, codec->sample_aspect_ratio.num);
307
        put_v(bc, codec->sample_aspect_ratio.den);
308
        put_v(bc, 0); /* csp type -- unknown */
309
        break;
310
    default:
311
        break;
312
    }
313
    return 0;
314
}
315

    
316
static int add_info(ByteIOContext *bc, char *type, char *value){
317
    put_str(bc, type);
318
    put_s(bc, -1);
319
    put_str(bc, value);
320
    return 1;
321
}
322

    
323
static void write_globalinfo(NUTContext *nut, ByteIOContext *bc){
324
    AVFormatContext *s= nut->avf;
325
    ByteIOContext dyn_bc;
326
    uint8_t *dyn_buf=NULL;
327
    int count=0, dyn_size;
328

    
329
    url_open_dyn_buf(&dyn_bc);
330

    
331
    if(s->title    [0]) count+= add_info(&dyn_bc, "Title"    , s->title);
332
    if(s->author   [0]) count+= add_info(&dyn_bc, "Author"   , s->author);
333
    if(s->copyright[0]) count+= add_info(&dyn_bc, "Copyright", s->copyright);
334
    if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
335
                        count+= add_info(&dyn_bc, "Encoder"  , LIBAVFORMAT_IDENT);
336

    
337
    put_v(bc, 0); //stream_if_plus1
338
    put_v(bc, 0); //chapter_id
339
    put_v(bc, 0); //timestamp_start
340
    put_v(bc, 0); //length
341

    
342
    put_v(bc, count);
343

    
344
    dyn_size= url_close_dyn_buf(&dyn_bc, &dyn_buf);
345
    put_buffer(bc, dyn_buf, dyn_size);
346
    av_free(dyn_buf);
347
}
348

    
349
static void write_headers(NUTContext *nut, ByteIOContext *bc){
350
    ByteIOContext dyn_bc;
351
    int i;
352

    
353
    url_open_dyn_buf(&dyn_bc);
354
    write_mainheader(nut, &dyn_bc);
355
    put_packet(nut, bc, &dyn_bc, 1, MAIN_STARTCODE);
356

    
357
    for (i=0; i < nut->avf->nb_streams; i++){
358
        AVCodecContext *codec = nut->avf->streams[i]->codec;
359

    
360
        url_open_dyn_buf(&dyn_bc);
361
        write_streamheader(nut, &dyn_bc, codec, i);
362
        put_packet(nut, bc, &dyn_bc, 1, STREAM_STARTCODE);
363
    }
364

    
365
    url_open_dyn_buf(&dyn_bc);
366
    write_globalinfo(nut, &dyn_bc);
367
    put_packet(nut, bc, &dyn_bc, 1, INFO_STARTCODE);
368

    
369
    nut->last_syncpoint_pos= INT_MIN;
370
    nut->header_count++;
371
}
372

    
373
static int write_header(AVFormatContext *s){
374
    NUTContext *nut = s->priv_data;
375
    ByteIOContext *bc = &s->pb;
376
    int i, j;
377

    
378
    if(s->streams[0]->codec->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){
379
        return -1;
380
    }
381

    
382
    nut->avf= s;
383

    
384
    nut->stream   = av_mallocz(sizeof(StreamContext)*s->nb_streams);
385
    nut->time_base= av_mallocz(sizeof(AVRational   )*s->nb_streams);
386

    
387
    for(i=0; i<s->nb_streams; i++){
388
        AVStream *st= s->streams[i];
389
        int ssize;
390
        AVRational time_base;
391
        ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num);
392

    
393
        av_set_pts_info(st, 64, time_base.num, time_base.den);
394

    
395
        for(j=0; j<nut->time_base_count; j++){
396
            if(!memcmp(&time_base, &nut->time_base[j], sizeof(AVRational))){
397
                break;
398
            }
399
        }
400
        nut->time_base[j]= time_base;
401
        nut->stream[i].time_base= &nut->time_base[j];
402
        if(j==nut->time_base_count)
403
            nut->time_base_count++;
404

    
405
        if(av_q2d(time_base) >= 0.001)
406
            nut->stream[i].msb_pts_shift = 7;
407
        else
408
            nut->stream[i].msb_pts_shift = 14;
409
        nut->stream[i].max_pts_distance= FFMAX(1/av_q2d(time_base), 1);
410
    }
411

    
412
    build_frame_code(s);
413
    assert(nut->frame_code['N'].flags == FLAG_INVALID);
414

    
415
    put_buffer(bc, ID_STRING, strlen(ID_STRING));
416
    put_byte(bc, 0);
417

    
418
    write_headers(nut, bc);
419

    
420
    put_flush_packet(bc);
421

    
422
    //FIXME index
423

    
424
    return 0;
425
}
426

    
427
static int get_needed_flags(NUTContext *nut, StreamContext *nus, FrameCode *fc, AVPacket *pkt){
428
    int flags= 0;
429

    
430
    if(pkt->flags & PKT_FLAG_KEY                ) flags |= FLAG_KEY;
431
    if(pkt->stream_index != fc->stream_id       ) flags |= FLAG_STREAM_ID;
432
    if(pkt->size / fc->size_mul                 ) flags |= FLAG_SIZE_MSB;
433
    if(pkt->pts - nus->last_pts != fc->pts_delta) flags |= FLAG_CODED_PTS;
434
    if(pkt->size > 2*nut->max_distance          ) flags |= FLAG_CHECKSUM;
435
    if(FFABS(pkt->pts - nus->last_pts)
436
                         > nus->max_pts_distance) flags |= FLAG_CHECKSUM;
437

    
438
    return flags;
439
}
440

    
441
static int write_packet(AVFormatContext *s, AVPacket *pkt){
442
    NUTContext *nut = s->priv_data;
443
    StreamContext *nus= &nut->stream[pkt->stream_index];
444
    ByteIOContext *bc = &s->pb, dyn_bc;
445
    FrameCode *fc;
446
    int64_t coded_pts;
447
    int best_length, frame_code, flags, needed_flags, i;
448
    int key_frame = !!(pkt->flags & PKT_FLAG_KEY);
449
    int store_sp=0;
450

    
451
    if(1LL<<(20+3*nut->header_count) <= url_ftell(bc))
452
        write_headers(nut, bc);
453

    
454
    if(key_frame && !!(nus->last_flags & FLAG_KEY))
455
        store_sp= 1;
456

    
457
    if(pkt->size + 30/*FIXME check*/ + url_ftell(bc) >= nut->last_syncpoint_pos + nut->max_distance)
458
        store_sp= 1;
459

    
460
//FIXME ensure store_sp is 1 for the first thing
461

    
462
    if(store_sp){
463
        syncpoint_t *sp, dummy= {.pos= INT64_MAX};
464

    
465
        ff_nut_reset_ts(nut, *nus->time_base, pkt->dts);
466
        for(i=0; i<s->nb_streams; i++){
467
            AVStream *st= s->streams[i];
468
            int index= av_index_search_timestamp(st, pkt->dts, AVSEEK_FLAG_BACKWARD);
469
            if(index<0) dummy.pos=0;
470
            else        dummy.pos= FFMIN(dummy.pos, st->index_entries[index].pos);
471
        }
472
        sp= av_tree_find(nut->syncpoints, &dummy, ff_nut_sp_pos_cmp, NULL);
473

    
474
        nut->last_syncpoint_pos= url_ftell(bc);
475
        url_open_dyn_buf(&dyn_bc);
476
        put_t(nut, nus, &dyn_bc, pkt->dts);
477
        put_v(&dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0);
478
        put_packet(nut, bc, &dyn_bc, 1, SYNCPOINT_STARTCODE);
479

    
480
        ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0/*unused*/, pkt->dts);
481
    }
482
    assert(nus->last_pts != AV_NOPTS_VALUE);
483

    
484
    coded_pts = pkt->pts & ((1<<nus->msb_pts_shift)-1);
485
    if(ff_lsb2full(nus, coded_pts) != pkt->pts)
486
        coded_pts= pkt->pts + (1<<nus->msb_pts_shift);
487

    
488
    best_length=INT_MAX;
489
    frame_code= -1;
490
    for(i=0; i<256; i++){
491
        int length= 0;
492
        FrameCode *fc= &nut->frame_code[i];
493
        int flags= fc->flags;
494

    
495
        if(flags & FLAG_INVALID)
496
            continue;
497
        needed_flags= get_needed_flags(nut, nus, fc, pkt);
498

    
499
        if(flags & FLAG_CODED){
500
            length++;
501
            flags &= ~needed_flags;
502
            flags |=  needed_flags;
503
        }
504

    
505
        if((flags & needed_flags) != needed_flags)
506
            continue;
507

    
508
        if((flags ^ needed_flags) & FLAG_KEY)
509
            continue;
510

    
511
        if(flags & FLAG_STREAM_ID)
512
            length+= get_length(pkt->stream_index);
513

    
514
        if(pkt->size % fc->size_mul != fc->size_lsb)
515
            continue;
516
        if(flags & FLAG_SIZE_MSB)
517
            length += get_length(pkt->size / fc->size_mul);
518

    
519
        if(flags & FLAG_CHECKSUM)
520
            length+=4;
521

    
522
        if(flags & FLAG_CODED_PTS)
523
            length += get_length(coded_pts);
524

    
525
        length*=4;
526
        length+= !(flags & FLAG_CODED_PTS);
527
        length+= !(flags & FLAG_CHECKSUM);
528

    
529
        if(length < best_length){
530
            best_length= length;
531
            frame_code=i;
532
        }
533
    }
534
    assert(frame_code != -1);
535
    fc= &nut->frame_code[frame_code];
536
    flags= fc->flags;
537
    needed_flags= get_needed_flags(nut, nus, fc, pkt);
538

    
539
    init_checksum(bc, av_crc04C11DB7_update, 0);
540
    put_byte(bc, frame_code);
541
    if(flags & FLAG_CODED){
542
        put_v(bc, (flags^needed_flags) & ~(FLAG_CODED));
543
        flags = needed_flags;
544
    }
545
    if(flags & FLAG_STREAM_ID)  put_v(bc, pkt->stream_index);
546
    if(flags & FLAG_CODED_PTS)  put_v(bc, coded_pts);
547
    if(flags & FLAG_SIZE_MSB)   put_v(bc, pkt->size / fc->size_mul);
548

    
549
    if(flags & FLAG_CHECKSUM)   put_le32(bc, get_checksum(bc));
550
    else                        get_checksum(bc);
551

    
552
    put_buffer(bc, pkt->data, pkt->size);
553
    nus->last_flags= flags;
554

    
555
    //FIXME just store one per syncpoint
556
    if(flags & FLAG_KEY)
557
        av_add_index_entry(
558
            s->streams[pkt->stream_index],
559
            nut->last_syncpoint_pos,
560
            pkt->pts,
561
            0,
562
            0,
563
            AVINDEX_KEYFRAME);
564

    
565
    return 0;
566
}
567

    
568
static int write_trailer(AVFormatContext *s){
569
    NUTContext *nut= s->priv_data;
570
    ByteIOContext *bc= &s->pb;
571

    
572
    while(nut->header_count<3)
573
        write_headers(nut, bc);
574
    put_flush_packet(bc);
575

    
576
    return 0;
577
}
578

    
579
AVOutputFormat nut_muxer = {
580
    "nut",
581
    "nut format",
582
    "video/x-nut",
583
    "nut",
584
    sizeof(NUTContext),
585
#ifdef CONFIG_LIBVORBIS
586
    CODEC_ID_VORBIS,
587
#elif defined(CONFIG_LIBMP3LAME)
588
    CODEC_ID_MP3,
589
#else
590
    CODEC_ID_MP2, /* AC3 needs liba52 decoder */
591
#endif
592
    CODEC_ID_MPEG4,
593
    write_header,
594
    write_packet,
595
    write_trailer,
596
    .flags = AVFMT_GLOBALHEADER,
597
    .codec_tag= (const AVCodecTag*[]){codec_bmp_tags, codec_wav_tags, 0},
598
};