Commit f178b143 authored by Josh Coalson's avatar Josh Coalson

finish foreign metadata implemetation

parent 02f91ed9
This diff is collapsed.
......@@ -2098,7 +2098,7 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
}
static_metadata_append(&static_metadata, p, /*needs_delete=*/true);
static_metadata.metadata[static_metadata.num_metadata-1]->length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8 + foreign_metadata->blocks[i].size;
fprintf(stderr,"@@@@@@ add PADDING=%u\n",static_metadata.metadata[static_metadata.num_metadata-1]->length);
/*fprintf(stderr,"@@@@@@ add PADDING=%u\n",static_metadata.metadata[static_metadata.num_metadata-1]->length);*/
}
}
if(options.padding != 0) {
......
......@@ -101,6 +101,10 @@ SOURCE=.\encode.c
# End Source File
# Begin Source File
SOURCE=.\foreign_metadata.c
# End Source File
# Begin Source File
SOURCE=.\main.c
# End Source File
# Begin Source File
......@@ -133,6 +137,10 @@ SOURCE=.\encode.h
# End Source File
# Begin Source File
SOURCE=.\foreign_metadata.h
# End Source File
# Begin Source File
SOURCE=.\local_string_utils.h
# End Source File
# Begin Source File
......
......@@ -199,6 +199,10 @@
RelativePath=".\encode.h"
>
</File>
<File
RelativePath=".\foreign_metadata.h"
>
</File>
<File
RelativePath=".\local_string_utils.h"
>
......@@ -229,6 +233,10 @@
RelativePath=".\encode.c"
>
</File>
<File
RelativePath=".\foreign_metadata.c"
>
</File>
<File
RelativePath=".\local_string_utils.c"
>
......
This diff is collapsed.
......@@ -26,6 +26,9 @@
#include "FLAC/metadata.h"
#include "utils.h"
/* WATCHOUT: these enums are used to index internal arrays */
typedef enum { FOREIGN_BLOCK_TYPE__AIFF = 0, FOREIGN_BLOCK_TYPE__RIFF = 1 } foreign_block_type_t;
typedef struct {
/* for encoding, this will be the offset in the WAVE/AIFF file of the chunk */
/* for decoding, this will be the offset in the FLAC file of the chunk data inside the APPLICATION block */
......@@ -34,13 +37,15 @@ typedef struct {
} foreign_block_t;
typedef struct {
foreign_block_type_t type; /* currently we don't support multiple foreign types in a stream (an maybe never will) */
foreign_block_t *blocks;
size_t num_blocks;
size_t format_block; /* block number of 'fmt ' or 'COMM' chunk */
size_t audio_block; /* block number of 'data' or 'SSND' chunk */
FLAC__uint32 ssnd_offset_size; /* 0 if type!=AIFF */
} foreign_metadata_t;
foreign_metadata_t *flac__foreign_metadata_new(void);
foreign_metadata_t *flac__foreign_metadata_new(foreign_block_type_t type);
void flac__foreign_metadata_delete(foreign_metadata_t *fm);
......@@ -49,7 +54,6 @@ FLAC__bool flac__foreign_metadata_read_from_wave(foreign_metadata_t *fm, const c
FLAC__bool flac__foreign_metadata_write_to_flac(foreign_metadata_t *fm, const char *infilename, const char *outfilename, const char **error);
FLAC__bool flac__foreign_metadata_read_from_flac(foreign_metadata_t *fm, const char *filename, const char **error);
FLAC__bool flac__foreign_metadata_write_to_aiff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, const char **error);
FLAC__bool flac__foreign_metadata_write_to_wave(foreign_metadata_t *fm, const char *infilename, const char *outfilename, const char **error);
FLAC__bool flac__foreign_metadata_write_to_iff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, off_t offset1, off_t offset2, off_t offset3, const char **error);
#endif
......@@ -28,7 +28,6 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#if !defined _MSC_VER && !defined __MINGW32__
/* unlink is in stdio.h in VC++ */
......@@ -460,6 +459,10 @@ int do_it(void)
/* we're not going to try and support the re-creation of broken WAVE files */
if(option_values.ignore_chunk_sizes)
return usage_error("ERROR: using --keep-foreign-metadata cannot be used with --ignore-chunk-sizes\n");
if(option_values.test_only)
return usage_error("ERROR: --keep-foreign-metadata is not allowed in test mode\n");
if(option_values.analyze)
return usage_error("ERROR: --keep-foreign-metadata is not allowed in analyis mode\n");
/*@@@@@@*/
if(option_values.delete_input)
return usage_error("ERROR: using --delete-input-file with --keep-foreign-metadata has been disabled until more testing has been done.\n");
......@@ -1875,7 +1878,7 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
/* read foreign metadata if requested */
if(option_values.keep_foreign_metadata) {
if(0 == (options.foreign_metadata = flac__foreign_metadata_new())) {
if(0 == (options.foreign_metadata = flac__foreign_metadata_new(input_format==AIF? FOREIGN_BLOCK_TYPE__AIFF : FOREIGN_BLOCK_TYPE__RIFF))) {
flac__utils_printf(stderr, 1, "ERROR: creating foreign metadata object\n");
conditional_fclose(encode_infile);
return 1;
......@@ -2044,7 +2047,7 @@ int decode_file(const char *infilename)
/* read foreign metadata if requested */
if(option_values.keep_foreign_metadata) {
if(0 == (options.foreign_metadata = flac__foreign_metadata_new())) {
if(0 == (options.foreign_metadata = flac__foreign_metadata_new(output_format==AIF? FOREIGN_BLOCK_TYPE__AIFF : FOREIGN_BLOCK_TYPE__RIFF))) {
flac__utils_printf(stderr, 1, "ERROR: creating foreign metadata object\n");
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment