write actual number of channels to mp4a box
authornu774 <honeycomb77@gmail.com>
Fri, 12 Sep 2014 12:34:37 +0000 (21:34 +0900)
committernu774 <honeycomb77@gmail.com>
Fri, 12 Sep 2014 12:34:37 +0000 (21:34 +0900)
src/m4af.c
src/m4af.h
src/main.c

index bdcae5f68912dc81abf7a440dbd02ab6a65e968e..f3a48525ea2276df64f20b11176c663464dd1f94 100644 (file)
@@ -42,6 +42,7 @@ typedef struct m4af_chunk_entry_t {
 typedef struct m4af_track_t {
     uint32_t codec;
     uint32_t timescale;
+    uint16_t num_channels;
     int64_t creation_time;
     int64_t modification_time;
     int64_t duration;
@@ -211,6 +212,7 @@ m4af_ctx_t *m4af_create(uint32_t codec, uint32_t timescale,
     ctx->track[0].timescale = timescale;
     ctx->track[0].creation_time = timestamp;
     ctx->track[0].modification_time = timestamp;
+    ctx->track[0].num_channels = 2;
     return ctx;
 }
 
@@ -254,6 +256,12 @@ void m4af_teardown(m4af_ctx_t **ctxp)
     *ctxp = 0;
 }
 
+void m4af_set_num_channels(m4af_ctx_t *ctx, uint32_t track_idx,
+                           uint16_t channels)
+{
+    ctx->track[track_idx].num_channels = channels;
+}
+
 void m4af_set_fixed_frame_duration(m4af_ctx_t *ctx, uint32_t track_idx,
                                    uint32_t length)
 {
@@ -816,11 +824,13 @@ void m4af_write_mp4a_box(m4af_ctx_t *ctx, uint32_t track_idx)
                "\0\001"       /* data_reference_index: 1 */
                "\0\0\0\0"     /* reserved[0]             */
                "\0\0\0\0"     /* reserved[1]             */
-               "\0\002"       /* channelcount: 2         */
+               ,16);
+    m4af_write16(ctx, track->num_channels);
+    m4af_write(ctx,
                "\0\020"       /* samplesize: 16          */
                "\0\0"         /* pre_defined             */
                "\0\0"         /* reserved                */
-               ,24);
+               ,6);
     if (track->codec == M4AF_FOURCC('m','p','4','a')) {
         m4af_write32(ctx, track->timescale << 16);
         m4af_write_esds_box(ctx, track_idx);
index b1d84bbe53e5a77c774459cebac6c4dc39ff4282..09ebe9333ba4b101190714e7116a76f103ff4a5e 100644 (file)
@@ -104,6 +104,9 @@ void m4af_set_priming(m4af_ctx_t *ctx, uint32_t track_idx,
 
 void m4af_set_priming_mode(m4af_ctx_t *ctx, int mode);
 
+void m4af_set_num_channels(m4af_ctx_t *ctx, uint32_t track_idx,
+                           uint16_t channels);
+
 void m4af_set_fixed_frame_duration(m4af_ctx_t *ctx, uint32_t track_idx,
                                    uint32_t length);
 
index 9e104a493cc671eefdc3debc2f949c0479bfab04..f4ecd756be0e238a9f6456a2c0a7ee7b09337f4c 100644 (file)
@@ -824,6 +824,7 @@ int main(int argc, char **argv)
         if ((m4af = m4af_create(M4AF_CODEC_MP4A, scale, &m4af_io,
                                 params.output_fp)) < 0)
             goto END;
+        m4af_set_num_channels(m4af, 0, sample_format->channels_per_frame);
         m4af_set_decoder_specific_info(m4af, 0,
                                        aacinfo.confBuf, aacinfo.confSize);
         m4af_set_fixed_frame_duration(m4af, 0, framelen >> scale_shift);
This page took 0.01365 seconds and 4 git commands to generate.