Waitrud Weber’s blog

things and reminders for memories

windows-make: mp4: we believe the end of jpeg in mp4 files as.

 


The end of jpeg must be the below:

0xD9:
256 - 32 = 224.
so, 232.

0xA0 = 160 so, might be 159 (at 20210918).

0x0F = 15, so, I was wrong as recognition (at 20210918).

0xDF:

256 - 32 = 223.

 

---
Tell the file end of image 0xD9 = 217 in 10.
int read_mp4 (char* filename ) ends.
void print_memories () starts.
void print_memories () ends.
---
i: 27 loop starts. p_dummy_token = |(null)| struct_fp.fp |1972870248|
char* get_string ( STRUCT_FILE structure_fp, int num ) starts.
array_count(ug_dummy)=4
001: struct_fp.fp |1972870248| struct_fp.index |27|
002: struct_fp.fp |1972870248| struct_fp.index |27|
struct_fp.fp |1972870248| array_count(ug_dummy)= 4 num=4 ug_dummy address=|4305120|
char* get_string ( STRUCT_FILE structure_fp, int num ) ends.
p_dummy array_count 4 address|4305120|
int m_start_with ( char *head, char *tail ) starts.
min 4 nh 4 nt 4
m_start_with: count: 0
int m_start_with ( char *head, char *tail ) ends as return.
int m_start_with ( char *head, char *tail ) starts.
min 4 nh 4 nt 4
m_start_with: count: 0
---
i: 27 loop starts. p_dummy_token = |(null)| struct_fp.fp |1972870248|
char* get_string ( STRUCT_FILE structure_fp, int num ) starts.
array_count(ug_dummy)=4
001: struct_fp.fp |1972870248| struct_fp.index |27|
002: struct_fp.fp |1972870248| struct_fp.index |27|
struct_fp.fp |1972870248| array_count(ug_dummy)= 4 num=4 ug_dummy address=|4305120|
char* get_string ( STRUCT_FILE structure_fp, int num ) ends.
p_dummy array_count 4 address|4305120|
int m_start_with ( char *head, char *tail ) starts.
min 4 nh 4 nt 4
m_start_with: count: 0
int m_start_with ( char *head, char *tail ) ends as return.
int m_start_with ( char *head, char *tail ) starts.
min 4 nh 4 nt 4
m_start_with: count: 0
int m_start_with ( char *head, char *tail ) ends as return.
int m_start_with ( char *head, char *tail ) starts.
min 4 nh 4 nt 4
m_start_with: count: 0
int m_start_with ( char *head, char *tail ) ends as return.
p_dummy=232 and exit.
---

 

int read_mp4_002 (char* filename ) {
	FILE *fp;
	char b_dummy[256];
	int i, j ;
	int file_end;
	STRUCT_FILE structure_fp;
	char c;
	unsigned char* p_dummy = NULL;
	char* p_dummy_token = NULL;
	int canread;
	char* block_string;
	int b_index = 0;
	char w_filename[255];
	int index = 0;
	int col = 0;
	char* typeofkey[3] = { "ftyp", "mdat", "moov" };
	int m = 0;

	printf("int read_mp4 (char* filename ) starts.\r\n");

	fp = fopen(filename, "rb");
	structure_fp.file_start = fp;
	structure_fp.fp = fp;

	file_end = filesize(fp);
	structure_fp.file_end_index = file_end;

	canread = 1;

	// Lootn check if we set 100 to the text file.
	for ( i =0; i<file_end && i <100; i++ ) {

		printf("i: %d loop starts. p_dummy_token = |%s| ", i, p_dummy_token );
		printf("struct_fp.fp |%d| \r\n", structure_fp.fp );

		structure_fp.index = i;
		p_dummy = (unsigned char*)get_string_002( structure_fp , 4);
		p_dummy[4] = '\0';

		printf( "p_dummy array_count %d address|%d|\r\n", array_count( (char*)p_dummy), (char*)p_dummy );

		for ( j = 0; j<3; j++ ) {
			if ( m_start_with ( (char*)p_dummy, (char*)typeofkey[j] ) == 1 && canread == 1 ) {
				printf("we could find |%s| as p_dummy |%s|  p_dummy[0]=|%c|%d|.\r\n", typeofkey[j], p_dummy, p_dummy[0], p_dummy[0]);
				sprintf( w_filename, "%s-001.txt", typeofkey[j] );
				printf("write filename: %s\r\n", w_filename);
				m_thread_sleep();
				write_mp4_block( w_filename, memory_allocation, m );
				m = -1;
//				exit(-1);
				break;
			}
		}

		for ( j =0 ; j<4; j++ ) {
			printf("p_dummy[%d] =|%d|\r\n", j, p_dummy[j] );
		}

		memory_allocation[m] = p_dummy[0];
		printf("p_dummy[0] = |%c| m|%d| memory_allocation %s\r\n", p_dummy[0], memory_allocation[m], memory_allocation);
		m++;
	}


	fclose ( structure_fp.fp );

	printf("Tell the file end of image 0xD9 = %d in 10.\r\n", 0xD9 ); 
	printf("int read_mp4 (char* filename ) ends.\r\n");
	return 0;
}