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