offset_t frames_hdr_all, frames_hdr_strm[MAX_STREAMS];
int audio_strm_length[MAX_STREAMS];
int riff_id;
+ int packet_count[MAX_STREAMS];
AVIIndex indexes[MAX_STREAMS];
} AVIContext;
{ CODEC_ID_H263, MKTAG('H', '2', '6', '3') },
{ CODEC_ID_H263P, MKTAG('H', '2', '6', '3') },
{ CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */
+ { CODEC_ID_H261, MKTAG('H', '2', '6', '1') },
/* added based on MPlayer */
{ CODEC_ID_H263P, MKTAG('U', '2', '6', '3') },
{ CODEC_ID_MPEG4, MKTAG('B', 'L', 'Z', '0') },
{ CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
{ CODEC_ID_MPEG4, MKTAG('U', 'M', 'P', '4') },
+ { CODEC_ID_MPEG4, MKTAG('W', 'V', '1', 'F') },
{ CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3'), .invalid_asf = 1 }, /* default signature when using MSMPEG4 */
{ CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
{ CODEC_ID_MPEG1VIDEO, MKTAG('V', 'C', 'R', '2') },
{ CODEC_ID_MPEG1VIDEO, 0x10000001 },
{ CODEC_ID_MPEG2VIDEO, 0x10000002 },
+ { CODEC_ID_MPEG2VIDEO, MKTAG('D', 'V', 'R', ' ') },
{ CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') },
{ CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') },
{ CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') },
{ CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') }, /* Pegasus lossless JPEG */
{ CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') },
+ { CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') },
{ CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') },
{ CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', '2') },
{ CODEC_ID_RAWVIDEO, MKTAG('I', '4', '2', '0') },
{ CODEC_ID_TRUEMOTION1, MKTAG('D', 'U', 'C', 'K') },
{ CODEC_ID_MSZH, MKTAG('M', 'S', 'Z', 'H') },
{ CODEC_ID_ZLIB, MKTAG('Z', 'L', 'I', 'B') },
+ { CODEC_ID_SNOW, MKTAG('S', 'N', 'O', 'W') },
{ CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') },
{ CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') },
{ CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') },
+ { CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') },
+ { CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') },
+ { CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') },
+ { CODEC_ID_QPEG, MKTAG('Q', 'P', 'E', 'G') },
+ { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '0') },
+ { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') },
+ { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') },
+ { CODEC_ID_RAWVIDEO, 0 },
{ 0, 0 },
};
return 0;
}
-static unsigned int codec_get_asf_tag(const CodecTag *tags, int id)
+static unsigned int codec_get_asf_tag(const CodecTag *tags, unsigned int id)
{
while (tags->id != 0) {
if (!tags->invalid_asf && tags->id == id)
put_byte(pb, 0);
}
-static void parse_specific_params(AVCodecContext *stream, int *au_byterate, int *au_ssize, int *au_scale)
+static void parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale)
{
- switch(stream->codec_id) {
- case CODEC_ID_PCM_S16LE:
- *au_scale = *au_ssize = 2*stream->channels;
- *au_byterate = *au_ssize * stream->sample_rate;
- break;
- case CODEC_ID_PCM_U8:
- case CODEC_ID_PCM_ALAW:
- case CODEC_ID_PCM_MULAW:
- *au_scale = *au_ssize = stream->channels;
- *au_byterate = *au_ssize * stream->sample_rate;
- break;
- case CODEC_ID_MP2:
- *au_ssize = 1;
- *au_scale = 1;
- *au_byterate = stream->bit_rate / 8;
- case CODEC_ID_MP3:
- *au_ssize = 1;
- *au_scale = 1;
- *au_byterate = stream->bit_rate / 8;
- default:
- *au_ssize = 1;
- *au_scale = 1;
- *au_byterate = stream->bit_rate / 8;
- break;
+ int gcd;
+
+ *au_ssize= stream->block_align;
+ if(stream->frame_size && stream->sample_rate){
+ *au_scale=stream->frame_size;
+ *au_rate= stream->sample_rate;
+ }else if(stream->codec_type == CODEC_TYPE_VIDEO){
+ *au_scale= stream->frame_rate_base;
+ *au_rate = stream->frame_rate;
+ }else{
+ *au_scale= stream->block_align ? stream->block_align*8 : 8;
+ *au_rate = stream->bit_rate;
}
+ gcd= ff_gcd(*au_scale, *au_rate);
+ *au_scale /= gcd;
+ *au_rate /= gcd;
}
static offset_t avi_start_new_riff(AVIContext *avi, ByteIOContext *pb,
put_le32(pb, stream->frame_rate_base); /* scale */
put_le32(pb, stream->frame_rate); /* rate */
+ av_set_pts_info(s->streams[i], 64, stream->frame_rate_base, stream->frame_rate);
put_le32(pb, 0); /* start */
avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this offset to fill later */
parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
put_le32(pb, au_scale); /* scale */
put_le32(pb, au_byterate); /* rate */
+ av_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
put_le32(pb, 0); /* start */
avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this offset to fill later */
put_le32(pb, 0); /* length, XXX: filled later */
put_le32(pb, 0);
break;
default:
- av_abort();
+ return -1;
}
end_tag(pb, strh);
}
break;
default:
- av_abort();
+ return -1;
}
end_tag(pb, strf);
if (avi->frames_hdr_strm[n] != 0) {
stream = &s->streams[n]->codec;
url_fseek(pb, avi->frames_hdr_strm[n], SEEK_SET);
- if (stream->codec_type == CODEC_TYPE_VIDEO) {
- put_le32(pb, stream->frame_number);
- if (nb_frames < stream->frame_number)
- nb_frames = stream->frame_number;
+ parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
+ if (au_ssize == 0) {
+ put_le32(pb, stream->frame_number);
+ nb_frames += stream->frame_number;
} else {
- if (stream->codec_id == CODEC_ID_MP2 || stream->codec_id == CODEC_ID_MP3) {
- put_le32(pb, stream->frame_number);
- nb_frames += stream->frame_number;
- } else {
- parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
- put_le32(pb, avi->audio_strm_length[n] / au_ssize);
- }
+ put_le32(pb, avi->audio_strm_length[n] / au_ssize);
}
}
}
ByteIOContext *pb = &s->pb;
unsigned char tag[5];
unsigned int flags=0;
- AVCodecContext *enc;
const int stream_index= pkt->stream_index;
+ AVCodecContext *enc= &s->streams[stream_index]->codec;
int size= pkt->size;
+// av_log(s, AV_LOG_DEBUG, "%lld %d %d\n", pkt->dts, avi->packet_count[stream_index], stream_index);
+ while(enc->codec_type == CODEC_TYPE_VIDEO && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avi->packet_count[stream_index]){
+ AVPacket empty_packet;
+
+ av_init_packet(&empty_packet);
+ empty_packet.size= 0;
+ empty_packet.data= NULL;
+ empty_packet.stream_index= stream_index;
+ avi_write_packet(s, &empty_packet);
+// av_log(s, AV_LOG_DEBUG, "dup %lld %d\n", pkt->dts, avi->packet_count[stream_index]);
+ }
+ avi->packet_count[stream_index]++;
+
if (url_ftell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE) {
avi_write_ix(s);
end_tag(pb, avi->movi_list);
avi->movi_list = avi_start_new_riff(avi, pb, "AVIX", "movi");
}
- enc = &s->streams[stream_index]->codec;
avi_stream2fourcc(&tag[0], stream_index, enc->codec_type);
if(pkt->flags&PKT_FLAG_KEY)
flags = 0x10;