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

« back to all changes in this revision

Viewing changes to avidemux/oplug_avi/op_avisavecopy.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2006-12-15 17:13:20 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061215171320-w79pvpehxx2fr217
Tags: 1:2.3.0-0.0ubuntu1
* Merge from debian-multimedia.org, remaining Ubuntu change:
  - desktop file,
  - no support for ccache and make -j.
* Closes Ubuntu: #69614.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <time.h>
29
29
#include <sys/time.h>
30
30
#include "config.h"
 
31
#include <pthread.h>
 
32
#define WIN32_CLASH
31
33
#include "fourcc.h"
32
34
#include "avi_vars.h"
33
35
#include "ADM_toolkit/toolkit.hxx"
51
53
 
52
54
 
53
55
static void updateUserData(uint8_t *start, uint32_t len);
54
 
 
 
56
uint8_t ADM_findMpegStartCode(uint8_t *start, uint8_t *end,uint8_t *outstartcode,uint32_t *offset);
55
57
uint8_t GenericAviSaveCopy::setupVideo (char *name)
56
58
{
57
59
  //  Setup avi file output, all is coming from original avi
89
91
                           audio_filter2
90
92
                ))
91
93
        {
92
 
                GUI_Error_HIG ("Cannot initiate save", NULL);
 
94
          GUI_Error_HIG (_("Cannot initiate save"), NULL);
93
95
                return 0;
94
96
        }
95
97
        if(audio_filter2)
199
201
                                                        if(!reigniteChunk(extraLen,extraData)) return 0;
200
202
                                                }
201
203
                                 }
202
 
  encoding_gui->feedFrame(len);  
 
204
//  encoding_gui->feedFrame(len);  
203
205
  if(_needUserDataUpdate)
204
206
        updateUserData(vbuffer,len);
 
207
  encoding_gui->setFrame(frame,len,0,frametogo);
205
208
  return writter->saveVideoFrame (len, _videoFlag, vbuffer);
206
209
 
207
210
}
212
215
void updateUserData(uint8_t *start, uint32_t len)
213
216
{
214
217
        // lookup startcode
215
 
        uint32_t sync;
216
 
        
217
 
        while(len)
 
218
        uint32_t sync,off,rlen;
 
219
        uint8_t code;
 
220
        uint8_t *end=start+len;
 
221
        while(ADM_findMpegStartCode(start, end,&code,&off))
218
222
        {
219
 
                sync=0xFFFFFFFF;
220
 
                while(len)
221
 
                {
222
 
                        sync=sync<<8;
223
 
                        sync+=*start++;
224
 
                        sync&=0xFFFFFF; // suboptimal...
225
 
                        len--;
226
 
                        if(sync==0x000001)
227
 
                        {
228
 
                                break;
229
 
                        }       
230
 
                }
231
 
                if(*start==0xb2 && len)
232
 
                {
233
 
                        printf("User data found\n");
234
 
                        start++; //skip the b2
235
 
                        len--;
236
 
                        // looks ok ?
237
 
                        if(strncmp((char *)start,"DivX",len))
238
 
                        {
239
 
#if 0                                           
240
 
                                memset(start,0,4); // should work better
241
 
#else                           
 
223
                // update
 
224
                start+=off;
 
225
                rlen=end-start;
 
226
                if(code!=0xb2 || rlen<4)
 
227
                    continue;
 
228
        
 
229
                printf("User data found\n");
 
230
                // looks ok ?
 
231
                if(!strncmp((char *)start,"DivX",4))
 
232
                {
242
233
 
 
234
                    //
 
235
                    start+=4;
 
236
                    rlen-=4; // skip "DivX"
243
237
                                // looks for a p while not null
244
238
                                // if there isnt we will reach a new startcode
245
239
                                // and it will stop
246
 
                                while((*start!='p') && len) 
 
240
                                while((*start!='p') && rlen) 
247
241
                                {
248
242
                                        if(!*start)
249
243
                                        {
250
 
                                                len=0;
251
 
                                        }
252
 
                                        else
253
 
                                        {
254
 
                                                len--;
255
 
                                                start++;
256
 
                                        }
 
244
                                                rlen=0;
 
245
                                                break;
 
246
                                        }
 
247
                                        rlen--;
 
248
                                        start++;
257
249
                                }
258
 
                                if(!len) 
 
250
                                if(!rlen) 
259
251
                                        {
260
252
                                                printf("Unpacketizer:packed marker not found!\n");
261
253
                                        }
262
 
                                else    *start='n'; // remove 'p'
263
 
                                
264
 
                                return;
265
 
#endif                          
266
 
                        
267
 
                        }
268
 
                        
 
254
                                else    
 
255
                                        *start='n'; // remove 'p'
 
256
                                return;                 
269
257
                }
270
258
        }
271
259
}
 
260
//EOF
 
 
b'\\ No newline at end of file'