]> git.sesse.net Git - vlc/blob - modules/codec/cinepak.c
* ALL: final improvements to the decoders/packetizers api.
[vlc] / modules / codec / cinepak.c
1 /*****************************************************************************
2  * cinepak.c: cinepak video decoder
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  * $Id: cinepak.c,v 1.3 2003/11/16 21:07:30 gbazin Exp $
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <string.h>
29
30 #include <vlc/vlc.h>
31 #include <vlc/vout.h>
32 #include <vlc/decoder.h>
33 #include <vlc/input.h>
34
35 #define CINEPAK_MAXSTRIP 32
36
37 typedef struct cinepak_codebook_s
38 {
39     uint8_t i_y[4];
40     uint8_t i_u, i_v;
41
42 } cinepak_codebook_t;
43
44 typedef struct cinepak_context_s
45 {
46     int b_grayscale; /* force to grayscale */
47
48     int i_width;
49     int i_height;
50
51     int i_stride_x;
52     int i_stride_y;
53
54     uint8_t *p_y, *p_u, *p_v;
55
56     int i_stride[3]; /* our 3 planes */
57     int i_lines[3];
58     uint8_t *p_pix[3];
59
60     cinepak_codebook_t codebook_v1[CINEPAK_MAXSTRIP][256];
61     cinepak_codebook_t codebook_v4[CINEPAK_MAXSTRIP][256];
62
63 } cinepak_context_t;
64
65 /*****************************************************************************
66  * decoder_sys_t : decoder descriptor
67  *****************************************************************************/
68 struct decoder_sys_t
69 {
70     /*
71      * Cinepak properties
72      */
73     cinepak_context_t *p_context;
74 };
75
76 /*****************************************************************************
77  * Local prototypes
78  *****************************************************************************/
79 static int  OpenDecoder( vlc_object_t * );
80 static void CloseDecoder( vlc_object_t * );
81 static picture_t *DecodeBlock ( decoder_t *, block_t ** );
82
83 static int cinepak_decode_frame( cinepak_context_t *, int, uint8_t * );
84
85 /*****************************************************************************
86  * Module descriptor
87  *****************************************************************************/
88 vlc_module_begin();
89     set_description( _("Cinepak video decoder") );
90     set_capability( "decoder", 70 );
91     set_callbacks( OpenDecoder, CloseDecoder );
92 vlc_module_end();
93
94 /*****************************************************************************
95  * OpenDecoder: probe the decoder and return score
96  *****************************************************************************
97  * Tries to launch a decoder and return score so that the interface is able
98  * to chose.
99  *****************************************************************************/
100 static int OpenDecoder( vlc_object_t *p_this )
101 {
102     decoder_t *p_dec = (decoder_t*)p_this;
103     decoder_sys_t *p_sys;
104     vlc_value_t val;
105
106     switch( p_dec->fmt_in.i_codec )
107     {
108         case VLC_FOURCC('c','v','i','d'):
109         case VLC_FOURCC('C','V','I','D'):
110             break;
111
112         default:
113             return VLC_EGENERIC;
114     }
115
116     /* Allocate the memory needed to store the decoder's structure */
117     if( ( p_dec->p_sys = p_sys =
118           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
119     {
120         msg_Err( p_dec, "out of memory" );
121         return VLC_EGENERIC;
122     }
123
124     if( !(p_sys->p_context = malloc( sizeof( cinepak_context_t ) ) ) )
125     {
126         msg_Err( p_dec, "out of memory" );
127     }
128     memset( p_sys->p_context, 0, sizeof( cinepak_context_t ) );
129
130     var_Create( p_dec, "grayscale", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
131     var_Get( p_dec, "grayscale", &val );
132     p_sys->p_context->b_grayscale = val.b_bool;
133
134     p_dec->pf_decode_video = DecodeBlock;
135
136     msg_Dbg( p_dec, "cinepak decoder started" );
137
138     return VLC_SUCCESS;
139 }
140
141 /****************************************************************************
142  * DecodeBlock: the whole thing
143  ****************************************************************************
144  * This function must be fed with whole frames.
145  ****************************************************************************/
146 static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
147 {
148     decoder_sys_t *p_sys = p_dec->p_sys;
149     int i_status, i_plane;
150     uint8_t *p_dst, *p_src;
151     picture_t *p_pic;
152     block_t *p_block;
153
154     if( !pp_block || !*pp_block ) return NULL;
155
156     p_block = *pp_block;
157
158     i_status = cinepak_decode_frame( p_sys->p_context, p_block->i_buffer,
159                                      p_block->p_buffer );
160     if( i_status < 0 )
161     {
162         msg_Warn( p_dec, "cannot decode one frame (%d bytes)",
163                   p_block->i_buffer );
164         block_Release( p_block );
165         return NULL;
166     }
167
168     p_dec->fmt_out.video.i_width = p_sys->p_context->i_width;
169     p_dec->fmt_out.video.i_height = p_sys->p_context->i_height;
170     p_dec->fmt_out.video.i_aspect = p_sys->p_context->i_width
171         * VOUT_ASPECT_FACTOR / p_sys->p_context->i_height;
172     p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0');
173
174     /* Get a new picture */
175     p_pic = p_dec->pf_vout_buffer_new( p_dec );
176
177     if( p_pic == NULL )
178     {
179         block_Release( p_block );
180         return NULL;
181     }
182
183     for( i_plane = 0; i_plane < 3; i_plane++ )
184     {
185         int i_line, i_lines;
186
187         p_dst = p_pic->p[i_plane].p_pixels;
188         p_src = p_sys->p_context->p_pix[i_plane];
189
190         i_lines = __MIN( p_sys->p_context->i_lines[i_plane],
191                          p_pic->p[i_plane].i_lines );
192         for( i_line = 0; i_line < i_lines; i_line++ )
193         {
194             memcpy( p_dst, p_src,
195                     __MIN( p_pic->p[i_plane].i_pitch,
196                            p_sys->p_context->i_stride[i_plane] ) );
197             p_dst += p_pic->p[i_plane].i_pitch;
198             p_src += p_sys->p_context->i_stride[i_plane];
199         }
200     }
201
202     p_pic->date = p_block->i_pts;
203     block_Release( p_block );
204
205     return p_pic;
206 }
207
208 /*****************************************************************************
209  * CloseDecoder: decoder destruction
210  *****************************************************************************/
211 static void CloseDecoder( vlc_object_t *p_this )
212 {
213     decoder_t *p_dec = (decoder_t *)p_this;
214     decoder_sys_t *p_sys = p_dec->p_sys;
215     int i;
216
217     msg_Dbg( p_dec, "cinepak decoder stopped" );
218
219     for( i = 0; i < 3; i++ )
220     {
221         if( p_sys->p_context->p_pix[i] ) free( p_sys->p_context->p_pix[i] );
222     }
223
224     free( p_sys->p_context );
225
226     free( p_sys );
227 }
228
229 /*****************************************************************************
230  * local Functions
231  *****************************************************************************/
232
233 #define GET2BYTES( p ) \
234     GetWBE( p ); p+= 2;
235 /* FIXME */
236 #define GET3BYTES( p ) \
237     (GetDWBE( p ) >> 8); p+= 3;
238
239 #define GET4BYTES( p ) \
240     GetDWBE( p ); p+= 4;
241
242 #define FREE( p ) \
243     if( p ) free( p )
244
245 static void cinepak_LoadCodebook( cinepak_codebook_t *p_codebook,
246                                   uint8_t *p_data, int b_grayscale )
247 {
248     int i, i_y[4], i_u, i_v, i_Cb, i_Cr;
249     int i_uv;
250 #define SCALEBITS 12
251 #define FIX( x ) ( (int)( (x) * ( 1L << SCALEBITS ) + 0.5 ) )
252
253     for( i = 0; i < 4; i++ )
254     {
255         i_y[i] = (uint8_t)( *(p_data++) );
256     }
257     if( b_grayscale )
258     {
259         i_u  = (int8_t)( *(p_data++) );
260         i_v  = (int8_t)( *(p_data++) );
261     }
262     else
263     {
264         i_u  = 0;
265         i_v  = 0;
266     }
267
268     /*
269           | Y  |   | 1 -0.0655  0.0110 | | CY |
270           | Cb | = | 0  1.1656 -0.0062 | | CU |
271           | Cr |   | 0  0.0467  1.4187 | | CV |
272      */
273     i_uv = ( FIX( -0.0655 ) * i_u + FIX( 0.0110 ) * i_v ) >> SCALEBITS;
274     for( i = 0; i < 4; i++ )
275     {
276         i_y[i] += i_uv;
277     }
278     i_Cb  = ( FIX( 1.1656 ) * i_u + FIX( -0.0062 ) * i_v ) >> SCALEBITS;
279     i_Cr  = ( FIX( 0.0467 ) * i_u + FIX(  1.4187 ) * i_v ) >> SCALEBITS;
280
281     for( i = 0; i < 4; i++ )
282     {
283         p_codebook->i_y[i] = __MIN( __MAX( 0, i_y[i] ), 255 );
284     }
285     p_codebook->i_u  = __MIN( __MAX( 0, i_Cb + 128 ), 255 );
286     p_codebook->i_v  = __MIN( __MAX( 0, i_Cr + 128 ), 255 );
287
288 #undef FIX
289 #undef SCALEBITS
290 }
291
292 static void cinepak_Getv4( cinepak_context_t *p_context,
293                            int i_strip, int i_x, int i_y,
294                            int i_x2, int i_y2, uint8_t *p_data )
295 {
296     uint8_t i_index[4];
297     int i,j;
298
299     uint8_t *p_dst_y, *p_dst_u, *p_dst_v;
300 #define PIX_SET_Y( x, y, v ) \
301     p_dst_y[(x) + (y)* p_context->i_stride[0]] = (v);
302
303 #define PIX_SET_UV( i, p, x, y, v ) \
304     p[(x) + (y)* (p_context->i_stride[i])] = (v);
305
306     for( i = 0; i < 4; i++ )
307     {
308         i_index[i] = *(p_data++);
309     }
310
311     /* y plane */
312     p_dst_y = p_context->p_pix[0] + p_context->i_stride[0] * i_y + i_x;
313     p_dst_u = p_context->p_pix[1] + p_context->i_stride[1] * (i_y/2) + (i_x/2);
314     p_dst_v = p_context->p_pix[2] + p_context->i_stride[2] * (i_y/2) + (i_x/2);
315
316     for( i = 0; i < 2; i++ )
317     {
318         for( j = 0; j < 2; j ++ )
319         {
320             PIX_SET_Y( 2*j + 0, 2*i + 0,
321                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[0]);
322             PIX_SET_Y( 2*j + 1, 2*i + 0,
323                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[1]);
324             PIX_SET_Y( 2*j + 0, 2*i + 1,
325                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[2]);
326             PIX_SET_Y( 2*j + 1, 2*i + 1,
327                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[3]);
328
329             PIX_SET_UV( 1, p_dst_u, j, i,
330                         p_context->codebook_v4[i_strip][i_index[j+2*i]].i_u );
331             PIX_SET_UV( 2, p_dst_v, j, i,
332                         p_context->codebook_v4[i_strip][i_index[j+2*i]].i_v );
333         }
334     }
335 #undef PIX_SET_Y
336 #undef PIX_SET_UV
337 }
338
339 static void cinepak_Getv1( cinepak_context_t *p_context,
340                            int i_strip, int i_x,  int i_y,
341                            int i_x2, int i_y2, uint8_t *p_data )
342 {
343     uint8_t i_index;
344     int i,j;
345
346     uint8_t *p_dst_y, *p_dst_u, *p_dst_v;
347 #define PIX_SET_Y( x, y, v ) \
348     p_dst_y[(x) + (y)* p_context->i_stride[0]] = (v);
349
350 #define PIX_SET_UV( i,p, x, y, v ) \
351     p[(x) + (y)* (p_context->i_stride[i])] = (v);
352
353     i_index = *(p_data++);
354
355     /* y plane */
356     p_dst_y = p_context->p_pix[0] + p_context->i_stride[0] * i_y + i_x;
357     p_dst_u = p_context->p_pix[1] + p_context->i_stride[1] * (i_y/2) + (i_x/2);
358     p_dst_v = p_context->p_pix[2] + p_context->i_stride[2] * (i_y/2) + (i_x/2);
359
360     for( i = 0; i < 2; i++ )
361     {
362         for( j = 0; j < 2; j ++ )
363         {
364             PIX_SET_Y( 2*j + 0, 2*i + 0,
365                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
366             PIX_SET_Y( 2*j + 1, 2*i + 0,
367                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
368             PIX_SET_Y( 2*j + 0, 2*i + 1,
369                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
370             PIX_SET_Y( 2*j + 1, 2*i + 1,
371                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
372
373             PIX_SET_UV( 1,p_dst_u, j, i,
374                         p_context->codebook_v1[i_strip][i_index].i_u );
375             PIX_SET_UV( 2,p_dst_v, j, i,
376                         p_context->codebook_v1[i_strip][i_index].i_v );
377         }
378     }
379
380 #undef PIX_SET_Y
381 #undef PIX_SET_UV
382 }
383
384 /*****************************************************************************
385  * The function that decode one frame
386  *****************************************************************************/
387 static int cinepak_decode_frame( cinepak_context_t *p_context,
388                                  int i_length, uint8_t *p_data )
389 {
390     int i_strip;
391
392     int i_frame_flags;
393     int i_frame_size;
394     int i_width, i_height;
395     int i_frame_strips;
396     int i_index;
397     int i_strip_x1 =0, i_strip_y1=0;
398     int i_strip_x2 =0, i_strip_y2=0;
399
400     if( i_length <= 10 )
401     {
402         /* Broken header or no data */
403         return( -1 );
404     }
405
406     /* get header */
407     i_frame_flags  = *(p_data++);
408     i_frame_size = GET3BYTES( p_data );
409     i_width  = GET2BYTES( p_data );
410     i_height = GET2BYTES( p_data );
411     i_frame_strips = GET2BYTES( p_data );
412
413     if( !i_frame_size || !i_width || !i_height )
414     {
415         /* Broken header */
416         return( -1 );
417     }
418
419     /* Check if we have a picture buffer with good size */
420     if( ( p_context->i_width != i_width ) ||
421         ( p_context->i_height != i_height ) )
422     {
423         int i;
424         for( i = 0; i < 3; i++ )
425         {
426             FREE( p_context->p_pix[i] );
427         }
428
429         p_context->i_width = i_width;
430         p_context->i_height = i_height;
431
432         p_context->i_stride[0] = ( i_width + 3 ) & 0xfffc;
433         p_context->i_stride[1] = p_context->i_stride[2] =
434                 p_context->i_stride[0] / 2;
435
436         p_context->i_lines[0] = ( i_height + 3 ) & 0xfffc;
437         p_context->i_lines[1] = p_context->i_lines[2] =
438                 p_context->i_lines[0] /2;
439
440         for( i = 0; i < 3; i++ )
441         {
442             p_context->p_pix[i] = malloc( p_context->i_stride[i] *
443                                           p_context->i_lines[i] );
444             /* Set it to all black */
445             memset( p_context->p_pix[i], ( i == 0 ) ? 0 : 128 ,
446                     p_context->i_stride[i] * p_context->i_lines[i] );
447         }
448     }
449
450     if( i_frame_size != i_length )
451     {
452         i_length = __MIN( i_length, i_frame_size );
453     }
454     i_length -= 10;
455
456     if( i_frame_strips >= CINEPAK_MAXSTRIP )
457     {
458         i_frame_strips = CINEPAK_MAXSTRIP;
459     }
460
461     /* Now decode each strip */
462     for( i_strip = 0; i_strip < i_frame_strips; i_strip++ )
463     {
464         int i_strip_id;
465         int i_strip_size;
466
467         if( i_length <= 12 )
468         {
469             break;
470         }
471
472         i_strip_id   = GET2BYTES( p_data );
473         i_strip_size = GET2BYTES( p_data );
474         i_strip_size = __MIN( i_strip_size, i_length );
475         /* FIXME I don't really understand how it's work; */
476         i_strip_y1  = i_strip_y2 + GET2BYTES( p_data );
477         i_strip_x1  = GET2BYTES( p_data );
478         i_strip_y2  = i_strip_y2 + GET2BYTES( p_data );
479         i_strip_x2  = GET2BYTES( p_data );
480
481         i_length -= i_strip_size;
482
483         i_strip_size -= 12;
484         /* init codebook , if needed */
485         if( ( i_strip > 0 )&&( !(i_frame_flags&0x01) ) )
486         {
487             memcpy( &p_context->codebook_v1[i_strip],
488                     &p_context->codebook_v1[i_strip-1],
489                     sizeof(cinepak_codebook_t[256] ) );
490
491             memcpy( &p_context->codebook_v4[i_strip],
492                     &p_context->codebook_v4[i_strip-1],
493                     sizeof(cinepak_codebook_t[256] ) );
494         }
495
496         /* Now parse all chunk in this strip */
497         while( i_strip_size > 0 )
498         {
499             cinepak_codebook_t (*p_codebook)[CINEPAK_MAXSTRIP][256];
500             int i_mode;
501
502             int i_chunk_id;
503             int i_chunk_size;
504             uint32_t i_vector_flags;
505             int i_count;
506             int i;
507             int i_x, i_y; /* (0,0) begin in fact at (x1,y1) ... */
508
509             i_chunk_id   = GET2BYTES( p_data );
510             i_chunk_size = GET2BYTES( p_data );
511             i_chunk_size  = __MIN( i_chunk_size, i_strip_size );
512             i_strip_size -= i_chunk_size;
513
514             i_chunk_size -= 4;
515
516             i_x = 0;
517             i_y = 0;
518             if( i_chunk_size < 0 )
519             {
520                 break;
521             }
522
523             switch( i_chunk_id )
524             {
525             case( 0x2000 ): /* 12bits v4 Intra*/
526             case( 0x2200 ): /* 12bits v1 Intra*/
527             case( 0x2400 ): /* 8bits v4 Intra*/
528             case( 0x2600 ): /* 8bits v1 Intra */
529                 i_mode = ( ( i_chunk_id&0x0400 ) == 0 );
530                 p_codebook = ( i_chunk_id&0x0200 ) ?
531                                &p_context->codebook_v1 :
532                                &p_context->codebook_v4;
533
534                 i_count = __MIN( i_chunk_size / ( i_mode ? 6 : 4 ), 256 );
535
536                 for( i = 0; i < i_count; i++ )
537                 {
538                     cinepak_LoadCodebook( &((*p_codebook)[i_strip][i]),
539                                           p_data,
540                                           i_mode&~p_context->b_grayscale );
541                     p_data += i_mode ? 6 : 4;
542                     i_chunk_size -= i_mode ? 6 : 4;
543                 }
544                 break;
545
546             case( 0x2100 ): /* selective 12bits v4 Inter*/
547             case( 0x2300 ): /* selective 12bits v1 Inter*/
548             case( 0x2500 ): /* selective 8bits v4 Inter*/
549             case( 0x2700 ): /* selective 8bits v1 Inter*/
550                 i_mode = ( ( i_chunk_id&0x0400 ) == 0 );
551                 p_codebook = ( i_chunk_id&0x0200 ) ?
552                                &p_context->codebook_v1 :
553                                &p_context->codebook_v4;
554
555                 i_index = 0;
556                 while( (i_chunk_size > 4)&&(i_index<256))
557                 {
558                     i_vector_flags = GET4BYTES( p_data );
559                     i_chunk_size -= 4;
560                     for( i = 0; i < 32; i++ )
561                     {
562                         if( ( i_chunk_size < ( i_mode ? 6 : 4 ) )
563                             || (i_index >= 256 ) )
564                         {
565                             break;
566                         }
567                         if( i_vector_flags&0x80000000UL )
568                         {
569                             cinepak_LoadCodebook(
570                                 &((*p_codebook)[i_strip][i_index]),
571                                 p_data, i_mode&~p_context->b_grayscale );
572
573                             p_data += i_mode ? 6 : 4;
574                             i_chunk_size -= i_mode ? 6 : 4;
575                         }
576                         i_index++;
577                         i_vector_flags <<= 1;
578                     }
579                 }
580                 break;
581
582             case( 0x3000 ): /* load image Intra */
583                 while( (i_chunk_size >= 4 )&&(i_y<i_strip_y2-i_strip_y1) )
584                 {
585                     i_vector_flags = GET4BYTES( p_data );
586                     i_chunk_size -= 4;
587                     i_strip_size -= 4;
588                     i_length     -= 4;
589
590                     for( i = 0; i < 32; i++ )
591                     {
592                         if( ( i_y >= i_strip_y2 - i_strip_y1) ||
593                             ( i_chunk_size<=0 ) )
594                         {
595                             break;
596                         }
597                         if( i_vector_flags&0x80000000UL )
598                         {
599                             cinepak_Getv4( p_context,
600                                            i_strip,
601                                            i_strip_x1 + i_x,
602                                            i_strip_y1 + i_y,
603                                            i_strip_x2, i_strip_y2,
604                                            p_data );
605                             p_data += 4;
606                             i_chunk_size -= 4;
607                         }
608                         else
609                         {
610                             cinepak_Getv1( p_context,
611                                            i_strip,
612                                            i_strip_x1 + i_x,
613                                            i_strip_y1 + i_y,
614                                            i_strip_x2, i_strip_y2,
615                                            p_data );
616                             p_data++;
617                             i_chunk_size--;
618                         }
619
620                         i_x += 4;
621                         if( i_x >= i_strip_x2 - i_strip_x1 )
622                         {
623                             i_x = 0;
624                             i_y += 4;
625                         }
626                         i_vector_flags <<= 1;
627                     }
628                 }
629                 break;
630
631             case( 0x3100 ): /* load image Inter */
632                 while( ( i_chunk_size > 4 )&&( i_y < i_strip_y2 - i_strip_y1) )
633                 {
634                     uint32_t i_mask;
635                     i_vector_flags = GET4BYTES( p_data );
636                     i_chunk_size -= 4;
637                     i_mask = 0x80000000UL;
638
639                     while( (i_chunk_size > 0 ) && ( i_mask )
640                            && ( i_y < i_strip_y2 - i_strip_y1 ) )
641                     {
642                         if( i_vector_flags&i_mask )
643                         {
644                             i_mask >>= 1;
645                             if( !i_mask )
646                             {
647                                 if( i_chunk_size < 4 )
648                                 {
649                                     break;
650                                 }
651                                 i_vector_flags = GET4BYTES( p_data );
652                                 i_chunk_size -= 4;
653                                 i_mask = 0x80000000UL;
654                             }
655                             if( i_vector_flags&i_mask )
656                             {
657                                 if( i_chunk_size < 4 ) break;
658                                 cinepak_Getv4( p_context,
659                                                i_strip,
660                                                i_strip_x1 + i_x,
661                                                i_strip_y1 + i_y,
662                                                i_strip_x2, i_strip_y2,
663                                                p_data );
664                                 p_data += 4;
665                                 i_chunk_size -= 4;
666                             }
667                             else
668                             {
669                                 if( i_chunk_size < 1 ) break;
670                                 cinepak_Getv1( p_context,
671                                                i_strip,
672                                                i_strip_x1 + i_x,
673                                                i_strip_y1 + i_y,
674                                                i_strip_x2, i_strip_y2,
675                                                p_data );
676                                 p_data++;
677                                 i_chunk_size--;
678                             }
679                         }
680                         i_mask >>= 1;
681
682                         i_x += 4;
683                         if( i_x >= i_strip_x2 - i_strip_x1 )
684                         {
685                             i_x = 0;
686                             i_y += 4;
687                         }
688                     }
689                 }
690                 break;
691
692             case( 0x3200 ): /* load intra picture but all v1*/
693                 while( ( i_chunk_size > 0 ) &&
694                        ( i_y < i_strip_y2 - i_strip_y1 ) )
695                 {
696                     cinepak_Getv1( p_context,
697                                    i_strip,
698                                    i_strip_x1 + i_x,
699                                    i_strip_y1 + i_y,
700                                    i_strip_x2, i_strip_y2,
701                                    p_data );
702                     p_data++;
703                     i_chunk_size--;
704
705                     i_x += 4;
706                     if( i_x >= i_strip_x2 - i_strip_x1 )
707                     {
708                         i_x = 0;
709                         i_y += 4;
710                     }
711                 }
712                 break;
713
714             default:
715                 break;
716
717             }
718             p_data += i_chunk_size ; /* skip remains bytes */
719         }
720     }
721
722     return( 0 );
723 }