mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-29 19:37:30 +01:00
Fixed FFmpeg codec not being displayed in case of recursive segments/layers
This commit is contained in:
parent
93a156235a
commit
e86091d853
@ -1200,37 +1200,107 @@ static const meta_info meta_info_list[] = {
|
||||
|
||||
};
|
||||
|
||||
|
||||
const char * get_vgmstream_coding_description(coding_t coding_type) {
|
||||
void get_vgmstream_coding_description(VGMSTREAM *vgmstream, char *out, size_t out_size) {
|
||||
int i, list_length;
|
||||
const char *description;
|
||||
|
||||
list_length = sizeof(coding_info_list) / sizeof(coding_info);
|
||||
for (i=0; i < list_length; i++) {
|
||||
if (coding_info_list[i].type == coding_type)
|
||||
return coding_info_list[i].description;
|
||||
/* we need to recurse down because of FFmpeg */
|
||||
if (vgmstream->layout_type == layout_layered) {
|
||||
layered_layout_data* layout_data = vgmstream->layout_data;
|
||||
get_vgmstream_coding_description(layout_data->layers[0], out, out_size);
|
||||
return;
|
||||
} else if (vgmstream->layout_type == layout_segmented) {
|
||||
segmented_layout_data* layout_data = vgmstream->layout_data;
|
||||
get_vgmstream_coding_description(layout_data->segments[0], out, out_size);
|
||||
return;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
description = "CANNOT DECODE";
|
||||
|
||||
switch (vgmstream->coding_type) {
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
case coding_FFmpeg:
|
||||
{
|
||||
ffmpeg_codec_data *data = vgmstream->codec_data;
|
||||
|
||||
if (data) {
|
||||
if (data->codec && data->codec->long_name) {
|
||||
description = data->codec->long_name;
|
||||
} else if (data->codec && data->codec->name) {
|
||||
description = data->codec->name;
|
||||
} else {
|
||||
description = "FFmpeg (unknown codec)";
|
||||
}
|
||||
} else {
|
||||
description = "FFmpeg";
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
list_length = sizeof(coding_info_list) / sizeof(coding_info);
|
||||
for (i = 0; i < list_length; i++) {
|
||||
if (coding_info_list[i].type == vgmstream->coding_type)
|
||||
description = coding_info_list[i].description;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
strncpy(out, description, out_size);
|
||||
}
|
||||
const char * get_vgmstream_layout_description(layout_t layout_type) {
|
||||
const char * get_vgmstream_layout_name(layout_t layout_type) {
|
||||
int i, list_length;
|
||||
|
||||
list_length = sizeof(layout_info_list) / sizeof(layout_info);
|
||||
for (i=0; i < list_length; i++) {
|
||||
for (i = 0; i < list_length; i++) {
|
||||
if (layout_info_list[i].type == layout_type)
|
||||
return layout_info_list[i].description;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
const char * get_vgmstream_meta_description(meta_t meta_type) {
|
||||
void get_vgmstream_layout_description(VGMSTREAM *vgmstream, char *out, size_t out_size) {
|
||||
char temp[256];
|
||||
VGMSTREAM* vgmstreamsub = NULL;
|
||||
const char* description;
|
||||
|
||||
description = get_vgmstream_layout_name(vgmstream->layout_type);
|
||||
if (!description) description = "INCONCEIVABLE";
|
||||
|
||||
if (vgmstream->layout_type == layout_layered) {
|
||||
vgmstreamsub = ((layered_layout_data*)vgmstream->layout_data)->layers[0];
|
||||
snprintf(temp, sizeof(temp), "%s (%i layers)", description, ((layered_layout_data*)vgmstream->layout_data)->layer_count);
|
||||
} else if (vgmstream->layout_type == layout_segmented) {
|
||||
snprintf(temp, sizeof(temp), "%s (%i segments)", description, ((segmented_layout_data*)vgmstream->layout_data)->segment_count);
|
||||
vgmstreamsub = ((segmented_layout_data*)vgmstream->layout_data)->segments[0];
|
||||
} else {
|
||||
snprintf(temp, sizeof(temp), "%s", description);
|
||||
}
|
||||
strncpy(out, temp, out_size);
|
||||
|
||||
/* layouts can contain layouts infinitely let's leave it at one level deep (most common) */
|
||||
/* TODO: improve this somehow */
|
||||
if (vgmstreamsub && vgmstreamsub->layout_type == layout_layered) {
|
||||
description = get_vgmstream_layout_name(vgmstreamsub->layout_type);
|
||||
snprintf(temp, sizeof(temp), " + %s (%i layers)", description, ((layered_layout_data*)vgmstreamsub->layout_data)->layer_count);
|
||||
concatn(out_size, out, temp);
|
||||
} else if (vgmstreamsub && vgmstreamsub->layout_type == layout_segmented) {
|
||||
description = get_vgmstream_layout_name(vgmstreamsub->layout_type);
|
||||
snprintf(temp, sizeof(temp), " + %s (%i segments)", description, ((segmented_layout_data*)vgmstream->layout_data)->segment_count);
|
||||
concatn(out_size, out, temp);
|
||||
}
|
||||
}
|
||||
void get_vgmstream_meta_description(VGMSTREAM *vgmstream, char *out, size_t out_size) {
|
||||
int i, list_length;
|
||||
const char *description;
|
||||
|
||||
description = "THEY SHOULD HAVE SENT A POET";
|
||||
|
||||
list_length = sizeof(meta_info_list) / sizeof(meta_info);
|
||||
for (i=0; i < list_length; i++) {
|
||||
if (meta_info_list[i].type == meta_type)
|
||||
return meta_info_list[i].description;
|
||||
if (meta_info_list[i].type == vgmstream->meta_type)
|
||||
description = meta_info_list[i].description;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
strncpy(out, description, out_size);
|
||||
}
|
||||
|
@ -2298,7 +2298,6 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) {
|
||||
void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
#define TEMPSIZE (256+32)
|
||||
char temp[TEMPSIZE];
|
||||
const char* description;
|
||||
double time_mm, time_ss, seconds;
|
||||
|
||||
if (!vgmstream) {
|
||||
@ -2378,83 +2377,14 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
|
||||
snprintf(temp,TEMPSIZE, "encoding: ");
|
||||
concatn(length,desc,temp);
|
||||
switch (vgmstream->coding_type) {
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
|
||||
case coding_FFmpeg: {
|
||||
//todo codec bugs with layout inside layouts (ex. TXTP)
|
||||
ffmpeg_codec_data *data = NULL;
|
||||
|
||||
if (vgmstream->layout_type == layout_layered) {
|
||||
layered_layout_data* layout_data = vgmstream->layout_data;
|
||||
if (layout_data->layers[0]->coding_type == coding_FFmpeg)
|
||||
data = layout_data->layers[0]->codec_data;
|
||||
}
|
||||
else if (vgmstream->layout_type == layout_segmented) {
|
||||
segmented_layout_data* layout_data = vgmstream->layout_data;
|
||||
if (layout_data->segments[0]->coding_type == coding_FFmpeg)
|
||||
data = layout_data->segments[0]->codec_data;
|
||||
}
|
||||
else {
|
||||
data = vgmstream->codec_data;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
if (data->codec && data->codec->long_name) {
|
||||
snprintf(temp,TEMPSIZE, "%s",data->codec->long_name);
|
||||
} else if (data->codec && data->codec->name) {
|
||||
snprintf(temp,TEMPSIZE, "%s",data->codec->name);
|
||||
} else {
|
||||
snprintf(temp,TEMPSIZE, "FFmpeg (unknown codec)");
|
||||
}
|
||||
} else {
|
||||
snprintf(temp,TEMPSIZE, "FFmpeg");
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
description = get_vgmstream_coding_description(vgmstream->coding_type);
|
||||
if (!description) description = "CANNOT DECODE";
|
||||
snprintf(temp,TEMPSIZE, "%s",description);
|
||||
break;
|
||||
}
|
||||
get_vgmstream_coding_description(vgmstream, temp, TEMPSIZE);
|
||||
concatn(length,desc,temp);
|
||||
concatn(length,desc,"\n");
|
||||
|
||||
snprintf(temp,TEMPSIZE, "layout: ");
|
||||
concatn(length,desc,temp);
|
||||
{
|
||||
VGMSTREAM* vgmstreamsub = NULL;
|
||||
|
||||
description = get_vgmstream_layout_description(vgmstream->layout_type);
|
||||
if (!description) description = "INCONCEIVABLE";
|
||||
|
||||
if (vgmstream->layout_type == layout_layered) {
|
||||
vgmstreamsub = ((layered_layout_data*)vgmstream->layout_data)->layers[0];
|
||||
snprintf(temp,TEMPSIZE, "%s (%i layers)", description, ((layered_layout_data*)vgmstream->layout_data)->layer_count);
|
||||
}
|
||||
else if (vgmstream->layout_type == layout_segmented) {
|
||||
snprintf(temp,TEMPSIZE, "%s (%i segments)", description, ((segmented_layout_data*)vgmstream->layout_data)->segment_count);
|
||||
vgmstreamsub = ((segmented_layout_data*)vgmstream->layout_data)->segments[0];
|
||||
}
|
||||
else {
|
||||
snprintf(temp,TEMPSIZE, "%s",description);
|
||||
}
|
||||
concatn(length,desc,temp);
|
||||
|
||||
/* layouts can contain layouts infinitely let's leave it at one level deep (most common) */
|
||||
if (vgmstreamsub && vgmstreamsub->layout_type == layout_layered) {
|
||||
description = get_vgmstream_layout_description(vgmstreamsub->layout_type);
|
||||
snprintf(temp,TEMPSIZE, " + %s (%i layers)",description, ((layered_layout_data*)vgmstreamsub->layout_data)->layer_count);
|
||||
concatn(length,desc,temp);
|
||||
}
|
||||
else if (vgmstreamsub && vgmstreamsub->layout_type == layout_segmented) {
|
||||
description = get_vgmstream_layout_description(vgmstreamsub->layout_type);
|
||||
snprintf(temp,TEMPSIZE, " + %s (%i segments)",description, ((segmented_layout_data*)vgmstream->layout_data)->segment_count);
|
||||
concatn(length,desc,temp);
|
||||
}
|
||||
}
|
||||
get_vgmstream_layout_description(vgmstream, temp, TEMPSIZE);
|
||||
concatn(length, desc, temp);
|
||||
concatn(length,desc,"\n");
|
||||
|
||||
if (vgmstream->layout_type == layout_interleave && vgmstream->channels > 1) {
|
||||
@ -2493,13 +2423,7 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
|
||||
snprintf(temp,TEMPSIZE, "metadata from: ");
|
||||
concatn(length,desc,temp);
|
||||
switch (vgmstream->meta_type) {
|
||||
default:
|
||||
description = get_vgmstream_meta_description(vgmstream->meta_type);
|
||||
if (!description) description = "THEY SHOULD HAVE SENT A POET";
|
||||
snprintf(temp,TEMPSIZE, "%s", description);
|
||||
break;
|
||||
}
|
||||
get_vgmstream_meta_description(vgmstream, temp, TEMPSIZE);
|
||||
concatn(length,desc,temp);
|
||||
concatn(length,desc,"\n");
|
||||
|
||||
|
@ -1365,8 +1365,8 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream);
|
||||
int vgmstream_open_stream(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t start_offset);
|
||||
|
||||
/* Get description info */
|
||||
const char * get_vgmstream_coding_description(coding_t coding_type);
|
||||
const char * get_vgmstream_layout_description(layout_t layout_type);
|
||||
const char * get_vgmstream_meta_description(meta_t meta_type);
|
||||
void get_vgmstream_coding_description(VGMSTREAM *vgmstream, char *out, size_t out_size);
|
||||
void get_vgmstream_layout_description(VGMSTREAM *vgmstream, char *out, size_t out_size);
|
||||
void get_vgmstream_meta_description(VGMSTREAM *vgmstream, char *out, size_t out_size);
|
||||
|
||||
#endif
|
||||
|
@ -330,7 +330,7 @@ char * WINAPI xmplay_GetTags() {
|
||||
/* main panel info text (short file info) */
|
||||
void WINAPI xmplay_GetInfoText(char* format, char* length) {
|
||||
int rate, samples, bps;
|
||||
const char* fmt;
|
||||
char fmt[128];
|
||||
int t, tmin, tsec;
|
||||
|
||||
if (!format)
|
||||
@ -341,7 +341,7 @@ void WINAPI xmplay_GetInfoText(char* format, char* length) {
|
||||
rate = vgmstream->sample_rate;
|
||||
samples = vgmstream->num_samples;
|
||||
bps = get_vgmstream_average_bitrate(vgmstream) / 1000;
|
||||
fmt = get_vgmstream_coding_description(vgmstream->coding_type);
|
||||
get_vgmstream_coding_description(vgmstream, fmt, sizeof(fmt));
|
||||
|
||||
t = samples / rate;
|
||||
tmin = t / 60;
|
||||
|
Loading…
x
Reference in New Issue
Block a user