On 24/4/21 8:35 am, Aidan Richmond wrote:
+
+ if (st->codecpar->codec_id != AV_CODEC_ID_ADPCM_IMA_WS) {
+ av_log(st, AV_LOG_ERROR, "%s codec not supported for Westwood AUD.\n",
+ avcodec_get_name(st->codecpar->codec_id));
+ return -1;
AVERROR(EINVAL)
+ }
+
+ if (ctx->nb_streams != 1) {
+ av_log(st, AV_LOG_ERROR, "AUD files have exactly one stream\n");
+ return AVERROR(EINVAL);
+ }
+
Move both these checks into an init function.
+static int wsaud_write_trailer(AVFormatContext *ctx)
+{
+ AVIOContext *pb = ctx->pb;
+ AUDMuxContext *a = ctx->priv_data;
+
+ if(!pb->seekable) {
+ av_log(ctx->streams[0], AV_LOG_ERROR, "Cannot seek to write file size to
header.");
+ return -1;
+ }
+
Same with this one. No point writing the file at all if it's not seekable.
+ avio_seek(pb, 2, SEEK_SET);
+ avio_wl32(pb, a->size);
+ avio_wl32(pb, a->uncomp_size);
+
+ return 0;
+}
+
+AVOutputFormat ff_wsaud_muxer = {
+ .name = "wsaud",
+ .long_name = NULL_IF_CONFIG_SMALL("Westwood Studios audio"),
+ .extensions = "aud",
+ .priv_data_size = sizeof(AUDMuxContext),
+ .audio_codec = AV_CODEC_ID_ADPCM_IMA_WS,
+ .video_codec = AV_CODEC_ID_NONE,
+ .write_header = wsaud_write_header,
+ .write_packet = wsaud_write_packet,
+ .write_trailer = wsaud_write_trailer,
+};
_______________________________________________
ffmpeg-devel mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".