also add more documentation about the header structure
| ... | ... |
@@ -19,9 +19,9 @@ |
| 19 | 19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | 20 |
*/ |
| 21 | 21 |
|
| 22 |
-#include "libavutil/intreadwrite.h" |
|
| 23 | 22 |
#include "avcodec.h" |
| 24 | 23 |
#include "adx.h" |
| 24 |
+#include "bytestream.h" |
|
| 25 | 25 |
#include "put_bits.h" |
| 26 | 26 |
|
| 27 | 27 |
/** |
| ... | ... |
@@ -81,20 +81,29 @@ static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav, |
| 81 | 81 |
flush_put_bits(&pb); |
| 82 | 82 |
} |
| 83 | 83 |
|
| 84 |
+#define HEADER_SIZE 36 |
|
| 85 |
+ |
|
| 84 | 86 |
static int adx_encode_header(AVCodecContext *avctx, uint8_t *buf, int bufsize) |
| 85 | 87 |
{
|
| 86 | 88 |
ADXContext *c = avctx->priv_data; |
| 87 | 89 |
|
| 88 |
- AV_WB32(buf + 0x00, 0x80000000 | 0x20); |
|
| 89 |
- AV_WB32(buf + 0x04, 0x03120400 | avctx->channels); |
|
| 90 |
- AV_WB32(buf + 0x08, avctx->sample_rate); |
|
| 91 |
- AV_WB32(buf + 0x0c, 0); |
|
| 92 |
- AV_WB16(buf + 0x10, c->cutoff); |
|
| 93 |
- AV_WB32(buf + 0x12, 0x03000000); |
|
| 94 |
- AV_WB32(buf + 0x16, 0x00000000); |
|
| 95 |
- AV_WB32(buf + 0x1a, 0x00000000); |
|
| 96 |
- memcpy (buf + 0x1e, "(c)CRI", 6); |
|
| 97 |
- return 0x20 + 4; |
|
| 90 |
+ bytestream_put_be16(&buf, 0x8000); /* header signature */ |
|
| 91 |
+ bytestream_put_be16(&buf, HEADER_SIZE - 4); /* copyright offset */ |
|
| 92 |
+ bytestream_put_byte(&buf, 3); /* encoding */ |
|
| 93 |
+ bytestream_put_byte(&buf, BLOCK_SIZE); /* block size */ |
|
| 94 |
+ bytestream_put_byte(&buf, 4); /* sample size */ |
|
| 95 |
+ bytestream_put_byte(&buf, avctx->channels); /* channels */ |
|
| 96 |
+ bytestream_put_be32(&buf, avctx->sample_rate); /* sample rate */ |
|
| 97 |
+ bytestream_put_be32(&buf, 0); /* total sample count */ |
|
| 98 |
+ bytestream_put_be16(&buf, c->cutoff); /* cutoff frequency */ |
|
| 99 |
+ bytestream_put_byte(&buf, 3); /* version */ |
|
| 100 |
+ bytestream_put_byte(&buf, 0); /* flags */ |
|
| 101 |
+ bytestream_put_be32(&buf, 0); /* unknown */ |
|
| 102 |
+ bytestream_put_be32(&buf, 0); /* loop enabled */ |
|
| 103 |
+ bytestream_put_be16(&buf, 0); /* padding */ |
|
| 104 |
+ bytestream_put_buffer(&buf, "(c)CRI", 6); /* copyright signature */ |
|
| 105 |
+ |
|
| 106 |
+ return HEADER_SIZE; |
|
| 98 | 107 |
} |
| 99 | 108 |
|
| 100 | 109 |
static av_cold int adx_encode_init(AVCodecContext *avctx) |