Merge commit '3407172b36a93cec410c6a287dbeec0f41257512'
* commit '3407172b36a93cec410c6a287dbeec0f41257512': avienc: K&R formatting cosmetics Conflicts: libavformat/avienc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
309171bea9
@ -128,11 +128,10 @@ static int avi_write_counters(AVFormatContext* s, int riff_id)
|
||||
stream = s->streams[n]->codec;
|
||||
avio_seek(pb, avist->frames_hdr_strm, SEEK_SET);
|
||||
ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
|
||||
if(au_ssize == 0) {
|
||||
if (au_ssize == 0)
|
||||
avio_wl32(pb, avist->packet_count);
|
||||
} else {
|
||||
else
|
||||
avio_wl32(pb, avist->audio_strm_length / au_ssize);
|
||||
}
|
||||
if (stream->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
nb_frames = FFMAX(nb_frames, avist->packet_count);
|
||||
}
|
||||
@ -187,11 +186,11 @@ static int avi_write_header(AVFormatContext *s)
|
||||
|
||||
nb_frames = 0;
|
||||
|
||||
if(video_enc){
|
||||
avio_wl32(pb, (uint32_t)(INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den));
|
||||
} else {
|
||||
if (video_enc)
|
||||
avio_wl32(pb, (uint32_t) (INT64_C(1000000) * video_enc->time_base.num /
|
||||
video_enc->time_base.den));
|
||||
else
|
||||
avio_wl32(pb, 0);
|
||||
}
|
||||
avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */
|
||||
avio_wl32(pb, 0); /* padding */
|
||||
if (!pb->seekable)
|
||||
@ -230,13 +229,22 @@ static int avi_write_header(AVFormatContext *s)
|
||||
// XSUB subtitles behave like video tracks, other subtitles
|
||||
// are not (yet) supported.
|
||||
if (stream->codec_id != AV_CODEC_ID_XSUB) {
|
||||
av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
case AVMEDIA_TYPE_VIDEO: ffio_wfourcc(pb, "vids"); break;
|
||||
case AVMEDIA_TYPE_AUDIO: ffio_wfourcc(pb, "auds"); break;
|
||||
// case AVMEDIA_TYPE_TEXT : ffio_wfourcc(pb, "txts"); break;
|
||||
case AVMEDIA_TYPE_DATA : ffio_wfourcc(pb, "dats"); break;
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
ffio_wfourcc(pb, "vids");
|
||||
break;
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
ffio_wfourcc(pb, "auds");
|
||||
break;
|
||||
// case AVMEDIA_TYPE_TEXT:
|
||||
// ffio_wfourcc(pb, "txts");
|
||||
// break;
|
||||
case AVMEDIA_TYPE_DATA:
|
||||
ffio_wfourcc(pb, "dats");
|
||||
break;
|
||||
}
|
||||
if (stream->codec_type == AVMEDIA_TYPE_VIDEO ||
|
||||
stream->codec_id == AV_CODEC_ID_XSUB)
|
||||
@ -264,9 +272,11 @@ static int avi_write_header(AVFormatContext *s)
|
||||
avio_wl32(pb, au_byterate); /* rate */
|
||||
|
||||
avio_wl32(pb, 0); /* start */
|
||||
avist->frames_hdr_strm = avio_tell(pb); /* remember this offset to fill later */
|
||||
/* remember this offset to fill later */
|
||||
avist->frames_hdr_strm = avio_tell(pb);
|
||||
if (!pb->seekable)
|
||||
avio_wl32(pb, AVI_MAX_RIFF_SIZE); /* FIXME: this may be broken, but who cares */
|
||||
/* FIXME: this may be broken, but who cares */
|
||||
avio_wl32(pb, AVI_MAX_RIFF_SIZE);
|
||||
else
|
||||
avio_wl32(pb, 0); /* length, XXX: filled later */
|
||||
|
||||
@ -290,16 +300,16 @@ static int avi_write_header(AVFormatContext *s)
|
||||
strf = ff_start_tag(pb, "strf");
|
||||
switch (stream->codec_type) {
|
||||
case AVMEDIA_TYPE_SUBTITLE:
|
||||
// XSUB subtitles behave like video tracks, other subtitles
|
||||
// are not (yet) supported.
|
||||
if (stream->codec_id != AV_CODEC_ID_XSUB) break;
|
||||
/* XSUB subtitles behave like video tracks, other subtitles
|
||||
* are not (yet) supported. */
|
||||
if (stream->codec_id != AV_CODEC_ID_XSUB)
|
||||
break;
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
ff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0, 0);
|
||||
break;
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
if ((ret = ff_put_wav_header(pb, stream)) < 0) {
|
||||
if ((ret = ff_put_wav_header(pb, stream)) < 0)
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
@ -331,8 +341,7 @@ static int avi_write_header(AVFormatContext *s)
|
||||
/* Starting to lay out AVI OpenDML master index.
|
||||
* We want to make it JUNK entry for now, since we'd
|
||||
* like to get away without making AVI an OpenDML one
|
||||
* for compatibility reasons.
|
||||
*/
|
||||
* for compatibility reasons. */
|
||||
avist->indexes.entry = avist->indexes.ents_allocated = 0;
|
||||
avist->indexes.indx_start = ff_start_tag(pb, "JUNK");
|
||||
avio_wl16(pb, 4); /* wLongsPerEntry */
|
||||
@ -341,19 +350,20 @@ static int avi_write_header(AVFormatContext *s)
|
||||
avio_wl32(pb, 0); /* nEntriesInUse (will fill out later on) */
|
||||
ffio_wfourcc(pb, avi_stream2fourcc(tag, i, stream->codec_type));
|
||||
/* dwChunkId */
|
||||
avio_wl64(pb, 0); /* dwReserved[3]
|
||||
avio_wl32(pb, 0); Must be 0. */
|
||||
avio_wl64(pb, 0); /* dwReserved[3] */
|
||||
// avio_wl32(pb, 0); /* Must be 0. */
|
||||
for (j = 0; j < AVI_MASTER_INDEX_SIZE * 2; j++)
|
||||
avio_wl64(pb, 0);
|
||||
ff_end_tag(pb, avist->indexes.indx_start);
|
||||
}
|
||||
|
||||
if( stream->codec_type == AVMEDIA_TYPE_VIDEO
|
||||
&& s->streams[i]->sample_aspect_ratio.num>0
|
||||
&& s->streams[i]->sample_aspect_ratio.den>0){
|
||||
if (stream->codec_type == AVMEDIA_TYPE_VIDEO &&
|
||||
s->streams[i]->sample_aspect_ratio.num > 0 &&
|
||||
s->streams[i]->sample_aspect_ratio.den > 0) {
|
||||
int vprp = ff_start_tag(pb, "vprp");
|
||||
AVRational dar = av_mul_q(s->streams[i]->sample_aspect_ratio,
|
||||
(AVRational){stream->width, stream->height});
|
||||
(AVRational) { stream->width,
|
||||
stream->height });
|
||||
int num, den;
|
||||
av_reduce(&num, &den, dar.num, dar.den, 0xFFFF);
|
||||
|
||||
@ -533,17 +543,18 @@ static int avi_write_idx1(AVFormatContext *s)
|
||||
|
||||
static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
AVIContext *avi = s->priv_data;
|
||||
AVIOContext *pb = s->pb;
|
||||
unsigned char tag[5];
|
||||
unsigned int flags = 0;
|
||||
const int stream_index = pkt->stream_index;
|
||||
int size = pkt->size;
|
||||
AVIContext *avi = s->priv_data;
|
||||
AVIOContext *pb = s->pb;
|
||||
AVIStream *avist = s->streams[stream_index]->priv_data;
|
||||
AVCodecContext *enc = s->streams[stream_index]->codec;
|
||||
int size= pkt->size;
|
||||
|
||||
av_dlog(s, "dts:%s packet_count:%d stream_index:%d\n", av_ts2str(pkt->dts), avist->packet_count, stream_index);
|
||||
while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avist->packet_count && enc->codec_id != AV_CODEC_ID_XSUB && avist->packet_count){
|
||||
while (enc->block_align == 0 && pkt->dts != AV_NOPTS_VALUE &&
|
||||
pkt->dts > avist->packet_count && enc->codec_id != AV_CODEC_ID_XSUB && avist->packet_count) {
|
||||
AVPacket empty_packet;
|
||||
|
||||
if (pkt->dts - avist->packet_count > 60000) {
|
||||
@ -563,7 +574,6 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
// Make sure to put an OpenDML chunk when the file size exceeds the limits
|
||||
if (pb->seekable &&
|
||||
(avio_tell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE)) {
|
||||
|
||||
avi_write_ix(s);
|
||||
ff_end_tag(pb, avi->movi_list);
|
||||
|
||||
@ -577,9 +587,8 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
avi_stream2fourcc(tag, stream_index, enc->codec_type);
|
||||
if (pkt->flags & AV_PKT_FLAG_KEY)
|
||||
flags = 0x10;
|
||||
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
avist->audio_strm_length += size;
|
||||
}
|
||||
|
||||
if (s->pb->seekable) {
|
||||
AVIIndex *idx = &avist->indexes;
|
||||
@ -592,7 +601,8 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
idx->entry = 0;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
idx->cluster[cl] = av_malloc(AVI_INDEX_CLUSTER_SIZE*sizeof(AVIIentry));
|
||||
idx->cluster[cl] =
|
||||
av_malloc(AVI_INDEX_CLUSTER_SIZE * sizeof(AVIIentry));
|
||||
if (!idx->cluster[cl])
|
||||
return AVERROR(ENOMEM);
|
||||
idx->ents_allocated += AVI_INDEX_CLUSTER_SIZE;
|
||||
@ -644,11 +654,11 @@ static int avi_write_trailer(AVFormatContext *s)
|
||||
if (nb_frames < avist->packet_count)
|
||||
nb_frames = avist->packet_count;
|
||||
} else {
|
||||
if (stream->codec_id == AV_CODEC_ID_MP2 || stream->codec_id == AV_CODEC_ID_MP3) {
|
||||
if (stream->codec_id == AV_CODEC_ID_MP2 ||
|
||||
stream->codec_id == AV_CODEC_ID_MP3)
|
||||
nb_frames += avist->packet_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
avio_wl32(pb, nb_frames);
|
||||
avio_seek(pb, file_size, SEEK_SET);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user