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