home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2004 March / PCWELT_3_2004.ISO / pcwsoft / flaskmpeg_078_39_src.z.exe / flaskmpeg / Misc / StatsStrings.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  6.0 KB  |  186 lines

  1. /* 
  2.  *  StatsStrings.cpp
  3.  *
  4.  *    Copyright (C) Alberto Vigata - January 2000 - ultraflask@yahoo.com
  5.  *
  6.  *  This file is part of FlasKMPEG, a free MPEG to MPEG/AVI converter
  7.  *    
  8.  *  FlasKMPEG is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  FlasKMPEG is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  21.  *
  22.  */
  23.  
  24.  
  25. #include <string.h>
  26. #include "../RunState.h"
  27. #include "../Language.h"
  28. #include "../Video/misc_tables.h"
  29. #include "StatsStrings.h"
  30.  
  31.  
  32.  
  33. extern TRunState rs;
  34.  
  35.  
  36. char *MPEGframeRateStrings[16]={
  37.                 "Unexpected",
  38.                 "FILM 23.976 fps", 
  39.                 "FILM 24 fps",   
  40.                 "PAL 25 fps",
  41.               "NTSC 29.97 fps",
  42.                 "NTSC 30 fps",     
  43.                 "PAL 50 fps",    
  44.                 "NTSC 59.94 fps",
  45.                 "NTSC 60 fps",
  46.                 "","","","","","",""
  47. };
  48.  
  49. char *MPEG2aspectStrings[16]=
  50.                 {"Unexpected", "1.0", "4:3","16:9",
  51.                 "2.21:1","","","",
  52.                 "","","","",
  53.                 "","","",""};
  54.  
  55. char *MPEG1aspectStrings[16]=
  56.                 { "Unexpected"      , "1.0",    "SAR 0.6735",     "16:9 PAL",
  57.                   "SAR 0.7615"      , "SAR 0.8055",           "16:9 NTSC",      "SAR 0.8935",
  58.                   "4:3 CCIR601 PAL" , "SAR 0.9815",           "1.0255",         "1.0695",
  59.                   "4:3 CCIR601 NTSC", "",                     "",               ""};
  60.  
  61. void RenderInaudioStatsStrings( TStatsStrings *stats )
  62. {
  63.   TAudioInfo    *Audinf;
  64.   if(!rs.audio)
  65.       Audinf = NULL;
  66.   else
  67.       Audinf = rs.audio->GetAudioInfo();
  68.  
  69.   //Audio
  70.     if (Audinf) {
  71.         sprintf( stats->InMedia.audio_sample_freq, "%d Hz", Audinf->sample_rate );
  72.     if(Audinf->format == AC3_FORMAT)
  73.     {
  74.       Audinf->subwoofer = Audinf->subwoofer ? 1 : 0;
  75.           sprintf( stats->InMedia.audio_channels, "%d.%d channels", Audinf->channels, Audinf->subwoofer );
  76.     }
  77.     else
  78.     {
  79.       sprintf( stats->InMedia.audio_channels, "%d channels", Audinf->channels);
  80.     }
  81.  
  82.         sprintf( stats->InMedia.audio_bit_rate, "%d Kbps", Audinf->bit_rate );
  83.         sprintf( stats->InMedia.audio_format, "%s", (Audinf->format == AC3_FORMAT)? "Dolby Digital" : "MPEG audio" );
  84.     }
  85.     else {
  86.         sprintf( stats->InMedia.audio_sample_freq, "N/A");
  87.         sprintf( stats->InMedia.audio_channels, "N/A");
  88.         sprintf( stats->InMedia.audio_bit_rate, "N/A");
  89.         sprintf( stats->InMedia.audio_format, "N/A");
  90.     }
  91.  
  92. }
  93. int RenderStatsStrings( TStatsStrings *stats )
  94. {
  95.    char szTemp[1024];
  96.  
  97.     if(!stats)
  98.         return 0;
  99.  
  100.     if(!rs.video)
  101.         return 0;
  102.  
  103.     TMPGVideoInfo *MPGinf;
  104.  
  105.  
  106.     MPGinf = rs.video->GetVideoInfo();
  107.     if(!MPGinf)
  108.         return 0;
  109.  
  110.  
  111. // Render InMedia
  112.     sprintf(stats->InMedia.video_width,  "%d %s", MPGinf->width, GS(LANG_STATS_PIXELS) );
  113.     sprintf(stats->InMedia.video_height, "%d %s", MPGinf->height, GS(LANG_STATS_PIXELS) );
  114.     sprintf(stats->InMedia.video_size,   "%d x %d %s", MPGinf->width, MPGinf->height, GS(LANG_STATS_PIXELS) );
  115.     //Aspect ratio
  116.     if(MPGinf->isMPEG2)
  117.         strcpy(stats->InMedia.video_aspect_ratio_information,
  118.                MPEG2aspectStrings[MPGinf->aspect_ratio_information]);
  119.     else
  120.         strcpy(stats->InMedia.video_aspect_ratio_information,
  121.                MPEG1aspectStrings[MPGinf->aspect_ratio_information]);
  122.     //Bitrate
  123.     sprintf(stats->InMedia.video_bit_rate, "%d bps",MPGinf->bit_rate_value*50*8);
  124.     //Detected Frame Rate
  125.     strcpy(stats->InMedia.video_detected_frame_rate, 
  126.            MPEGframeRateStrings[MPGinf->detected_frame_rate_code]);
  127.     //Frame Rate
  128.     strcpy(stats->InMedia.video_frame_rate, 
  129.            MPEGframeRateStrings[MPGinf->frame_rate_code]);
  130.     //Format
  131.     if(MPGinf->isMPEG2)
  132.         strcpy(stats->InMedia.video_format,  "MPEG 2");
  133.     else
  134.         strcpy(stats->InMedia.video_format,  "MPEG 1");
  135.  
  136.     //Progressive
  137.     if(MPGinf->progressive_frame)
  138.         strcpy(stats->InMedia.video_structure, GS(LANG_STATS_PROGRESSIVE) );
  139.     else
  140.         strcpy(stats->InMedia.video_structure, GS(LANG_STATS_INTERLACED) );
  141.  
  142.  
  143.   RenderInaudioStatsStrings( stats );
  144.  
  145.   // OUTPUTS
  146.   videoinfo_s vi; 
  147.   rs.plugs.outPlugs[rs.selected_out_plug].plug.floutentry( flo_getinfo, flo_getvideoinfo, (ui32)&vi);
  148.   sprintf( stats->OutMedia.video_format, vi.fmtname );
  149.  
  150.   sprintf(stats->OutMedia.video_width,  "%d %s", 0 , GS(LANG_STATS_PIXELS) );
  151.   sprintf(stats->OutMedia.video_height, "%d %s", 0 , GS(LANG_STATS_PIXELS) );
  152.  
  153.   FlPostProcess pp;
  154.   TPPost pps;
  155.   FromConfigToPPost( rs.profiler->GetSelected(), &pps, rs.video->GetWidth(), rs.video->GetHeight(), rs.video->DAR, FRAME_YV12 );
  156.   pp.Set( &pps );
  157.  
  158.   sprintf(stats->OutMedia.video_size,   "%d x %d %s", pp.GetWidth(), pp.GetHeight(), GS(LANG_STATS_PIXELS) );
  159.   
  160.  
  161.   audioinfo_s ai;
  162.   rs.plugs.outPlugs[rs.selected_out_plug].plug.floutentry( flo_getinfo, flo_getaudioinfo, (ui32)&ai);
  163.  
  164.   bool bAudio = rs.prof.audioMode == DO_AUDIO;
  165.   if( bAudio ) {
  166.       sprintf( stats->OutMedia.audio_sample_freq, "%d Hz", rs.prof.outSampleFrequency );
  167.     sprintf( stats->OutMedia.audio_channels, "%d channels (Stereo)", 2 );
  168.     sprintf( stats->OutMedia.audio_bit_rate, "N/A" );
  169.     sprintf( stats->OutMedia.audio_format, "%s", ai.fmtname );
  170.   }
  171.   else {
  172.       sprintf( stats->OutMedia.audio_sample_freq, "No Audio");
  173.     sprintf( stats->OutMedia.audio_channels, "No Audio");
  174.     sprintf( stats->OutMedia.audio_bit_rate, "No Audio" );
  175.     sprintf( stats->OutMedia.audio_format, "No Audio" );
  176.   }
  177.  
  178.   float frame_rate = (float)rs.prof.timeBase.scale / (float)rs.prof.timeBase.sampleSize;
  179.   if(rs.prof.timeBase.scale==23976)
  180.     strcpy( szTemp, "23.976" );
  181.   else
  182.     sprintf( szTemp, "%0.2f", frame_rate );
  183.   sprintf( stats->OutMedia.video_frame_rate, "%s fps", szTemp );
  184.   return 1;
  185. }
  186.