44
44
#include "internal.h"
45
45
46
46
typedef struct BlockInfo {
47
- uint8_t * pos ;
47
+ const uint8_t * pos ;
48
48
int size ;
49
49
} BlockInfo ;
50
50
@@ -59,7 +59,8 @@ typedef struct FlashSVContext {
59
59
int ver ;
60
60
const uint32_t * pal ;
61
61
int is_keyframe ;
62
- uint8_t * keyframedata ;
62
+ const uint8_t * keyframedata ;
63
+ AVBufferRef * keyframedata_buf ;
63
64
uint8_t * keyframe ;
64
65
BlockInfo * blocks ;
65
66
uint8_t * deflate_block ;
@@ -138,7 +139,7 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx)
138
139
return 0 ;
139
140
}
140
141
141
- static int flashsv2_prime (FlashSVContext * s , uint8_t * src , int size )
142
+ static int flashsv2_prime (FlashSVContext * s , const uint8_t * src , int size )
142
143
{
143
144
z_stream zs ;
144
145
int zret ; // Zlib return code
@@ -355,10 +356,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
355
356
/* we care for keyframes only in Screen Video v2 */
356
357
s -> is_keyframe = (avpkt -> flags & AV_PKT_FLAG_KEY ) && (s -> ver == 2 );
357
358
if (s -> is_keyframe ) {
358
- int err ;
359
- if (( err = av_reallocp ( & s -> keyframedata , avpkt -> size )) < 0 )
359
+ int err = av_buffer_replace ( & s -> keyframedata_buf , avpkt -> buf ) ;
360
+ if (err < 0 )
360
361
return err ;
361
- memcpy ( s -> keyframedata , avpkt -> data , avpkt -> size ) ;
362
+ s -> keyframedata = avpkt -> data ;
362
363
}
363
364
if (s -> ver == 2 && !s -> blocks )
364
365
s -> blocks = av_mallocz ((v_blocks + !!v_part ) * (h_blocks + !!h_part ) *
@@ -566,7 +567,7 @@ static av_cold int flashsv2_decode_end(AVCodecContext *avctx)
566
567
{
567
568
FlashSVContext * s = avctx -> priv_data ;
568
569
569
- av_freep (& s -> keyframedata );
570
+ av_buffer_unref (& s -> keyframedata_buf );
570
571
av_freep (& s -> blocks );
571
572
av_freep (& s -> keyframe );
572
573
av_freep (& s -> deflate_block );
0 commit comments