-#if 0
- struct {
- uint32_t offset; /* 0x80000000 + sample start - 4 */
- unsigned char unknown1[3]; /* 03 12 04 */
- unsigned char channel; /* 1 or 2 */
- uint32_t freq;
- uint32_t size;
- uint32_t unknown2; /* 01 f4 03 00 */
- uint32_t unknown3; /* 00 00 00 00 */
- uint32_t unknown4; /* 00 00 00 00 */
-
- /* if loop
- unknown3 00 15 00 01
- unknown4 00 00 00 01
- long loop_start_sample;
- long loop_start_byte;
- long loop_end_sample;
- long loop_end_byte;
- long
- */
- } adxhdr; /* big endian */
- /* offset-6 "(c)CRI" */
-#endif
- AV_WB32(buf+0x00,0x80000000|0x20);
- AV_WB32(buf+0x04,0x03120400|avctx->channels);
- AV_WB32(buf+0x08,avctx->sample_rate);
- AV_WB32(buf+0x0c,0); /* FIXME: set after */
- AV_WB32(buf+0x10,0x01040300);
- AV_WB32(buf+0x14,0x00000000);
- AV_WB32(buf+0x18,0x00000000);
- memcpy(buf+0x1c,"\0\0(c)CRI",8);
- return 0x20+4;
+ ADXContext *c = avctx->priv_data;
+
+ if (bufsize < HEADER_SIZE)
+ return AVERROR(EINVAL);
+
+ bytestream_put_be16(&buf, 0x8000); /* header signature */
+ bytestream_put_be16(&buf, HEADER_SIZE - 4); /* copyright offset */
+ bytestream_put_byte(&buf, 3); /* encoding */
+ bytestream_put_byte(&buf, BLOCK_SIZE); /* block size */
+ bytestream_put_byte(&buf, 4); /* sample size */
+ bytestream_put_byte(&buf, avctx->channels); /* channels */
+ bytestream_put_be32(&buf, avctx->sample_rate); /* sample rate */
+ bytestream_put_be32(&buf, 0); /* total sample count */
+ bytestream_put_be16(&buf, c->cutoff); /* cutoff frequency */
+ bytestream_put_byte(&buf, 3); /* version */
+ bytestream_put_byte(&buf, 0); /* flags */
+ bytestream_put_be32(&buf, 0); /* unknown */
+ bytestream_put_be32(&buf, 0); /* loop enabled */
+ bytestream_put_be16(&buf, 0); /* padding */
+ bytestream_put_buffer(&buf, "(c)CRI", 6); /* copyright signature */
+
+ return HEADER_SIZE;