~ubuntu-branches/ubuntu/feisty/avidemux/feisty

« back to all changes in this revision

Viewing changes to avidemux/ADM_codecs/ADM_mpeg.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:
49
49
#undef free
50
50
#undef alloc
51
51
#undef realloc
52
 
        
 
52
 
53
53
#include "libMpeg2Dec/mpeg2.h"
54
54
#include "libMpeg2Dec/mpeg2_internal.h"
55
55
#include <ADM_assert.h>
58
58
#include "ADM_toolkit/ADM_debug.h"
59
59
 
60
60
 
61
 
extern void                     mpeg2_pop(mpeg2dec_t *m);
62
 
extern void                     mpeg2_popI(mpeg2dec_t *m);
63
 
static vo_instance_t            *yv12_open (void);
64
 
static void                     yv12_close (vo_instance_t * _instance);
65
 
static int                      yv12_setup (vo_instance_t * _instance, unsigned int width,      
66
 
                                        unsigned int height,unsigned  int chroma_w, 
67
 
                                        unsigned int chroma_h,vo_setup_result_t *result);
68
 
static void                     yv12_setup_fbuf (vo_instance_t * _instance, uint8_t ** buf, void ** id);
69
 
extern int                      mpeg2_cleanup(mpeg2dec_t * mpeg2dec);
 
61
  extern void mpeg2_pop (mpeg2dec_t * m);
 
62
  extern void mpeg2_popI (mpeg2dec_t * m);
 
63
  static vo_instance_t *yv12_open (void);
 
64
  static void yv12_close (vo_instance_t * _instance);
 
65
  static int yv12_setup (vo_instance_t * _instance, unsigned int width,
 
66
                         unsigned int height, unsigned int chroma_w,
 
67
                         unsigned int chroma_h, vo_setup_result_t * result);
 
68
  static void yv12_setup_fbuf (vo_instance_t * _instance, uint8_t ** buf,
 
69
                               void **id);
 
70
  extern int mpeg2_cleanup (mpeg2dec_t * mpeg2dec);
70
71
};
71
72
 
72
73
//static uint8_t *zero=NULL;
73
74
 
74
 
decoderMpeg             *_father=NULL;
75
 
static vo_instance_t            *output;
 
75
decoderMpeg *_father = NULL;
 
76
static vo_instance_t *output;
76
77
// avoid exporting our stuff...
77
78
typedef struct yv12_instance_s
78
79
{
79
 
    vo_instance_t                       vo;
80
 
   decoderMpeg                  *father;
81
 
    uint32_t                            w,h;
82
 
    uint8_t                     *buffer;
 
80
  vo_instance_t vo;
 
81
  decoderMpeg *father;
 
82
  uint32_t w, h;
 
83
  uint8_t *buffer;
83
84
} yv12_instance_t;
84
85
 
85
86
static uint8_t *iBuff[3];
86
87
static uint8_t *oBuff[3];
87
 
static int strideTab[3],strideTab2[3];
 
88
static int strideTab[3], strideTab2[3];
88
89
 
89
90
decoderMpeg::~decoderMpeg ()
90
91
{
91
92
#warning clean up libmpeg2 here
92
 
        kill_codec();
93
 
        delete [] unpackBuffer;
 
93
  kill_codec ();
 
94
  delete[]unpackBuffer;
94
95
}
95
96
//____________________________________
96
 
uint8_t decoderMpeg::isMpeg1( void)
 
97
uint8_t decoderMpeg::isMpeg1 (void)
97
98
{
98
 
 mpeg2_decoder_t *dec;
99
 
  dec=&((MPEG2DEC)->decoder);
100
 
   return (dec->mpeg1);
 
99
  mpeg2_decoder_t *
 
100
    dec;
 
101
  dec = &((MPEG2DEC)->decoder);
 
102
  return (dec->mpeg1);
101
103
}
102
104
//____________________-un init ____________________
103
105
uint8_t decoderMpeg::kill_codec (void)
104
106
{
105
 
  mpeg2_decoder_t *dec;
106
 
  dec=&((MPEG2DEC)->decoder);
107
 
  
108
 
  if(dec->quant)
109
 
  {
110
 
        ADM_dealloc(dec->quant);
111
 
        dec->quant=NULL;
112
 
  }
 
107
  mpeg2_decoder_t *
 
108
    dec;
 
109
  dec = &((MPEG2DEC)->decoder);
 
110
 
 
111
  if (dec->quant)
 
112
    {
 
113
      ADM_dealloc (dec->quant);
 
114
      dec->quant = NULL;
 
115
    }
113
116
  mpeg2_close (MPEG2DEC);
114
 
  _decoder=NULL;
115
 
  yv12_close (output);     
 
117
  _decoder = NULL;
 
118
  yv12_close (output);
116
119
 
117
120
  return 1;
118
121
}
119
122
//________________________________________________
120
 
void decoderMpeg::setParam( void )
 
123
void
 
124
decoderMpeg::setParam (void)
121
125
{
122
126
 
123
127
 
124
 
        return; 
125
 
}       
 
128
  return;
 
129
}
126
130
/*
127
131
______________________________________________________________________________________
128
132
                Constructor for mpeg decoder
129
133
______________________________________________________________________________________
130
134
*/
131
 
decoderMpeg::decoderMpeg(uint32_t w,uint32_t h,uint32_t extraLen, uint8_t *extraData)
132
 
        : decoders(w,h)
 
135
decoderMpeg::decoderMpeg (uint32_t w, uint32_t h, uint32_t extraLen, uint8_t * extraData):decoders (w,
 
136
          h)
133
137
{
134
 
mpeg2_decoder_t *dec;
135
 
uint32_t wmb,hmb;
136
 
yv12_instance_t *inst;
137
 
                        _seqLen=extraLen;
138
 
                        if(extraLen)
139
 
                        {
140
 
                                _seqHeader=new uint8_t [extraLen];
141
 
                                memcpy(_seqHeader,extraData,extraLen);
142
 
                        }
143
 
                        else
144
 
                        {
145
 
                                _seqHeader=NULL;
146
 
                        }
147
 
                        // store for future use
148
 
                        _seqFound=0;
149
 
                        postprocessed=NULL;
150
 
                        // now init libmpeg2
151
 
                        printf ("\n initializing mpeg2 decoder %lu x %lu\n",_w,_h);
152
 
                        output =yv12_open ();
153
 
                        inst=(yv12_instance_t *)output;
154
 
                        unpackBuffer=new uint8_t [(w*h*9)>>1];
155
 
                        inst->buffer=unpackBuffer;
156
 
                        _decoder=mpeg2_init();
157
 
                        dec=&((MPEG2DEC)->decoder);
158
 
                        wmb=(_w+15)>>4;;
159
 
                        hmb=(_h+15)>>4;;
160
 
                        dec->quant_stride=wmb;
161
 
                        dec->quant=(int8_t*)ADM_alloc( (wmb*hmb)*sizeof(int8_t));
162
 
                        //
163
 
                        feedData(extraLen,_seqHeader);
164
 
                        feedData(extraLen,_seqHeader);
165
 
                        
166
 
                        // Post processing settings
167
 
                        //___________________________
168
 
                        
169
 
                        _swapUV=0;
170
 
                        // Post Proc is disabled by default
171
 
                        
172
 
                        printf ("\n done\n");
 
138
  mpeg2_decoder_t *
 
139
    dec;
 
140
  uint32_t wmb, hmb;
 
141
  yv12_instance_t *
 
142
    inst;
 
143
  _seqLen = extraLen;
 
144
  if (extraLen)
 
145
    {
 
146
      _seqHeader = new uint8_t[extraLen];
 
147
      memcpy (_seqHeader, extraData, extraLen);
 
148
    }
 
149
  else
 
150
    {
 
151
      _seqHeader = NULL;
 
152
    }
 
153
  // store for future use
 
154
  _seqFound = 0;
 
155
  par_width=par_height=1;
 
156
  postprocessed = NULL;
 
157
  // now init libmpeg2
 
158
  printf ("\n initializing mpeg2 decoder %lu x %lu\n", _w, _h);
 
159
  output = yv12_open ();
 
160
  inst = (yv12_instance_t *) output;
 
161
  unpackBuffer = new uint8_t[(w * h * 9) >> 1];
 
162
  inst->buffer = unpackBuffer;
 
163
  _decoder = mpeg2_init ();
 
164
  dec = &((MPEG2DEC)->decoder);
 
165
  wmb = (_w + 15) >> 4;;
 
166
  hmb = (_h + 15) >> 4;;
 
167
  dec->quant_stride = wmb;
 
168
  dec->quant = (int8_t *) ADM_alloc ((wmb * hmb) * sizeof (int8_t));
 
169
  //
 
170
  feedData (extraLen, _seqHeader);
 
171
  feedData (extraLen, _seqHeader);
 
172
 
 
173
  // Post processing settings
 
174
  //___________________________
 
175
 
 
176
  _swapUV = 0;
 
177
  // Post Proc is disabled by default
 
178
 
 
179
  printf ("\n done\n");
173
180
 
174
181
}
175
182
/*------------------------------------------------------------------*/
176
 
uint8_t         decoderMpeg::uncompress(uint8_t *in,ADMImage *out,uint32_t len,uint32_t *flag)
 
183
uint8_t
 
184
  decoderMpeg::uncompress (uint8_t * in, ADMImage * out, uint32_t len,
 
185
                           uint32_t * flag)
177
186
{
178
 
                if(flag) *flag=0;
 
187
  if (flag)
 
188
    *flag = 0;
179
189
#if defined( REMOVE_PADDING)
180
 
                while(*(in+len-1)==0) len--;
181
 
#endif          
182
 
                if(!len)
183
 
                {
184
 
                        if(!dontcopy())
185
 
                                return 1;
186
 
                }
187
 
                if(len)
188
 
                      feedData(len,in);
189
 
 
190
 
        const mpeg2_info_t  *info ;
191
 
        uint8_t *t;
192
 
 
193
 
                t=(uint8_t *) MPEG2DEC->fbuf[0]->buf[0];
194
 
                mpeg2_cleanup(MPEG2DEC);
195
 
                info= mpeg2_info (MPEG2DEC);
196
 
                out->_noPicture=0;    // For mpeg1/2 we ALWAYS have a picture
197
 
                if(out->quant && MPEG2DEC->decoder.quant_stride>=out->_qStride)
198
 
                {
199
 
                        
200
 
 
201
 
                        if(dontcopy())
202
 
                        {
203
 
                             out->_qSize=((_w+15)>>4)*((_h+15)>>4);
204
 
                             out->_qStride=(_w+15)>>4;
205
 
                             out->quant=(uint8_t *)MPEG2DEC->decoder.quant;                             
206
 
                        }
207
 
                        else
208
 
                             memcpy(out->quant,MPEG2DEC->decoder.quant,out->_qSize);
209
 
                
210
 
                }
211
 
                if(dontcopy())
212
 
                {
213
 
                        uint32_t plane=_w*_h;
214
 
 
215
 
                        out->_planes[0]=t;
216
 
                        out->_planes[1]=t+plane;
217
 
                        out->_planes[2]=t+((plane*5)>>2);
218
 
                        out->_planeStride[0]=_w;
219
 
                        out->_planeStride[1]=_w>>1;
220
 
                        out->_planeStride[2]=_w>>1;
221
 
                }
222
 
                else
223
 
                {
224
 
                      memcpy(out->data,t,(_w*_h*3)>>1);
225
 
                }
226
 
                
227
 
                switch(MPEG2DEC->decoder.coding_type)
228
 
                        {
229
 
                                case I_TYPE:out->flags=AVI_KEY_FRAME;break;
230
 
                                case B_TYPE:out->flags=AVI_B_FRAME;break;
231
 
                                case P_TYPE:out->flags=0;break;
232
 
                                default:
233
 
                                        printf("\n unknown frame type ! %d\n",MPEG2DEC->decoder.coding_type);
234
 
                                        //ADM_assert(0);
235
 
                                        //return 0;
236
 
                                        out->flags=0;
237
 
                        }
238
 
                if(flag)
239
 
                {
240
 
                        *flag=out->flags;
241
 
                }
242
 
                if(MPEG2DEC->ext_state & PIC_FLAG_PROGRESSIVE_FRAME)
243
 
                        {
244
 
                                aprintf("Progressive\n");
245
 
                        }
246
 
                return 1;
247
 
}
248
 
void decoderMpeg::feedData(uint32_t len, uint8_t *data)
249
 
{
250
 
                decode_mpeg2(data,data+len);
251
 
 
252
 
}
253
 
void decoderMpeg::setFather( decoderMpeg *f)
254
 
{
255
 
                _father=f;
 
190
  while (*(in + len - 1) == 0)
 
191
    len--;
 
192
#endif
 
193
  if (!len)
 
194
    {
 
195
      if (!dontcopy ())
 
196
        return 1;
 
197
    }
 
198
  if (len)
 
199
    feedData (len, in);
 
200
 
 
201
  const mpeg2_info_t *info;
 
202
  uint8_t *t;
 
203
 
 
204
  t = (uint8_t *) MPEG2DEC->fbuf[0]->buf[0];
 
205
  mpeg2_cleanup (MPEG2DEC);
 
206
  info = mpeg2_info (MPEG2DEC);
 
207
 
 
208
  if (info->sequence) {
 
209
    par_width = info->sequence->pixel_width;
 
210
    par_height = info->sequence->pixel_height;
 
211
  }
 
212
 
 
213
  aprintf("Mpeg  %u * %u\n",par_width,par_height);
 
214
  out->_noPicture = 0;          // For mpeg1/2 we ALWAYS have a picture
 
215
  if (out->quant && MPEG2DEC->decoder.quant_stride >= out->_qStride)
 
216
    {
 
217
 
 
218
 
 
219
      if (dontcopy ())
 
220
        {
 
221
          out->_qSize = ((_w + 15) >> 4) * ((_h + 15) >> 4);
 
222
          out->_qStride = (_w + 15) >> 4;
 
223
          out->quant = (uint8_t *) MPEG2DEC->decoder.quant;
 
224
        }
 
225
      else
 
226
        memcpy (out->quant, MPEG2DEC->decoder.quant, out->_qSize);
 
227
 
 
228
    }
 
229
  if (dontcopy ())
 
230
    {
 
231
      uint32_t plane = _w * _h;
 
232
 
 
233
      out->_planes[0] = t;
 
234
      out->_planes[1] = t + plane;
 
235
      out->_planes[2] = t + ((plane * 5) >> 2);
 
236
      out->_planeStride[0] = _w;
 
237
      out->_planeStride[1] = _w >> 1;
 
238
      out->_planeStride[2] = _w >> 1;
 
239
    }
 
240
  else
 
241
    {
 
242
      memcpy (out->data, t, (_w * _h * 3) >> 1);
 
243
    }
 
244
 
 
245
  switch (MPEG2DEC->decoder.coding_type)
 
246
    {
 
247
    case I_TYPE:
 
248
      out->flags = AVI_KEY_FRAME;
 
249
      break;
 
250
    case B_TYPE:
 
251
      out->flags = AVI_B_FRAME;
 
252
      break;
 
253
    case P_TYPE:
 
254
      out->flags = 0;
 
255
      break;
 
256
    default:
 
257
      printf ("\n unknown frame type ! %d\n", MPEG2DEC->decoder.coding_type);
 
258
      //ADM_assert(0);
 
259
      //return 0;
 
260
      out->flags = 0;
 
261
    }
 
262
  if (flag)
 
263
    {
 
264
      *flag = out->flags;
 
265
    }
 
266
  if (MPEG2DEC->ext_state & PIC_FLAG_PROGRESSIVE_FRAME)
 
267
    {
 
268
      aprintf ("Progressive\n");
 
269
    }
 
270
  return 1;
 
271
}
 
272
void
 
273
decoderMpeg::feedData (uint32_t len, uint8_t * data)
 
274
{
 
275
  decode_mpeg2 (data, data + len);
 
276
 
 
277
}
 
278
void
 
279
decoderMpeg::setFather (decoderMpeg * f)
 
280
{
 
281
  _father = f;
256
282
}
257
283
 
258
284
 
260
286
        decode_mpeg2: Just a copy/paste from mpeg2dec
261
287
 
262
288
*/
263
 
void  decoderMpeg::decode_mpeg2 (uint8_t * current, uint8_t * end)
 
289
void
 
290
decoderMpeg::decode_mpeg2 (uint8_t * current, uint8_t * end)
264
291
{
265
 
    const mpeg2_info_t * info;
266
 
    int state;
267
 
    int loop=0;
268
 
 
269
 
    mpeg2_buffer (MPEG2DEC, current, end);
270
 
 
271
 
    info = mpeg2_info (MPEG2DEC);
272
 
    while (1) {
273
 
        
274
 
        state = mpeg2_parse (MPEG2DEC);
275
 
        aprintf("Mpeg2dec : %d \n",state);
276
 
        switch (state) {
 
292
  const mpeg2_info_t *info;
 
293
  int state;
 
294
  int loop = 0;
 
295
 
 
296
  mpeg2_buffer (MPEG2DEC, current, end);
 
297
 
 
298
  info = mpeg2_info (MPEG2DEC);
 
299
  while (1)
 
300
    {
 
301
 
 
302
      state = mpeg2_parse (MPEG2DEC);
 
303
      aprintf ("Mpeg2dec : %d \n", state);
 
304
      switch (state)
 
305
        {
277
306
        case STATE_BUFFER:
278
 
                        loop++;
279
 
                        if(loop>2)
280
 
                                {
281
 
                                        aprintf("Mpeg2dec: Running empty...\n");
282
 
                                        return;
283
 
                                }
284
 
                        break;
 
307
          loop++;
 
308
          if (loop > 2)
 
309
            {
 
310
              aprintf ("Mpeg2dec: Running empty...\n");
 
311
              return;
 
312
            }
 
313
          break;
285
314
        case -1:
286
 
               printf("Not ready \n");
287
 
            return;
 
315
          printf ("Not ready \n");
 
316
          return;
288
317
        case STATE_SEQUENCE:
289
 
            /* might set nb fbuf, convert format, stride */
290
 
            /* might set fbufs */
291
 
            printf("\n Seq found\n");
292
 
            
293
 
            vo_setup_result_t res;
294
 
         if(!_seqFound)
 
318
          /* might set nb fbuf, convert format, stride */
 
319
          /* might set fbufs */
 
320
          printf ("\n Seq found\n");
 
321
 
 
322
          vo_setup_result_t res;
 
323
          if (!_seqFound)
295
324
            {
296
 
                if (output->setup (output,
297
 
                                info->sequence->width,
298
 
                                info->sequence->height,
299
 
                                info->sequence->width>>1,
300
 
                                info->sequence->height>>1,
301
 
                                &res))
302
 
                        {
303
 
                                        fprintf (stderr, "display setup failed\n");
304
 
                                        exit (1);
305
 
                        }
306
 
                        uint8_t * buf[3];
307
 
                        void * id;
308
 
                        //mpeg2_custom_fbuf(MPEG2DEC,1);
309
 
                        output->setup_fbuf (output, buf, (void **)0);  // 3 buffer ...
310
 
                        mpeg2_set_buf (MPEG2DEC, buf, (void *)0);
311
 
                        output->setup_fbuf (output, buf, (void **)1);
312
 
                        mpeg2_set_buf (MPEG2DEC, buf, (void *)1);
313
 
                        output->setup_fbuf (output, buf, (void **)2);
314
 
                        mpeg2_set_buf (MPEG2DEC, buf, (void *)2);
315
 
                        _seqFound=0;
 
325
              if (output->setup (output,
 
326
                                 info->sequence->width,
 
327
                                 info->sequence->height,
 
328
                                 info->sequence->width >> 1,
 
329
                                 info->sequence->height >> 1, &res))
 
330
                {
 
331
                  fprintf (stderr, "display setup failed\n");
 
332
                  exit (1);
316
333
                }
317
 
                else
318
 
                        printf("..already initialized...\n");
 
334
              uint8_t *buf[3];
 
335
              void *id;
 
336
              //mpeg2_custom_fbuf(MPEG2DEC,1);
 
337
              output->setup_fbuf (output, buf, (void **) 0);    // 3 buffer ...
 
338
              mpeg2_set_buf (MPEG2DEC, buf, (void *) 0);
 
339
              output->setup_fbuf (output, buf, (void **) 1);
 
340
              mpeg2_set_buf (MPEG2DEC, buf, (void *) 1);
 
341
              output->setup_fbuf (output, buf, (void **) 2);
 
342
              mpeg2_set_buf (MPEG2DEC, buf, (void *) 2);
 
343
              _seqFound = 0;
 
344
            }
 
345
          else
 
346
            printf ("..already initialized...\n");
319
347
 
320
 
            break;
 
348
          break;
321
349
        case STATE_PICTURE:
322
 
            /* might skip */
323
 
            /* might set fbuf */
324
 
                
325
 
                _seen=MPEG2DEC->decoder.coding_type;
326
 
                //printf("1st %d\n",_seen);
327
 
            break;
 
350
          /* might skip */
 
351
          /* might set fbuf */
 
352
 
 
353
          _seen = MPEG2DEC->decoder.coding_type;
 
354
          //printf("1st %d\n",_seen);
 
355
          break;
328
356
        case STATE_PICTURE_2ND:
329
 
                /* should not do anything */
330
 
                //printf("2nd\n");
331
 
            break;
 
357
          /* should not do anything */
 
358
          //printf("2nd\n");
 
359
          break;
332
360
        case STATE_SLICE:
333
361
        case STATE_END:
334
 
            /* draw current picture */
335
 
            /* might free frame buffer */
336
 
           
337
 
            break;
 
362
          /* draw current picture */
 
363
          /* might free frame buffer */
 
364
 
 
365
          break;
338
366
        }
339
367
    }
340
368
}
343
371
/**
344
372
                yv12_open : set up the callbacks
345
373
*/
346
 
vo_instance_t * yv12_open (void)
 
374
vo_instance_t *
 
375
yv12_open (void)
347
376
{
348
 
    yv12_instance_t * instance;
349
 
 
350
 
    instance = new yv12_instance_t;
351
 
    if (instance == NULL)
352
 
                                return NULL;
353
 
    memset(instance,0,sizeof(*instance));
354
 
 
355
 
    instance->vo.setup = yv12_setup;
356
 
    instance->vo.setup_fbuf = yv12_setup_fbuf;
357
 
    instance->vo.set_fbuf = NULL;
358
 
    instance->vo.draw = NULL;
359
 
    instance->vo.discard = NULL;
360
 
    instance->vo.close = yv12_close;
361
 
    instance->father=_father;
362
 
 
363
 
           printf(" YV12 open called\n");
364
 
 
365
 
    return (vo_instance_t *) instance;
 
377
  yv12_instance_t *instance;
 
378
 
 
379
  instance = new yv12_instance_t;
 
380
  if (instance == NULL)
 
381
    return NULL;
 
382
  memset (instance, 0, sizeof (*instance));
 
383
 
 
384
  instance->vo.setup = yv12_setup;
 
385
  instance->vo.setup_fbuf = yv12_setup_fbuf;
 
386
  instance->vo.set_fbuf = NULL;
 
387
  instance->vo.draw = NULL;
 
388
  instance->vo.discard = NULL;
 
389
  instance->vo.close = yv12_close;
 
390
  instance->father = _father;
 
391
 
 
392
  printf (" YV12 open called\n");
 
393
 
 
394
  return (vo_instance_t *) instance;
366
395
}
367
396
/**
368
397
                yv12_setup : Nothing to do
369
398
*/
370
 
int yv12_setup (vo_instance_t * _instance, unsigned int width, unsigned int height,unsigned int chroma_w,unsigned  int chroma_h,vo_setup_result_t *result)
 
399
int
 
400
yv12_setup (vo_instance_t * _instance, unsigned int width,
 
401
            unsigned int height, unsigned int chroma_w, unsigned int chroma_h,
 
402
            vo_setup_result_t * result)
371
403
{
372
 
        yv12_instance_t *ins;
 
404
  yv12_instance_t *ins;
373
405
 
374
 
        ins=(yv12_instance_t *)_instance;
375
 
        ins->w=width;
376
 
        ins->h=height;
377
 
    result->convert=NULL;
378
 
    printf(" YV12 setup called\n");
379
 
    return 0;
 
406
  ins = (yv12_instance_t *) _instance;
 
407
  ins->w = width;
 
408
  ins->h = height;
 
409
  result->convert = NULL;
 
410
  printf (" YV12 setup called\n");
 
411
  return 0;
380
412
}
381
413
/**
382
414
        yv12_close : nothing to do
383
415
*/
384
 
void yv12_close (vo_instance_t * _instance)
 
416
void
 
417
yv12_close (vo_instance_t * _instance)
385
418
{
386
 
   UNUSED_ARG(_instance);
387
 
   printf(" yv12close called\n");
 
419
  UNUSED_ARG (_instance);
 
420
  printf (" yv12close called\n");
388
421
}
389
422
 
390
423
/**
391
424
        yv12_setup_fbuf : Allocate some buffers
392
425
*/
393
 
static void yv12_setup_fbuf (vo_instance_t * _instance,                     uint8_t ** buf, void ** id)
 
426
static void
 
427
yv12_setup_fbuf (vo_instance_t * _instance, uint8_t ** buf, void **id)
394
428
{
395
 
        uint8_t *all;
396
 
        uint32_t page,img;
397
 
#ifdef ARCH_X86_64 
398
 
        uint64_t i;
399
 
        i=(uint64_t)id;
 
429
  uint8_t *all;
 
430
  uint32_t page, img;
 
431
#ifdef ARCH_64_BITS
 
432
  uint64_t i;
 
433
  i = (uint64_t) id;
400
434
 
401
435
#else
402
 
        uint32_t i;
403
 
        i=(uint32_t)id;
404
 
#endif  
405
 
    
406
 
        yv12_instance_t * instance = (yv12_instance_t *) _instance;
407
 
        printf(" **********YV12 setup fbuf called : %lu x %lu (%lu)\n",instance->w,instance->h,i);
408
 
 
409
 
        page=instance->w*instance->h;
410
 
        img=(page*3)>>1;
411
 
 
412
 
        all=instance->buffer;
413
 
        all+=img*i;
414
 
        memset(all,0,img);
415
 
    buf[0] =all;
416
 
    buf[2] =all+page;;
417
 
    buf[1] =all+page+(page>>2);;
418
 
    //@*id=NULL;
 
436
  uint32_t i;
 
437
  i = (uint32_t) id;
 
438
#endif
 
439
 
 
440
  yv12_instance_t *instance = (yv12_instance_t *) _instance;
 
441
  printf (" **********YV12 setup fbuf called : %lu x %lu (%lu)\n",
 
442
          instance->w, instance->h, i);
 
443
 
 
444
  page = instance->w * instance->h;
 
445
  img = (page * 3) >> 1;
 
446
 
 
447
  all = instance->buffer;
 
448
  all += img * i;
 
449
  memset (all, 0, img);
 
450
  buf[0] = all;
 
451
  buf[2] = all + page;;
 
452
  buf[1] = all + page + (page >> 2);;
 
453
  //@*id=NULL;
419
454
 
420
455
}