]> git.sesse.net Git - vlc/blob - modules/codec/cinepak.c
Copyright fixes
[vlc] / modules / codec / cinepak.c
1 /*****************************************************************************
2  * cinepak.c: cinepak video decoder
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN (Centrale Réseaux) and its contributors
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <vlc/vlc.h>
28 #include <vlc/vout.h>
29 #include <vlc/decoder.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 #define FREE( p ) \
229     if( p ) free( p )
230
231 static void cinepak_LoadCodebook( cinepak_codebook_t *p_codebook,
232                                   uint8_t *p_data, int b_grayscale )
233 {
234     int i, i_y[4], i_u, i_v, i_Cb, i_Cr;
235     int i_uv;
236 #define SCALEBITS 12
237 #define FIX( x ) ( (int)( (x) * ( 1L << SCALEBITS ) + 0.5 ) )
238
239     for( i = 0; i < 4; i++ )
240     {
241         i_y[i] = (uint8_t)( *(p_data++) );
242     }
243     if( b_grayscale )
244     {
245         i_u  = (int8_t)( *(p_data++) );
246         i_v  = (int8_t)( *(p_data++) );
247     }
248     else
249     {
250         i_u  = 0;
251         i_v  = 0;
252     }
253
254     /*
255           | Y  |   | 1 -0.0655  0.0110 | | CY |
256           | Cb | = | 0  1.1656 -0.0062 | | CU |
257           | Cr |   | 0  0.0467  1.4187 | | CV |
258      */
259     i_uv = ( FIX( -0.0655 ) * i_u + FIX( 0.0110 ) * i_v ) >> SCALEBITS;
260     for( i = 0; i < 4; i++ )
261     {
262         i_y[i] += i_uv;
263     }
264     i_Cb  = ( FIX( 1.1656 ) * i_u + FIX( -0.0062 ) * i_v ) >> SCALEBITS;
265     i_Cr  = ( FIX( 0.0467 ) * i_u + FIX(  1.4187 ) * i_v ) >> SCALEBITS;
266
267     for( i = 0; i < 4; i++ )
268     {
269         p_codebook->i_y[i] = __MIN( __MAX( 0, i_y[i] ), 255 );
270     }
271     p_codebook->i_u  = __MIN( __MAX( 0, i_Cb + 128 ), 255 );
272     p_codebook->i_v  = __MIN( __MAX( 0, i_Cr + 128 ), 255 );
273
274 #undef FIX
275 #undef SCALEBITS
276 }
277
278 static void cinepak_Getv4( cinepak_context_t *p_context,
279                            int i_strip, int i_x, int i_y,
280                            int i_x2, int i_y2, uint8_t *p_data )
281 {
282     uint8_t i_index[4];
283     int i,j;
284
285     uint8_t *p_dst_y, *p_dst_u, *p_dst_v;
286 #define PIX_SET_Y( x, y, v ) \
287     p_dst_y[(x) + (y)* p_context->i_stride[0]] = (v);
288
289 #define PIX_SET_UV( i, p, x, y, v ) \
290     p[(x) + (y)* (p_context->i_stride[i])] = (v);
291
292     for( i = 0; i < 4; i++ )
293     {
294         i_index[i] = *(p_data++);
295     }
296
297     /* y plane */
298     p_dst_y = p_context->p_pix[0] + p_context->i_stride[0] * i_y + i_x;
299     p_dst_u = p_context->p_pix[1] + p_context->i_stride[1] * (i_y/2) + (i_x/2);
300     p_dst_v = p_context->p_pix[2] + p_context->i_stride[2] * (i_y/2) + (i_x/2);
301
302     for( i = 0; i < 2; i++ )
303     {
304         for( j = 0; j < 2; j ++ )
305         {
306             PIX_SET_Y( 2*j + 0, 2*i + 0,
307                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[0]);
308             PIX_SET_Y( 2*j + 1, 2*i + 0,
309                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[1]);
310             PIX_SET_Y( 2*j + 0, 2*i + 1,
311                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[2]);
312             PIX_SET_Y( 2*j + 1, 2*i + 1,
313                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[3]);
314
315             PIX_SET_UV( 1, p_dst_u, j, i,
316                         p_context->codebook_v4[i_strip][i_index[j+2*i]].i_u );
317             PIX_SET_UV( 2, p_dst_v, j, i,
318                         p_context->codebook_v4[i_strip][i_index[j+2*i]].i_v );
319         }
320     }
321 #undef PIX_SET_Y
322 #undef PIX_SET_UV
323 }
324
325 static void cinepak_Getv1( cinepak_context_t *p_context,
326                            int i_strip, int i_x,  int i_y,
327                            int i_x2, int i_y2, uint8_t *p_data )
328 {
329     uint8_t i_index;
330     int i,j;
331
332     uint8_t *p_dst_y, *p_dst_u, *p_dst_v;
333 #define PIX_SET_Y( x, y, v ) \
334     p_dst_y[(x) + (y)* p_context->i_stride[0]] = (v);
335
336 #define PIX_SET_UV( i,p, x, y, v ) \
337     p[(x) + (y)* (p_context->i_stride[i])] = (v);
338
339     i_index = *(p_data++);
340
341     /* y plane */
342     p_dst_y = p_context->p_pix[0] + p_context->i_stride[0] * i_y + i_x;
343     p_dst_u = p_context->p_pix[1] + p_context->i_stride[1] * (i_y/2) + (i_x/2);
344     p_dst_v = p_context->p_pix[2] + p_context->i_stride[2] * (i_y/2) + (i_x/2);
345
346     for( i = 0; i < 2; i++ )
347     {
348         for( j = 0; j < 2; j ++ )
349         {
350             PIX_SET_Y( 2*j + 0, 2*i + 0,
351                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
352             PIX_SET_Y( 2*j + 1, 2*i + 0,
353                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
354             PIX_SET_Y( 2*j + 0, 2*i + 1,
355                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
356             PIX_SET_Y( 2*j + 1, 2*i + 1,
357                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
358
359             PIX_SET_UV( 1,p_dst_u, j, i,
360                         p_context->codebook_v1[i_strip][i_index].i_u );
361             PIX_SET_UV( 2,p_dst_v, j, i,
362                         p_context->codebook_v1[i_strip][i_index].i_v );
363         }
364     }
365
366 #undef PIX_SET_Y
367 #undef PIX_SET_UV
368 }
369
370 /*****************************************************************************
371  * The function that decode one frame
372  *****************************************************************************/
373 static int cinepak_decode_frame( cinepak_context_t *p_context,
374                                  int i_length, uint8_t *p_data )
375 {
376     int i_strip;
377
378     int i_frame_flags;
379     int i_frame_size;
380     int i_width, i_height;
381     int i_frame_strips;
382     int i_index;
383     int i_strip_x1 =0, i_strip_y1=0;
384     int i_strip_x2 =0, i_strip_y2=0;
385
386     if( i_length <= 10 )
387     {
388         /* Broken header or no data */
389         return( -1 );
390     }
391
392     /* get header */
393     i_frame_flags  = *(p_data++);
394     i_frame_size = GET3BYTES( p_data );
395     i_width  = GET2BYTES( p_data );
396     i_height = GET2BYTES( p_data );
397     i_frame_strips = GET2BYTES( p_data );
398
399     if( !i_frame_size || !i_width || !i_height )
400     {
401         /* Broken header */
402         return( -1 );
403     }
404
405     /* Check if we have a picture buffer with good size */
406     if( ( p_context->i_width != i_width ) ||
407         ( p_context->i_height != i_height ) )
408     {
409         int i;
410         for( i = 0; i < 3; i++ )
411         {
412             FREE( p_context->p_pix[i] );
413         }
414
415         p_context->i_width = i_width;
416         p_context->i_height = i_height;
417
418         p_context->i_stride[0] = ( i_width + 3 ) & 0xfffc;
419         p_context->i_stride[1] = p_context->i_stride[2] =
420                 p_context->i_stride[0] / 2;
421
422         p_context->i_lines[0] = ( i_height + 3 ) & 0xfffc;
423         p_context->i_lines[1] = p_context->i_lines[2] =
424                 p_context->i_lines[0] /2;
425
426         for( i = 0; i < 3; i++ )
427         {
428             p_context->p_pix[i] = malloc( p_context->i_stride[i] *
429                                           p_context->i_lines[i] );
430             /* Set it to all black */
431             memset( p_context->p_pix[i], ( i == 0 ) ? 0 : 128 ,
432                     p_context->i_stride[i] * p_context->i_lines[i] );
433         }
434     }
435
436     if( i_frame_size != i_length )
437     {
438         i_length = __MIN( i_length, i_frame_size );
439     }
440     i_length -= 10;
441
442     if( i_frame_strips >= CINEPAK_MAXSTRIP )
443     {
444         i_frame_strips = CINEPAK_MAXSTRIP;
445     }
446
447     /* Now decode each strip */
448     for( i_strip = 0; i_strip < i_frame_strips; i_strip++ )
449     {
450         int i_strip_id;
451         int i_strip_size;
452
453         if( i_length <= 12 )
454         {
455             break;
456         }
457
458         i_strip_id   = GET2BYTES( p_data );
459         i_strip_size = GET2BYTES( p_data );
460         i_strip_size = __MIN( i_strip_size, i_length );
461         /* FIXME I don't really understand how it's work; */
462         i_strip_y1  = i_strip_y2 + GET2BYTES( p_data );
463         i_strip_x1  = GET2BYTES( p_data );
464         i_strip_y2  = i_strip_y2 + GET2BYTES( p_data );
465         i_strip_x2  = GET2BYTES( p_data );
466
467         i_length -= i_strip_size;
468
469         i_strip_size -= 12;
470         /* init codebook , if needed */
471         if( ( i_strip > 0 )&&( !(i_frame_flags&0x01) ) )
472         {
473             memcpy( &p_context->codebook_v1[i_strip],
474                     &p_context->codebook_v1[i_strip-1],
475                     sizeof(cinepak_codebook_t[256] ) );
476
477             memcpy( &p_context->codebook_v4[i_strip],
478                     &p_context->codebook_v4[i_strip-1],
479                     sizeof(cinepak_codebook_t[256] ) );
480         }
481
482         /* Now parse all chunk in this strip */
483         while( i_strip_size > 0 )
484         {
485             cinepak_codebook_t (*p_codebook)[CINEPAK_MAXSTRIP][256];
486             int i_mode;
487
488             int i_chunk_id;
489             int i_chunk_size;
490             uint32_t i_vector_flags;
491             int i_count;
492             int i;
493             int i_x, i_y; /* (0,0) begin in fact at (x1,y1) ... */
494
495             i_chunk_id   = GET2BYTES( p_data );
496             i_chunk_size = GET2BYTES( p_data );
497             i_chunk_size  = __MIN( i_chunk_size, i_strip_size );
498             i_strip_size -= i_chunk_size;
499
500             i_chunk_size -= 4;
501
502             i_x = 0;
503             i_y = 0;
504             if( i_chunk_size < 0 )
505             {
506                 break;
507             }
508
509             switch( i_chunk_id )
510             {
511             case( 0x2000 ): /* 12bits v4 Intra*/
512             case( 0x2200 ): /* 12bits v1 Intra*/
513             case( 0x2400 ): /* 8bits v4 Intra*/
514             case( 0x2600 ): /* 8bits v1 Intra */
515                 i_mode = ( ( i_chunk_id&0x0400 ) == 0 );
516                 p_codebook = ( i_chunk_id&0x0200 ) ?
517                                &p_context->codebook_v1 :
518                                &p_context->codebook_v4;
519
520                 i_count = __MIN( i_chunk_size / ( i_mode ? 6 : 4 ), 256 );
521
522                 for( i = 0; i < i_count; i++ )
523                 {
524                     cinepak_LoadCodebook( &((*p_codebook)[i_strip][i]),
525                                           p_data,
526                                           i_mode&~p_context->b_grayscale );
527                     p_data += i_mode ? 6 : 4;
528                     i_chunk_size -= i_mode ? 6 : 4;
529                 }
530                 break;
531
532             case( 0x2100 ): /* selective 12bits v4 Inter*/
533             case( 0x2300 ): /* selective 12bits v1 Inter*/
534             case( 0x2500 ): /* selective 8bits v4 Inter*/
535             case( 0x2700 ): /* selective 8bits v1 Inter*/
536                 i_mode = ( ( i_chunk_id&0x0400 ) == 0 );
537                 p_codebook = ( i_chunk_id&0x0200 ) ?
538                                &p_context->codebook_v1 :
539                                &p_context->codebook_v4;
540
541                 i_index = 0;
542                 while( (i_chunk_size > 4)&&(i_index<256))
543                 {
544                     i_vector_flags = GET4BYTES( p_data );
545                     i_chunk_size -= 4;
546                     for( i = 0; i < 32; i++ )
547                     {
548                         if( ( i_chunk_size < ( i_mode ? 6 : 4 ) )
549                             || (i_index >= 256 ) )
550                         {
551                             break;
552                         }
553                         if( i_vector_flags&0x80000000UL )
554                         {
555                             cinepak_LoadCodebook(
556                                 &((*p_codebook)[i_strip][i_index]),
557                                 p_data, i_mode&~p_context->b_grayscale );
558
559                             p_data += i_mode ? 6 : 4;
560                             i_chunk_size -= i_mode ? 6 : 4;
561                         }
562                         i_index++;
563                         i_vector_flags <<= 1;
564                     }
565                 }
566                 break;
567
568             case( 0x3000 ): /* load image Intra */
569                 while( (i_chunk_size >= 4 )&&(i_y<i_strip_y2-i_strip_y1) )
570                 {
571                     i_vector_flags = GET4BYTES( p_data );
572                     i_chunk_size -= 4;
573                     i_strip_size -= 4;
574                     i_length     -= 4;
575
576                     for( i = 0; i < 32; i++ )
577                     {
578                         if( ( i_y >= i_strip_y2 - i_strip_y1) ||
579                             ( i_chunk_size<=0 ) )
580                         {
581                             break;
582                         }
583                         if( i_vector_flags&0x80000000UL )
584                         {
585                             cinepak_Getv4( p_context,
586                                            i_strip,
587                                            i_strip_x1 + i_x,
588                                            i_strip_y1 + i_y,
589                                            i_strip_x2, i_strip_y2,
590                                            p_data );
591                             p_data += 4;
592                             i_chunk_size -= 4;
593                         }
594                         else
595                         {
596                             cinepak_Getv1( p_context,
597                                            i_strip,
598                                            i_strip_x1 + i_x,
599                                            i_strip_y1 + i_y,
600                                            i_strip_x2, i_strip_y2,
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                                                i_strip_x2, i_strip_y2,
649                                                p_data );
650                                 p_data += 4;
651                                 i_chunk_size -= 4;
652                             }
653                             else
654                             {
655                                 if( i_chunk_size < 1 ) break;
656                                 cinepak_Getv1( p_context,
657                                                i_strip,
658                                                i_strip_x1 + i_x,
659                                                i_strip_y1 + i_y,
660                                                i_strip_x2, i_strip_y2,
661                                                p_data );
662                                 p_data++;
663                                 i_chunk_size--;
664                             }
665                         }
666                         i_mask >>= 1;
667
668                         i_x += 4;
669                         if( i_x >= i_strip_x2 - i_strip_x1 )
670                         {
671                             i_x = 0;
672                             i_y += 4;
673                         }
674                     }
675                 }
676                 break;
677
678             case( 0x3200 ): /* load intra picture but all v1*/
679                 while( ( i_chunk_size > 0 ) &&
680                        ( i_y < i_strip_y2 - i_strip_y1 ) )
681                 {
682                     cinepak_Getv1( p_context,
683                                    i_strip,
684                                    i_strip_x1 + i_x,
685                                    i_strip_y1 + i_y,
686                                    i_strip_x2, i_strip_y2,
687                                    p_data );
688                     p_data++;
689                     i_chunk_size--;
690
691                     i_x += 4;
692                     if( i_x >= i_strip_x2 - i_strip_x1 )
693                     {
694                         i_x = 0;
695                         i_y += 4;
696                     }
697                 }
698                 break;
699
700             default:
701                 break;
702
703             }
704             p_data += i_chunk_size ; /* skip remains bytes */
705         }
706     }
707
708     return( 0 );
709 }