~ubuntu-branches/ubuntu/hardy/avidemux/hardy

« back to all changes in this revision

Viewing changes to avidemux/guiplay.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matvey Kozhev
  • Date: 2007-12-18 13:53:04 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218135304-cdqec2lg2bglyz15
Tags: 1:2.4~preview3-0.0ubuntu1
* Upload to Ubuntu. (LP: #163287, LP: #126572)
* debian/changelog: re-added Ubuntu releases.
* debian/control:
  - Require debhelper >= 5.0.51 (for dh_icons) and imagemagick.
  - Build-depend on libsdl1.2-dev instead of libsdl-dev.
  - Build against newer libx264-dev. (LP: #138854)
  - Removed libamrnb-dev, not in Ubuntu yet.
* debian/rules:
  - Install all icon sizes, using convert (upstream installs none).
  - Added missing calls to dh_installmenu, dh_installman, dh_icons and
    dh_desktop.
* debian/menu, debian/avidemux-qt.menu:
  - Corrected package and executable names.
* debian/avidemux-common.install: Install icons.
* debian/avidemux.common.manpages: Install man/avidemux.1.
* debian/links, debian/avidemux-cli.links, debian/avidemux-gtk.links:
  - Link manpages to avidemux.1.gz.
* debian/install, debian/avidemux-qt.install, debian/avidemux-gtk.desktop,
  debian/avidemux-qt.desktop: Install desktop files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *   (at your option) any later version.                                   *
19
19
 *                                                                         *
20
20
 ***************************************************************************/
21
 
#include <config.h>
 
21
#include "config.h"
22
22
 
23
23
#include <stdio.h>
24
24
#include <stdlib.h>
26
26
#include <unistd.h>
27
27
#include <errno.h>
28
28
 
29
 
 
30
 
 
31
 
 
32
 
 
33
 
#include <gtk/gtk.h>
34
 
 
35
29
#include "config.h"
36
 
#include "callbacks.h"
37
 
#include "interface.h"
38
 
#include "support.h"
 
30
#include "prefs.h"
39
31
 
40
32
#include "fourcc.h"
41
33
#include "avi_vars.h"
44
36
#include "ADM_toolkit/filesel.h"
45
37
#include "prototype.h"
46
38
#include "ADM_audiodevice/audio_out.h"
47
 
//#include "avdm_mad.h"
48
39
 
49
40
#include "ADM_toolkit/toolkit.hxx"
50
 
#include "ADM_toolkit/toolkit_gtk.h"
51
41
#include "ADM_audio/aviaudio.hxx"
52
42
#include "ADM_audiofilter/audioprocess.hxx"
53
43
 
54
44
#include "ADM_video/ADM_genvideo.hxx"
55
45
#include "ADM_filter/video_filters.h"
56
46
#include "gtkgui.h"
57
 
#include "ADM_gui2/GUI_render.h"
 
47
#include "GUI_render.h"
58
48
#include "ADM_audiofilter/audioeng_buildfilters.h"
 
49
#include "ADM_libraries/ADM_utilities/avidemutils.h"
59
50
 
60
51
//___________________________________
61
52
#define AUDIO_PRELOAD 150
64
55
static void resetTime(void);
65
56
static void ComputePreload(void);
66
57
static void FillAudio(void);
67
 
 
 
58
extern void UI_purge(void);
68
59
#define EVEN(x) (x&0xffffffe)
69
60
 
70
 
 
71
 
 extern void  UI_setPreviewToggleStatus( uint8_t status );
72
 
 extern uint8_t GUI_getFrame(uint32_t frameno, ADMImage *image, uint32_t *flags);
73
61
//___________________________________
74
 
extern uint8_t stop_req;
 
62
uint8_t stop_req;
75
63
static int called = 0;
76
64
static uint32_t vids = 0, auds = 0, dauds = 0;
77
65
static int32_t delta;
94
82
 
95
83
    uint32_t framelen,flags;
96
84
    AVDMGenericVideoStream *filter;
97
 
    ADMImage *buffer=NULL;
98
85
 
99
86
    vids = 0, auds = 0, dauds = 0;
100
87
    // check we got everything...
112
99
        stop_req = 1;
113
100
        return;
114
101
      }
 
102
 
 
103
        uint32_t priorityLevel;
 
104
 
 
105
        originalPriority = getpriority(PRIO_PROCESS, 0);
 
106
        prefs->get(PRIORITY_PLAYBACK,&priorityLevel);
 
107
        setpriority(PRIO_PROCESS, 0, ADM_getNiceValue(priorityLevel));
 
108
 
115
109
  uint32_t played_frame=0;
116
110
  uint32_t remaining=avifileinfo->nb_frames-curframe;
117
111
 
118
 
 
119
 
    if(guiOutputDisplay)
 
112
    
 
113
    if(getPreviewMode()==ADM_PREVIEW_OUTPUT)
120
114
    {
121
 
                filter=getLastVideoFilter(curframe,remaining);
122
 
                if(mode_preview)
123
 
                {
124
 
                      editorKillPreview ();
125
 
                      UI_setPreviewToggleStatus( 0 );
126
 
                      mode_preview=0;
127
 
                }
 
115
            filter=getLastVideoFilter(curframe,remaining);
128
116
    }
129
117
    else
130
118
    {
131
119
            filter=getFirstVideoFilter(curframe,remaining );
132
120
    }
 
121
    
133
122
    max=filter->getInfo()->nb_frames;
134
123
 
135
124
    // compute how much a frame lasts in ms
136
125
    one_frame = (uint32_t) floor(1000.*1000.*10. / filter->getInfo()->fps1000);
137
126
    err = one_frame % 10;
138
127
    one_frame /= 10; // Duration of a frame in ms, err =leftover in 1/10 ms
139
 
    buffer=new ADMImage(filter->getInfo()->width,filter->getInfo()->height);
 
128
    
140
129
    // go to RealTime...    
141
 
    printf(" One frame : %lu, err=%lu ms\n", one_frame, err);
142
 
    // read frame in chunk
143
 
    if(!filter->getFrameNumberNoAlloc(1,&framelen,buffer,&flags))
144
 
    {
145
 
        printf("\n cannot read frame!\n");
146
 
        goto abort_play;
147
 
    }
148
 
      curframe++;
149
 
      played_frame++;
 
130
    printf("One frame : %lu, err=%lu ms\n", one_frame, err);
 
131
    
150
132
    // prepare 1st frame
151
133
 
152
134
    stop_req = 0;
155
137
#ifdef HAVE_AUDIO
156
138
    ComputePreload();
157
139
#endif
158
 
     renderResize(filter->getInfo()->width,filter->getInfo()->height,currentZoom);
159
 
     renderStartPlaying();
 
140
    
 
141
     
 
142
     //renderStartPlaying();
160
143
// reset timer reference
161
144
    resetTime();
 
145
    admPreview::deferDisplay(1,curframe);
 
146
    admPreview::update(played_frame);
162
147
    do
163
148
    {
164
149
        vids++;
165
 
        renderUpdateImage(buffer->data);
166
 
        if(mode_preview&&!guiOutputDisplay)
167
 
        {       
168
 
            editorUpdatePreview(played_frame);
169
 
        }
170
 
        update_status_bar(buffer);
 
150
        admPreview::displayNow(played_frame);;
 
151
        update_status_bar();
171
152
        if (time_a == 0)
172
153
            time_a = getTime(0);
173
154
        // mark !
176
157
 
177
158
        if((played_frame)>=(max-1))
178
159
        {
179
 
            printf("\n End met (%lu  / %lu )\n",played_frame,max);
 
160
            printf("\nEnd met (%lu  / %lu )\n",played_frame,max);
180
161
            goto abort_play;
181
162
         }
182
 
        if(!filter->getFrameNumberNoAlloc(played_frame+1,&framelen,buffer,&flags))
183
 
        {
184
 
            printf("\n cannot read frame!\n");
185
 
            goto abort_play;
186
 
        }
 
163
        
 
164
        admPreview::update(played_frame+1);;
187
165
        curframe++;
188
166
        played_frame++;
189
167
 
220
198
            }
221
199
        //
222
200
            UI_purge();
223
 
            if(mode_preview)
 
201
            if(getPreviewMode()==ADM_PREVIEW_SEPARATE )
224
202
            {
225
203
              UI_purge();
226
204
              UI_purge(); 
234
212
    // go back to normal display mode
235
213
    //____________________________________
236
214
    playing = 0;
237
 
          delete  buffer;
238
 
 
239
 
           renderStopPlaying();
240
 
           renderResize(avifileinfo->width ,  avifileinfo->height,currentZoom);
 
215
          
241
216
           getFirstVideoFilter( );
242
 
           //video_body->getUncompressedFrame(curframe, rdr_decomp_buffer,&flags);
243
 
           GUI_getFrame(curframe, rdr_decomp_buffer, &flags);
244
 
           renderUpdateImage(rdr_decomp_buffer->data);
245
 
           renderRefresh();
246
 
           update_status_bar(rdr_decomp_buffer);
247
 
           if(mode_preview)
248
 
           {
249
 
                editorUpdatePreview(curframe);
250
 
           }
 
217
 
 
218
           admPreview::deferDisplay(0,0);
 
219
           UI_purge();
 
220
           // Updated by expose ? 
 
221
           admPreview::update(curframe);
 
222
           UI_purge();
 
223
           update_status_bar();
251
224
#ifdef HAVE_AUDIO
252
225
    if (currentaudiostream)
253
226
      {
260
233
      }
261
234
#endif
262
235
    // done.
 
236
 
 
237
        setpriority(PRIO_PROCESS, 0, originalPriority);
263
238
};
264
239
 
265
240
// return time in ms
370
345
    channels= playback->getInfo()->channels;
371
346
    one_audio_frame = (one_frame * wavinfo->frequency * channels);      // 1000 *nb audio bytes per ms
372
347
    one_audio_frame /= 1000; // In elemtary info (float)
373
 
    printf("\n 1 audio frame = %lu bytes (1)", one_audio_frame);
 
348
    printf("1 audio frame = %lu bytes\n", one_audio_frame);
374
349
    // 3 sec buffer..               
375
350
    wavbuf =  (float *)  ADM_alloc((3 *  channels * wavinfo->frequency*wavinfo->channels));
376
351
    ADM_assert(wavbuf);
381
356
 
382
357
      if (!latency)
383
358
      {
384
 
          GUI_Error_HIG(_("Trouble initializing audio device"), NULL);
 
359
          GUI_Error_HIG(QT_TR_NOOP("Trouble initializing audio device"), NULL);
385
360
          return;
386
361
      }
387
362
    // compute preload                      
405
380
    audio_available = 1;
406
381
}
407
382
 
408
 
//
409
 
// Build audio filters
410
383
 
411
384
#endif
412
385
// EOF