예제 #1
0
static void ext_user_data()
{
  int code,ext_ID;

  startcode();

  while ((code = showbits(32))==EXT_START_CODE || code==USER_START_CODE)
  {
    if (code==EXT_START_CODE)
    {
      flushbits32();
      ext_ID = getbits(4);
      switch (ext_ID)
      {
      case SEQ_ID:
        sequence_extension();
        break;
      case DISP_ID:
        sequence_display_extension();
        break;
      case QUANT_ID:
        quant_matrix_extension();
        break;
      case SEQSCAL_ID:
        sequence_scalable_extension();
        break;
      case PANSCAN_ID:
        picture_display_extension();
        break;
      case CODING_ID:
        picture_coding_extension();
        break;
      case SPATSCAL_ID:
        picture_spatial_scalable_extension();
        break;
      case TEMPSCAL_ID:
        picture_temporal_scalable_extension();
        break;
      default:
        fprintf(stderr,"reserved extension start code ID %d\n",ext_ID);
        break;
      }
      startcode();
    }
    else
    {
      if (verbose)
        printf("user data\n");
      flushbits32();
      startcode();
    }
  }
}
예제 #2
0
int main(int argc, char* argv[])
{
  char tmpStr[256];

  col = 0;
  verbose_level = 1;
  sequence_headers = 0;
  sequence_extensions = 0;
  user_data_bytes = 0;
  sequence_scalable_extension_present = 0;
  printf("bbVINFO - version 1.7, by Brent Beyeler ([email protected])\n");
  printf("   speed increases by, Apachez and Christian Vogelgsang\n\n");
  if (argc < 2)
  {
    printf("\nbbVINFO is an MPEG video stream analyzer\n\n");
    printf("Usage: bbVINFO  MPEG video filename  <verbose level 1..3, default = 1>\n\n");
    printf("Examples:\n");
    printf("  To list all packet start codes (excluding slice codes) to file test.txt\n");
    printf("     bbVINFO test.mpg 1 > test.txt\n\n");
    printf("  To list all packets (excluding slice packets) in detail\n");
    printf("     bbVINFO test.vob 2\n\n");
    printf("  To list all packets (including slice packets) in detail to file test.txt\n");
    printf("     bbVINFO test.mpg 3 > test.txt\n\n");
	 exit (1);
  }

  init_getbits(argv[1]);
  strcpy(tmpStr, argv[1]);
//  strlwr(tmpStr);
  if (argc > 2)
  {
    sscanf(argv[2], "%d", &verbose_level);

    if (verbose_level < 1)
      verbose_level = 1;
    if (verbose_level > 3)
      verbose_level = 3;
  }

  next_start_code();
  if (getbits(8) != SEQUENCE_HEADER_CODE)
  {
    printf("\nFile is not an MPEG Video Stream\n");
    exit(1);
  }

  next_start_code();

  if (getbits(8) != EXTENSION_START_CODE)
    mpeg2 = 0;
  else
    mpeg2 = 1;

  printf("\nFile %s is an MPEG-%d video stream\n", argv[1], mpeg2 + 1);

  finish_getbits();
  init_getbits(argv[1]);

  next_start_code();
  sequence_header();

  if (mpeg2)
    sequence_extension();

  do
  {
    extension_and_user_data(0);
    do
    {
      if (nextbits(8) == GROUP_START_CODE)
      {
        group_of_pictures_header();
        extension_and_user_data(1);
      }
      picture_header();
      if (mpeg2)
        picture_coding_extension();
      extension_and_user_data(2);
      picture_data();
    } while ((nextbits(8) == PICTURE_START_CODE) ||
             (nextbits(8) == GROUP_START_CODE));
    if (nextbits(8) != SEQUENCE_END_CODE)
    {
      sequence_header();
      if (mpeg2)
        sequence_extension();
    }
  } while (nextbits(8) != SEQUENCE_END_CODE);
  zprintf(1, "\nsequence_end_code = 0x000001%02X\n", getbits(8));

  finish_getbits();
  return (0);
}