Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define MASK1 1
- #define MASK2 3
- #define MASK4 15
- #define MASK11 2047
- void mostrar_representacion(int, int);
- int main(int argc, char *argv[]){
- struct mptres{
- unsigned enfasis :2;
- unsigned original :1;
- unsigned copyright :1;
- unsigned extension_mode :2;
- unsigned channel_mode :2;
- unsigned bit_privado :1;
- unsigned padding_bit :1;
- unsigned tasa_muestreo :2;
- unsigned bitrate_index :4;
- unsigned proteccion :1;
- unsigned layer :2;
- unsigned version :2;
- unsigned frame_sync :11;
- }header;
- FILE *ptr;
- int i = 0;
- int encontrado = 0;
- ptr = fopen("/home/desing/Música/06 - Full Focus.mp3","r");
- while (!encontrado) {
- fseek(ptr, i, SEEK_SET);
- fread(&header, sizeof(int), 1, ptr);
- if(header.frame_sync == MASK11)
- encontrado = 1;
- i++;
- }
- printf("bits de sync:");
- mostrar_representacion (header.frame_sync, 11);
- printf("bits de version:");
- mostrar_representacion(header.version, 2);
- printf("bits de layer:");
- mostrar_representacion(header.layer, 2);
- printf("bit de proteccion:");
- mostrar_representacion(header.proteccion, 1);
- printf("bits de bitrate index:");
- mostrar_representacion(header.bitrate_index, 4);
- printf("bits de tasa de muestreo:");
- mostrar_representacion(header.tasa_muestreo, 2);
- printf("bit de padding:");
- mostrar_representacion(header.padding_bit, 1);
- printf("bit privado:");
- mostrar_representacion(header.bit_privado, 1);
- printf("bits de channel mode:");
- mostrar_representacion(header.channel_mode, 2);
- printf("bits de extension mode:");
- mostrar_representacion(header.extension_mode, 2);
- printf("bit de copyright:");
- mostrar_representacion(header.copyright, 1);
- printf("bit de original:");
- mostrar_representacion(header.original, 1);
- printf("bits de enfasis:");
- mostrar_representacion(header.enfasis, 2);
- return EXIT_SUCCESS;
- }
- void mostrar_representacion(int c, int k){
- int i;
- for(i = k - 1; i>=0; i--){
- if((c >> i) & 1)
- printf("1");
- else
- printf("0");
- }
- printf("\n");
- }
Add Comment
Please, Sign In to add comment