1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2014-2017 L-SMASH project
6 * Authors: Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 *****************************************************************************/
21 /* This file is available under an ISC license. */
23 #include "common/internal.h" /* must be placed first */
29 #define WFEX_BOX_MIN_LENGTH 26
31 #define WAVE_FORMAT_TAG_ID_WMA_V2 0x0161
32 #define WAVE_FORMAT_TAG_ID_WMA_V3 0x0162
34 int wma_print_codec_specific( FILE *fp
, lsmash_file_t
*file
, isom_box_t
*box
, int level
)
36 assert( fp
&& file
&& box
&& (box
->manager
& LSMASH_BINARY_CODED_BOX
) );
38 lsmash_ifprintf( fp
, indent
++, "[%s: General Extended Waveform Format Box]\n", isom_4cc2str( box
->type
.fourcc
) );
39 lsmash_ifprintf( fp
, indent
, "position = %"PRIu64
"\n", box
->pos
);
40 lsmash_ifprintf( fp
, indent
, "size = %"PRIu64
"\n", box
->size
);
41 if( box
->size
< WFEX_BOX_MIN_LENGTH
)
42 return LSMASH_ERR_INVALID_DATA
;
43 uint8_t *data
= box
->binary
;
44 isom_skip_box_common( &data
);
45 uint16_t wFormatTag
= LSMASH_GET_LE16( &data
[0] );
46 static const char *codec_name
[] =
48 "Windows Media Audio V2",
49 "Windows Media Audio V3"
51 if( wFormatTag
== WAVE_FORMAT_TAG_ID_WMA_V2
52 || wFormatTag
== WAVE_FORMAT_TAG_ID_WMA_V3
)
53 lsmash_ifprintf( fp
, indent
, "wFormatTag = 0x%04"PRIx16
" (%s)\n", wFormatTag
, codec_name
[wFormatTag
- WAVE_FORMAT_TAG_ID_WMA_V2
] );
55 lsmash_ifprintf( fp
, indent
, "wFormatTag = 0x%04"PRIx16
"\n", wFormatTag
);
56 lsmash_ifprintf( fp
, indent
, "nChannels = %"PRIu16
"\n", LSMASH_GET_LE16( &data
[ 2] ) );
57 lsmash_ifprintf( fp
, indent
, "nSamplesPerSec = %"PRIu32
"\n", LSMASH_GET_LE32( &data
[ 4] ) );
58 lsmash_ifprintf( fp
, indent
, "nAvgBytesPerSec = %"PRIu32
"\n", LSMASH_GET_LE32( &data
[ 8] ) );
59 lsmash_ifprintf( fp
, indent
, "nBlockAlign = %"PRIu16
"\n", LSMASH_GET_LE16( &data
[12] ) );
60 lsmash_ifprintf( fp
, indent
, "wBitsPerSample = %"PRIu16
"\n", LSMASH_GET_LE16( &data
[14] ) );
61 uint16_t cbSize
= LSMASH_GET_BYTE( &data
[16] );
62 lsmash_ifprintf( fp
, indent
, "cbSize = %"PRIu16
"\n", cbSize
);
65 case WAVE_FORMAT_TAG_ID_WMA_V2
:
67 return LSMASH_ERR_INVALID_DATA
;
68 lsmash_ifprintf( fp
, indent
, "dwSamplesPerBlock = %"PRIu32
"\n", LSMASH_GET_LE32( &data
[18] ) );
69 lsmash_ifprintf( fp
, indent
, "wEncodeOptions = 0x%04"PRIu16
"\n", LSMASH_GET_LE16( &data
[22] ) );
70 lsmash_ifprintf( fp
, indent
, "dwSuperBlockAlign = %"PRIu32
"\n", LSMASH_GET_LE32( &data
[24] ) );
72 case WAVE_FORMAT_TAG_ID_WMA_V3
:
74 return LSMASH_ERR_INVALID_DATA
;
75 lsmash_ifprintf( fp
, indent
, "wValidBitsPerSample = %"PRIu16
"\n", LSMASH_GET_LE16( &data
[18] ) );
76 lsmash_ifprintf( fp
, indent
, "dwChannelMask = 0x%08"PRIu32
"\n", LSMASH_GET_LE32( &data
[20] ) );
77 lsmash_ifprintf( fp
, indent
, "dwReserved1 = 0x%08"PRIu32
"\n", LSMASH_GET_LE32( &data
[24] ) );
78 lsmash_ifprintf( fp
, indent
, "dwReserved2 = 0x%08"PRIu32
"\n", LSMASH_GET_LE32( &data
[28] ) );
79 lsmash_ifprintf( fp
, indent
, "wEncodeOptions = 0x%04"PRIu16
"\n", LSMASH_GET_LE16( &data
[32] ) );
80 lsmash_ifprintf( fp
, indent
, "wReserved3 = 0x%04"PRIu16
"\n", LSMASH_GET_LE16( &data
[34] ) );