|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* This file is part of libbluray
|
|
Packit |
5e46da |
* Copyright (C) 2010 hpi1
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is free software; you can redistribute it and/or
|
|
Packit |
5e46da |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License as published by the Free Software Foundation; either
|
|
Packit |
5e46da |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
5e46da |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
5e46da |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
5e46da |
* Lesser General Public License for more details.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License along with this library. If not, see
|
|
Packit |
5e46da |
* <http://www.gnu.org/licenses/>.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#include <stdio.h>
|
|
Packit |
5e46da |
#include <stdlib.h>
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#include "bluray.h"
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _sound_print(int sound_index, BLURAY_SOUND_EFFECT *data)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
printf(" Sound %d:\n", sound_index);
|
|
Packit |
5e46da |
printf(" bits per sample: %d\n", 16);
|
|
Packit |
5e46da |
printf(" sample rate: %d\n", 48000);
|
|
Packit |
5e46da |
printf(" channels: %d\n", data->num_channels);
|
|
Packit |
5e46da |
printf(" audio frames: %d", data->num_frames);
|
|
Packit |
5e46da |
printf(" (%d ms)\n", data->num_frames * 1000 / 48000);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _sound_dump(int sound_index, BLURAY_SOUND_EFFECT *data)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
size_t bytes;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
fprintf(stderr, "Sound %d: %d frames LPCM_LE, %dHz, %d bits, %s\n",
|
|
Packit |
5e46da |
sound_index,
|
|
Packit |
5e46da |
data->num_frames,
|
|
Packit |
5e46da |
48000,
|
|
Packit |
5e46da |
16,
|
|
Packit |
5e46da |
data->num_channels == 1 ? "mono" : "stereo");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
bytes = 2 * data->num_channels * data->num_frames;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (fwrite(data->samples, bytes, 1, stdout) != 1) {
|
|
Packit |
5e46da |
fprintf(stderr, "I/O error\n");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
int main(int argc, const char *argv[])
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
BLURAY_SOUND_EFFECT effect;
|
|
Packit |
5e46da |
BLURAY *bd;
|
|
Packit |
5e46da |
int sound_index = -1;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (argc < 2 || argc > 3) {
|
|
Packit |
5e46da |
fprintf(stderr, "usage: sound_dump [sound_index] <disc_root>\n");
|
|
Packit |
5e46da |
fprintf(stderr, "If sound index is given, raw LPCM data is dumped to stdout\n");
|
|
Packit |
5e46da |
return 1;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (argc == 3) {
|
|
Packit |
5e46da |
sound_index = atoi(argv[1]);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* open disc */
|
|
Packit |
5e46da |
bd = bd_open(argv[argc-1], NULL);
|
|
Packit |
5e46da |
if (!bd) {
|
|
Packit |
5e46da |
fprintf(stderr, "error opening disc %s\n", argv[argc-1]);
|
|
Packit |
5e46da |
return -1;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (sound_index >= 0) {
|
|
Packit |
5e46da |
if (bd_get_sound_effect(bd, sound_index, &effect) <= 0) {
|
|
Packit |
5e46da |
fprintf(stderr, "Invalid sound index %d\n", sound_index);
|
|
Packit |
5e46da |
} else {
|
|
Packit |
5e46da |
_sound_dump(sound_index, &effect);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
} else {
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
while (bd_get_sound_effect(bd, ++sound_index, &effect) > 0) {
|
|
Packit |
5e46da |
_sound_print(sound_index, &effect);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (sound_index == 0) {
|
|
Packit |
5e46da |
fprintf(stderr, "No sound effects\n");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
bd_close(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
return 0;
|
|
Packit |
5e46da |
}
|