static int wav_write_header(AVFormatContext *s) { WAVMuxContext *wav = s->priv_data; AVIOContext *pb = s->pb; int64_t fmt; if (wav->rf64 == RF64_ALWAYS) { ffio_wfourcc(pb, "RF64"); avio_wl32(pb, -1); /* RF64 chunk size: use size in ds64 */ } else { ffio_wfourcc(pb, "RIFF"); avio_wl32(pb, 0); /* file length */ } ffio_wfourcc(pb, "WAVE"); if (wav->rf64 != RF64_NEVER) { /* write empty ds64 chunk or JUNK chunk to reserve space for ds64 */ ffio_wfourcc(pb, wav->rf64 == RF64_ALWAYS ? "ds64" : "JUNK"); avio_wl32(pb, 28); /* chunk size */ wav->ds64 = avio_tell(pb); ffio_fill(pb, 0, 28); } /* format header */ fmt = ff_start_tag(pb, "fmt "); if (ff_put_wav_header(pb, s->streams[0]->codec) < 0) { av_log(s, AV_LOG_ERROR, "%s codec not supported in WAVE format\n", s->streams[0]->codec->codec ? s->streams[0]->codec->codec->name : "NONE"); return -1; } ff_end_tag(pb, fmt); if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */ && s->pb->seekable) { wav->fact_pos = ff_start_tag(pb, "fact"); avio_wl32(pb, 0); ff_end_tag(pb, wav->fact_pos); } if (wav->write_bext) bwf_write_bext_chunk(s); avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); wav->maxpts = wav->last_duration = 0; wav->minpts = INT64_MAX; /* info header */ ff_riff_write_info(s); /* data header */ wav->data = ff_start_tag(pb, "data"); avio_flush(pb); return 0; }
static int wav_write_header(AVFormatContext *s) { WAVMuxContext *wav = s->priv_data; AVIOContext *pb = s->pb; int64_t fmt; ffio_wfourcc(pb, "RIFF"); avio_wl32(pb, 0); /* file length */ ffio_wfourcc(pb, "WAVE"); /* format header */ fmt = ff_start_tag(pb, "fmt "); if (ff_put_wav_header(pb, s->streams[0]->codec) < 0) { av_log(s, AV_LOG_ERROR, "%s codec not supported in WAVE format\n", s->streams[0]->codec->codec ? s->streams[0]->codec->codec->name : "NONE"); return -1; } ff_end_tag(pb, fmt); if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */ && s->pb->seekable) { wav->fact_pos = ff_start_tag(pb, "fact"); avio_wl32(pb, 0); ff_end_tag(pb, wav->fact_pos); } if (wav->write_bext) bwf_write_bext_chunk(s); avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); wav->maxpts = wav->last_duration = 0; wav->minpts = INT64_MAX; /* info header */ ff_riff_write_info(s); /* data header */ wav->data = ff_start_tag(pb, "data"); avio_flush(pb); return 0; }
static int wav_write_header(AVFormatContext *s) { WAVMuxContext *wav = s->priv_data; AVIOContext *pb = s->pb; int64_t fmt; if (s->nb_streams != 1) { av_log(s, AV_LOG_ERROR, "WAVE files have exactly one stream\n"); return AVERROR(EINVAL); } if (wav->rf64 == RF64_ALWAYS) { ffio_wfourcc(pb, "RF64"); avio_wl32(pb, -1); /* RF64 chunk size: use size in ds64 */ } else { ffio_wfourcc(pb, "RIFF"); avio_wl32(pb, -1); /* file length */ } ffio_wfourcc(pb, "WAVE"); if (wav->rf64 != RF64_NEVER) { /* write empty ds64 chunk or JUNK chunk to reserve space for ds64 */ ffio_wfourcc(pb, wav->rf64 == RF64_ALWAYS ? "ds64" : "JUNK"); avio_wl32(pb, 28); /* chunk size */ wav->ds64 = avio_tell(pb); ffio_fill(pb, 0, 28); } if (wav->write_peak != 2) { /* format header */ fmt = ff_start_tag(pb, "fmt "); if (ff_put_wav_header(pb, s->streams[0]->codec, 0) < 0) { const AVCodecDescriptor *desc = avcodec_descriptor_get(s->streams[0]->codec->codec_id); av_log(s, AV_LOG_ERROR, "%s codec not supported in WAVE format\n", desc ? desc->name : "unknown"); return AVERROR(ENOSYS); } ff_end_tag(pb, fmt); } if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */ && s->pb->seekable) { wav->fact_pos = ff_start_tag(pb, "fact"); avio_wl32(pb, 0); ff_end_tag(pb, wav->fact_pos); } if (wav->write_bext) bwf_write_bext_chunk(s); if (wav->write_peak) { int ret; if ((ret = peak_init_writer(s)) < 0) return ret; } avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate); wav->maxpts = wav->last_duration = 0; wav->minpts = INT64_MAX; if (wav->write_peak != 2) { /* info header */ ff_riff_write_info(s); /* data header */ wav->data = ff_start_tag(pb, "data"); } avio_flush(pb); return 0; }