0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

break if error in decompressing, moved buffer allocating

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4645 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
alex 2002-02-10 18:17:17 +00:00
parent 24e208b65b
commit e9063eed00

View File

@ -27,8 +27,10 @@ void decode_nuv( unsigned char *encoded, int encoded_size,
int r; int r;
unsigned int out_len; unsigned int out_len;
struct rtframeheader *encodedh = ( struct rtframeheader* ) encoded; struct rtframeheader *encodedh = ( struct rtframeheader* ) encoded;
static unsigned char *buffer = 0; static unsigned char *buffer = 0; /* for RTJpeg with LZO decompress */
static unsigned char *previous_buffer = 0; #ifdef KEEP_BUFFER
static unsigned char *previous_buffer = 0; /* to support Last-frame-copy */
#endif
static is_lzo_inited = 0; static is_lzo_inited = 0;
// printf("frametype: %c, comtype: %c, encoded_size: %d, width: %d, height: %d\n", // printf("frametype: %c, comtype: %c, encoded_size: %d, width: %d, height: %d\n",
@ -49,25 +51,9 @@ void decode_nuv( unsigned char *encoded, int encoded_size,
} }
case 'V': case 'V':
{ {
/* do the buffer stuffs */
if ( buffer == NULL )
{
buffer = ( unsigned char * ) malloc ( width * height + ( width * height ) / 2 );
#if 0
printf ( "Allocated for %dx%d image %d bytes\n", width, height,
width * height + ( width * height ) / 2 );
#endif
}
#ifdef KEEP_BUFFER #ifdef KEEP_BUFFER
if ( previous_buffer == NULL ) if (!previous_buffer)
{
previous_buffer = ( unsigned char * ) malloc ( width * height + ( width * height ) / 2 ); previous_buffer = ( unsigned char * ) malloc ( width * height + ( width * height ) / 2 );
#if 0
printf ( "Allocated for %dx%d image %d bytes\n", width, height,
width * height + ( width * height ) / 2 );
#endif
}
#endif #endif
if (((encodedh->comptype == '2') || if (((encodedh->comptype == '2') ||
@ -91,10 +77,18 @@ void decode_nuv( unsigned char *encoded, int encoded_size,
RTjpeg_decompressYUV420 ( ( __s8 * ) encoded + 12, decoded ); RTjpeg_decompressYUV420 ( ( __s8 * ) encoded + 12, decoded );
break; break;
case '2': /* RTJpeg with LZO */ case '2': /* RTJpeg with LZO */
if (!buffer)
buffer = ( unsigned char * ) malloc ( width * height + ( width * height ) / 2 );
if (!buffer)
{
printf ( "Error decompressing\n" );
break;
}
r = lzo1x_decompress ( encoded + 12, encodedh->packetlength, buffer, &out_len, NULL ); r = lzo1x_decompress ( encoded + 12, encodedh->packetlength, buffer, &out_len, NULL );
if ( r != LZO_E_OK ) if ( r != LZO_E_OK )
{ {
printf ( "Error decompressing\n" ); printf ( "Error decompressing\n" );
break;
} }
RTjpeg_decompressYUV420 ( ( __s8 * ) buffer, decoded ); RTjpeg_decompressYUV420 ( ( __s8 * ) buffer, decoded );
break; break;
@ -103,8 +97,8 @@ void decode_nuv( unsigned char *encoded, int encoded_size,
if ( r != LZO_E_OK ) if ( r != LZO_E_OK )
{ {
printf ( "Error decompressing\n" ); printf ( "Error decompressing\n" );
break;
} }
// memcpy(decoded, buffer, width*height*3/2);
break; break;
case 'N': /* black frame */ case 'N': /* black frame */
memset ( decoded, 0, width * height ); memset ( decoded, 0, width * height );