Click here to Skip to main content
15,899,126 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
RantRe: Reusing an Incremented Variable within a Single Statement Pin
JFDR_0225-Aug-10 6:37
JFDR_0225-Aug-10 6:37 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Skippums25-Aug-10 7:04
Skippums25-Aug-10 7:04 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Niklas L25-Aug-10 8:02
Niklas L25-Aug-10 8:02 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Skippums25-Aug-10 8:08
Skippums25-Aug-10 8:08 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Niklas L25-Aug-10 8:27
Niklas L25-Aug-10 8:27 
Questiondisplaying the layout of an ogg file Pin
rukita24-Aug-10 4:40
rukita24-Aug-10 4:40 
AnswerRe: displaying the layout of an ogg file Pin
Richard MacCutchan24-Aug-10 5:31
mveRichard MacCutchan24-Aug-10 5:31 
GeneralRe: displaying the layout of an ogg file Pin
rukita24-Aug-10 22:40
rukita24-Aug-10 22:40 
hey Richard,
Thanks for your answer. i've changed my code. However i still do not know if what is dipakyed is correct or not. So, is there a way to know it? All what i know about the Ogg layout is, that an ogg page header is composed of:

Capture pattern – 32 bits
The capture pattern or sync code is a magic number used to ensure synchronisation when parsing Ogg files. Every page starts with the four ASCII character sequence OggS.

Version – 8 bits
This field indicates the version of the Ogg bitstream format. It is currently mandated to be 0.

Header type – 8 bits
This is an 8 bit field of flags, which indicates the type of page that follows. The rightmost or least significant bit is considered bit 0, with value 0x01, the next least significant digit is bit 1, with value 0x02. The third is bit 2, with value 0x04, and so on.


Granule position – 64 bits
A granule position is the time marker in Ogg files. It is an abstract value, whose meaning is determined by the codec. It may for example be a count of the number of samples, the number of frames or a more complex scheme.

Bitstream serial number – 32 bits
This field is a serial number that identifies a page as belonging to a particular logical bitstream. Each logical bitstream in a file has a unique value, and this field allows implementations to deliver the pages to the appropriate decoder.

Page sequence number – 32 bits
This field is a monotonically increasing field for each logical bitstream. The first page is 0, the second 1, etc. This allows implementations to detect when data has been lost.

Checksum – 32 bits
This field provides a checksum of the data in the entire page, performed with the checksum field set to 0.

Page segments – 8 bits
This field indicates the number of segments that exist in this page. It also indicates how many bytes are in the segment table that follows this field. There can be a maximum of 255 segments in any one page.

Segment table
The segment table is an 8 bit vector of values indicating the length of each segment within the page body. The number of segments is determined from the preceding Page Segments field. Each segment is between 0 and 255 bytes in length.


and here is my new code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

typedef struct				
{
	char magic_number[4];// Magic_number « OggS »	
	int version;// version of the ogg bitstream	 format	
	long header_type;//Indicatess the type of page that follows 	
	int granule_position;// time marker in Ogg file
    long bitstream_serial_number;//is a serial number that identifies a page belonging to a particular bitstream.
    int page_sequence_number;/*this field is a monotonically increasing field for each logical bitstream
	for example the first page is 0, the next is 1 etc..*/
    int crc;//checksum of the data in the entire page
	int page_segments;// indicates the number of segment that exists in a page
	int segment_table;// indicates the length of each segment in the page
	
} OggS;
// Prototype des fonctions
   OggS* lecture(char*) ;

   
   
   //int conv (unsigned char hex[4],int) ;
main (void)
{
	char nom[100]; //pour stocker le nom et le chemin du fichier ogg
	OggS* ogg;   //pour récupérer les infos du fichier ogg

	printf("Veuillez entrer le nom et chemin du fichier OGG sans l'extension .ogg :\n");
	gets(nom); // on récupère le nom et le chemin de l'image
	strcat(nom,".ogg"); // on ajoute l'extension .ogg à ce fichier
	ogg=lecture(nom); //on utilise la fonction lecture pour récupérer les infos 
	printf ("The magic_number is:\t %.4s\n",ogg-> magic_number); //et on les affiche en parcourant les différents champs de la structure ogg
	printf ("Version du fichier :%d\n",ogg->version);
	printf ("Le type du header du fichier :\t %d\n",ogg->header_type);
	printf ("Le granule position du fichier :\t %d\n",ogg->granule_position);
	printf ("Le bitstream_serial_number :\t%d\n",ogg->bitstream_serial_number);
	printf ("page_sequence_number :\t %d\n",ogg->page_sequence_number);
	printf ("crc :\t\t %d\n",ogg->crc);
	printf ("page_segments :\t\t %d\n",ogg->page_segments);
	printf ("segment_table :\t\t\t %d\n",ogg->segment_table);
	
	
}

OggS* lecture(char* nom)
{
	unsigned char temp[4];	// chaine de carac temporaire qui sera utilisé pour récupérer les différentes infos 	
	OggS *ogg;		// variable renvoyée par la fonction
	FILE * fichier;		// un pointeur sur FILE
	ogg=(OggS*)malloc(sizeof(OggS)); // on alloue dynamiquement le pointeur sur OggS
	fichier = fopen (nom,"r");     // on ouvre le fichier en lecture seule
	
	fread (ogg->magic_number,4,1,fichier);	// on récupère le magic number
	fread (&ogg->version,sizeof(int),1,fichier);   // version 
	
	fread (&ogg->header_type,sizeof(long),8,fichier);	// header type
	ogg->header_type = conv (temp,2);	// que l'on converti aussi 
	
	fread (&ogg->granule_position,sizeof(int),1,fichier);	// granule position
	ogg->granule_position = conv (temp,4);
	
	fread (&ogg->bitstream_serial_number,sizeof(long),1,fichier);	// bitsream-serial_number
	//ogg->bitstream_serial_number = conv(temp,4);
	
	fread (&ogg->page_sequence_number,sizeof(int),1,fichier);	// page sequence number	
	ogg->page_sequence_number = conv(temp,4);
	
	fread (&ogg->crc,sizeof(int),1,fichier);	// crc
	ogg->crc = conv (temp,2);   
	
	fread (&ogg->page_segments,sizeof(int),1,fichier);	// page segment
	ogg->page_segments = conv (temp,2);  
	
	fread (&ogg->segment_table,sizeof(int),1,fichier);	// segment table
	//ogg->segment_table = conv (temp,4);     
	
	fclose(fichier);
	return ogg;		// on retourne le pointeur sur la structure OggS
}


	
int conv (unsigned char hex[4],int nb)
{
	int res=0,i;
	for (i=nb-1;i>=0;i--)res=res*256+hex[i];
	return res;
}


please can u help me??
GeneralRe: displaying the layout of an ogg file Pin
Richard MacCutchan25-Aug-10 0:21
mveRichard MacCutchan25-Aug-10 0:21 
QuestionGetting list of user accounts Pin
David Crow24-Aug-10 4:32
David Crow24-Aug-10 4:32 
AnswerRe: Getting list of user accounts Pin
Yusuf24-Aug-10 5:09
Yusuf24-Aug-10 5:09 
QuestionReset dwDesiredAccess, Pin
gothic_coder23-Aug-10 21:47
gothic_coder23-Aug-10 21:47 
AnswerRe: Reset dwDesiredAccess, Pin
Luc Pattyn24-Aug-10 1:09
sitebuilderLuc Pattyn24-Aug-10 1:09 
GeneralRe: Reset dwDesiredAccess, Pin
gothic_coder24-Aug-10 2:17
gothic_coder24-Aug-10 2:17 
GeneralRe: Reset dwDesiredAccess, Pin
gothic_coder24-Aug-10 3:14
gothic_coder24-Aug-10 3:14 
GeneralRe: Reset dwDesiredAccess, Pin
gothic_coder25-Aug-10 22:41
gothic_coder25-Aug-10 22:41 
QuestionMessage Removed Pin
23-Aug-10 20:53
sayonee23-Aug-10 20:53 
AnswerRe: Bitmapped button functionality Pin
Peter_in_278023-Aug-10 20:56
professionalPeter_in_278023-Aug-10 20:56 
GeneralRe: Bitmapped button functionality Pin
sayonee23-Aug-10 21:05
sayonee23-Aug-10 21:05 
GeneralRe: Bitmapped button functionality Pin
Richard MacCutchan24-Aug-10 2:49
mveRichard MacCutchan24-Aug-10 2:49 
QuestionError Message Pin
ganesh_IT23-Aug-10 19:20
ganesh_IT23-Aug-10 19:20 
AnswerRe: Error Message Pin
Niklas L23-Aug-10 19:38
Niklas L23-Aug-10 19:38 
QuestionHow to check dll's reference count? Pin
Jack2009523-Aug-10 16:45
Jack2009523-Aug-10 16:45 
AnswerRe: How to check dll's reference count? Pin
Yusuf23-Aug-10 16:54
Yusuf23-Aug-10 16:54 
GeneralRe: How to check dll's reference count? Pin
Jack2009523-Aug-10 20:38
Jack2009523-Aug-10 20:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.