doc/cleanup

This commit is contained in:
bnnm 2024-07-07 21:25:21 +02:00
parent 761a759d50
commit b1b218bea5
2 changed files with 10 additions and 11 deletions

View File

@ -902,7 +902,7 @@ static int write_file(VGMSTREAM* vgmstream, cli_config* cfg) {
render_vgmstream(buf, to_get, vgmstream);
swap_samples_le(buf, channels * to_get); /* write PC endian */
fwrite(buf, sizeof(sample_t) * channels, to_get, outfile);
fwrite(buf, sizeof(sample_t), to_get * channels, outfile);
/* should write infinitely until program kill */
}
@ -930,7 +930,7 @@ static int write_file(VGMSTREAM* vgmstream, cli_config* cfg) {
if (!cfg->decode_only) {
swap_samples_le(buf, channels * to_get); /* write PC endian */
fwrite(buf, sizeof(sample_t) * channels, to_get, outfile);
fwrite(buf, sizeof(sample_t), to_get * channels, outfile);
}
}

View File

@ -438,8 +438,8 @@ fail:
*
* AVCodecContext // sample rate and general info
*
* - open avformat to get all possible info (needs file or IO)
* - open avcodec to decode based on target stream
* - open avformat to get all possible format info (needs file or custom IO)
* - open avcodec based on target stream + codec info from avformat
* - decode chunks of data (feed style)
* - read next frame into packet via avformat
* - decode packet via avcodec
@ -449,7 +449,7 @@ fail:
static int init_ffmpeg_config(ffmpeg_codec_data* data, int target_subsong, int reset) {
int errcode = 0;
/* basic IO/format setup */
/* custom IO/format setup */
data->buffer = av_malloc(FFMPEG_DEFAULT_IO_BUFFER_SIZE);
if (!data->buffer) goto fail;
@ -464,13 +464,14 @@ static int init_ffmpeg_config(ffmpeg_codec_data* data, int target_subsong, int r
//data->inputFormatCtx = av_find_input_format("h264"); /* set directly? */
/* on reset could use AVFormatContext.iformat to reload old format too */
/* format detection */
errcode = avformat_open_input(&data->formatCtx, NULL /*""*/, NULL, NULL);
if (errcode < 0) goto fail;
errcode = avformat_find_stream_info(data->formatCtx, NULL);
if (errcode < 0) goto fail;
/* find valid audio stream and set other streams to discard */
/* find valid audio stream and set other streams to be discarded */
{
int i, stream_index, stream_count;
@ -501,24 +502,22 @@ static int init_ffmpeg_config(ffmpeg_codec_data* data, int target_subsong, int r
data->stream_count = stream_count;
}
/* setup codec with stream info */
/* setup codec from stream info */
data->codecCtx = avcodec_alloc_context3(NULL);
if (!data->codecCtx) goto fail;
errcode = avcodec_parameters_to_context(data->codecCtx, data->formatCtx->streams[data->stream_index]->codecpar);
if (errcode < 0) goto fail;
/* deprecated and seemingly not needed */
//av_codec_set_pkt_timebase(data->codecCtx, stream->time_base);
//av_codec_set_pkt_timebase(data->codecCtx, stream->time_base); /* deprecated and seemingly not needed */
/* not useddeprecated and seemingly not needed */
data->codec = avcodec_find_decoder(data->codecCtx->codec_id);
if (!data->codec) goto fail;
errcode = avcodec_open2(data->codecCtx, data->codec, NULL);
if (errcode < 0) goto fail;
/* prepare codec and frame/packet buffers */
/* prepare frame/packet buffers */
data->packet = av_malloc(sizeof(AVPacket)); /* av_packet_alloc? */
if (!data->packet) goto fail;
av_new_packet(data->packet, 0);