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