00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "avformat.h"
00022 #include "internal.h"
00023 #include "avi.h"
00024 #include "avio_internal.h"
00025 #include "riff.h"
00026 #include "libavutil/intreadwrite.h"
00027 #include "libavutil/dict.h"
00028
00029
00030
00031
00032
00033
00034 typedef struct AVIIentry {
00035 unsigned int flags, pos, len;
00036 } AVIIentry;
00037
00038 #define AVI_INDEX_CLUSTER_SIZE 16384
00039
00040 typedef struct AVIIndex {
00041 int64_t indx_start;
00042 int entry;
00043 int ents_allocated;
00044 AVIIentry** cluster;
00045 } AVIIndex;
00046
00047 typedef struct {
00048 int64_t riff_start, movi_list, odml_list;
00049 int64_t frames_hdr_all;
00050 int riff_id;
00051 } AVIContext;
00052
00053 typedef struct {
00054 int64_t frames_hdr_strm;
00055 int audio_strm_length;
00056 int packet_count;
00057 int entry;
00058
00059 AVIIndex indexes;
00060 } AVIStream ;
00061
00062 static inline AVIIentry* avi_get_ientry(AVIIndex* idx, int ent_id)
00063 {
00064 int cl = ent_id / AVI_INDEX_CLUSTER_SIZE;
00065 int id = ent_id % AVI_INDEX_CLUSTER_SIZE;
00066 return &idx->cluster[cl][id];
00067 }
00068
00069 static int64_t avi_start_new_riff(AVFormatContext *s, AVIOContext *pb,
00070 const char* riff_tag, const char* list_tag)
00071 {
00072 AVIContext *avi= s->priv_data;
00073 int64_t loff;
00074 int i;
00075
00076 avi->riff_id++;
00077 for (i=0; i<s->nb_streams; i++){
00078 AVIStream *avist= s->streams[i]->priv_data;
00079 avist->indexes.entry = 0;
00080 }
00081
00082 avi->riff_start = ff_start_tag(pb, "RIFF");
00083 ffio_wfourcc(pb, riff_tag);
00084 loff = ff_start_tag(pb, "LIST");
00085 ffio_wfourcc(pb, list_tag);
00086 return loff;
00087 }
00088
00089 static char* avi_stream2fourcc(char* tag, int index, enum AVMediaType type)
00090 {
00091 tag[0] = '0' + index/10;
00092 tag[1] = '0' + index%10;
00093 if (type == AVMEDIA_TYPE_VIDEO) {
00094 tag[2] = 'd';
00095 tag[3] = 'c';
00096 } else if (type == AVMEDIA_TYPE_SUBTITLE) {
00097
00098 tag[2] = 's';
00099 tag[3] = 'b';
00100 } else {
00101 tag[2] = 'w';
00102 tag[3] = 'b';
00103 }
00104 tag[4] = '\0';
00105 return tag;
00106 }
00107
00108 static void avi_write_info_tag(AVIOContext *pb, const char *tag, const char *str)
00109 {
00110 int len = strlen(str);
00111 if (len > 0) {
00112 len++;
00113 ffio_wfourcc(pb, tag);
00114 avio_wl32(pb, len);
00115 avio_put_str(pb, str);
00116 if (len & 1)
00117 avio_w8(pb, 0);
00118 }
00119 }
00120
00121 static int avi_write_counters(AVFormatContext* s, int riff_id)
00122 {
00123 AVIOContext *pb = s->pb;
00124 AVIContext *avi = s->priv_data;
00125 int n, au_byterate, au_ssize, au_scale, nb_frames = 0;
00126 int64_t file_size;
00127 AVCodecContext* stream;
00128
00129 file_size = avio_tell(pb);
00130 for(n = 0; n < s->nb_streams; n++) {
00131 AVIStream *avist= s->streams[n]->priv_data;
00132
00133 assert(avist->frames_hdr_strm);
00134 stream = s->streams[n]->codec;
00135 avio_seek(pb, avist->frames_hdr_strm, SEEK_SET);
00136 ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
00137 if(au_ssize == 0) {
00138 avio_wl32(pb, avist->packet_count);
00139 } else {
00140 avio_wl32(pb, avist->audio_strm_length / au_ssize);
00141 }
00142 if(stream->codec_type == AVMEDIA_TYPE_VIDEO)
00143 nb_frames = FFMAX(nb_frames, avist->packet_count);
00144 }
00145 if(riff_id == 1) {
00146 assert(avi->frames_hdr_all);
00147 avio_seek(pb, avi->frames_hdr_all, SEEK_SET);
00148 avio_wl32(pb, nb_frames);
00149 }
00150 avio_seek(pb, file_size, SEEK_SET);
00151
00152 return 0;
00153 }
00154
00155 static int avi_write_header(AVFormatContext *s)
00156 {
00157 AVIContext *avi = s->priv_data;
00158 AVIOContext *pb = s->pb;
00159 int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
00160 AVCodecContext *stream, *video_enc;
00161 int64_t list1, list2, strh, strf;
00162 AVDictionaryEntry *t = NULL;
00163
00164 if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
00165 av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",
00166 AVI_MAX_STREAM_COUNT);
00167 return -1;
00168 }
00169
00170 for(n=0;n<s->nb_streams;n++) {
00171 s->streams[n]->priv_data= av_mallocz(sizeof(AVIStream));
00172 if(!s->streams[n]->priv_data)
00173 return AVERROR(ENOMEM);
00174 }
00175
00176
00177 avi->riff_id = 0;
00178 list1 = avi_start_new_riff(s, pb, "AVI ", "hdrl");
00179
00180
00181 ffio_wfourcc(pb, "avih");
00182 avio_wl32(pb, 14 * 4);
00183 bitrate = 0;
00184
00185 video_enc = NULL;
00186 for(n=0;n<s->nb_streams;n++) {
00187 stream = s->streams[n]->codec;
00188 bitrate += stream->bit_rate;
00189 if (stream->codec_type == AVMEDIA_TYPE_VIDEO)
00190 video_enc = stream;
00191 }
00192
00193 nb_frames = 0;
00194
00195 if(video_enc){
00196 avio_wl32(pb, (uint32_t)(INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den));
00197 } else {
00198 avio_wl32(pb, 0);
00199 }
00200 avio_wl32(pb, bitrate / 8);
00201 avio_wl32(pb, 0);
00202 if (!pb->seekable)
00203 avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED);
00204 else
00205 avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED);
00206 avi->frames_hdr_all = avio_tell(pb);
00207 avio_wl32(pb, nb_frames);
00208 avio_wl32(pb, 0);
00209 avio_wl32(pb, s->nb_streams);
00210 avio_wl32(pb, 1024 * 1024);
00211 if(video_enc){
00212 avio_wl32(pb, video_enc->width);
00213 avio_wl32(pb, video_enc->height);
00214 } else {
00215 avio_wl32(pb, 0);
00216 avio_wl32(pb, 0);
00217 }
00218 avio_wl32(pb, 0);
00219 avio_wl32(pb, 0);
00220 avio_wl32(pb, 0);
00221 avio_wl32(pb, 0);
00222
00223
00224 for(i=0;i<n;i++) {
00225 AVIStream *avist= s->streams[i]->priv_data;
00226 list2 = ff_start_tag(pb, "LIST");
00227 ffio_wfourcc(pb, "strl");
00228
00229 stream = s->streams[i]->codec;
00230
00231
00232 strh = ff_start_tag(pb, "strh");
00233 switch(stream->codec_type) {
00234 case AVMEDIA_TYPE_SUBTITLE:
00235
00236
00237 if (stream->codec_id != CODEC_ID_XSUB) {
00238 av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
00239 return AVERROR_PATCHWELCOME;
00240 }
00241 case AVMEDIA_TYPE_VIDEO: ffio_wfourcc(pb, "vids"); break;
00242 case AVMEDIA_TYPE_AUDIO: ffio_wfourcc(pb, "auds"); break;
00243
00244 case AVMEDIA_TYPE_DATA : ffio_wfourcc(pb, "dats"); break;
00245 }
00246 if(stream->codec_type == AVMEDIA_TYPE_VIDEO ||
00247 stream->codec_id == CODEC_ID_XSUB)
00248 avio_wl32(pb, stream->codec_tag);
00249 else
00250 avio_wl32(pb, 1);
00251 avio_wl32(pb, 0);
00252 avio_wl16(pb, 0);
00253 avio_wl16(pb, 0);
00254 avio_wl32(pb, 0);
00255
00256 ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
00257
00258 avpriv_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
00259 if(stream->codec_id == CODEC_ID_XSUB)
00260 au_scale = au_byterate = 0;
00261
00262 avio_wl32(pb, au_scale);
00263 avio_wl32(pb, au_byterate);
00264
00265 avio_wl32(pb, 0);
00266 avist->frames_hdr_strm = avio_tell(pb);
00267 if (!pb->seekable)
00268 avio_wl32(pb, AVI_MAX_RIFF_SIZE);
00269 else
00270 avio_wl32(pb, 0);
00271
00272
00273 if(stream->codec_type == AVMEDIA_TYPE_VIDEO)
00274 avio_wl32(pb, 1024 * 1024);
00275 else if(stream->codec_type == AVMEDIA_TYPE_AUDIO)
00276 avio_wl32(pb, 12 * 1024);
00277 else
00278 avio_wl32(pb, 0);
00279 avio_wl32(pb, -1);
00280 avio_wl32(pb, au_ssize);
00281 avio_wl32(pb, 0);
00282 avio_wl16(pb, stream->width);
00283 avio_wl16(pb, stream->height);
00284 ff_end_tag(pb, strh);
00285
00286 if(stream->codec_type != AVMEDIA_TYPE_DATA){
00287 strf = ff_start_tag(pb, "strf");
00288 switch(stream->codec_type) {
00289 case AVMEDIA_TYPE_SUBTITLE:
00290
00291
00292 if (stream->codec_id != CODEC_ID_XSUB) break;
00293 case AVMEDIA_TYPE_VIDEO:
00294 ff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0);
00295 break;
00296 case AVMEDIA_TYPE_AUDIO:
00297 if (ff_put_wav_header(pb, stream) < 0) {
00298 return -1;
00299 }
00300 break;
00301 default:
00302 return -1;
00303 }
00304 ff_end_tag(pb, strf);
00305 if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) {
00306 avi_write_info_tag(s->pb, "strn", t->value);
00307 t = NULL;
00308 }
00309 }
00310
00311 if (pb->seekable) {
00312 unsigned char tag[5];
00313 int j;
00314
00315
00316
00317
00318
00319
00320 avist->indexes.entry = avist->indexes.ents_allocated = 0;
00321 avist->indexes.indx_start = ff_start_tag(pb, "JUNK");
00322 avio_wl16(pb, 4);
00323 avio_w8(pb, 0);
00324 avio_w8(pb, 0);
00325 avio_wl32(pb, 0);
00326 ffio_wfourcc(pb, avi_stream2fourcc(tag, i, stream->codec_type));
00327
00328 avio_wl64(pb, 0);
00329
00330 for (j=0; j < AVI_MASTER_INDEX_SIZE * 2; j++)
00331 avio_wl64(pb, 0);
00332 ff_end_tag(pb, avist->indexes.indx_start);
00333 }
00334
00335 if( stream->codec_type == AVMEDIA_TYPE_VIDEO
00336 && s->streams[i]->sample_aspect_ratio.num>0
00337 && s->streams[i]->sample_aspect_ratio.den>0){
00338 int vprp= ff_start_tag(pb, "vprp");
00339 AVRational dar = av_mul_q(s->streams[i]->sample_aspect_ratio,
00340 (AVRational){stream->width, stream->height});
00341 int num, den;
00342 av_reduce(&num, &den, dar.num, dar.den, 0xFFFF);
00343
00344 avio_wl32(pb, 0);
00345 avio_wl32(pb, 0);
00346 avio_wl32(pb, lrintf(1.0/av_q2d(stream->time_base)));
00347 avio_wl32(pb, stream->width );
00348 avio_wl32(pb, stream->height);
00349 avio_wl16(pb, den);
00350 avio_wl16(pb, num);
00351 avio_wl32(pb, stream->width );
00352 avio_wl32(pb, stream->height);
00353 avio_wl32(pb, 1);
00354
00355 avio_wl32(pb, stream->height);
00356 avio_wl32(pb, stream->width );
00357 avio_wl32(pb, stream->height);
00358 avio_wl32(pb, stream->width );
00359 avio_wl32(pb, 0);
00360 avio_wl32(pb, 0);
00361
00362 avio_wl32(pb, 0);
00363 avio_wl32(pb, 0);
00364 ff_end_tag(pb, vprp);
00365 }
00366
00367 ff_end_tag(pb, list2);
00368 }
00369
00370 if (pb->seekable) {
00371
00372 avi->odml_list = ff_start_tag(pb, "JUNK");
00373 ffio_wfourcc(pb, "odml");
00374 ffio_wfourcc(pb, "dmlh");
00375 avio_wl32(pb, 248);
00376 for (i = 0; i < 248; i+= 4)
00377 avio_wl32(pb, 0);
00378 ff_end_tag(pb, avi->odml_list);
00379 }
00380
00381 ff_end_tag(pb, list1);
00382
00383 list2 = ff_start_tag(pb, "LIST");
00384 ffio_wfourcc(pb, "INFO");
00385 ff_metadata_conv(&s->metadata, ff_riff_info_conv, NULL);
00386 for (i = 0; *ff_riff_tags[i]; i++) {
00387 if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE)))
00388 avi_write_info_tag(s->pb, t->key, t->value);
00389 }
00390 ff_end_tag(pb, list2);
00391
00392
00393 list2 = ff_start_tag(pb, "JUNK");
00394 for (i = 0; i < 1016; i += 4)
00395 avio_wl32(pb, 0);
00396 ff_end_tag(pb, list2);
00397
00398 avi->movi_list = ff_start_tag(pb, "LIST");
00399 ffio_wfourcc(pb, "movi");
00400
00401 avio_flush(pb);
00402
00403 return 0;
00404 }
00405
00406 static int avi_write_ix(AVFormatContext *s)
00407 {
00408 AVIOContext *pb = s->pb;
00409 AVIContext *avi = s->priv_data;
00410 char tag[5];
00411 char ix_tag[] = "ix00";
00412 int i, j;
00413
00414 assert(pb->seekable);
00415
00416 if (avi->riff_id > AVI_MASTER_INDEX_SIZE)
00417 return -1;
00418
00419 for (i=0;i<s->nb_streams;i++) {
00420 AVIStream *avist= s->streams[i]->priv_data;
00421 int64_t ix, pos;
00422
00423 avi_stream2fourcc(tag, i, s->streams[i]->codec->codec_type);
00424 ix_tag[3] = '0' + i;
00425
00426
00427 ix = avio_tell(pb);
00428 ffio_wfourcc(pb, ix_tag);
00429 avio_wl32(pb, avist->indexes.entry * 8 + 24);
00430
00431 avio_wl16(pb, 2);
00432 avio_w8(pb, 0);
00433 avio_w8(pb, 1);
00434 avio_wl32(pb, avist->indexes.entry);
00435
00436 ffio_wfourcc(pb, tag);
00437 avio_wl64(pb, avi->movi_list);
00438 avio_wl32(pb, 0);
00439
00440 for (j=0; j<avist->indexes.entry; j++) {
00441 AVIIentry* ie = avi_get_ientry(&avist->indexes, j);
00442 avio_wl32(pb, ie->pos + 8);
00443 avio_wl32(pb, ((uint32_t)ie->len & ~0x80000000) |
00444 (ie->flags & 0x10 ? 0 : 0x80000000));
00445 }
00446 avio_flush(pb);
00447 pos = avio_tell(pb);
00448
00449
00450 avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
00451 ffio_wfourcc(pb, "indx");
00452 avio_skip(pb, 8);
00453 avio_wl32(pb, avi->riff_id);
00454 avio_skip(pb, 16*avi->riff_id);
00455 avio_wl64(pb, ix);
00456 avio_wl32(pb, pos - ix);
00457 avio_wl32(pb, avist->indexes.entry);
00458
00459 avio_seek(pb, pos, SEEK_SET);
00460 }
00461 return 0;
00462 }
00463
00464 static int avi_write_idx1(AVFormatContext *s)
00465 {
00466 AVIOContext *pb = s->pb;
00467 AVIContext *avi = s->priv_data;
00468 int64_t idx_chunk;
00469 int i;
00470 char tag[5];
00471
00472 if (pb->seekable) {
00473 AVIStream *avist;
00474 AVIIentry* ie = 0, *tie;
00475 int empty, stream_id = -1;
00476
00477 idx_chunk = ff_start_tag(pb, "idx1");
00478 for(i=0; i<s->nb_streams; i++){
00479 avist= s->streams[i]->priv_data;
00480 avist->entry=0;
00481 }
00482
00483 do {
00484 empty = 1;
00485 for (i=0; i<s->nb_streams; i++) {
00486 avist= s->streams[i]->priv_data;
00487 if (avist->indexes.entry <= avist->entry)
00488 continue;
00489
00490 tie = avi_get_ientry(&avist->indexes, avist->entry);
00491 if (empty || tie->pos < ie->pos) {
00492 ie = tie;
00493 stream_id = i;
00494 }
00495 empty = 0;
00496 }
00497 if (!empty) {
00498 avist= s->streams[stream_id]->priv_data;
00499 avi_stream2fourcc(tag, stream_id,
00500 s->streams[stream_id]->codec->codec_type);
00501 ffio_wfourcc(pb, tag);
00502 avio_wl32(pb, ie->flags);
00503 avio_wl32(pb, ie->pos);
00504 avio_wl32(pb, ie->len);
00505 avist->entry++;
00506 }
00507 } while (!empty);
00508 ff_end_tag(pb, idx_chunk);
00509
00510 avi_write_counters(s, avi->riff_id);
00511 }
00512 return 0;
00513 }
00514
00515 static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
00516 {
00517 AVIContext *avi = s->priv_data;
00518 AVIOContext *pb = s->pb;
00519 unsigned char tag[5];
00520 unsigned int flags=0;
00521 const int stream_index= pkt->stream_index;
00522 AVIStream *avist= s->streams[stream_index]->priv_data;
00523 AVCodecContext *enc= s->streams[stream_index]->codec;
00524 int size= pkt->size;
00525
00526
00527 while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avist->packet_count && enc->codec_id != CODEC_ID_XSUB){
00528 AVPacket empty_packet;
00529
00530 if(pkt->dts - avist->packet_count > 60000){
00531 av_log(s, AV_LOG_ERROR, "Too large number of skiped frames %"PRId64"\n", pkt->dts - avist->packet_count);
00532 return AVERROR(EINVAL);
00533 }
00534
00535 av_init_packet(&empty_packet);
00536 empty_packet.size= 0;
00537 empty_packet.data= NULL;
00538 empty_packet.stream_index= stream_index;
00539 avi_write_packet(s, &empty_packet);
00540
00541 }
00542 avist->packet_count++;
00543
00544
00545 if (pb->seekable &&
00546 (avio_tell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE)) {
00547
00548 avi_write_ix(s);
00549 ff_end_tag(pb, avi->movi_list);
00550
00551 if (avi->riff_id == 1)
00552 avi_write_idx1(s);
00553
00554 ff_end_tag(pb, avi->riff_start);
00555 avi->movi_list = avi_start_new_riff(s, pb, "AVIX", "movi");
00556 }
00557
00558 avi_stream2fourcc(tag, stream_index, enc->codec_type);
00559 if(pkt->flags&AV_PKT_FLAG_KEY)
00560 flags = 0x10;
00561 if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
00562 avist->audio_strm_length += size;
00563 }
00564
00565 if (s->pb->seekable) {
00566 AVIIndex* idx = &avist->indexes;
00567 int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE;
00568 int id = idx->entry % AVI_INDEX_CLUSTER_SIZE;
00569 if (idx->ents_allocated <= idx->entry) {
00570 idx->cluster = av_realloc_f(idx->cluster, sizeof(void*), cl+1);
00571 if (!idx->cluster)
00572 return -1;
00573 idx->cluster[cl] = av_malloc(AVI_INDEX_CLUSTER_SIZE*sizeof(AVIIentry));
00574 if (!idx->cluster[cl])
00575 return -1;
00576 idx->ents_allocated += AVI_INDEX_CLUSTER_SIZE;
00577 }
00578
00579 idx->cluster[cl][id].flags = flags;
00580 idx->cluster[cl][id].pos = avio_tell(pb) - avi->movi_list;
00581 idx->cluster[cl][id].len = size;
00582 idx->entry++;
00583 }
00584
00585 avio_write(pb, tag, 4);
00586 avio_wl32(pb, size);
00587 avio_write(pb, pkt->data, size);
00588 if (size & 1)
00589 avio_w8(pb, 0);
00590
00591 avio_flush(pb);
00592 return 0;
00593 }
00594
00595 static int avi_write_trailer(AVFormatContext *s)
00596 {
00597 AVIContext *avi = s->priv_data;
00598 AVIOContext *pb = s->pb;
00599 int res = 0;
00600 int i, j, n, nb_frames;
00601 int64_t file_size;
00602
00603 if (pb->seekable){
00604 if (avi->riff_id == 1) {
00605 ff_end_tag(pb, avi->movi_list);
00606 res = avi_write_idx1(s);
00607 ff_end_tag(pb, avi->riff_start);
00608 } else {
00609 avi_write_ix(s);
00610 ff_end_tag(pb, avi->movi_list);
00611 ff_end_tag(pb, avi->riff_start);
00612
00613 file_size = avio_tell(pb);
00614 avio_seek(pb, avi->odml_list - 8, SEEK_SET);
00615 ffio_wfourcc(pb, "LIST");
00616 avio_skip(pb, 16);
00617
00618 for (n=nb_frames=0;n<s->nb_streams;n++) {
00619 AVCodecContext *stream = s->streams[n]->codec;
00620 AVIStream *avist= s->streams[n]->priv_data;
00621
00622 if (stream->codec_type == AVMEDIA_TYPE_VIDEO) {
00623 if (nb_frames < avist->packet_count)
00624 nb_frames = avist->packet_count;
00625 } else {
00626 if (stream->codec_id == CODEC_ID_MP2 || stream->codec_id == CODEC_ID_MP3) {
00627 nb_frames += avist->packet_count;
00628 }
00629 }
00630 }
00631 avio_wl32(pb, nb_frames);
00632 avio_seek(pb, file_size, SEEK_SET);
00633
00634 avi_write_counters(s, avi->riff_id);
00635 }
00636 }
00637 avio_flush(pb);
00638
00639 for (i=0; i<s->nb_streams; i++) {
00640 AVIStream *avist= s->streams[i]->priv_data;
00641 for (j=0; j<avist->indexes.ents_allocated/AVI_INDEX_CLUSTER_SIZE; j++)
00642 av_free(avist->indexes.cluster[j]);
00643 av_freep(&avist->indexes.cluster);
00644 avist->indexes.ents_allocated = avist->indexes.entry = 0;
00645 }
00646
00647 return res;
00648 }
00649
00650 AVOutputFormat ff_avi_muxer = {
00651 .name = "avi",
00652 .long_name = NULL_IF_CONFIG_SMALL("AVI format"),
00653 .mime_type = "video/x-msvideo",
00654 .extensions = "avi",
00655 .priv_data_size = sizeof(AVIContext),
00656 #if CONFIG_LIBMP3LAME_ENCODER
00657 .audio_codec = CODEC_ID_MP3,
00658 #else
00659 .audio_codec = CODEC_ID_AC3,
00660 #endif
00661 .video_codec = CODEC_ID_MPEG4,
00662 .write_header = avi_write_header,
00663 .write_packet = avi_write_packet,
00664 .write_trailer = avi_write_trailer,
00665 .codec_tag = (const AVCodecTag* const []){
00666 ff_codec_bmp_tags, ff_codec_wav_tags, 0
00667 },
00668 .flags = AVFMT_VARIABLE_FPS,
00669 };