]> git.sesse.net Git - vlc/blob - modules/codec/cinepak.c
Another time : remove useless test before free().
[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         free( p_sys->context.p_pix[i] );
213
214     free( p_sys );
215 }
216
217 /*****************************************************************************
218  * local Functions
219  *****************************************************************************/
220
221 #define GET2BYTES( p ) \
222     GetWBE( p ); p+= 2;
223 /* FIXME */
224 #define GET3BYTES( p ) \
225     (GetDWBE( p ) >> 8); p+= 3;
226
227 #define GET4BYTES( p ) \
228     GetDWBE( p ); p+= 4;
229
230 static void cinepak_LoadCodebook( cinepak_codebook_t *p_codebook,
231                                   uint8_t *p_data, int b_grayscale )
232 {
233     int i, i_y[4], i_u, i_v, i_Cb, i_Cr;
234     int i_uv;
235 #define SCALEBITS 12
236 #define FIX( x ) ( (int)( (x) * ( 1L << SCALEBITS ) + 0.5 ) )
237
238     for( i = 0; i < 4; i++ )
239     {
240         i_y[i] = (uint8_t)( *(p_data++) );
241     }
242     if( b_grayscale )
243     {
244         i_u  = (int8_t)( *(p_data++) );
245         i_v  = (int8_t)( *(p_data++) );
246     }
247     else
248     {
249         i_u  = 0;
250         i_v  = 0;
251     }
252
253     /*
254           | Y  |   | 1 -0.0655  0.0110 | | CY |
255           | Cb | = | 0  1.1656 -0.0062 | | CU |
256           | Cr |   | 0  0.0467  1.4187 | | CV |
257      */
258     i_uv = ( FIX( -0.0655 ) * i_u + FIX( 0.0110 ) * i_v ) >> SCALEBITS;
259     for( i = 0; i < 4; i++ )
260     {
261         i_y[i] += i_uv;
262     }
263     i_Cb  = ( FIX( 1.1656 ) * i_u + FIX( -0.0062 ) * i_v ) >> SCALEBITS;
264     i_Cr  = ( FIX( 0.0467 ) * i_u + FIX(  1.4187 ) * i_v ) >> SCALEBITS;
265
266     for( i = 0; i < 4; i++ )
267     {
268         p_codebook->i_y[i] = __MIN( __MAX( 0, i_y[i] ), 255 );
269     }
270     p_codebook->i_u  = __MIN( __MAX( 0, i_Cb + 128 ), 255 );
271     p_codebook->i_v  = __MIN( __MAX( 0, i_Cr + 128 ), 255 );
272
273 #undef FIX
274 #undef SCALEBITS
275 }
276
277 static void cinepak_Getv4( cinepak_context_t *p_context,
278                            int i_strip, int i_x, int i_y,
279                            uint8_t *p_data )
280 {
281     uint8_t i_index[4];
282     int i,j;
283
284     uint8_t *p_dst_y, *p_dst_u, *p_dst_v;
285 #define PIX_SET_Y( x, y, v ) \
286     p_dst_y[(x) + (y)* p_context->i_stride[0]] = (v);
287
288 #define PIX_SET_UV( i, p, x, y, v ) \
289     p[(x) + (y)* (p_context->i_stride[i])] = (v);
290
291     for( i = 0; i < 4; i++ )
292     {
293         i_index[i] = *(p_data++);
294     }
295
296     /* y plane */
297     p_dst_y = p_context->p_pix[0] + p_context->i_stride[0] * i_y + i_x;
298     p_dst_u = p_context->p_pix[1] + p_context->i_stride[1] * (i_y/2) + (i_x/2);
299     p_dst_v = p_context->p_pix[2] + p_context->i_stride[2] * (i_y/2) + (i_x/2);
300
301     for( i = 0; i < 2; i++ )
302     {
303         for( j = 0; j < 2; j ++ )
304         {
305             PIX_SET_Y( 2*j + 0, 2*i + 0,
306                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[0]);
307             PIX_SET_Y( 2*j + 1, 2*i + 0,
308                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[1]);
309             PIX_SET_Y( 2*j + 0, 2*i + 1,
310                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[2]);
311             PIX_SET_Y( 2*j + 1, 2*i + 1,
312                        p_context->codebook_v4[i_strip][i_index[j+2*i]].i_y[3]);
313
314             PIX_SET_UV( 1, p_dst_u, j, i,
315                         p_context->codebook_v4[i_strip][i_index[j+2*i]].i_u );
316             PIX_SET_UV( 2, p_dst_v, j, i,
317                         p_context->codebook_v4[i_strip][i_index[j+2*i]].i_v );
318         }
319     }
320 #undef PIX_SET_Y
321 #undef PIX_SET_UV
322 }
323
324 static void cinepak_Getv1( cinepak_context_t *p_context,
325                            int i_strip, int i_x,  int i_y,
326                            uint8_t *p_data )
327 {
328     uint8_t i_index;
329     int i,j;
330
331     uint8_t *p_dst_y, *p_dst_u, *p_dst_v;
332 #define PIX_SET_Y( x, y, v ) \
333     p_dst_y[(x) + (y)* p_context->i_stride[0]] = (v);
334
335 #define PIX_SET_UV( i,p, x, y, v ) \
336     p[(x) + (y)* (p_context->i_stride[i])] = (v);
337
338     i_index = *(p_data++);
339
340     /* y plane */
341     p_dst_y = p_context->p_pix[0] + p_context->i_stride[0] * i_y + i_x;
342     p_dst_u = p_context->p_pix[1] + p_context->i_stride[1] * (i_y/2) + (i_x/2);
343     p_dst_v = p_context->p_pix[2] + p_context->i_stride[2] * (i_y/2) + (i_x/2);
344
345     for( i = 0; i < 2; i++ )
346     {
347         for( j = 0; j < 2; j ++ )
348         {
349             PIX_SET_Y( 2*j + 0, 2*i + 0,
350                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
351             PIX_SET_Y( 2*j + 1, 2*i + 0,
352                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
353             PIX_SET_Y( 2*j + 0, 2*i + 1,
354                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
355             PIX_SET_Y( 2*j + 1, 2*i + 1,
356                        p_context->codebook_v1[i_strip][i_index].i_y[2*i+j] );
357
358             PIX_SET_UV( 1,p_dst_u, j, i,
359                         p_context->codebook_v1[i_strip][i_index].i_u );
360             PIX_SET_UV( 2,p_dst_v, j, i,
361                         p_context->codebook_v1[i_strip][i_index].i_v );
362         }
363     }
364
365 #undef PIX_SET_Y
366 #undef PIX_SET_UV
367 }
368
369 /*****************************************************************************
370  * The function that decode one frame
371  *****************************************************************************/
372 static int cinepak_decode_frame( cinepak_context_t *p_context,
373                                  int i_length, uint8_t *p_data )
374 {
375     int i_strip;
376
377     int i_frame_flags;
378     int i_frame_size;
379     int i_width, i_height;
380     int i_frame_strips;
381     int i_index;
382     int i_strip_x1 =0, i_strip_y1=0;
383     int i_strip_x2 =0, i_strip_y2=0;
384
385     if( i_length <= 10 )
386     {
387         /* Broken header or no data */
388         return( -1 );
389     }
390
391     /* get header */
392     i_frame_flags  = *(p_data++);
393     i_frame_size = GET3BYTES( p_data );
394     i_width  = GET2BYTES( p_data );
395     i_height = GET2BYTES( p_data );
396     i_frame_strips = GET2BYTES( p_data );
397
398     if( !i_frame_size || !i_width || !i_height ||
399         i_width > 0xffff-3 || i_height > 0xffff-3)
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 works; */
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                                            p_data );
590                             p_data += 4;
591                             i_chunk_size -= 4;
592                         }
593                         else
594                         {
595                             cinepak_Getv1( p_context,
596                                            i_strip,
597                                            i_strip_x1 + i_x,
598                                            i_strip_y1 + i_y,
599                                            p_data );
600                             p_data++;
601                             i_chunk_size--;
602                         }
603
604                         i_x += 4;
605                         if( i_x >= i_strip_x2 - i_strip_x1 )
606                         {
607                             i_x = 0;
608                             i_y += 4;
609                         }
610                         i_vector_flags <<= 1;
611                     }
612                 }
613                 break;
614
615             case( 0x3100 ): /* load image Inter */
616                 while( ( i_chunk_size > 4 )&&( i_y < i_strip_y2 - i_strip_y1) )
617                 {
618                     uint32_t i_mask;
619                     i_vector_flags = GET4BYTES( p_data );
620                     i_chunk_size -= 4;
621                     i_mask = 0x80000000UL;
622
623                     while( (i_chunk_size > 0 ) && ( i_mask )
624                            && ( i_y < i_strip_y2 - i_strip_y1 ) )
625                     {
626                         if( i_vector_flags&i_mask )
627                         {
628                             i_mask >>= 1;
629                             if( !i_mask )
630                             {
631                                 if( i_chunk_size < 4 )
632                                 {
633                                     break;
634                                 }
635                                 i_vector_flags = GET4BYTES( p_data );
636                                 i_chunk_size -= 4;
637                                 i_mask = 0x80000000UL;
638                             }
639                             if( i_vector_flags&i_mask )
640                             {
641                                 if( i_chunk_size < 4 ) break;
642                                 cinepak_Getv4( p_context,
643                                                i_strip,
644                                                i_strip_x1 + i_x,
645                                                i_strip_y1 + i_y,
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                                                p_data );
658                                 p_data++;
659                                 i_chunk_size--;
660                             }
661                         }
662                         i_mask >>= 1;
663
664                         i_x += 4;
665                         if( i_x >= i_strip_x2 - i_strip_x1 )
666                         {
667                             i_x = 0;
668                             i_y += 4;
669                         }
670                     }
671                 }
672                 break;
673
674             case( 0x3200 ): /* load intra picture but all v1*/
675                 while( ( i_chunk_size > 0 ) &&
676                        ( i_y < i_strip_y2 - i_strip_y1 ) )
677                 {
678                     cinepak_Getv1( p_context,
679                                    i_strip,
680                                    i_strip_x1 + i_x,
681                                    i_strip_y1 + i_y,
682                                    p_data );
683                     p_data++;
684                     i_chunk_size--;
685
686                     i_x += 4;
687                     if( i_x >= i_strip_x2 - i_strip_x1 )
688                     {
689                         i_x = 0;
690                         i_y += 4;
691                     }
692                 }
693                 break;
694
695             default:
696                 break;
697
698             }
699             p_data += i_chunk_size ; /* skip remains bytes */
700         }
701     }
702
703     return( 0 );
704 }