⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bincue.c

📁 linux下的MPEG1
💻 C
📖 第 1 页 / 共 3 页
字号:
		break;	      default:		cd->disc_mode = CDIO_DISC_MODE_ERROR;	      }	    }	  } else if (0 == strcmp ("MODE1/2048", psz_field)) {	    if (cd) {	      this_track->mode        = MODE1;	      this_track->blocksize   = 2048;	      this_track->track_format= TRACK_FORMAT_DATA;	      this_track->track_green = false;	      /* Is the below correct? */	      this_track->datastart   = 0;         	      this_track->datasize    = CDIO_CD_FRAMESIZE;	      this_track->endsize     = 0;  	      switch(cd->disc_mode) {	      case CDIO_DISC_MODE_NO_INFO:		cd->disc_mode = CDIO_DISC_MODE_CD_DATA;		break;	      case CDIO_DISC_MODE_CD_DATA:	      case CDIO_DISC_MODE_CD_MIXED:	      case CDIO_DISC_MODE_ERROR:		/* Disc type stays the same. */		break;	      case CDIO_DISC_MODE_CD_DA:	      case CDIO_DISC_MODE_CD_XA:		cd->disc_mode = CDIO_DISC_MODE_CD_MIXED;		break;	      default:		cd->disc_mode = CDIO_DISC_MODE_ERROR;	      }	    }	  } else if (0 == strcmp ("MODE1/2352", psz_field)) {	    if (cd) {	      this_track->blocksize   = 2352;	      this_track->track_format= TRACK_FORMAT_DATA;	      this_track->track_green = false;	      this_track->datastart   = CDIO_CD_SYNC_SIZE 		+ CDIO_CD_HEADER_SIZE;	      this_track->datasize    = CDIO_CD_FRAMESIZE; 	      this_track->endsize     = CDIO_CD_EDC_SIZE 		+ CDIO_CD_M1F1_ZERO_SIZE + CDIO_CD_ECC_SIZE;	      this_track->mode        = MODE1_RAW; 	      switch(cd->disc_mode) {	      case CDIO_DISC_MODE_NO_INFO:		cd->disc_mode = CDIO_DISC_MODE_CD_DATA;		break;	      case CDIO_DISC_MODE_CD_DATA:	      case CDIO_DISC_MODE_CD_MIXED:	      case CDIO_DISC_MODE_ERROR:		/* Disc type stays the same. */		break;	      case CDIO_DISC_MODE_CD_DA:	      case CDIO_DISC_MODE_CD_XA:		cd->disc_mode = CDIO_DISC_MODE_CD_MIXED;		break;	      default:		cd->disc_mode = CDIO_DISC_MODE_ERROR;	      }	    }	  } else if (0 == strcmp ("MODE2/2336", psz_field)) {	    if (cd) {	      this_track->blocksize   = 2336;	      this_track->track_format= TRACK_FORMAT_XA;	      this_track->track_green = true;	      this_track->mode        = MODE2;	      this_track->datastart   = CDIO_CD_SYNC_SIZE 		+ CDIO_CD_HEADER_SIZE;	      this_track->datasize    = M2RAW_SECTOR_SIZE;  	      this_track->endsize     = 0;	      switch(cd->disc_mode) {	      case CDIO_DISC_MODE_NO_INFO:		cd->disc_mode = CDIO_DISC_MODE_CD_DATA;		break;	      case CDIO_DISC_MODE_CD_DATA:	      case CDIO_DISC_MODE_CD_MIXED:	      case CDIO_DISC_MODE_ERROR:		/* Disc type stays the same. */		break;	      case CDIO_DISC_MODE_CD_DA:	      case CDIO_DISC_MODE_CD_XA:		cd->disc_mode = CDIO_DISC_MODE_CD_MIXED;		break;	      default:		cd->disc_mode = CDIO_DISC_MODE_ERROR;	      }	    }	  } else if (0 == strcmp ("MODE2/2048", psz_field)) {	    if (cd) {	      this_track->blocksize   = 2048;	      this_track->track_format= TRACK_FORMAT_XA;	      this_track->track_green = true;	      this_track->mode        = MODE2_FORM1;	      switch(cd->disc_mode) {	      case CDIO_DISC_MODE_NO_INFO:		cd->disc_mode = CDIO_DISC_MODE_CD_XA;		break;	      case CDIO_DISC_MODE_CD_XA:	      case CDIO_DISC_MODE_CD_MIXED:	      case CDIO_DISC_MODE_ERROR:		/* Disc type stays the same. */		break;	      case CDIO_DISC_MODE_CD_DA:	      case CDIO_DISC_MODE_CD_DATA:		cd->disc_mode = CDIO_DISC_MODE_CD_MIXED;		break;	      default:		cd->disc_mode = CDIO_DISC_MODE_ERROR;	      }	    }	  } else if (0 == strcmp ("MODE2/2324", psz_field)) {	    if (cd) {	      this_track->blocksize   = 2324;	      this_track->track_format= TRACK_FORMAT_XA;	      this_track->track_green = true;	      this_track->mode        = MODE2_FORM2;	      switch(cd->disc_mode) {	      case CDIO_DISC_MODE_NO_INFO:		cd->disc_mode = CDIO_DISC_MODE_CD_XA;		break;	      case CDIO_DISC_MODE_CD_XA:	      case CDIO_DISC_MODE_CD_MIXED:	      case CDIO_DISC_MODE_ERROR:		/* Disc type stays the same. */		break;	      case CDIO_DISC_MODE_CD_DA:	      case CDIO_DISC_MODE_CD_DATA:		cd->disc_mode = CDIO_DISC_MODE_CD_MIXED;		break;	      default:		cd->disc_mode = CDIO_DISC_MODE_ERROR;	      }	    }	  } else if (0 == strcmp ("MODE2/2336", psz_field)) {	    if (cd) {	      this_track->blocksize   = 2336;	      this_track->track_format= TRACK_FORMAT_XA;	      this_track->track_green = true;	      this_track->mode        = MODE2_FORM_MIX;	      this_track->datastart   = CDIO_CD_SYNC_SIZE 		+ CDIO_CD_HEADER_SIZE;	      this_track->datasize    = M2RAW_SECTOR_SIZE;  	      this_track->endsize     = 0;	      switch(cd->disc_mode) {	      case CDIO_DISC_MODE_NO_INFO:		cd->disc_mode = CDIO_DISC_MODE_CD_XA;		break;	      case CDIO_DISC_MODE_CD_XA:	      case CDIO_DISC_MODE_CD_MIXED:	      case CDIO_DISC_MODE_ERROR:		/* Disc type stays the same. */		break;	      case CDIO_DISC_MODE_CD_DA:	      case CDIO_DISC_MODE_CD_DATA:		cd->disc_mode = CDIO_DISC_MODE_CD_MIXED;		break;	      default:		cd->disc_mode = CDIO_DISC_MODE_ERROR;	      }	    }	  } else if (0 == strcmp ("MODE2/2352", psz_field)) {	    if (cd) {	      this_track->blocksize   = 2352;	      this_track->track_format= TRACK_FORMAT_XA;	      this_track->track_green = true;	      this_track->mode        = MODE2_RAW;	      this_track->datastart   = CDIO_CD_SYNC_SIZE 		+ CDIO_CD_HEADER_SIZE + CDIO_CD_SUBHEADER_SIZE;	      this_track->datasize    = CDIO_CD_FRAMESIZE;	      this_track->endsize     = CDIO_CD_SYNC_SIZE + CDIO_CD_ECC_SIZE;	      switch(cd->disc_mode) {	      case CDIO_DISC_MODE_NO_INFO:		cd->disc_mode = CDIO_DISC_MODE_CD_XA;		break;	      case CDIO_DISC_MODE_CD_XA:	      case CDIO_DISC_MODE_CD_MIXED:	      case CDIO_DISC_MODE_ERROR:		/* Disc type stays the same. */		break;	      case CDIO_DISC_MODE_CD_DA:	      case CDIO_DISC_MODE_CD_DATA:		cd->disc_mode = CDIO_DISC_MODE_CD_MIXED;		break;	      default:		cd->disc_mode = CDIO_DISC_MODE_ERROR;	      }	    }	  } else {	    cdio_log(log_level, 		     "%s line %d after word TRACK:",		     psz_cue_name, i_line);	    cdio_log(log_level, 		     "Unknown track mode %s", psz_field);	    goto err_exit;	  }	} else {	  goto format_error;	}		/* FLAGS flag1 flag2 ... */      } else if (0 == strcmp ("FLAGS", psz_keyword)) {	if (0 <= i) {	  while (NULL != (psz_field = strtok (NULL, " \t\n\r"))) {	    if (0 == strcmp ("PRE", psz_field)) {	      if (cd) cd->tocent[i].flags |= PRE_EMPHASIS;	    } else if (0 == strcmp ("DCP", psz_field)) {	      if (cd) cd->tocent[i].flags |= COPY_PERMITTED;	    } else if (0 == strcmp ("4CH", psz_field)) {	      if (cd) cd->tocent[i].flags |= FOUR_CHANNEL_AUDIO;	    } else if (0 == strcmp ("SCMS", psz_field)) {	      if (cd) cd->tocent[i].flags |= SCMS;	    } else {	      goto format_error;	    }	  }	} else {	  goto format_error;	}		/* ISRC CCOOOYYSSSSS */      } else if (0 == strcmp ("ISRC", psz_keyword)) {	if (0 <= i) {	  if (NULL != (psz_field = strtok (NULL, " \t\n\r"))) {	    if (cd) cd->tocent[i].isrc = strdup (psz_field);	  } else {	    goto format_error;	  }	} else {	  goto in_global_section;	}		/* PREGAP MM:SS:FF */      } else if (0 == strcmp ("PREGAP", psz_keyword)) {	if (0 <= i) {	  if (NULL != (psz_field = strtok (NULL, " \t\n\r"))) {	    lba_t lba = cdio_lsn_to_lba(cdio_mmssff_to_lba (psz_field));	    if (CDIO_INVALID_LBA == lba) {	      cdio_log(log_level, "%s line %d: after word PREGAP:", 		       psz_cue_name, i_line);	      cdio_log(log_level, "Invalid MSF string %s", 		       psz_field);	      goto err_exit;	    }	    if (cd) {	      cd->tocent[i].pregap = lba;	    }	  } else {	    goto format_error;	  } if (NULL != (psz_field = strtok (NULL, " \t\n\r"))) {	    goto format_error;	  }	} else {	  goto in_global_section;	}		/* INDEX [##] MM:SS:FF */      } else if (0 == strcmp ("INDEX", psz_keyword)) {	if (0 <= i) {	  if (NULL != (psz_field = strtok (NULL, " \t\n\r")))	    if (1!=sscanf(psz_field, "%d", &start_index)) {	      cdio_log(log_level, 		       "%s line %d after word INDEX:",		       psz_cue_name, i_line);	      cdio_log(log_level, 		       "expecting an index number, got %s", 		       psz_field);	      goto err_exit;	    }	  if (NULL != (psz_field = strtok (NULL, " \t\n\r"))) {	    lba_t lba = cdio_mmssff_to_lba (psz_field);	    if (CDIO_INVALID_LBA == lba) {	      cdio_log(log_level, "%s line %d: after word INDEX:", 		       psz_cue_name, i_line);	      cdio_log(log_level, "Invalid MSF string %s", 		       psz_field);	      goto err_exit;	    }	    if (cd) {#if FIXED_ME	      cd->tocent[i].indexes[cd->tocent[i].nindex++] = lba;#else     	      track_info_t  *this_track=		&(cd->tocent[cd->gen.i_tracks - cd->gen.i_first_track]);	      if (start_index != 0) {		if (!b_first_index_for_track) {		  lba += CDIO_PREGAP_SECTORS;		  cdio_lba_to_msf(lba, &(this_track->start_msf));		  b_first_index_for_track = true;		  this_track->start_lba   = lba;		}				if (cd->gen.i_tracks > 1) {		  /* Figure out number of sectors for previous track */		  track_info_t *prev_track=&(cd->tocent[cd->gen.i_tracks-2]);		  if ( this_track->start_lba < prev_track->start_lba ) {		    cdio_log (log_level,			      "track %d at LBA %lu starts before track %d at LBA %lu", 			      cd->gen.i_tracks,   			      (unsigned long int) this_track->start_lba, 			      cd->gen.i_tracks, 			      (unsigned long int) prev_track->start_lba);		    prev_track->sec_count = 0;		  } else if ( this_track->start_lba >= prev_track->start_lba 			      + CDIO_PREGAP_SECTORS ) {		    prev_track->sec_count = this_track->start_lba - 		      prev_track->start_lba - CDIO_PREGAP_SECTORS ;		  } else {		    cdio_log (log_level, 			      "%lu fewer than pregap (%d) sectors in track %d",			      (long unsigned int) 			      this_track->start_lba - prev_track->start_lba,			      CDIO_PREGAP_SECTORS,			      cd->gen.i_tracks);		    /* Include pregap portion in sec_count. Maybe the pregap		       was omitted. */		    prev_track->sec_count = this_track->start_lba - 		      prev_track->start_lba;		  }		}		this_track->num_indices++;	      }	    }#endif  	  } else {	    goto format_error;	  }	} else {	  goto in_global_section;	}		/* CD-TEXT */      } else if ( CDTEXT_INVALID != 		  (cdtext_key = cdtext_is_keyword (psz_keyword)) ) {	if (-1 == i) {	  if (cd) {	    cdtext_set (cdtext_key, 			strtok (NULL, "\"\t\n\r"), 			&(cd->gen.cdtext));	  }	} else {	  if (cd) {	    cdtext_set (cdtext_key, strtok (NULL, "\"\t\n\r"), 			&(cd->gen.cdtext_track[i]));	  }	}		/* unrecognized line */      } else {	cdio_log(log_level, "%s line %d: warning: unrecognized keyword: %s", 		 psz_cue_name, i_line, psz_keyword);	goto err_exit;      }    }  }  if (NULL != cd) {    cd->gen.toc_init = true;  }  fclose (fp);  return true; format_error:  cdio_log(log_level, "%s line %d after word %s", 	   psz_cue_name, i_line, psz_keyword);  goto err_exit; in_global_section:  cdio_log(log_level, "%s line %d: word %s not allowed in global section", 	   psz_cue_name, i_line, psz_keyword);  goto err_exit; not_in_global_section:  cdio_log(log_level, "%s line %d: word %s only allowed in global section", 	   psz_cue_name, i_line, psz_keyword); err_exit:   fclose (fp);  return false;}/*!   Reads a single audio sector from CD device into data starting   from lsn. Returns 0 if no error.  */static int_read_audio_sectors_bincue (void *user_data, void *data, lsn_t lsn, 			  unsigned int nblocks){  _img_private_t *env = user_data;  int ret;  /* Why the adjustment of 272, I don't know. It seems to work though */  if (lsn != 0) {    ret = cdio_stream_seek (env->gen.data_source, 			    (lsn * CDIO_CD_FRAMESIZE_RAW) - 272, SEEK_SET);    if (ret!=0) return ret;    ret = cdio_stream_read (env->gen.data_source, data, 			    CDIO_CD_FRAMESIZE_RAW, nblocks);  } else {    /* We need to pad out the first 272 bytes with 0's */    BZERO(data, 272);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -