[MPlayer-dev-eng] [PATCH 5/5] Various rectifications uncrustify wasn't able to do.

Clément Bœsch ubitux at gmail.com
Sat Apr 16 00:02:53 CEST 2011


Due to uncrustify and A.I. limitations, humans are still needed
sometimes.
---
 mplayer.c |  283 +++++++++++++++++++++++++------------------------------------
 1 files changed, 114 insertions(+), 169 deletions(-)

diff --git a/mplayer.c b/mplayer.c
index 2d1386d..64e1990 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -453,16 +453,11 @@ char *get_metadata(metadata_t type)
         return strdup(mp_basename(filename));
 
     case META_VIDEO_CODEC:
-        if (sh_video->format == 0x10000001)
-            return strdup("mpeg1");
-        else if (sh_video->format == 0x10000002)
-            return strdup("mpeg2");
-        else if (sh_video->format == 0x10000004)
-            return strdup("mpeg4");
-        else if (sh_video->format == 0x10000005)
-            return strdup("h264");
-        else if (sh_video->format >= 0x20202020)
-            return mp_asprintf("%.4s", (char *)&sh_video->format);
+             if (sh_video->format == 0x10000001) return strdup("mpeg1");
+        else if (sh_video->format == 0x10000002) return strdup("mpeg2");
+        else if (sh_video->format == 0x10000004) return strdup("mpeg4");
+        else if (sh_video->format == 0x10000005) return strdup("h264");
+        else if (sh_video->format >= 0x20202020) return mp_asprintf("%.4s", (char *)&sh_video->format);
         return mp_asprintf("0x%08X", sh_video->format);
 
     case META_VIDEO_BITRATE:
@@ -483,26 +478,13 @@ char *get_metadata(metadata_t type)
         return mp_asprintf("%d Hz, %d ch.", sh_audio->samplerate, sh_audio->channels);
 
     /* check for valid demuxer */
-    case META_INFO_TITLE:
-        return get_demuxer_info("Title");
-
-    case META_INFO_ARTIST:
-        return get_demuxer_info("Artist");
-
-    case META_INFO_ALBUM:
-        return get_demuxer_info("Album");
-
-    case META_INFO_YEAR:
-        return get_demuxer_info("Year");
-
-    case META_INFO_COMMENT:
-        return get_demuxer_info("Comment");
-
-    case META_INFO_TRACK:
-        return get_demuxer_info("Track");
-
-    case META_INFO_GENRE:
-        return get_demuxer_info("Genre");
+    case META_INFO_TITLE:   return get_demuxer_info("Title");
+    case META_INFO_ARTIST:  return get_demuxer_info("Artist");
+    case META_INFO_ALBUM:   return get_demuxer_info("Album");
+    case META_INFO_YEAR:    return get_demuxer_info("Year");
+    case META_INFO_COMMENT: return get_demuxer_info("Comment");
+    case META_INFO_TRACK:   return get_demuxer_info("Track");
+    case META_INFO_GENRE:   return get_demuxer_info("Genre");
 
     default:
         break;
@@ -520,14 +502,14 @@ static void print_file_properties(const MPContext *mpctx, const char *filename)
     if (mpctx->sh_video) {
         /* Assume FOURCC if all bytes >= 0x20 (' ') */
         if (mpctx->sh_video->format >= 0x20202020)
-            mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_FORMAT=%.4s\n", (char *)&mpctx->sh_video->format);
+            mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_FORMAT=%.4s\n",   (char *)&mpctx->sh_video->format);
         else
             mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_FORMAT=0x%08X\n", mpctx->sh_video->format);
-        mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_BITRATE=%d\n", mpctx->sh_video->i_bps * 8);
-        mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_WIDTH=%d\n", mpctx->sh_video->disp_w);
-        mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_HEIGHT=%d\n", mpctx->sh_video->disp_h);
-        mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_FPS=%5.3f\n", mpctx->sh_video->fps);
-        mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n", mpctx->sh_video->aspect);
+        mp_msg(MSGT_IDENTIFY, MSGL_INFO,     "ID_VIDEO_BITRATE=%d\n",    mpctx->sh_video->i_bps * 8);
+        mp_msg(MSGT_IDENTIFY, MSGL_INFO,     "ID_VIDEO_WIDTH=%d\n",      mpctx->sh_video->disp_w);
+        mp_msg(MSGT_IDENTIFY, MSGL_INFO,     "ID_VIDEO_HEIGHT=%d\n",     mpctx->sh_video->disp_h);
+        mp_msg(MSGT_IDENTIFY, MSGL_INFO,     "ID_VIDEO_FPS=%5.3f\n",     mpctx->sh_video->fps);
+        mp_msg(MSGT_IDENTIFY, MSGL_INFO,     "ID_VIDEO_ASPECT=%1.4f\n",  mpctx->sh_video->aspect);
         video_start_pts = ds_get_next_pts(mpctx->d_video);
     }
     if (mpctx->sh_audio) {
@@ -535,10 +517,10 @@ static void print_file_properties(const MPContext *mpctx, const char *filename)
         if (mpctx->sh_audio->format >= 0x20202020)
             mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_FORMAT=%.4s\n", (char *)&mpctx->sh_audio->format);
         else
-            mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_FORMAT=%d\n", mpctx->sh_audio->format);
-        mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_BITRATE=%d\n", mpctx->sh_audio->i_bps * 8);
-        mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_RATE=%d\n", mpctx->sh_audio->samplerate);
-        mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_NCH=%d\n", mpctx->sh_audio->channels);
+            mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_FORMAT=%d\n",   mpctx->sh_audio->format);
+        mp_msg(MSGT_IDENTIFY, MSGL_INFO,     "ID_AUDIO_BITRATE=%d\n",  mpctx->sh_audio->i_bps * 8);
+        mp_msg(MSGT_IDENTIFY, MSGL_INFO,     "ID_AUDIO_RATE=%d\n",     mpctx->sh_audio->samplerate);
+        mp_msg(MSGT_IDENTIFY, MSGL_INFO,     "ID_AUDIO_NCH=%d\n",      mpctx->sh_audio->channels);
         start_pts = ds_get_next_pts(mpctx->d_audio);
     }
     if (video_start_pts != MP_NOPTS_VALUE) {
@@ -565,13 +547,12 @@ static void mp_dvdnav_context_free(MPContext *ctx)
 {
     if (ctx->nav_smpi)
         free_mp_image(ctx->nav_smpi);
-    ctx->nav_smpi = NULL;
-    free(ctx->nav_buffer);
+    ctx->nav_smpi    = NULL;
     ctx->nav_buffer  = NULL;
     ctx->nav_start   = NULL;
     ctx->nav_in_size = 0;
+    free(ctx->nav_buffer);
 }
-
 #endif
 
 void uninit_player(unsigned int mask)
@@ -725,10 +706,10 @@ void exit_player_with_rc(enum exit_reason how, int rc)
 
     current_module = "exit_player";
 
-// free mplayer config
-    if (mconfig)
+    if (mconfig) {
         m_config_free(mconfig);
-    mconfig = NULL;
+        mconfig = NULL;
+    }
 
     if (mpctx->playtree_iter)
         play_tree_iter_free(mpctx->playtree_iter);
@@ -769,7 +750,7 @@ void exit_player(enum exit_reason how)
 static void child_sighandler(int x)
 {
     pid_t pid;
-    while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) ;
+    while ((pid = waitpid(-1, NULL, WNOHANG)) > 0);
 }
 
 #endif
@@ -1027,14 +1008,11 @@ static int playtree_add_playlist(play_tree_t *entry)
     {
         if (!entry) {
             entry = mpctx->playtree_iter->tree;
-            if (play_tree_iter_step(mpctx->playtree_iter, 1, 0) != PLAY_TREE_ITER_ENTRY) {
+            if (play_tree_iter_step(mpctx->playtree_iter, 1, 0) != PLAY_TREE_ITER_ENTRY)
                 return PT_NEXT_ENTRY;
-            }
-            if (mpctx->playtree_iter->tree == entry) { // Loop with a single file
-                if (play_tree_iter_up_step(mpctx->playtree_iter, 1, 0) != PLAY_TREE_ITER_ENTRY) {
+            if (mpctx->playtree_iter->tree == entry) // Loop with a single file
+                if (play_tree_iter_up_step(mpctx->playtree_iter, 1, 0) != PLAY_TREE_ITER_ENTRY)
                     return PT_NEXT_ENTRY;
-                }
-            }
             play_tree_remove(entry, 1, 1);
             return PT_NEXT_SRC;
         }
@@ -1056,9 +1034,8 @@ void add_subtitles(char *filename, float fps, int noerr)
     ASS_Track *asst = 0;
 #endif
 
-    if (filename == NULL || mpctx->set_of_sub_size >= MAX_SUBTITLE_FILES) {
+    if (filename == NULL || mpctx->set_of_sub_size >= MAX_SUBTITLE_FILES)
         return;
-    }
 
     subd = sub_read_file(filename, fps);
 #ifdef CONFIG_ASS
@@ -1600,24 +1577,23 @@ static void update_osd_msg(void)
                 percentage_text[0] = 0;
 
             if (osd_fractions == 1) {
-                //print fractions as sub-second timestamp
+                // print fractions as sub-second timestamp
                 snprintf(fractions_text, sizeof(fractions_text), ".%02d",
                          (int)((mpctx->sh_video->pts - pts) * 100 + 0.5)
                          % 100);
             } else if (osd_fractions == 2) {
-                //print fractions by estimating the frame count within the
-                //second
-
-                //rounding or cutting off numbers after the decimal point
-                //causes problems because of float's precision and movies,
-                //whose first frame is not exactly at timestamp 0. Therefore,
-                //we add 0.2 and cut off at the decimal point, which proved
-                //as good heuristic
+                // print fractions by estimating the frame count within the
+                // second.
+                // Rounding or cutting off numbers after the decimal point
+                // causes problems because of float's precision and movies,
+                // whose first frame is not exactly at timestamp 0. Therefore,
+                // we add 0.2 and cut off at the decimal point, which proved
+                // as good heuristic.
                 snprintf(fractions_text, sizeof(fractions_text), ".%02d",
                          (int)((mpctx->sh_video->pts - pts) *
                                mpctx->sh_video->fps + 0.2));
             } else {
-                //do not print fractions
+                // do not print fractions
                 fractions_text[0] = 0;
             }
 
@@ -1662,9 +1638,8 @@ void reinit_audio_chain(void)
     if (!(initialized_flags & INITIALIZED_ACODEC)) {
         current_module = "init_audio_codec";
         mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n");
-        if (!init_best_audio_codec(mpctx->sh_audio, audio_codec_list, audio_fm_list)) {
+        if (!init_best_audio_codec(mpctx->sh_audio, audio_codec_list, audio_fm_list))
             goto init_error;
-        }
         initialized_flags |= INITIALIZED_ACODEC;
         mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n");
     }
@@ -1775,8 +1750,9 @@ static int check_framedrop(double frame_time)
             ++drop_frame_cnt;
             ++dropped_frames;
             return frame_dropping;
-        } else
+        } else {
             dropped_frames = 0;
+        }
     }
     return 0;
 }
@@ -1903,22 +1879,22 @@ static int select_subtitle(MPContext *mpctx)
 #ifndef FF_B_TYPE
 #define FF_B_TYPE 3
 #endif
-/// store decoded video image
+// store decoded video image
 static mp_image_t *mp_dvdnav_copy_mpi(mp_image_t *to_mpi,
                                       mp_image_t *from_mpi)
 {
     mp_image_t *mpi;
 
-    /// Do not store B-frames
+    // Do not store B-frames
     if (from_mpi->pict_type == FF_B_TYPE)
         return to_mpi;
 
     if (to_mpi &&
         to_mpi->w == from_mpi->w &&
         to_mpi->h == from_mpi->h &&
-        to_mpi->imgfmt == from_mpi->imgfmt)
+        to_mpi->imgfmt == from_mpi->imgfmt) {
         mpi = to_mpi;
-    else {
+    } else {
         if (to_mpi)
             free_mp_image(to_mpi);
         if (from_mpi->w == 0 || from_mpi->h == 0)
@@ -1933,7 +1909,7 @@ static mp_image_t *mp_dvdnav_copy_mpi(mp_image_t *to_mpi,
 static void mp_dvdnav_reset_stream(MPContext *ctx)
 {
     if (ctx->sh_video) {
-        /// clear video pts
+        // clear video pts
         ctx->d_video->pts                 = 0.0f;
         ctx->sh_video->pts                = 0.0f;
         ctx->sh_video->i_pts              = 0.0f;
@@ -1948,7 +1924,7 @@ static void mp_dvdnav_reset_stream(MPContext *ctx)
     }
 
     if (ctx->sh_audio) {
-        /// free audio packets and reset
+        // free audio packets and reset
         ds_free_packs(ctx->d_audio);
         audio_delay -= ctx->sh_audio->stream_delay;
         ctx->delay   = -audio_delay;
@@ -1966,11 +1942,11 @@ static void mp_dvdnav_reset_stream(MPContext *ctx)
         }
     }
 
-    /// clear all EOF related flags
+    // clear all EOF related flags
     ctx->d_video->eof = ctx->d_audio->eof = ctx->stream->eof = 0;
 }
 
-/// Restore last decoded DVDNAV (still frame)
+// Restore last decoded DVDNAV (still frame)
 static mp_image_t *mp_dvdnav_restore_smpi(int *in_size,
                                           unsigned char **start,
                                           mp_image_t *decoded_frame)
@@ -1978,7 +1954,7 @@ static mp_image_t *mp_dvdnav_restore_smpi(int *in_size,
     if (mpctx->stream->type != STREAMTYPE_DVDNAV)
         return decoded_frame;
 
-    /// a change occured in dvdnav stream
+    // a change occured in dvdnav stream
     if (mp_dvdnav_cell_has_changed(mpctx->stream, 0)) {
         mp_dvdnav_read_wait(mpctx->stream, 1, 1);
         mp_dvdnav_context_free(mpctx);
@@ -1990,11 +1966,11 @@ static mp_image_t *mp_dvdnav_restore_smpi(int *in_size,
     if (*in_size < 0) {
         float len;
 
-        /// Display still frame, if any
+        // Display still frame, if any
         if (mpctx->nav_smpi && !mpctx->nav_buffer)
             decoded_frame = mpctx->nav_smpi;
 
-        /// increment video frame : continue playing after still frame
+        // increment video frame : continue playing after still frame
         len = demuxer_get_time_length(mpctx->demuxer);
         if (mpctx->sh_video->pts >= len &&
             mpctx->sh_video->pts > 0.0 && len > 0.0) {
@@ -2014,7 +1990,7 @@ static mp_image_t *mp_dvdnav_restore_smpi(int *in_size,
     return decoded_frame;
 }
 
-/// Save last decoded DVDNAV (still frame)
+// Save last decoded DVDNAV (still frame)
 static void mp_dvdnav_save_smpi(int in_size,
                                 unsigned char *start,
                                 mp_image_t *decoded_frame)
@@ -2283,7 +2259,7 @@ int reinit_video_chain(void)
     if (!fixed_vo || !(initialized_flags & INITIALIZED_VO)) {
         current_module = "preinit_libvo";
 
-        //shouldn't we set dvideo->id=-2 when we fail?
+        // shouldn't we set dvideo->id=-2 when we fail?
         vo_config_count = 0;
         //if((mpctx->video_out->preinit(vo_subdevice))!=0){
         if (!(mpctx->video_out = init_best_video_out(video_driver_list))) {
@@ -2404,7 +2380,7 @@ static double update_video(int *blit_frame)
             in_size        = video_read_frame(sh_video, &sh_video->next_frame_time,
                                               &start, force_fps);
 #ifdef CONFIG_DVDNAV
-            /// wait, still frame or EOF
+            // wait, still frame or EOF
             if (mpctx->stream->type == STREAMTYPE_DVDNAV && in_size < 0) {
                 if (mp_dvdnav_is_eof(mpctx->stream))
                     return -1;
@@ -2424,7 +2400,7 @@ static double update_video(int *blit_frame)
 #ifdef CONFIG_DVDNAV
             full_frame    = 1;
             decoded_frame = mp_dvdnav_restore_smpi(&in_size, &start, decoded_frame);
-            /// still frame has been reached, no need to decode
+            // still frame has been reached, no need to decode
             if (in_size > 0 && !decoded_frame)
 #endif
             decoded_frame = decode_video(sh_video, start, in_size, drop_frame,
@@ -2464,7 +2440,7 @@ static double update_video(int *blit_frame)
                 update_osd_msg();
             }
 #ifdef CONFIG_DVDNAV
-            /// save back last still frame for future display
+            // save back last still frame for future display
             mp_dvdnav_save_smpi(in_size, start, decoded_frame);
 #endif
         } while (!full_frame);
@@ -2559,9 +2535,10 @@ static void pause_loop(void)
                     set_osd_msg(OSD_MSG_PAUSE, 1, 0, MSGTR_Paused " %d%%",
                                 new_cache_fill);
                     update_osd_msg();
-                } else
+                } else {
                     mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_Paused " %d%%\r",
                            new_cache_fill);
+                }
                 old_cache_fill = new_cache_fill;
             }
         }
@@ -2608,9 +2585,8 @@ static void edl_loadfile(void)
 // Execute EDL command for the current position if one exists
 static void edl_update(MPContext *mpctx)
 {
-    if (!edl_records) {
+    if (!edl_records)
         return;
-    }
 
     if (!mpctx->sh_video) {
         mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlNOsh_video);
@@ -2683,7 +2659,7 @@ static void edl_update(MPContext *mpctx)
 }
 
 // style & SEEK_ABSOLUTE == 0 means seek relative to current position, == 1 means absolute
-// style & SEEK_FACTOR == 0 means amount in seconds, == 2 means fraction of file length
+// style & SEEK_FACTOR   == 0 means amount in seconds, == 2 means fraction of file length
 // return -1 if seek failed (non-seekable stream?), 0 otherwise
 static int seek(MPContext *mpctx, double amount, int style)
 {
@@ -2746,10 +2722,7 @@ static int seek(MPContext *mpctx, double amount, int style)
 #ifndef DISABLE_MAIN
 int main(int argc, char *argv[])
 {
-// movie info:
-
-/* Flag indicating whether MPlayer should exit without playing anything. */
-    int opt_exit = 0;
+    int opt_exit = 0; // Flag indicating whether MPlayer should exit without playing anything.
     int i;
 
     int gui_no_filename = 0;
@@ -2784,9 +2757,9 @@ int main(int argc, char *argv[])
 #endif
 
     mpctx->playtree = m_config_parse_mp_command_line(mconfig, argc, argv);
-    if (mpctx->playtree == NULL)
+    if (mpctx->playtree == NULL) {
         opt_exit = 1;
-    else {
+    } else {
         mpctx->playtree = play_tree_cleanup(mpctx->playtree);
         if (mpctx->playtree) {
             mpctx->playtree_iter = play_tree_iter_new(mpctx->playtree, mconfig);
@@ -2958,8 +2931,8 @@ int main(int argc, char *argv[])
         }
     }
 #ifdef CONFIG_GUI
-// breaks DGA and SVGAlib and VESA drivers:  --A'rpi
-// and now ? -- Pontscho
+    // breaks DGA and SVGAlib and VESA drivers:  --A'rpi
+    // and now ? -- Pontscho
     if (use_gui)
         setuid(getuid());           // strongly test, please check this.
 #endif
@@ -2975,7 +2948,7 @@ int main(int argc, char *argv[])
 
 // ========== Init keyboard FIFO (connection to libvo) ============
 
-// Init input system
+    // Init input system
     current_module = "init_input";
     mp_input_init();
     mp_input_add_key_fd(-1, 0, mplayer_get_key, NULL);
@@ -2983,7 +2956,7 @@ int main(int argc, char *argv[])
         mp_input_add_cmd_fd(0, USE_SELECT, MP_INPUT_SLAVE_CMD_FUNC, NULL);
     else if (!noconsolecontrols)
         mp_input_add_event_fd(0, getch2);
-// Set the libstream interrupt callback
+    // Set the libstream interrupt callback
     stream_set_interrupt_callback(mp_input_check_interrupt);
 
 #ifdef CONFIG_MENU
@@ -3009,7 +2982,7 @@ int main(int argc, char *argv[])
     initialized_flags |= INITIALIZED_INPUT;
     current_module     = NULL;
 
-    /// Catch signals
+    // Catch signals
 #ifndef __MINGW32__
     signal(SIGCHLD, child_sighandler);
 #endif
@@ -3067,8 +3040,8 @@ play_next_file:
     if (audio_driver_list)
         load_per_output_config(mconfig, PROFILE_CFG_AO, audio_driver_list[0]);
 
-// We must enable getch2 here to be able to interrupt network connection
-// or cache filling
+    // We must enable getch2 here to be able to interrupt network connection
+    // or cache filling
     if (!noconsolecontrols && !slave_mode) {
         if (initialized_flags & INITIALIZED_GETCH2)
             mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_Getch2InitializedTwice);
@@ -3291,19 +3264,15 @@ play_next_file:
     }
 
     if (mpctx->stream->type == STREAMTYPE_BD) {
-        if (audio_lang && audio_id == -1)
-            audio_id = bd_aid_from_lang(mpctx->stream, audio_lang);
-        if (dvdsub_lang && dvdsub_id == -1)
-            dvdsub_id = bd_sid_from_lang(mpctx->stream, dvdsub_lang);
+        if (audio_lang && audio_id == -1)   audio_id  = bd_aid_from_lang(mpctx->stream, audio_lang);
+        if (dvdsub_lang && dvdsub_id == -1) dvdsub_id = bd_sid_from_lang(mpctx->stream, dvdsub_lang);
     }
 
 #ifdef CONFIG_DVDREAD
     if (mpctx->stream->type == STREAMTYPE_DVD) {
         current_module = "dvd lang->id";
-        if (audio_lang && audio_id == -1)
-            audio_id = dvd_aid_from_lang(mpctx->stream, audio_lang);
-        if (dvdsub_lang && dvdsub_id == -1)
-            dvdsub_id = dvd_sid_from_lang(mpctx->stream, dvdsub_lang);
+        if (audio_lang && audio_id == -1)   audio_id = dvd_aid_from_lang(mpctx->stream, audio_lang);
+        if (dvdsub_lang && dvdsub_id == -1) dvdsub_id = dvd_sid_from_lang(mpctx->stream, dvdsub_lang);
         // setup global sub numbering
         mpctx->sub_counts[SUB_SOURCE_DEMUX] = dvd_number_of_subs(mpctx->stream);
         current_module = NULL;
@@ -3330,7 +3299,7 @@ goto_enable_cache:
         int res;
         current_module = "enable_cache";
         res            = stream_enable_cache(mpctx->stream, stream_cache_size * 1024,
-                                             stream_cache_size * 1024 * (stream_cache_min_percent / 100.0),
+                                             stream_cache_size * 1024 * (stream_cache_min_percent      / 100.0),
                                              stream_cache_size * 1024 * (stream_cache_seek_min_percent / 100.0));
         if (res == 0)
             if ((mpctx->eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY)))
@@ -3342,8 +3311,7 @@ goto_enable_cache:
 
     mpctx->demuxer = demux_open(mpctx->stream, mpctx->file_format, audio_id, video_id, dvdsub_id, filename);
 
-// HACK to get MOV Reference Files working
-
+    // HACK to get MOV Reference Files working
     if (mpctx->demuxer && mpctx->demuxer->type == DEMUXER_TYPE_PLAYLIST) {
         unsigned char *playlist_entry;
         play_tree_t *list = NULL, *entry = NULL;
@@ -3431,40 +3399,28 @@ goto_enable_cache:
         int tmp = ts_prog;
         mp_property_do("switch_program", M_PROPERTY_SET, &tmp, mpctx);
     }
-// select audio stream
+    // select audio stream
     select_audio(mpctx->demuxer, audio_id, audio_lang);
 
-// DUMP STREAMS:
+    // DUMP STREAMS:
     if ((stream_dump_type) && (stream_dump_type < 4)) {
         FILE *f;
         demux_stream_t *ds = NULL;
         current_module = "dump";
         // select stream to dump
         switch (stream_dump_type) {
-        case 1: ds = mpctx->d_audio;
-            break;
-        case 2: ds = mpctx->d_video;
-            break;
-        case 3: ds = mpctx->d_sub;
-            break;
+        case 1: ds = mpctx->d_audio; break;
+        case 2: ds = mpctx->d_video; break;
+        case 3: ds = mpctx->d_sub;   break;
         }
         if (!ds) {
             mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_DumpSelectedStreamMissing);
             exit_player(EXIT_ERROR);
         }
         // disable other streams:
-        if (mpctx->d_audio && mpctx->d_audio != ds) {
-            ds_free_packs(mpctx->d_audio);
-            mpctx->d_audio->id = -2;
-        }
-        if (mpctx->d_video && mpctx->d_video != ds) {
-            ds_free_packs(mpctx->d_video);
-            mpctx->d_video->id = -2;
-        }
-        if (mpctx->d_sub && mpctx->d_sub != ds) {
-            ds_free_packs(mpctx->d_sub);
-            mpctx->d_sub->id = -2;
-        }
+        if (mpctx->d_audio && mpctx->d_audio != ds) { ds_free_packs(mpctx->d_audio); mpctx->d_audio->id = -2; }
+        if (mpctx->d_video && mpctx->d_video != ds) { ds_free_packs(mpctx->d_video); mpctx->d_video->id = -2; }
+        if (mpctx->d_sub   && mpctx->d_sub   != ds) { ds_free_packs(mpctx->d_sub);   mpctx->d_sub->id   = -2; }
         // let's dump it!
         f = fopen(stream_dump_name, "wb");
         if (!f) {
@@ -3536,7 +3492,7 @@ goto_enable_cache:
         goto goto_next_file; // exit_player(MSGTR_Exit_error);
     }
 
-/* display clip info */
+    /* display clip info */
     demux_info_print(mpctx->demuxer);
 
 //================== Read SUBTITLES (DVD & TEXT) ==========================
@@ -3546,9 +3502,9 @@ goto_enable_cache:
     }
 
     if (1 || mpctx->sh_video) {
-// after reading video params we should load subtitles because
-// we know fps so now we can adjust subtitle time to ~6 seconds AST
-// check .sub
+        // after reading video params we should load subtitles because
+        // we know fps so now we can adjust subtitle time to ~6 seconds AST
+        // check .sub
         double fps = mpctx->sh_video ? mpctx->sh_video->fps : 25;
         current_module = "read_subtitles_file";
         load_subtitles(filename, fps, add_subtitles);
@@ -3557,21 +3513,16 @@ goto_enable_cache:
     }
 
     if (select_subtitle(mpctx)) {
-        if (subdata)
+        if (subdata) {
             switch (stream_dump_type) {
-            case 3: list_sub_file(subdata);
-                break;
-            case 4: dump_mpsub(subdata, mpctx->sh_video->fps);
-                break;
-            case 6: dump_srt(subdata, mpctx->sh_video->fps);
-                break;
-            case 7: dump_microdvd(subdata, mpctx->sh_video->fps);
-                break;
-            case 8: dump_jacosub(subdata, mpctx->sh_video->fps);
-                break;
-            case 9: dump_sami(subdata, mpctx->sh_video->fps);
-                break;
+            case 3: list_sub_file(subdata);                       break;
+            case 4: dump_mpsub(subdata, mpctx->sh_video->fps);    break;
+            case 6: dump_srt(subdata, mpctx->sh_video->fps);      break;
+            case 7: dump_microdvd(subdata, mpctx->sh_video->fps); break;
+            case 8: dump_jacosub(subdata, mpctx->sh_video->fps);  break;
+            case 9: dump_sami(subdata, mpctx->sh_video->fps);     break;
             }
+        }
     }
 
     print_file_properties(mpctx, filename);
@@ -3608,7 +3559,7 @@ goto_enable_cache:
         free(msg);
     }
 
-// Disable the term OSD in verbose mode
+    // Disable the term OSD in verbose mode
     if (verbose)
         term_osd = 0;
 
@@ -3616,8 +3567,8 @@ goto_enable_cache:
         mpctx->num_buffered_frames = 0;
         mpctx->framestep_found     = 0;
 
-// Make sure old OSD does not stay around,
-// e.g. with -fixed-vo and same-resolution files
+        // Make sure old OSD does not stay around,
+        // e.g. with -fixed-vo and same-resolution files
         clear_osd_msgs();
         update_osd_msg();
 
@@ -3687,11 +3638,9 @@ goto_enable_cache:
 #endif
 
         mp_input_set_section(NULL);
-//TODO: add desired (stream-based) sections here
-        if (mpctx->stream->type == STREAMTYPE_TV)
-            mp_input_set_section("tv");
-        if (mpctx->stream->type == STREAMTYPE_DVDNAV)
-            mp_input_set_section("dvdnav");
+        //TODO: add desired (stream-based) sections here
+        if (mpctx->stream->type == STREAMTYPE_TV)      mp_input_set_section("tv");
+        if (mpctx->stream->type == STREAMTYPE_DVDNAV)  mp_input_set_section("dvdnav");
 
 //==================== START PLAYING =======================
 
@@ -3861,20 +3810,16 @@ goto_enable_cache:
 
 //============================ Auto QUALITY ============================
 
-/*Output quality adjustments:*/
+                /* Output quality adjustments: */
                 if (auto_quality > 0) {
                     current_module = "autoq";
-//  float total=0.000001f * (GetTimer()-aq_total_time);
-//  if(output_quality<auto_quality && aq_sleep_time>0.05f*total)
                     if (output_quality < auto_quality && aq_sleep_time > 0)
                         ++output_quality;
                     else
-//  if(output_quality>0 && aq_sleep_time<-0.05f*total)
                     if (output_quality > 1 && aq_sleep_time < 0)
                         --output_quality;
                     else if (output_quality > 0 && aq_sleep_time < -0.050f) // 50ms
                         output_quality = 0;
-//  printf("total: %8.6f  sleep: %8.6f  q: %d\n",(0.000001f*aq_total_time),aq_sleep_time,output_quality);
                     set_video_quality(mpctx->sh_video, output_quality);
                 }
 
@@ -3923,7 +3868,7 @@ goto_enable_cache:
                 pause_loop();
             }
 
-// handle -sstep
+            // handle -sstep
             if (step_sec > 0) {
                 mpctx->osd_function = OSD_FFW;
                 rel_seek_secs      += step_sec;
@@ -4045,9 +3990,9 @@ goto_next_file:  // don't jump here after ao/vo/getch initialization!
                total_time_usage - tot, total_time_usage);
         if (total_time_usage > 0.0)
             mp_msg(MSGT_CPLAYER, MSGL_INFO, "BENCHMARK%%: VC:%8.4f%% VO:%8.4f%% A:%8.4f%% Sys:%8.4f%% = %8.4f%%\n",
-                   100.0 * video_time_usage / total_time_usage,
-                   100.0 * vout_time_usage / total_time_usage,
-                   100.0 * audio_time_usage / total_time_usage,
+                   100.0 * video_time_usage         / total_time_usage,
+                   100.0 * vout_time_usage          / total_time_usage,
+                   100.0 * audio_time_usage         / total_time_usage,
                    100.0 * (total_time_usage - tot) / total_time_usage,
                    100.0);
         if (total_frame_cnt && frame_dropping)
@@ -4060,7 +4005,7 @@ goto_next_file:  // don't jump here after ao/vo/getch initialization!
                    (total_time_usage > 0.5) ? (total_frame_cnt / total_time_usage) : 0);
     }
 
-// time to uninit all, except global stuff:
+    // time to uninit all, except global stuff:
     uninit_player(INITIALIZED_ALL - (INITIALIZED_GUI + INITIALIZED_INPUT + (fixed_vo ? INITIALIZED_VO : 0)));
 
     if (mpctx->set_of_sub_size > 0) {
@@ -4118,8 +4063,9 @@ goto_next_file:  // don't jump here after ao/vo/getch initialization!
                 play_tree_iter_free(mpctx->playtree_iter);
                 mpctx->playtree_iter = NULL;
             }
-        } else
+        } else {
             break;
+        }
     }
 
 #ifdef CONFIG_GUI
@@ -4139,7 +4085,6 @@ goto_next_file:  // don't jump here after ao/vo/getch initialization!
     }
 
     exit_player_with_rc(EXIT_EOF, 0);
-
     return 1;
 }
 
-- 
1.7.4.4



More information about the MPlayer-dev-eng mailing list