mirror of
https://github.com/google/liblc3.git
synced 2026-04-18 05:35:31 +00:00
Adopt review suggestions
This commit is contained in:
@@ -34,8 +34,8 @@ parser.add_argument(
|
||||
type=argparse.FileType('wb'), default=sys.stdout.buffer)
|
||||
|
||||
parser.add_argument(
|
||||
'--bitdepth',
|
||||
help='Output bitdepth, default is 16 bits',
|
||||
'--bit_depth',
|
||||
help='Output bit depth, default is 16 bits',
|
||||
type=int, choices=[16, 24], default=16)
|
||||
|
||||
parser.add_argument(
|
||||
@@ -58,13 +58,13 @@ stream_length = header[7]
|
||||
|
||||
# --- Setup output ---
|
||||
|
||||
bitdepth = args.bitdepth
|
||||
pcm_size = nchannels * (bitdepth // 8)
|
||||
bit_depth = args.bit_depth
|
||||
pcm_size = nchannels * (bit_depth // 8)
|
||||
|
||||
f_wav = args.wav_file
|
||||
wavfile = wave.open(f_wav)
|
||||
wavfile.setnchannels(nchannels)
|
||||
wavfile.setsampwidth(bitdepth // 8)
|
||||
wavfile.setsampwidth(bit_depth // 8)
|
||||
wavfile.setframerate(samplerate)
|
||||
wavfile.setnframes(stream_length)
|
||||
|
||||
@@ -80,7 +80,7 @@ encoded_length = stream_length + dec.get_delay_samples()
|
||||
for i in range(0, encoded_length, frame_length):
|
||||
|
||||
lc3_frame_size = struct.unpack('=H', f_lc3.read(2))[0]
|
||||
pcm = dec.decode(f_lc3.read(lc3_frame_size), bit_depth=bitdepth)
|
||||
pcm = dec.decode(f_lc3.read(lc3_frame_size), bit_depth=bit_depth)
|
||||
|
||||
pcm = pcm[max(encoded_length - stream_length - i, 0) * pcm_size:
|
||||
min(encoded_length - i, frame_length) * pcm_size]
|
||||
|
||||
@@ -51,7 +51,7 @@ wavfile = wave.open(f_wav, 'rb')
|
||||
|
||||
samplerate = wavfile.getframerate()
|
||||
nchannels = wavfile.getnchannels()
|
||||
bitdepth = wavfile.getsampwidth() * 8
|
||||
bit_depth = wavfile.getsampwidth() * 8
|
||||
stream_length = wavfile.getnframes()
|
||||
|
||||
# --- Setup encoder ---
|
||||
@@ -77,7 +77,7 @@ for i in range(0, stream_length, frame_length):
|
||||
f_lc3.write(struct.pack('=H', frame_size))
|
||||
|
||||
pcm = wavfile.readframes(frame_length)
|
||||
f_lc3.write(enc.encode(pcm, frame_size, bit_depth=bitdepth))
|
||||
f_lc3.write(enc.encode(pcm, frame_size, bit_depth=bit_depth))
|
||||
|
||||
# --- Cleanup ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user