On 5/28/17, James Almer <jamr...@gmail.com> wrote: > Signed-off-by: James Almer <jamr...@gmail.com> > --- > libavformat/aiffenc.c | 45 +++++++++++++++++++++++++++++---------------- > 1 file changed, 29 insertions(+), 16 deletions(-) > > diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c > index fcadf149a0..1e0c5b11a0 100644 > --- a/libavformat/aiffenc.c > +++ b/libavformat/aiffenc.c > @@ -98,13 +98,11 @@ static void put_meta(AVFormatContext *s, const char > *key, uint32_t id) > } > } > > -static int aiff_write_header(AVFormatContext *s) > +static int aiff_init(AVFormatContext *s) > { > AIFFOutputContext *aiff = s->priv_data; > - AVIOContext *pb = s->pb; > AVCodecParameters *par; > - uint64_t sample_rate; > - int i, aifc = 0; > + int i; > > aiff->audio_stream_idx = -1; > for (i = 0; i < s->nb_streams; i++) { > @@ -126,6 +124,32 @@ static int aiff_write_header(AVFormatContext *s) > /* First verify if format is ok */ > if (!par->codec_tag) > return -1; > + > + if (!par->bits_per_coded_sample) > + par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id); > + if (!par->bits_per_coded_sample) { > + av_log(s, AV_LOG_ERROR, "could not compute bits per sample\n"); > + return -1; > + } > + if (!par->block_align) > + par->block_align = (par->bits_per_coded_sample * par->channels) >> > 3; > + > + avpriv_set_pts_info(s->streams[aiff->audio_stream_idx], 64, 1, > + > s->streams[aiff->audio_stream_idx]->codecpar->sample_rate); > + > + return 0; > +} > + > +static int aiff_write_header(AVFormatContext *s) > +{ > + AIFFOutputContext *aiff = s->priv_data; > + AVIOContext *pb = s->pb; > + AVCodecParameters *par; > + uint64_t sample_rate; > + int aifc = 0; > + > + par = s->streams[aiff->audio_stream_idx]->codecpar; > + > if (par->codec_tag != MKTAG('N','O','N','E')) > aifc = 1; > > @@ -165,15 +189,6 @@ static int aiff_write_header(AVFormatContext *s) > aiff->frames = avio_tell(pb); > avio_wb32(pb, 0); /* Number of frames */ > > - if (!par->bits_per_coded_sample) > - par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id); > - if (!par->bits_per_coded_sample) { > - av_log(s, AV_LOG_ERROR, "could not compute bits per sample\n"); > - return -1; > - } > - if (!par->block_align) > - par->block_align = (par->bits_per_coded_sample * par->channels) >> > 3; > - > avio_wb16(pb, par->bits_per_coded_sample); /* Sample size */ > > sample_rate = av_double2int(par->sample_rate); > @@ -199,9 +214,6 @@ static int aiff_write_header(AVFormatContext *s) > avio_wb32(pb, 0); /* Data offset */ > avio_wb32(pb, 0); /* Block-size (block align) */ > > - avpriv_set_pts_info(s->streams[aiff->audio_stream_idx], 64, 1, > - > s->streams[aiff->audio_stream_idx]->codecpar->sample_rate); > - > /* Data is starting here */ > avio_flush(pb); > > @@ -327,6 +339,7 @@ AVOutputFormat ff_aiff_muxer = { > .priv_data_size = sizeof(AIFFOutputContext), > .audio_codec = AV_CODEC_ID_PCM_S16BE, > .video_codec = AV_CODEC_ID_PNG, > + .init = aiff_init, > .write_header = aiff_write_header, > .write_packet = aiff_write_packet, > .write_trailer = aiff_write_trailer, > -- > 2.12.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
Could you explain in detail what this patch does? _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel