mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-10 05:01:50 +09:00
TAV-DT: no Zstd
This commit is contained in:
@@ -1824,12 +1824,35 @@ static int run_decoder(dt_decoder_t *dec) {
|
||||
// Main
|
||||
// =============================================================================
|
||||
|
||||
// Generate output filename by replacing extension with .mkv
|
||||
static char *generate_output_filename(const char *input_file) {
|
||||
size_t len = strlen(input_file);
|
||||
char *output = malloc(len + 5); // Worst case: add ".mkv" + null
|
||||
if (!output) return NULL;
|
||||
|
||||
strcpy(output, input_file);
|
||||
|
||||
// Find last dot in filename (not in path)
|
||||
char *last_dot = strrchr(output, '.');
|
||||
char *last_slash = strrchr(output, '/');
|
||||
|
||||
// Only replace if dot is after last slash (i.e., in filename, not path)
|
||||
if (last_dot && (!last_slash || last_dot > last_slash)) {
|
||||
strcpy(last_dot, ".mkv");
|
||||
} else {
|
||||
// No extension found, append .mkv
|
||||
strcat(output, ".mkv");
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
dt_decoder_t dec;
|
||||
memset(&dec, 0, sizeof(dec));
|
||||
|
||||
// Default thread count
|
||||
dec.num_threads = get_default_thread_count();
|
||||
dec.num_threads = 0;//get_default_thread_count();
|
||||
|
||||
// Initialize FEC libraries
|
||||
rs_init();
|
||||
@@ -1884,11 +1907,20 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
// Validate arguments
|
||||
if (!dec.input_file || !dec.output_file) {
|
||||
if (!dec.input_file) {
|
||||
fprintf(stderr, "Error: Input and output files are required\n");
|
||||
print_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Generate output filename if not provided
|
||||
if (!dec.output_file) {
|
||||
dec.output_file = generate_output_filename(dec.input_file);
|
||||
if (!dec.output_file) {
|
||||
fprintf(stderr, "Error: Failed to generate output filename\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return run_decoder(&dec);
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ int main(int argc, char *argv[]) {
|
||||
// Encode chunk using linked tad32_encode_chunk() from encoder_tad32.c
|
||||
size_t encoded_size = tad32_encode_chunk(chunk_buffer, TAD32_DEFAULT_CHUNK_SIZE,
|
||||
max_index,
|
||||
quantiser_scale, output_buffer);
|
||||
quantiser_scale, TAD32_ZSTD_LEVEL, output_buffer);
|
||||
|
||||
if (encoded_size == 0) {
|
||||
fprintf(stderr, "Error: Chunk encoding failed at chunk %zu\n", chunk_idx);
|
||||
|
||||
@@ -826,7 +826,8 @@ static int write_audio_packet(FILE *fp, cli_context_t *cli, float *pcm_samples,
|
||||
|
||||
// Encode with TAD (returns: sample_count(2) + max_index(1) + payload_size(4) + payload)
|
||||
int max_index = tad32_quality_to_max_index(cli->audio_quality);
|
||||
size_t tad_chunk_size = tad32_encode_chunk(pcm_samples, num_samples, max_index, 1.0f, tad_buffer);
|
||||
size_t tad_chunk_size = tad32_encode_chunk(pcm_samples, num_samples, max_index, 1.0f,
|
||||
cli->enc_params.zstd_level, tad_buffer);
|
||||
|
||||
if (tad_chunk_size == 0) {
|
||||
fprintf(stderr, "Error: TAD encoding failed\n");
|
||||
|
||||
@@ -556,7 +556,8 @@ static void *worker_thread_main(void *arg) {
|
||||
if (job->success && job->audio_sample_count > 0) {
|
||||
int max_index = tad32_quality_to_max_index(enc->quality_index);
|
||||
job->tad_size = tad32_encode_chunk(job->audio_samples, job->audio_sample_count,
|
||||
max_index, 1.0f, job->tad_output);
|
||||
max_index, 1.0f, enc->enc_params.zstd_level,
|
||||
job->tad_output);
|
||||
}
|
||||
|
||||
tav_encoder_free(ctx);
|
||||
@@ -783,7 +784,8 @@ static int run_encoder_st(dt_encoder_t *enc, FILE *video_pipe, FILE *audio_pipe,
|
||||
|
||||
int max_index = tad32_quality_to_max_index(enc->quality_index);
|
||||
size_t tad_size = tad32_encode_chunk(enc->audio_buffer, enc->audio_buffer_samples,
|
||||
max_index, 1.0f, tad_output);
|
||||
max_index, 1.0f, enc->enc_params.zstd_level,
|
||||
tad_output);
|
||||
|
||||
write_packet(enc, enc->current_timecode_ns,
|
||||
tad_output, tad_size,
|
||||
@@ -827,7 +829,8 @@ static int run_encoder_st(dt_encoder_t *enc, FILE *video_pipe, FILE *audio_pipe,
|
||||
if (result >= 0 && video_packet) {
|
||||
int max_index = tad32_quality_to_max_index(enc->quality_index);
|
||||
size_t tad_size = tad32_encode_chunk(enc->audio_buffer, enc->audio_buffer_samples,
|
||||
max_index, 1.0f, tad_output);
|
||||
max_index, 1.0f, enc->enc_params.zstd_level,
|
||||
tad_output);
|
||||
|
||||
write_packet(enc, enc->current_timecode_ns,
|
||||
tad_output, tad_size,
|
||||
@@ -1168,6 +1171,7 @@ static int run_encoder(dt_encoder_t *enc) {
|
||||
enc->enc_params.encoder_preset = 0x01; // Sports mode
|
||||
enc->enc_params.monoblock = 1; // Force monoblock
|
||||
enc->enc_params.verbose = enc->verbose;
|
||||
enc->enc_params.zstd_level = -1; // disable Zstd
|
||||
|
||||
// For single-threaded mode, create a context to validate params
|
||||
enc->video_ctx = tav_encoder_create(&enc->enc_params);
|
||||
|
||||
Reference in New Issue
Block a user